Browse Source

修改26号模型

main
sjh 1 year ago
parent
commit
ed418f6513
  1. 71
      src/main/java/com/biutag/supervision/service/ModelClueService.java

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

@ -24,10 +24,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
@ -252,7 +249,7 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
List<String> uniqueKeys = modelClues.stream().map(ModelClue::getUniqueKey).filter(k -> k != null && !k.isEmpty()).toList();
List<String> oldUniqueKeys = new ArrayList<>();
// 无需更新状态的模型
if (modelId != 19 && modelId != 27 && modelId != 28 && modelId != 30) {
if (modelId != 19 && modelId != 26 && modelId != 27 && modelId != 28 && modelId != 30) {
oldUniqueKeys = this.listObjs(new LambdaQueryWrapper<ModelClue>().select(ModelClue::getUniqueKey).ne(ModelClue::getDistributionState, "2").eq(ModelClue::getModelId, modelId), String::valueOf);
List<String> changeStatusIds = oldUniqueKeys.stream().filter(item -> !uniqueKeys.contains(item)).toList();
if (!changeStatusIds.isEmpty()) {
@ -273,32 +270,26 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
return new ArrayList<>();
}
List<ModelClue> needsInsertModelClues = modelClues.stream().filter(item -> needsInsertIds.contains(item.getUniqueKey())).toList();
System.out.println("needsInsertModelClues:" + needsInsertModelClues.size());
String newSql = generateNewSql(sql, needsInsertIds, modelId);
System.out.println("开始查询新sql" + newSql);
List<Map<String, Object>> allData = modelClueDataMapper.selectByUniqueKeys(newSql);
if (modelId == 26) {
filterDataForModel26(allData);
}
System.out.println("查询新sql完成,结果数量:" + allData.size());
String originalFieldName = getKeyFieldName(sql);
System.out.println("originalFieldName:" + originalFieldName);
for (ModelClue modelClue : needsInsertModelClues) {
for (Map<String, Object> data : allData) {
String keyColumn = (String) data.get(originalFieldName);
System.out.println("测试1:" + keyColumn + "测试" + modelClue.getUniqueKey());
if (Objects.equals(keyColumn, modelClue.getUniqueKey())) {
System.out.println("测试2");
modelClue.setData(JSONObject.toJSONString(data));
modelClue.setDistributionState("0");
System.out.println("测试3");
SupExternalDepart supExternalDepart = supExternalDepartMapper.selectOne(new LambdaQueryWrapper<SupExternalDepart>().eq(SupExternalDepart::getExternalId, modelClue.getInvolveDepartId()).last("LIMIT 1"));
System.out.println("测试4"+modelClue.getInvolveDepartId());
if (supExternalDepart != null && supExternalDepart.getInternalShortName() != null && !supExternalDepart.getInternalShortName().isEmpty()) {
System.out.println("测试5");
modelClue.setInvolveDepartName(supExternalDepart.getInternalShortName());
modelClue.setInvolveDepartId(supExternalDepart.getInternalId());
}
System.out.println("测试6");
setPerson(modelId, modelClue, data);
System.out.println("测试7");
generateThingDesc(modelId, modelClue, data);
System.out.println("测试8");
break;
@ -308,6 +299,54 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
return needsInsertModelClues;
}
private static void filterDataForModel26(List<Map<String, Object>> allData) {
List<Map<String, Object>> filteredData = allData.stream().filter(map -> map.get("ajbh") != null).toList();
Map<String, List<Map<String, Object>>> groupedData = filteredData.stream().collect(Collectors.groupingBy(map -> (String) map.get("ajbh")));
allData.clear();
for (Map.Entry<String, List<Map<String, Object>>> entry : groupedData.entrySet()) {
String ajbh = entry.getKey();
List<Map<String, Object>> records = entry.getValue();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
String earliestJRSJ = null;
LocalDateTime earliestDateTime = LocalDateTime.MIN;
for (Map<String, Object> record : records) {
String jrsj = (String) record.get("jrsj");
LocalDateTime dateTime = LocalDateTime.parse(jrsj, formatter);
if (earliestJRSJ == null || !dateTime.isAfter(earliestDateTime)) {
earliestJRSJ = jrsj;
earliestDateTime = dateTime;
}
}
String latestLKSJ = null;
LocalDateTime latestDateTime = LocalDateTime.MIN;
for (Map<String, Object> record : records) {
String lksj = (String) record.get("lksj");
LocalDateTime dateTime = LocalDateTime.parse(lksj, formatter);
if (latestLKSJ == null || dateTime.isAfter(latestDateTime)) {
latestLKSJ = lksj;
latestDateTime = dateTime;
}
}
if (earliestJRSJ != null && latestLKSJ != null) {
Duration duration = Duration.between(earliestDateTime, latestDateTime);
if (duration.toHours() < 3) {
continue;
}
Map<String, Object> newRecord = new HashMap<>();
newRecord.put("ajbh", ajbh);
newRecord.put("jrsj", earliestJRSJ);
newRecord.put("lksj", latestLKSJ);
for (String key : records.get(0).keySet()) {
if (!key.equals("jrsj") && !key.equals("lksj")) {
newRecord.put(key, records.get(0).get(key));
}
}
allData.add(newRecord);
}
}
System.out.println("模型26筛选后的alldata数量:" + allData.size());
}
private void setPerson(Integer modelId, ModelClue modelClue, Map<String, Object> data) {
// 执法区域人员表
if (modelId == 3) {
@ -487,10 +526,10 @@ public class ModelClueService extends ServiceImpl<ModelClueMapper, ModelClue> {
} else if (modelId == 26) { // 26号模型:执法办案场所进出时间过短
if (data.get("lksj") != null && !data.get("lksj").equals("")) {
modelClue.setThingDesc("发现" + modelClue.getInvolveDepartName() + "办理的被处以刑事打处的嫌疑人员“"
+ data.get("xm") + "”(身份证号" + data.get("zjhm")
+ data.get("xm") + "”(身份证号" + data.get("zjhm")
+ "),其于" + getDateMinuteString(data.get("jrsj"))
+ "登记进入" + modelClue.getInvolveDepartName()
+ "执法办案区,但仅停留" + calculateMinutesBetween(data.get("djsj"), data.get("lksj"))
+ "执法办案区,但仅停留" + calculateMinutesBetween(data.get("jrsj"), data.get("lksj"))
+ "后便予以离开,少于3小时,与正常开展流程办理刑事案件所需时长相违背,存在疑似不如实登记执法办案场所的异常问题。");
}
} else if (modelId == 27) { // 27号模型:盗窃车内财物警情结警性质变动的异常数据

Loading…
Cancel
Save