Browse Source

修改104号模型

main
sjh 1 year ago
parent
commit
097012e83d
  1. 4
      src/main/java/com/biutag/supervision/pojo/entity/ModelClue.java
  2. 32
      src/main/java/com/biutag/supervision/service/ModelClueService.java

4
src/main/java/com/biutag/supervision/pojo/entity/ModelClue.java

@ -76,6 +76,10 @@ public class ModelClue {
@TableField(exist = false)
private Long zjjs;
// 104号模型用
@TableField(exist = false)
private Long allZjjs;
// 执法场所登记数
@TableField(exist = false)
private Long zfcsdjs;

32
src/main/java/com/biutag/supervision/service/ModelClueService.java

@ -1048,7 +1048,7 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
private void getModelCluesForModel104(String param, List<ModelClue> modelClues) {
System.out.println("模型104开始查询数据库");
List<String> params = parseSqlForModel2(param);
String sql = "SELECT gxdwdm, gxdwmc, COUNT(*) AS zjjs from dwd_asj_zhtx_jjd where bjsj BETWEEN '" + params.get(0) + " 00:00:00' AND '" + params.get(1) + " 00:00:00' AND jqjb != '04' AND (ysjqxzdm LIKE '01%' OR ysjqxzdm LIKE'02%' OR ysjqxzdm LIKE'06%') AND (bjxldm NOT LIKE '01%' AND bjxldm NOT LIKE '02%' AND bjxldm NOT LIKE '06%') and bjfsdm = '0101' GROUP BY gxdwdm, gxdwmc;";
String sql = "select a.gxdwdm, a.gxdwmc, a.num anum, b.num bnum from ((SELECT gxdwdm, gxdwmc, COUNT(*) AS zjjs from dwd_asj_zhtx_jjd where bjsj BETWEEN '" + params.get(0) + " 00:00:00' AND '" + params.get(1) + " 00:00:00' AND (ysjqxzdm LIKE '01%' OR ysjqxzdm LIKE'02%' OR ysjqxzdm LIKE'06%') AND (bjxldm NOT LIKE '01%' AND bjxldm NOT LIKE '02%' AND bjxldm NOT LIKE '06%') and bjfsdm = '0101' GROUP BY gxdwdm, gxdwmc) a join (SELECT gxdwdm, gxdwmc, COUNT(*) AS zjjs from dwd_asj_zhtx_jjd where bjsj BETWEEN '" + params.get(0) + " 00:00:00' AND '" + params.get(1) + " 00:00:00' AND (ysjqxzdm LIKE '01%' OR ysjqxzdm LIKE'02%' OR ysjqxzdm LIKE'06%') and bjfsdm = '0101' GROUP BY gxdwdm, gxdwmc) b on a.gxdwdm = b.gxdwdm);";
List<Map<String, Object>> jjdmaps = modelClueDataMapper.selectByUniqueKeys(sql);
System.out.println("模型104查询数据库完毕");
if (jjdmaps.isEmpty()) {
@ -1062,7 +1062,8 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
modelClue.setData(JSONObject.toJSONString(data));
modelClue.setInvolveDepartId(supExternalDepart.getExternalId());
modelClue.setInvolveDepartName(supExternalDepart.getExternalName());
modelClue.setZjjs((Long) data.get("zjjs"));
modelClue.setZjjs((Long) data.get("anum"));
modelClue.setAllZjjs((Long)data.get("bnum"));
modelClue.setDepartLevel(supExternalDepart.getLevel());
modelClue.setParentId(supExternalDepart.getPid());
modelClue.setThisId(supExternalDepart.getInternalId());
@ -1072,22 +1073,19 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
List<ModelClue> jjdModelClues3 = new ArrayList<>(jjdModelClues.stream().filter(clue -> clue.getDepartLevel() == 3).toList());
List<ModelClue> jjdModelClues4 = new ArrayList<>(jjdModelClues.stream().filter(clue -> clue.getDepartLevel() == 4).toList());
List<ModelClue> jjdModelClues5 = new ArrayList<>(jjdModelClues.stream().filter(clue -> clue.getDepartLevel() == 5).toList());
mergeModelClues(jjdModelClues5, jjdModelClues4, 1);
mergeModelClues(jjdModelClues4, jjdModelClues3, 1);
BigDecimal zjjsTotal = BigDecimal.valueOf(jjdModelClues3.stream().mapToLong(ModelClue::getZjjs).sum());
mergeModelClues(jjdModelClues5, jjdModelClues4, 3);
mergeModelClues(jjdModelClues4, jjdModelClues3, 3);
Map<String, BigDecimal> departPercentageMap = new HashMap<>();
Map<String, Long> departNumMap = new HashMap<>();
Map<String, Long> departAllNumMap = new HashMap<>();
for (ModelClue jjdModelClue : jjdModelClues3) {
BigDecimal percentage = BigDecimal.valueOf(jjdModelClue.getZjjs()).divide(zjjsTotal, 3, RoundingMode.HALF_UP);
BigDecimal percentage = BigDecimal.valueOf(jjdModelClue.getZjjs()).divide(BigDecimal.valueOf(jjdModelClue.getAllZjjs()), 3, RoundingMode.HALF_UP);
departPercentageMap.put(jjdModelClue.getInvolveDepartId(), percentage);
departNumMap.put(jjdModelClue.getInvolveDepartId(), jjdModelClue.getZjjs());
departAllNumMap.put(jjdModelClue.getInvolveDepartId(), jjdModelClue.getAllZjjs());
}
BigDecimal sumOfPercentages = departPercentageMap.values().stream()
.reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal avgPercentage = sumOfPercentages.divide(BigDecimal.valueOf(departPercentageMap.size()), 3, RoundingMode.HALF_UP);
BigDecimal multiply = avgPercentage.multiply(new BigDecimal("1.5"));
List<String> highPercentageDepartments = departPercentageMap.entrySet().stream()
.filter(entry -> entry.getValue().compareTo(multiply) > 0)
.filter(entry -> entry.getValue().compareTo(BigDecimal.valueOf(0.7)) > 0)
.map(Map.Entry::getKey)
.toList();
for (String department : highPercentageDepartments) {
@ -1106,10 +1104,8 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
newModelClue.setDistributionState("0");
newModelClue.setThingDesc("发现" + newModelClue.getInvolveDepartName()
+ "在" + getDateString(params.get(0)) + "到" + getDateString(params.get(1))
+ "之间变更了" + departNumMap.get(department) + "个警情的结警性质,占全市的"
+ convertToPercentString(departPercentageMap.get(department)) + ",超过了全市单位平均值("
+ convertToPercentString(avgPercentage) + ")的50%(即"
+ convertToPercentString(multiply) + ")以上,存在大量变更接警性质的异常情况。");
+ "之间共有" + departAllNumMap.get(department) + "个警情,变更了" + departNumMap.get(department)
+ "个警情的结警性质,超过了该单位总警情的70%,存在大量变更接警性质的异常情况。");
newModelClue.setData(newModelClue.getThingDesc());
modelClues.add(newModelClue);
}
@ -1126,6 +1122,9 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
modelClue1.setZjjs(modelClue2.getZjjs() + modelClue1.getZjjs());
} else if (no == 2) {
modelClue1.setZfcsdjs(modelClue2.getZfcsdjs() + modelClue1.getZfcsdjs());
} else if (no == 3) {
modelClue1.setZjjs(modelClue2.getZjjs() + modelClue1.getZjjs());
modelClue1.setAllZjjs(modelClue2.getAllZjjs() + modelClue1.getAllZjjs());
}
modelClue1.setData(modelClue1.getData() + modelClue2.getData());
found = true;
@ -1146,6 +1145,9 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
newModelClue.setZjjs(modelClue2.getZjjs());
} else if (no == 2) {
newModelClue.setZfcsdjs(modelClue2.getZfcsdjs());
} else if (no == 3) {
newModelClue.setZjjs(modelClue2.getZjjs());
newModelClue.setAllZjjs(modelClue2.getAllZjjs());
}
modelClues1.add(newModelClue);
} else {

Loading…
Cancel
Save