diff --git a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java index 4f10000..cb267df 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java +++ b/dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java @@ -101,7 +101,7 @@ public class BusinessAlertStatisticsController extends BaseController { * @param businessAlertBo * @return */ - @Operation(summary="综治管理-资规/农水/环保(高发分析)/住建(高发分析)", description="综治管理-资规/农水/环保(高发分析)/住建(高发分析)") + @Operation(summary="综治管理-资规/农水/环保(高发分析)/住建(高发分析)(参数:postCode)", description="综治管理-资规/农水/环保(高发分析)/住建(高发分析)") @GetMapping(value = "/comprehensive/manage") public R> comprehensiveManage(BusinessAlertBo businessAlertBo) { return R.ok(statisticsService.comprehensiveManage(businessAlertBo)); @@ -114,7 +114,7 @@ public class BusinessAlertStatisticsController extends BaseController { */ @Operation(summary="预警信息-资规/农水", description="预警信息-资规/农水") @GetMapping(value = "/alert/list") - public R>> listAlert(BusinessAlertBo businessAlertBo) { + public R> listAlert(BusinessAlertBo businessAlertBo) { return R.ok(businessAlertService.listAlert(businessAlertBo)); } @@ -124,9 +124,9 @@ public class BusinessAlertStatisticsController extends BaseController { * @param businessAlertBo * @return */ - @Operation(summary="综治管理-城管/环保(事件处理情况)/住建(事件处理情况)", description="综治管理-城管/环保(事件处理情况)/住建(事件处理情况)") + @Operation(summary="综治管理-城管/环保(事件处理情况)/住建(事件处理情况)(参数:postCode、aiName)", description="综治管理-城管/环保(事件处理情况)/住建(事件处理情况)") @GetMapping(value = "/city/comprehensive/manage") - public R>> cityComprehensiveManage(BusinessAlertBo businessAlertBo) { + public R> cityComprehensiveManage(BusinessAlertBo businessAlertBo) { return R.ok(statisticsService.cityComprehensiveManage(businessAlertBo)); } @@ -138,19 +138,11 @@ public class BusinessAlertStatisticsController extends BaseController { */ @Operation(summary="预警信息-城管/环保/住建", description="预警信息-城管/环保/住建") @GetMapping(value = "/city/alert/list") - public R>> cityListAlert(BusinessAlertBo businessAlertBo) { + public R> cityListAlert(BusinessAlertBo businessAlertBo) { return R.ok(businessAlertService.cityListAlert(businessAlertBo)); } - - - - - - - - //饼图显示每个月根据部门 @Operation(summary="根据月份显示预警个数", description="根据月份显示预警个数") @GetMapping(value = "/month/count") diff --git a/dk-modules/business/src/main/java/org/dromara/business/domain/BusinessTask.java b/dk-modules/business/src/main/java/org/dromara/business/domain/BusinessTask.java index 01bbece..c231f64 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/domain/BusinessTask.java +++ b/dk-modules/business/src/main/java/org/dromara/business/domain/BusinessTask.java @@ -63,7 +63,7 @@ public class BusinessTask extends BaseEntity { private String deptName; private String waylineId; - private String fileName; + private String waylineName; private String jobName; private String jobId; diff --git a/dk-modules/business/src/main/java/org/dromara/business/domain/bo/BusinessAlertBo.java b/dk-modules/business/src/main/java/org/dromara/business/domain/bo/BusinessAlertBo.java index 9dd64c8..bf701bc 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/domain/bo/BusinessAlertBo.java +++ b/dk-modules/business/src/main/java/org/dromara/business/domain/bo/BusinessAlertBo.java @@ -239,4 +239,6 @@ public class BusinessAlertBo { private String endTime; + private String aiName; + } diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java b/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java index b7329bc..b1f6488 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java @@ -69,9 +69,9 @@ public interface IBusinessAlertService { TableDataInfo getInfo(BusinessAlertBo bo, PageQuery pageQuery, String alertCode); - List> listAlert(BusinessAlertBo businessAlertBo); + Map listAlert(BusinessAlertBo businessAlertBo); - List> cityListAlert(BusinessAlertBo businessAlertBo); + Map cityListAlert(BusinessAlertBo businessAlertBo); List listVerifyAlert(RemoteBusinessAlertBo businessAlertBo); diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java b/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java index 8fe4bd8..bcd9748 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java @@ -34,5 +34,5 @@ public interface IBusinessAlertStatisticsService { Map comprehensiveManage(BusinessAlertBo businessAlertBo); - List> cityComprehensiveManage(BusinessAlertBo businessAlertBo); + Map cityComprehensiveManage(BusinessAlertBo businessAlertBo); } diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java index 7a1942f..7a059ca 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java @@ -1,6 +1,7 @@ package org.dromara.business.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -317,71 +318,56 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { @Override - public List> listAlert(BusinessAlertBo businessAlertBo) { - List> resultList = new ArrayList<>(); - + public Map listAlert(BusinessAlertBo businessAlertBo) { + Map result = new HashMap<>(); //生成近一周开始时间、结束时间 List dayList = getLastSixDays(); String startTime = dayList.get(dayList.size() - 1); String endTime = dayList.get(0); + result.put("date", startTime + "~" + endTime); + //查看的是总览的预警信息 if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) { - Map result = new HashMap<>(); - - result.put("date", startTime + "~" + endTime); - result.put("list",this.baseMapper.listAlert(businessAlertBo,startTime,endTime)); - resultList.add(result); - - return resultList; + return result; } //不是空的话查看是对应各局的 - List postVoList = remoteLablePostService.selectLabelByList(businessAlertBo.getPostCode(), LoginHelper.getDeptId()); - - postVoList.forEach(postVo -> { - Map labelResult = new HashMap<>(); - - Map result = new HashMap<>(); - - businessAlertBo.setAiLabelEnList(List.of(postVo.getLabelEn())); + businessAlertBo.setAiLabelEnList(List.of(businessAlertBo.getLabelEn())); - Map handlerMap = new HashMap<>(); + Map handlerMap = new HashMap<>(); - List alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime); + List alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime); - handlerMap.put("total",alertList.size()); - handlerMap.put("finishCount",ObjectUtil.isEmpty(alertList)?0:alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.FINISH.getStatus())).count()); - handlerMap.put("todoCount",ObjectUtil.isEmpty(alertList)?0:alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.WAITING.getStatus())).count()); - handlerMap.put("cancelCount",ObjectUtil.isEmpty(alertList)?0:alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.CANCEL.getStatus())).count()); + handlerMap.put("total",alertList.size()); + handlerMap.put("finishCount",ObjectUtil.isEmpty(alertList)?0:alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.FINISH.getStatus())).count()); + handlerMap.put("todoCount",ObjectUtil.isEmpty(alertList)?0:alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.WAITING.getStatus())).count()); + handlerMap.put("cancelCount",ObjectUtil.isEmpty(alertList)?0:alertList.stream().filter(p-> p.getHandleType().equalsIgnoreCase(BusinessStatusEnum.CANCEL.getStatus())).count()); - result.put("panel",handlerMap); + result.put("panel",handlerMap); - result.put("list",alertList); + result.put("list",alertList); - result.put("date", startTime + "~" + endTime); - - labelResult.put(postVo.getLabelCn(),result); - - resultList.add(labelResult); - }); - - - return resultList; + return result; } @Override - public List> cityListAlert(BusinessAlertBo businessAlertBo) { - List> resultList = new ArrayList<>(); + public Map cityListAlert(BusinessAlertBo businessAlertBo) { + if (ObjectUtil.hasEmpty(businessAlertBo.getPostCode(),businessAlertBo.getAiName())) { + throw new ServiceException("参数为空!"); + } + + Map infoMap = new HashMap<>(); //生成近一周开始时间、结束时间 List dayList = getLastSixDays(); String startTime = dayList.get(dayList.size() - 1); String endTime = dayList.get(0); + infoMap.put("date", startTime + "~" + endTime); //不是空的话查看是对应各局的 List postVoList = remoteLablePostService.selectLabelByList(businessAlertBo.getPostCode(), LoginHelper.getDeptId()); @@ -389,36 +375,30 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService { Map> aiNameMap = postVoList.stream().collect(Collectors.groupingBy(RemoteAiLabelPostVo::getAiName)); if (ObjectUtil.isEmpty(postVoList)){ - return resultList; - } + infoMap.put("panel",Map.of()); - aiNameMap.keySet().forEach(key -> { - Map result = new HashMap<>(); + infoMap.put("list", ListUtil.empty()); - Map infoMap = new HashMap<>(); - - businessAlertBo.setAiLabelEnList(aiNameMap.get(key).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList()); + return infoMap; + } - List alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime); - Map labelCnMap = alertList.stream() - .collect(Collectors.groupingBy( - BusinessAlert::getLabelCn, - Collectors.summingInt(e -> 1) - )); + businessAlertBo.setAiLabelEnList(aiNameMap.get(businessAlertBo.getAiName()).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList()); - infoMap.put("panel",labelCnMap); + List alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime); - infoMap.put("list",alertList); + Map labelCnMap = alertList.stream() + .collect(Collectors.groupingBy( + BusinessAlert::getLabelEn, + Collectors.summingInt(e -> 1) + )); - infoMap.put("date", startTime + "~" + endTime); + infoMap.put("panel",labelCnMap); - result.put(key,infoMap); + infoMap.put("list",alertList); - resultList.add(result); - }); - return resultList; + return infoMap; } @Override diff --git a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java index 0d3ec23..2806267 100644 --- a/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java +++ b/dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java @@ -29,7 +29,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -import java.util.stream.Stream; import static org.dromara.common.core.constant.Constants.FLY_ACC_TIME; import static org.dromara.common.core.constant.Constants.FLY_COUNT; @@ -579,13 +578,11 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist } @Override - public List> cityComprehensiveManage(BusinessAlertBo businessAlertBo) { - if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) { - throw new ServiceException("【postCode】 岗位编码为空!"); + public Map cityComprehensiveManage(BusinessAlertBo businessAlertBo) { + if (ObjectUtil.hasEmpty(businessAlertBo.getPostCode(),businessAlertBo.getAiName())) { + throw new ServiceException("【参数为空!】"); } - List> resultList = new ArrayList<>(); - //-------------------------------------------------------条件构建-------------------------------------------- List postVoList = remoteLabelPostService.selectLabelByList(businessAlertBo.getPostCode(), LoginHelper.getDeptId()); @@ -600,68 +597,59 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist if (ObjectUtil.isEmpty(postVoList)) { - return ListUtil.empty(); + return Map.of(); } - aiNameMap.keySet().forEach(key -> { - Map result = new HashMap<>(); - - Map keyMap = new HashMap<>(); - - //-------------------------------------------------------事件处理情况-------------------------------------------- + Map keyMap = new HashMap<>(); - List aiLabelList = aiNameMap.get(key).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList(); + //-------------------------------------------------------事件处理情况-------------------------------------------- - businessAlertBo.setAiLabelEnList(aiLabelList); + List aiLabelList = aiNameMap.get(businessAlertBo.getAiName()).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList(); + businessAlertBo.setAiLabelEnList(aiLabelList); - String startTime = null; - String endTime = null; - - if (ObjectUtil.isEmpty(businessAlertBo.getDateType())){ - Map dateMap = getStartTimeAndEndTime(0); - startTime = dateMap.get("startTime"); - endTime = dateMap.get("endTime"); - }else { - Map dateMap = getStartTimeAndEndTime(businessAlertBo.getDateType()); - startTime = dateMap.get("startTime"); - endTime = dateMap.get("endTime"); - } + String startTime = null; + String endTime = null; - List> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime); + if (ObjectUtil.isEmpty(businessAlertBo.getDateType())){ + Map dateMap = getStartTimeAndEndTime(0); + startTime = dateMap.get("startTime"); + endTime = dateMap.get("endTime"); + }else { + Map dateMap = getStartTimeAndEndTime(businessAlertBo.getDateType()); + startTime = dateMap.get("startTime"); + endTime = dateMap.get("endTime"); + } - List incidentHandlerStatStat = new ArrayList<>(); - labelMapList.forEach(map -> { - incidentHandlerStatStat.add(new StatObj(map.get("labelCn").toString(),map.get("total"))); - }); + List> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime); - keyMap.put("incidentHandlerStat", incidentHandlerStatStat); + List incidentHandlerStatStat = new ArrayList<>(); + labelMapList.forEach(map -> { + incidentHandlerStatStat.add(new StatObj(map.get("labelCn").toString(),map.get("total"))); + }); - //-------------------------------------------------------事件高发区-------------------------------------------- + keyMap.put("incidentHandlerStat", incidentHandlerStatStat); - //事件高发区top1 - Map topStreet = this.baseMapper.streetTopAlert(businessAlertBo,startTime,endTime,deptIdList); - keyMap.put("incidentTop1",ObjectUtil.isEmpty(topStreet)?null:topStreet.get("deptName")); + //-------------------------------------------------------事件高发区-------------------------------------------- - //-------------------------------------------------------处理效率-------------------------------------------- - //处理效率top1 - Map topStreetRate = this.baseMapper.streetRateTopAlert(businessAlertBo,startTime,endTime,deptIdList); + //事件高发区top1 + Map topStreet = this.baseMapper.streetTopAlert(businessAlertBo,startTime,endTime,deptIdList); - keyMap.put("handlerRateTop1", ObjectUtil.isEmpty(topStreetRate)?null:topStreetRate.get("deptName")); + keyMap.put("incidentTop1",ObjectUtil.isEmpty(topStreet)?null:topStreet.get("deptName")); + //-------------------------------------------------------处理效率-------------------------------------------- + //处理效率top1 + Map topStreetRate = this.baseMapper.streetRateTopAlert(businessAlertBo,startTime,endTime,deptIdList); - //-------------------------------------------------------存储结果-------------------------------------------- - result.put(key, keyMap); + keyMap.put("handlerRateTop1", ObjectUtil.isEmpty(topStreetRate)?null:topStreetRate.get("deptName")); - resultList.add(result); - }); - return resultList; + return keyMap; } /** diff --git a/dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml b/dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml index 692edc5..6d5313c 100644 --- a/dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml +++ b/dk-modules/business/src/main/resources/mapper/business/BusinessAlertMapper.xml @@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" b.business_id businessId, b.id instanceId from dk_business.business_alert ba - left join dk_workflow.flow_instance b on ba.id = b.business_id) t + INNER join dk_workflow.flow_instance b on ba.id = b.business_id) t ${ew.getCustomSqlSegment} @@ -461,16 +461,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WITH warning_summary AS ( - SELECT al.label_cn, al.label_en FROM dk_cloud.ai_label al WHERE al.label_en IN + SELECT + al.label_cn, + al.label_en + FROM + dk_cloud.ai_label al + WHERE + al.label_en IN #{item} ) SELECT - label_cn AS labelCn, - label_en AS labelEn, - avg_duration AS avgInfo - FROM ( - SELECT - dt.label_cn, - dt.label_en, - ROUND( - SUM(TIMESTAMPDIFF(HOUR, ba.create_time, ba.complete_date)) - / COUNT(ba.id) - ) AS avg_duration - FROM business_alert ba - JOIN warning_summary dt - ON ba.label_en = dt.label_en - WHERE 1=1 + ws.label_cn AS labelCn, + ws.label_en AS labelEn, + COALESCE(ROUND( + SUM( + TIMESTAMPDIFF(HOUR, ba.create_time, ba.complete_date) + ) / COUNT(ba.id) + ), 0) AS avgInfo + FROM + warning_summary ws + LEFT JOIN business_alert ba ON ws.label_en = ba.label_en + where + 1=1 and ba.handle_type = 'finish' and = #{startTime} ]]> and - GROUP BY dt.label_en, dt.label_cn - ) label_stats - ORDER BY avgInfo DESC + GROUP BY + ws.label_en, + ws.label_cn + ORDER BY + avgInfo DESC