From a356e37bdb48a9305683572094af5c9536c5a65f Mon Sep 17 00:00:00 2001 From: ic_excellent <2570192571@qq.com> Date: Tue, 18 Jul 2023 14:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E6=B5=B7=E5=A4=A7=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/DataChangeProcess.java | 4 +- .../xiao/sh_bigdata/mapper/ReportMapper.java | 16 ++++--- .../sh_bigdata/service/ReportService.java | 46 +++++++++++++------ 3 files changed, 43 insertions(+), 23 deletions(-) diff --git a/src/main/java/aiyh/utils/response_deal/process/DataChangeProcess.java b/src/main/java/aiyh/utils/response_deal/process/DataChangeProcess.java index d2d2703..f996d7f 100644 --- a/src/main/java/aiyh/utils/response_deal/process/DataChangeProcess.java +++ b/src/main/java/aiyh/utils/response_deal/process/DataChangeProcess.java @@ -82,10 +82,10 @@ public class DataChangeProcess { String cusText = responseConfigValueChange.getCusText(); cusText = Util.dbc2sbcCase(cusText); if(StringUtils.isBlank(cusText)){ - throw new CustomerException("when selecting Custom sql, the sql string cannot be empty !!!"); + throw new ResponseException("when selecting Custom sql, the sql string cannot be empty !!!"); } if(!cusText.startsWith("select ")){ - throw new CustomerException("When you select custom sql, you are not allowed to perform dangerous operations other than SELECT !!!"); + throw new ResponseException("When you select custom sql, you are not allowed to perform dangerous operations other than SELECT !!!"); } String tempValue = CONFIG_MAPPER.executeCusQuerySql(cusText, param,new HashMap<>()); responseConfigValueChange.setJsonData(tempValue); 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 6a136ae..ea4a6c7 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 @@ -42,7 +42,7 @@ public interface ReportMapper { " (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 ") + " from uf_zwfwdjjmb main $t{param.whereSql} order by dlsk1 ") @CaseConversion(value = false) List> queryReportData3(@ParamMapper("param") Map param,@ParamMapper("uid") int uid); @@ -53,19 +53,21 @@ public interface ReportMapper { */ @Select("select xxhm from uf_bjxxjmbd_dt1 where xxrq = #{currentDate}") @CaseConversion(value = false) - List queryTrafficControl(@ParamMapper("param") Map param); + List queryTrafficControl(Map param); /** * 查询当日值班人员 * @param param 查询参数 * @return 当日值班人员 */ - @Select("select hrm.lastname,ry.zblx,ry.zbry " + + @Select("select hrm.lastname today_welcome,ry.zbry,hrm1.lastname organ_watch,ry.zbry1,hrm2.lastname head_watch,ry.zbry2 " + " from uf_ryzbjlbzjb_dt1 ry " + - " inner join hrmresource hrm on ry.zbry = hrm.id" + + " inner join hrmresource hrm on ry.zbry = hrm.id " + + " inner join hrmresource hrm1 on ry.zbry1 = hrm1.id " + + " inner join hrmresource hrm2 on ry.zbry2 = hrm2.id " + " where #{currentDate} >= ry.zbksrq and #{currentDate} <= ry.zbjsrq }") @CaseConversion(value = false) - List> queryDutyData(@ParamMapper("param") Map param); + List> queryDutyData(Map param); /** * 查询车队排班信息 @@ -74,9 +76,9 @@ public interface ReportMapper { */ @Select("select hrm.lastname " + " from uf_jsyzbap_dt1 jsy " + - " inner join hrmresource hrm on jsy.zbry = hrm.id" + + " inner join hrmresource hrm on jsy.$t{field} = hrm.id" + " where jsy.zblx = #{dutyType} and #{currentDate} >= jsy.zbksrq and #{currentDate} <= jsy.zbjsrq }") @CaseConversion(value = false) - List queryCarSchedule(@ParamMapper("param") Map param); + List queryCarSchedule(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 a18b245..5d3abcb 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 @@ -46,10 +46,10 @@ public class ReportService { String flightAndTrain = Util.null2String(param.get("flightAndTrain")); String whereSql = ""; if(!"".equals(beginDate) && !"".equals(endData)){ - whereSql += " and (dlsk between #{param.beginDate} and #{param.endData} )"; + whereSql += " and (dlsk1 between #{param.beginDate} and #{param.endData} )"; }else { param.put("today", TimeUtil.getCurrentDateString()); - whereSql += " and dlsk >= #{param.today} "; + whereSql += " and dlsk1 >= #{param.today} "; } if(!"".equals(registrationPeople)){ whereSql += " and dyjbr = #{param.registrationPeople} "; @@ -72,30 +72,30 @@ public class ReportService { //查询值班信息 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"); + String headWatch = convertToString(dutyData, "head_watch"); + titleData.put("headWatch",headWatch); //机关值班员 - filterAndPut(dutyTypeMap.get("1"),titleData,"organWatch"); + String organWatch = convertToString(dutyData, "organ_watch"); + titleData.put("organWatch",organWatch); //今日迎送人员 - filterAndPut(dutyTypeMap.get("2"),titleData,"todayWelcome"); + String todayWelcome = convertToString(dutyData, "today_welcome"); + titleData.put("todayWelcome",todayWelcome); } - titleData.put("dutyData",dutyData); //查询当日送报人员 - param.put("dutyType",1); + param.put("field","zbry1"); 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"); + judgeEmptyAndPut(tomorrowNewsboys,titleData,"tomorrowNewsboy"); + //查询驾驶值班员 + param.put("field","zbry"); + List pilots = reportMapper.queryCarSchedule(param); + judgeEmptyAndPut(pilots,titleData,"pilot"); return titleData; } @@ -112,4 +112,22 @@ public class ReportService { } } + /** + * 将列表中特定键的值转换为逗号分隔的字符串 + * + * @param list 列表 + * @param key 要提取的键 + * @return 逗号分隔的字符串 + */ + public String convertToString(List> list, String key) { + if(Objects.isNull(list) || list.isEmpty()){ + return ""; + } + return list.stream() + .map(map -> map.get(key)) + .filter(Objects::nonNull) + .map(Object::toString) + .collect(Collectors.joining(",")); + } + }