From 3a2c4a84f907d960a6daca1f6b53b7c04519de1a Mon Sep 17 00:00:00 2001 From: ic_excellent <2570192571@qq.com> Date: Sat, 15 Jul 2023 10:02:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=90=8C=E6=AD=A5=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response_deal/mapper/ConfigMapper.java | 4 +- .../utils/response_deal/state/InsertSate.java | 1 + .../controller/ReportController.java | 7 +- .../xiao/sh_bigdata/mapper/ReportMapper.java | 42 ++++++++++ .../sh_bigdata/service/ReportService.java | 80 +++++++++++++++++-- .../controller/ReserveSelectController.java | 38 ++++++++- .../bokang/xiao/zscq/mapper/QueryMapper.java | 2 +- .../zscq/service/impl/ReserveServiceImpl.java | 22 ++++- .../generate_code/mapper/GenerateMapper.java | 14 ++-- .../service/GenerateContractNoService.java | 7 +- src/test/java/bokang/xiao/NormalTest.java | 3 +- 11 files changed, 199 insertions(+), 21 deletions(-) diff --git a/src/main/java/aiyh/utils/response_deal/mapper/ConfigMapper.java b/src/main/java/aiyh/utils/response_deal/mapper/ConfigMapper.java index 927d986..c7e9bc4 100644 --- a/src/main/java/aiyh/utils/response_deal/mapper/ConfigMapper.java +++ b/src/main/java/aiyh/utils/response_deal/mapper/ConfigMapper.java @@ -45,7 +45,7 @@ public interface ConfigMapper { * @param mainId 主数据id * @return 响应数据别名配置信息列表 */ - @Select("select * from uf_response_config_dt1 where mainid = #{mainId}") + @Select("select * from uf_response_config_dt1 where mainid = #{mainId} and enable = 0") @CollectionMethod(1) List queryResponseConfigAlias(@ParamMapper("mainId")int mainId); @@ -54,7 +54,7 @@ public interface ConfigMapper { * @param mainId 主数据id * @return 响应数据转换配置信息列表 */ - @Select("select * from uf_response_config_dt3 where mainid = #{mainId}") + @Select("select * from uf_response_config_dt3 where mainid = #{mainId} and enable = 0") @CollectionMethod(2) List queryResponseConfigValueChange(@ParamMapper("mainId")int mainId); diff --git a/src/main/java/aiyh/utils/response_deal/state/InsertSate.java b/src/main/java/aiyh/utils/response_deal/state/InsertSate.java index 5d8aba1..8d2ceb5 100644 --- a/src/main/java/aiyh/utils/response_deal/state/InsertSate.java +++ b/src/main/java/aiyh/utils/response_deal/state/InsertSate.java @@ -21,6 +21,7 @@ import java.util.stream.Collectors; * @Description

**/ public class InsertSate extends State{ + @Override public void handle() { int tableType = this.context.getTableType(); diff --git a/src/main/java/com/api/bokang/xiao/sh_bigdata/controller/ReportController.java b/src/main/java/com/api/bokang/xiao/sh_bigdata/controller/ReportController.java index 854970b..5fc7b30 100644 --- a/src/main/java/com/api/bokang/xiao/sh_bigdata/controller/ReportController.java +++ b/src/main/java/com/api/bokang/xiao/sh_bigdata/controller/ReportController.java @@ -15,6 +15,7 @@ import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -45,7 +46,11 @@ public class ReportController { log.info("into getReportData success params ==> "+param); User loginUser = HrmUserVarify.getUser(request, response); List> reportData = reportService.queryReportData(param, loginUser); - return ApiResult.success(reportData); + Map titleData = reportService.queryTitleData(param); + Map res = new HashMap<>(); + res.put("titleData",titleData); + res.put("reportData",reportData); + return ApiResult.success(res); }catch (Exception e){ log.error("getReportData error ==> "+Util.getErrString(e)); return ApiResult.error(e.getMessage()); diff --git a/src/main/java/com/api/bokang/xiao/sh_bigdata/mapper/ReportMapper.java b/src/main/java/com/api/bokang/xiao/sh_bigdata/mapper/ReportMapper.java index b8a308c..6a136ae 100644 --- a/src/main/java/com/api/bokang/xiao/sh_bigdata/mapper/ReportMapper.java +++ b/src/main/java/com/api/bokang/xiao/sh_bigdata/mapper/ReportMapper.java @@ -37,4 +37,46 @@ public interface ReportMapper { @CaseConversion(value = false) List> queryReportData2(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); + @Select("select id,hbwb,ysclwb,gzrywb,gzclwb,ldrwb,sfsjyc,ddsjyc,dlsk,yslx,hbcc,sfsj,ddsj,sfd,ddd,wdwcl,dwcljsy,wdwclqt,xcap,lxr," + + " lxrdh,bz,gzcl,gzry,zs,dyjbr,djr,ldr,lddw,rwzt,ykdh,gbs, " + + " (select LISTAGG(concat(wb, ',', zw), '-') WITHIN GROUP (ORDER BY wb) from uf_zwfwdjjmb_dt1 where mainid = main.id) ysdx, " + + " dyjbr, (select lastname from hrmresource where id = dyjbr) dyjbr_span," + + " djr, (select lastname from hrmresource where id = djr) djr_span " + + " from uf_zwfwdjjmb main $t{param.whereSql} order by dlsk ") + @CaseConversion(value = false) + List> queryReportData3(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); + + /** + * 查询限行信息 + * @param param 查询参数 + * @return 今日限行信息 + */ + @Select("select xxhm from uf_bjxxjmbd_dt1 where xxrq = #{currentDate}") + @CaseConversion(value = false) + List queryTrafficControl(@ParamMapper("param") Map param); + + /** + * 查询当日值班人员 + * @param param 查询参数 + * @return 当日值班人员 + */ + @Select("select hrm.lastname,ry.zblx,ry.zbry " + + " from uf_ryzbjlbzjb_dt1 ry " + + " inner join hrmresource hrm on ry.zbry = hrm.id" + + " where #{currentDate} >= ry.zbksrq and #{currentDate} <= ry.zbjsrq }") + @CaseConversion(value = false) + List> queryDutyData(@ParamMapper("param") Map param); + + /** + * 查询车队排班信息 + * @param param 查询参数 + * @return 值班人员 + */ + @Select("select hrm.lastname " + + " from uf_jsyzbap_dt1 jsy " + + " inner join hrmresource hrm on jsy.zbry = hrm.id" + + " where jsy.zblx = #{dutyType} and #{currentDate} >= jsy.zbksrq and #{currentDate} <= jsy.zbjsrq }") + @CaseConversion(value = false) + List queryCarSchedule(@ParamMapper("param") Map param); + } diff --git a/src/main/java/com/api/bokang/xiao/sh_bigdata/service/ReportService.java b/src/main/java/com/api/bokang/xiao/sh_bigdata/service/ReportService.java index 4b70644..a18b245 100644 --- a/src/main/java/com/api/bokang/xiao/sh_bigdata/service/ReportService.java +++ b/src/main/java/com/api/bokang/xiao/sh_bigdata/service/ReportService.java @@ -5,8 +5,11 @@ import com.api.bokang.xiao.sh_bigdata.mapper.ReportMapper; import weaver.general.TimeUtil; import weaver.hrm.User; +import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; /** * @ClassName ReviewService @@ -25,23 +28,88 @@ public class ReportService { * @return 前五条流程数据 */ public List> queryReportData(Map param, User user){ + param.put("whereSql",getWhereSql(param)); + return reportMapper.queryReportData3(param,user.getUID()); + } + + private String getWhereSql(Map param){ String currentDate = Util.null2String(param.get("currentDate")); String registrationPeople = Util.null2String(param.get("registrationPeople")); String registrationPeopleSpan = Util.null2String(param.get("registrationPeopleSpan")); - param.put("whereSql",""); + //迎送对象 + String project = Util.null2String(param.get("project")); + //开始日期 + String beginDate = Util.null2String(param.get("beginDate")); + //结束日期 + String endData = Util.null2String(param.get("endData")); + //航班车次 + String flightAndTrain = Util.null2String(param.get("flightAndTrain")); String whereSql = ""; - if(!"".equals(currentDate)){ - whereSql += " and dlsk = #{param.currentDate} "; + if(!"".equals(beginDate) && !"".equals(endData)){ + whereSql += " and (dlsk between #{param.beginDate} and #{param.endData} )"; }else { param.put("today", TimeUtil.getCurrentDateString()); whereSql += " and dlsk >= #{param.today} "; } if(!"".equals(registrationPeople)){ - whereSql += " and djr = #{param.registrationPeople} "; + whereSql += " and dyjbr = #{param.registrationPeople} "; + } + if(!"".equals(flightAndTrain)){ + whereSql += " and hbwb = #{param.flightAndTrain} "; + } + if(!"".equals(project)){ + whereSql += " and exits (select 1 from uf_zwfwdjjmb_dt1 where mainid = main.id and ysdx = #{param.project}) "; } whereSql = whereSql.replaceFirst(" and "," where "); - param.put("whereSql",whereSql); - return reportMapper.queryReportData2(param,user.getUID()); + return whereSql; + } + + public Map queryTitleData(Map param){ + Map titleData = new HashMap<>(); + //查询限行信息 + List trafficControlList = reportMapper.queryTrafficControl(param); + judgeEmptyAndPut(trafficControlList,titleData,"trafficControl"); + //查询值班信息 + List> dutyData = reportMapper.queryDutyData(param); + if(Objects.nonNull(dutyData) && !dutyData.isEmpty()) { + Map>> dutyTypeMap = dutyData.stream().collect(Collectors.groupingBy(item -> Util.null2String(item.get("zblx")))); + //带班值班员 + filterAndPut(dutyTypeMap.get("0"),titleData,"headWatch"); + //机关值班员 + filterAndPut(dutyTypeMap.get("1"),titleData,"organWatch"); + //今日迎送人员 + filterAndPut(dutyTypeMap.get("2"),titleData,"todayWelcome"); + } + titleData.put("dutyData",dutyData); + //查询当日送报人员 + param.put("dutyType",1); + List strings = reportMapper.queryCarSchedule(param); + judgeEmptyAndPut(strings,titleData,"currentNewsboy"); + //查询驾驶值班员 + param.put("dutyType",0); + List pilots = reportMapper.queryCarSchedule(param); + judgeEmptyAndPut(pilots,titleData,"pilot"); + //查询明日送报人员 + param.put("dutyType",1); + String currentDate = Util.null2String(param.get("currentDate")); + currentDate = TimeUtil.dateAdd(currentDate,-1); + param.put("currentDate",currentDate); + List tomorrowNewsboys = reportMapper.queryCarSchedule(param); + judgeEmptyAndPut(tomorrowNewsboys,titleData,"currentNewsboy"); + return titleData; + } + + private void filterAndPut(List> data,Map map,String key){ + if(Objects.nonNull(data) && !data.isEmpty()){ + List lastname = data.stream().map(item -> Util.null2String(item.get("lastname"))).collect(Collectors.toList()); + judgeEmptyAndPut(lastname,map,key); + } + } + + private void judgeEmptyAndPut(List list,Map map,String key){ + if(Objects.nonNull(list) && !list.isEmpty()) { + map.put(key,String.join(",", list)); + } } } diff --git a/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java b/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java index ee75f63..acb15d7 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java +++ b/src/main/java/com/api/bokang/xiao/zscq/controller/ReserveSelectController.java @@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.parameters.RequestBody; import org.apache.log4j.Logger; import weaver.bokang.xiao.zscq.store.TableNameStore; import weaver.file.ImageFileManager; +import weaver.general.GCONST; import weaver.hrm.HrmUserVarify; import weaver.hrm.User; import weaver.xiao.commons.config.entity.WeaverFile; @@ -19,6 +20,10 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.nio.file.Files; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -67,13 +72,15 @@ public class ReserveSelectController { @Produces(MediaType.APPLICATION_OCTET_STREAM) public Response downloadBatchFiles(@QueryParam("datePicker") String datePicker, @QueryParam("checkResult") String checkResult, - @QueryParam("checkResultShow") String checkResultShow) { + @QueryParam("checkResultShow") String checkResultShow, + @QueryParam("region") String region) { log.info("====== into downloadBatchFiles success ======="); - log.info(String.format("====== datePicker:[%s] checkResult:[%s] checkResultShow:[%s] =======",datePicker,checkResult,checkResultShow)); + log.info(String.format("====== datePicker:[%s] checkResult:[%s] checkResultShow:[%s] region:[%s] =======",datePicker,checkResult,checkResultShow,region)); Map param = new HashMap<>(8); param.put("datePicker",datePicker); param.put("checkResult",checkResult); param.put("checkResultShow",checkResultShow); + param.put("region",region); String zipFileName = reserveService.getFileName(param) + ".zip"; StreamingOutput streamingOutput = outputStream -> { try { @@ -88,6 +95,33 @@ public class ReserveSelectController { .build(); } + @GET + @Path("/batchDownloadTemp") + @Produces(MediaType.APPLICATION_OCTET_STREAM) + public String batchDownloadTemp(@QueryParam("datePicker") String datePicker, + @QueryParam("checkResult") String checkResult, + @QueryParam("checkResultShow") String checkResultShow, + @QueryParam("region") String region) { + log.info("====== into batchDownloadTemp success ======="); + log.info(String.format("====== datePicker:[%s] checkResult:[%s] checkResultShow:[%s] region:[%s] =======",datePicker,checkResult,checkResultShow,region)); + Map param = new HashMap<>(8); + param.put("datePicker",datePicker); + param.put("checkResult",checkResult); + param.put("checkResultShow",checkResultShow); + param.put("region",region); + String zipFileName = reserveService.getFileName(param) + ".zip"; + try { + String filePath = "/data/filesystem"; + String fileFullPath = filePath + File.separator + zipFileName; + OutputStream outputStream = Files.newOutputStream(new File(fileFullPath).toPath()); + reserveService.batchDownload(param, outputStream); + }catch (Exception e){ + log.error("下载文件异常 ==>"+Util.getErrString(e)); + } + return ApiResult.successNoData(); + } + + @GET @Path("/refreshStore") public String refreshStore(@Context HttpServletRequest request, @Context HttpServletResponse response){ diff --git a/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java b/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java index ab2d464..866ecfc 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java +++ b/src/main/java/com/api/bokang/xiao/zscq/mapper/QueryMapper.java @@ -25,7 +25,7 @@ public interface QueryMapper { " from uf_gjjtb gjj " + " inner join hrmdepartment depart on gjj.xfqj = depart.id " + " where concat(',',concat(sjpcdxk,',')) like concat('%,',concat(#{datePicker},',%')) " + - " and hcqkdx = #{checkResult} and gjj.xgfj is not null ") + " and hcqkdx = #{checkResult} and gjj.xgfj is not null $t{cusWhere} ") @Associations( @Association(property = "weaverFile",column = "xgfj",id = @Id(value = Integer.class,methodId = 1))) List queryDownloadList(Map param); diff --git a/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java b/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java index 4813c23..7c5d649 100644 --- a/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java +++ b/src/main/java/com/api/bokang/xiao/zscq/service/impl/ReserveServiceImpl.java @@ -7,6 +7,7 @@ import com.api.bokang.xiao.zscq.entity.WeaverFile; import com.api.bokang.xiao.zscq.mapper.QueryMapper; import com.api.bokang.xiao.zscq.mapper.ReserveSelectMapper; import com.api.bokang.xiao.zscq.service.ReserveService; +import com.icbc.api.internal.apache.http.impl.cookie.S; import weaver.bokang.xiao.zscq.config.service.ModeChangeService; import weaver.conn.RecordSet; import weaver.file.ImageFileManager; @@ -162,17 +163,24 @@ public class ReserveServiceImpl implements ReserveService { @Override public void batchDownload(Map param, OutputStream outputStream) throws IOException { + String region = Util.null2String(param.get("region")); + String cusWhere = ""; + if(!"".equals(region)){ + cusWhere = " and gjj.xfqj in ("+region+")"; + } + param.put("cusWhere",cusWhere); List sendList = queryMapper.queryDownloadList(param); if(Objects.isNull(sendList) || sendList.isEmpty()){ log.info("附件列表为空 attachment empty !!!"); //throw new CustomerException("附件列表查询为空"); return; } - log.info("查询到的附件信息 query fileList ==>"+ JSON.toJSONString(sendList)); + log.info("查询到的附件信息 query fileList ==>"+ sendList.size()); // 1. 将 SendFileEntity 按照 departName 分组 Map> sendMap = sendList.stream().collect(Collectors.groupingBy(SendFileEntity::getDepartName)); // 2. 创建 ZipOutputStream ZipOutputStream zipOutputStream = new ZipOutputStream(new BufferedOutputStream(outputStream)); + String defaultFileType = ".txt"; // 3. 遍历 SendFileEntity for (Map.Entry> entry : sendMap.entrySet()) { String departName = entry.getKey(); @@ -185,7 +193,17 @@ public class ReserveServiceImpl implements ReserveService { WeaverFile fileMsg = sendFileEntity.getWeaverFile(); int imageFileId = fileMsg.getImageFileId(); String fileName = fileMsg.getFileName(); - String fileType = fileName.substring(fileName.lastIndexOf(".")); + int index = fileName.lastIndexOf("."); + String fileType = ""; + if(fileMsg.getFileSize() > 1048576){ + log.info("文件大于 10M ==>"+JSON.toJSONString(sendFileEntity)); + } + if(index == -1){ + fileType = defaultFileType; + log.info("文件名有误 ==>"+JSON.toJSONString(sendFileEntity)); + }else { + fileType = fileName.substring(index); + } String tempFileName = sendFileEntity.getRequestNumber() + fileType; InputStream inputStream = ImageFileManager.getInputStreamById(imageFileId); // 6. 将单个附件写入 ZipOutputStream diff --git a/src/main/java/com/api/bokang/xiao/zxyh/generate_code/mapper/GenerateMapper.java b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/mapper/GenerateMapper.java index 30c312f..a9873c6 100644 --- a/src/main/java/com/api/bokang/xiao/zxyh/generate_code/mapper/GenerateMapper.java +++ b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/mapper/GenerateMapper.java @@ -1,9 +1,6 @@ package com.api.bokang.xiao.zxyh.generate_code.mapper; -import aiyh.utils.annotation.recordset.Delete; -import aiyh.utils.annotation.recordset.Select; -import aiyh.utils.annotation.recordset.SqlMapper; -import aiyh.utils.annotation.recordset.Update; +import aiyh.utils.annotation.recordset.*; import java.util.Map; @@ -23,7 +20,7 @@ public interface GenerateMapper { * @return 更新结果 */ @Update("update uf_contract_num_log set workflow_info = #{workflowInfo},file_info = #{fileInfo},detail_id = #{detailId}," + - "row_id = #{rowId},contract_name = #{contractName},contract_num = #{contractNum},flow_num = #{flowNum} where id = #{dataId}") + "row_id = #{rowId},contract_name = #{contractName},contract_num = #{contractNum},flow_num = #{flowNum},contract_month = #{contractMonth} where id = #{dataId}") boolean updateContractLog(Map param); /** @@ -33,6 +30,13 @@ public interface GenerateMapper { @Select("select max(flow_num) from uf_contract_num_log") int getMaxFlow(); + /** + *

查询最大的流水号

+ * @return 最大的流水号 + */ + @Select("select max(flow_num) from uf_contract_num_log where contract_month = #{month}") + int getMaxFlowByMonth(@ParamMapper("month")int month); + /** *

删除编号信息

* @param param 参数信息 diff --git a/src/main/java/com/api/bokang/xiao/zxyh/generate_code/service/GenerateContractNoService.java b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/service/GenerateContractNoService.java index f9dc06d..fe7953f 100644 --- a/src/main/java/com/api/bokang/xiao/zxyh/generate_code/service/GenerateContractNoService.java +++ b/src/main/java/com/api/bokang/xiao/zxyh/generate_code/service/GenerateContractNoService.java @@ -5,6 +5,7 @@ import com.api.bokang.xiao.zxyh.generate_code.mapper.GenerateMapper; import org.apache.log4j.Logger; import java.text.SimpleDateFormat; +import java.util.Calendar; import java.util.Date; import java.util.Map; @@ -29,7 +30,10 @@ public class GenerateContractNoService { private final static Integer FLOW_LENGTH = 3; public String generateCode(Map param){ - int maxFlow = generateMapper.getMaxFlow(); + Calendar calendar = Calendar.getInstance(); + int month = calendar.get(Calendar.MONTH); + //int maxFlow = generateMapper.getMaxFlow(); + int maxFlow = generateMapper.getMaxFlowByMonth(month); maxFlow = Math.max(maxFlow,0); maxFlow++; String contractNo = ""; @@ -47,6 +51,7 @@ public class GenerateContractNoService { param.put("dataId",dataId); param.put("contractNum",contractNo); param.put("flowNum",maxFlow); + param.put("contractMonth",month); boolean updateFlag = generateMapper.updateContractLog(param); Util.rebuildModeDataShareByAsync(1,TABLE_NAME,dataId); if(updateFlag){ diff --git a/src/test/java/bokang/xiao/NormalTest.java b/src/test/java/bokang/xiao/NormalTest.java index 1803b34..01f406e 100644 --- a/src/test/java/bokang/xiao/NormalTest.java +++ b/src/test/java/bokang/xiao/NormalTest.java @@ -45,6 +45,7 @@ import weaver.bokang.xiao.porsche.schedule.CompanyWriteBackSchedule; import weaver.bokang.xiao.porsche.schedule.SalaryUpdateSchedule; import weaver.bokang.xiao.sh_bigdata.action.DataPushAction; import weaver.bokang.xiao.shtx.schedule.ExamineSchedule; +import weaver.bokang.xiao.shtx.schedule.SyncTeachDataSchedule; import weaver.bokang.xiao.xhny_mode.search.CustomSearchDepart; import weaver.bokang.xiao.xhny_report.entity.SourceTrackingData; import weaver.bokang.xiao.xhny_report.schedule.GenerateReportSchedule; @@ -84,7 +85,7 @@ public class NormalTest extends BaseTest { @Test public void testWord(){ - GenerateFileUtil.createCronJobDocument(ExamineSchedule.class); + GenerateFileUtil.createCronJobDocument(SyncTeachDataSchedule.class); //GenerateFileUtil.createActionDocument(DataPushAction.class); //GenerateFileUtil.createActionDocument(DateFieldUpdateAction.class); }