Browse Source

[feat]

1、开发城管首页预警统计
pull/1/head
杨威 3 months ago
parent
commit
10a7a896d1
  1. 26
      dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java
  2. 2
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java
  3. 2
      dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java
  4. 49
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java
  5. 95
      dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java
  6. 2
      dk-modules/system/src/main/java/org/dromara/system/domain/vo/AiLabelPostVo.java
  7. 2
      dk-modules/system/src/main/java/org/dromara/system/dubbo/RemoteLabelPostServicelmpl.java
  8. 4
      dk-modules/system/src/main/resources/mapper/system/AiLabelPostMapper.xml

26
dk-modules/business/src/main/java/org/dromara/business/controller/BusinessAlertStatisticsController.java

@ -97,11 +97,11 @@ public class BusinessAlertStatisticsController extends BaseController {
}
/**
* 综治管理
* 综治管理-资规
* @param businessAlertBo
* @return
*/
@Operation(summary="综治管理", description="综治管理")
@Operation(summary="综治管理-资规", description="综治管理-资规")
@GetMapping(value = "/comprehensive/manage")
public R<Map<String,Object>> comprehensiveManage(BusinessAlertBo businessAlertBo) {
return R.ok(statisticsService.comprehensiveManage(businessAlertBo));
@ -119,6 +119,28 @@ public class BusinessAlertStatisticsController extends BaseController {
}
/**
* 综治管理-城管
* @param businessAlertBo
* @return
*/
@Operation(summary="综治管理-城管", description="综治管理-城管")
@GetMapping(value = "/city/comprehensive/manage")
public R<List<Map<String,Object>>> cityComprehensiveManage(BusinessAlertBo businessAlertBo) {
return R.ok(statisticsService.cityComprehensiveManage(businessAlertBo));
}
/**
* 预警信息-城管
* @param businessAlertBo
* @return
*/
@Operation(summary="预警信息-城管", description="预警信息-城管")
@GetMapping(value = "/city/alert/list")
public R<List<Map<String,Object>>> cityListAlert(BusinessAlertBo businessAlertBo) {
return R.ok(businessAlertService.cityListAlert(businessAlertBo));
}

2
dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertService.java

@ -68,4 +68,6 @@ public interface IBusinessAlertService {
TableDataInfo<BusinessAlert> getInfo(BusinessAlertBo bo, PageQuery pageQuery, String alertCode);
List<Map<String,Object>> listAlert(BusinessAlertBo businessAlertBo);
List<Map<String, Object>> cityListAlert(BusinessAlertBo businessAlertBo);
}

2
dk-modules/business/src/main/java/org/dromara/business/service/IBusinessAlertStatisticsService.java

@ -33,4 +33,6 @@ public interface IBusinessAlertStatisticsService {
List<StatObj> handlerRate(BusinessAlertBo businessAlertBo);
Map<String, Object> comprehensiveManage(BusinessAlertBo businessAlertBo);
List<Map<String,Object>> cityComprehensiveManage(BusinessAlertBo businessAlertBo);
}

49
dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertServiceImpl.java

@ -32,6 +32,7 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* 预警任务Service业务层处理
@ -363,6 +364,54 @@ public class BusinessAlertServiceImpl implements IBusinessAlertService {
}
@Override
public List<Map<String, Object>> cityListAlert(BusinessAlertBo businessAlertBo) {
List<Map<String,Object>> resultList = new ArrayList<>();
//生成近一周开始时间、结束时间
List<String> dayList = getLastSixDays();
String startTime = dayList.get(dayList.size() - 1);
String endTime = dayList.get(0);
//不是空的话查看是对应各局的
List<RemoteAiLabelPostVo> postVoList = remoteLablePostService.selectLabelByList(businessAlertBo.getPostCode(), LoginHelper.getDeptId());
Map<String, List<RemoteAiLabelPostVo>> aiNameMap = postVoList.stream().collect(Collectors.groupingBy(RemoteAiLabelPostVo::getAiName));
if (ObjectUtil.isEmpty(postVoList)){
return resultList;
}
aiNameMap.keySet().forEach(key -> {
Map<String,Object> result = new HashMap<>();
Map<String,Object> infoMap = new HashMap<>();
businessAlertBo.setAiLabelEnList(aiNameMap.get(key).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList());
List<BusinessAlert> alertList = this.baseMapper.listAlert(businessAlertBo, startTime, endTime);
Map<String, Integer> labelCnMap = alertList.stream()
.collect(Collectors.groupingBy(
BusinessAlert::getLabelCn,
Collectors.summingInt(e -> 1)
));
infoMap.put("panel",labelCnMap);
infoMap.put("list",alertList);
infoMap.put("date", startTime + "~" + endTime);
result.put(key,infoMap);
resultList.add(result);
});
return resultList;
}
public static List<String> getLastSixDays() {
List<String> days = new ArrayList<>(7);

95
dk-modules/business/src/main/java/org/dromara/business/service/impl/BusinessAlertStatisticsServiceImpl.java

@ -456,6 +456,101 @@ public class BusinessAlertStatisticsServiceImpl implements IBusinessAlertStatist
return result;
}
@Override
public List<Map<String,Object>> cityComprehensiveManage(BusinessAlertBo businessAlertBo) {
if (ObjectUtil.isEmpty(businessAlertBo.getPostCode())) {
throw new ServiceException("【postCode】 岗位编码为空!");
}
List<Map<String,Object>> resultList = new ArrayList<>();
List<RemoteAiLabelPostVo> postVoList = remoteLabelPostService.selectLabelByList(businessAlertBo.getPostCode(), LoginHelper.getDeptId());
Map<String, List<RemoteAiLabelPostVo>> aiNameMap = postVoList.stream().collect(Collectors.groupingBy(RemoteAiLabelPostVo::getAiName));
if (ObjectUtil.isEmpty(postVoList)) {
return ListUtil.empty();
}
aiNameMap.keySet().forEach(key -> {
Map<String,Object> result = new HashMap<>();
Map<String,Object> keyMap = new HashMap<>();
List<String> aiLabelList = aiNameMap.get(key).stream().map(RemoteAiLabelPostVo::getLabelEn).distinct().toList();
businessAlertBo.setAiLabelEnList(aiLabelList);
List<String> monthList = getLastSixMonths();
String startTime = monthList.get(monthList.size() - 1);
String endTime = monthList.get(0);
List<Map<String,Object>> labelMapList = this.baseMapper.countAiLabel(businessAlertBo,startTime,endTime);
Map<String,Object> labelMap = new HashMap<>();
labelMapList.forEach(label -> {
labelMap.put(label.get("labelCn")+ "",label.get("total"));
});
keyMap.put("handlerStat", labelMap);
//事件高发区
Long deptId = LoginHelper.getDeptId();
//获取街道信息
List<RemoteDeptVo> streetList = remoteDeptService.selectListByParentId(String.valueOf(deptId));
Map<String,Integer> streeMap = new HashMap<>();
streetList.forEach(street -> {
businessAlertBo.setDeptId(String.valueOf(street.getDeptId()));
Integer alertCount = this.baseMapper.countStreetAlert(businessAlertBo,startTime,endTime);
streeMap.put(street.getDeptName(),alertCount);
});
//降序排序,取前五个
String topMap = streeMap.entrySet().stream()
.sorted(Map.Entry.<String, Integer>comparingByValue().reversed())
.limit(1)
.map(Map.Entry::getKey)
.findFirst()
.orElse(null);
keyMap.put("topAlert",topMap);
//处理效率top5
Map<String,Integer> streeRateMap = new HashMap<>();
streetList.forEach(street -> {
businessAlertBo.setDeptId(String.valueOf(street.getDeptId()));
Integer alertCount = this.baseMapper.countStreetRateAlert(businessAlertBo,startTime,endTime);
if (ObjectUtil.isEmpty(alertCount)) {
streeRateMap.put(street.getDeptName(),0);
}else {
streeRateMap.put(street.getDeptName(),alertCount);
}
});
String topKey = streeRateMap.entrySet().stream()
.sorted(Map.Entry.<String, Integer>comparingByValue().reversed())
.limit(1)
.map(Map.Entry::getKey)
.findFirst()
.orElse(null);
keyMap.put("handlerRate", topKey);
//识别类型存储
result.put(key, keyMap);
resultList.add(result);
});
return resultList;
}
/**
* 获取近6个月的月份集合格式yyyy-MM
*/

2
dk-modules/system/src/main/java/org/dromara/system/domain/vo/AiLabelPostVo.java

@ -41,4 +41,6 @@ public class AiLabelPostVo implements Serializable {
private String postName;
private String aiName;
}

2
dk-modules/system/src/main/java/org/dromara/system/dubbo/RemoteLabelPostServicelmpl.java

@ -44,6 +44,7 @@ public class RemoteLabelPostServicelmpl implements RemoteLabelPostService {
remoteAiLabelPostVo.setLabelId(aiLabel.getLabelId());
remoteAiLabelPostVo.setLabelEn(aiLabel.getLabelEn());
remoteAiLabelPostVo.setLabelCn(aiLabel.getLabelCn());
remoteAiLabelPostVo.setAiName(aiLabel.getAiName());
return remoteAiLabelPostVo;
})
.collect(Collectors.toList());
@ -59,6 +60,7 @@ public class RemoteLabelPostServicelmpl implements RemoteLabelPostService {
remoteAiLabelPostVo.setLabelId(aiLabel.getLabelId());
remoteAiLabelPostVo.setLabelEn(aiLabel.getLabelEn());
remoteAiLabelPostVo.setLabelCn(aiLabel.getLabelCn());
remoteAiLabelPostVo.setAiName(aiLabel.getAiName());
return remoteAiLabelPostVo;
})
.collect(Collectors.toList());

4
dk-modules/system/src/main/resources/mapper/system/AiLabelPostMapper.xml

@ -5,10 +5,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="org.dromara.system.mapper.AiLabelPostMapper">
<select id="selectAiLabelPostPage" resultType="org.dromara.system.domain.vo.AiLabelPostVo">
SELECT *,a.label_cn ,label_en FROM ai_label_post p inner JOIN ai_label a ON p.label_id = a.label_id ${ew.customSqlSegment}
SELECT *,a.label_cn ,a.label_en FROM ai_label_post p inner JOIN ai_label a ON p.label_id = a.label_id ${ew.customSqlSegment}
</select>
<select id="queryListByLabel" resultType="org.dromara.system.domain.vo.AiLabelPostVo">
SELECT p.*,a.label_cn ,label_en FROM ai_label_post p inner JOIN ai_label a ON p.label_id = a.label_id
SELECT p.*,a.label_cn ,a.label_en,a.ai_name FROM ai_label_post p inner JOIN ai_label a ON p.label_id = a.label_id
where p.post_id = #{postId}
</select>

Loading…
Cancel
Save