Browse Source

修改人员标签和风险项的入库逻辑

master
kami 1 year ago
parent
commit
21056d21de
  1. 5
      src/main/java/com/biutag/supervisiondata/pojo/ClueData.java
  2. 4
      src/main/java/com/biutag/supervisiondata/pojo/entity/mine/RiskModelTaskClue.java
  3. 69
      src/main/java/com/biutag/supervisiondata/service/impl/PointServiceImpl.java
  4. 17
      src/main/java/com/biutag/supervisiondata/service/impl/RiskModelTaskClueServiceImpl.java
  5. 36
      src/main/java/com/biutag/supervisiondata/util/DataUtil.java

5
src/main/java/com/biutag/supervisiondata/pojo/ClueData.java

@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author kami on 2024-11-13 13:08:18
@ -44,4 +45,8 @@ public class ClueData implements Serializable {
Integer personId;
String sourceData;
List<String> tags;
Integer score;
}

4
src/main/java/com/biutag/supervisiondata/pojo/entity/mine/RiskModelTaskClue.java

@ -6,6 +6,7 @@ import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author kami on 2024-11-11 11:37:50
@ -111,6 +112,9 @@ public class RiskModelTaskClue implements Serializable {
@TableField("update_time")
LocalDateTime updateTime;
@TableField(exist = false)
List<String> tags;
/**
* 逻辑删除键
*/

69
src/main/java/com/biutag/supervisiondata/service/impl/PointServiceImpl.java

@ -6,7 +6,6 @@ import com.biutag.supervisiondata.common.interfaces.CompletableFutureUtil;
import com.biutag.supervisiondata.common.utils.StreamUtil;
import com.biutag.supervisiondata.config.cache.RedisDao;
import com.biutag.supervisiondata.mapper.dwd.ModelClueDataMapper;
import com.biutag.supervisiondata.mapper.mine.SupDepartMapper;
import com.biutag.supervisiondata.pojo.ClueData;
import com.biutag.supervisiondata.pojo.constants.Default;
import com.biutag.supervisiondata.pojo.database.MuchCall;
@ -23,6 +22,7 @@ import com.biutag.supervisiondata.service.PointService;
import com.biutag.supervisiondata.service.RiskModelTaskClueService;
import com.biutag.supervisiondata.service.RiskPersonalService;
import com.biutag.supervisiondata.util.BhUtil;
import com.biutag.supervisiondata.util.DataUtil;
import com.biutag.supervisiondata.util.IdCodeUtil;
import com.biutag.supervisiondata.util.PatternUtil;
import lombok.AllArgsConstructor;
@ -124,12 +124,23 @@ public class PointServiceImpl implements PointService {
if (sb.isEmpty()) {
continue;
}
toInsert.add(createClue(task.getModelId(), 5, task.getId(), ClueData.builder()
.tag("重点人员")
// toInsert.add(createClue(task.getModelId(), 5, task.getId(), ClueData.builder()
// .tag("重点人员")
// .name(personals.getFirst().getName())
// .idCode(personals.getFirst().getIdCode())
// .eventTime(Optional.ofNullable(personals.getFirst().getControlTime()).orElse(LocalDateTime.now()))
// .sourceData("发现该人员为重点人员,存在" + personals.size() + "个标签")
// .build()));
toInsert.add(DataUtil.createClueData(task, ClueData.builder()
// 案件编号、接警单编号之类
.id("")
.score(5)
.personId(personals.getFirst().getId())
.tags(List.of("重点人员"))
.sourceData("发现该人员为重点人员,存在" + personals.size() + "个标签")
.name(personals.getFirst().getName())
.idCode(personals.getFirst().getIdCode())
.eventTime(Optional.ofNullable(personals.getFirst().getControlTime()).orElse(LocalDateTime.now()))
.sourceData("该人员存在标签:" +sb.substring(0,sb.length()-1) + ",属于重点人员")
.eventTime(personals.getFirst().getControlTime())
.build()));
}
if (!toInsert.isEmpty()) {
@ -156,7 +167,7 @@ public class PointServiceImpl implements PointService {
List<RiskModelTaskClue> olds = Optional.ofNullable(domain.getMap().get(task.getModelId())).orElse(new ArrayList<>());
Map<String, List<RiskModelTaskClue>> personMap = olds.stream().collect(Collectors.groupingBy(RiskModelTaskClue::getIdCode));
List<RiskModelTaskClue> toInsert = new ArrayList<>();
Map<String, List<RiskModelTaskClue>> mapPerson = new WeakHashMap<>();
Map<String, List<ClueData>> mapPerson = new WeakHashMap<>();
for (GBaseZDRY ry : list) {
RiskPersonal person = personalMap.get(ry.getSfzh());
if (person == null) {
@ -180,18 +191,43 @@ public class PointServiceImpl implements PointService {
.tag(zblx.getDmmc())
.name(person.getName())
.idCode(person.getIdCode())
.sourceData("该人员存在标签:" + zblx.getDmmc() )
.score(zblx.getScore().intValue())
.build();
try {
data.setEventTime(LocalDateTime.parse(ry.getJlbgsj(), DateTimeFormatter.ofPattern("yyyyMMddHHmmss")));
} catch (Exception e) {
data.setEventTime(LocalDateTime.now());
} catch (Exception ignored) {
}
mapPerson.computeIfAbsent(person.getIdCode(), k -> new ArrayList<>()).add(createClue(task.getModelId(), zblx.getScore().intValue(), task.getId(), data));
mapPerson.computeIfAbsent(person.getIdCode(), k -> new ArrayList<>()).add(data);
}
}
for (Map.Entry<String, List<RiskModelTaskClue>> entry : mapPerson.entrySet()) {
toInsert.addAll(entry.getValue().stream().filter(StreamUtil.distinctByKey(RiskModelTaskClue::getRiskReason)).toList());
for (Map.Entry<String, List<ClueData>> entry : mapPerson.entrySet()) {
LocalDateTime tmpDateTime = null;
List<ClueData> tmp = entry.getValue().stream().filter(StreamUtil.distinctByKey(ClueData::getTag)).toList();
StringBuilder sb = new StringBuilder();
int score = 0;
List<String> tags = new ArrayList<>();
for (ClueData clue : tmp) {
if (tmpDateTime == null) {
tmpDateTime = clue.getEventTime();
}
if (tmpDateTime.isBefore(clue.getEventTime())) {
tmpDateTime = clue.getEventTime();
}
tags.add(clue.getTag());
sb.append(clue.getTag()).append(",");
score += clue.getScore();
}
toInsert.add(DataUtil.createClueData(task, ClueData.builder()
// 案件编号、接警单编号之类
.id("")
.score(Math.min(5, score))
.personId(tmp.getFirst().getPersonId())
.tags(tags)
.sourceData(sb.substring(0, sb.length() - 1))
.name(tmp.getFirst().getName())
.idCode(tmp.getFirst().getIdCode())
.eventTime(tmpDateTime)
.build()));
}
if (!toInsert.isEmpty()) {
log.info("保存重点人员标签 {}", toInsert.size());
@ -644,7 +680,8 @@ public class PointServiceImpl implements PointService {
Map<String, Integer> idCode = new HashMap<>();
log.info("模型129开始查询");
List<WdpcGrjdJsbry> list1 = jsbryRepository.getBaseMapper().selectByIdNos();
List<WdpcJZJLB> list2 = jZJLBRepository.getBaseMapper().selectForModel129();;
List<WdpcJZJLB> list2 = jZJLBRepository.getBaseMapper().selectForModel129();
;
List<WdpcXdry> list3 = xdryRepository.getBaseMapper().selectXIDU();
List<WdpcSqjzry> list4 = sqjzryRepository.getBaseMapper().selectByIdNos();
List<WdpcXmsfry> list5 = xmsfryRepository.getBaseMapper().selectByIdNos();
@ -767,7 +804,8 @@ public class PointServiceImpl implements PointService {
Map<String, Integer> idCode = new HashMap<>();
log.info("模型130开始查询");
List<WdpcGrjdJsbry> list1 = jsbryRepository.getBaseMapper().selectByIdNos();
List<WdpcJZJLB> list2 = jZJLBRepository.getBaseMapper().selectForModel129();;
List<WdpcJZJLB> list2 = jZJLBRepository.getBaseMapper().selectForModel129();
;
List<WdpcXdry> list3 = xdryRepository.getBaseMapper().selectXIDU();
List<WdpcSqjzry> list4 = sqjzryRepository.getBaseMapper().selectByIdNos();
List<WdpcXmsfry> list5 = xmsfryRepository.getBaseMapper().selectByIdNos();
@ -1505,7 +1543,8 @@ public class PointServiceImpl implements PointService {
"中技毕业", "中等专科学校", "高中", "高中毕业", "农业高中毕业" -> 3;// 高中中专
case "农业初中毕业", "技工学校", "技工学校肄业", "技工学校毕业", "初中", "职业初中毕业", "初中毕业",
"初中肆业", "相当初中毕业" -> 4;// 初中
case "小学", "小学肄业", "小学肆业", "小学毕业", "相当小学毕业", "文盲", "文盲或半文盲", "学龄前儿童" -> 5;// 小学
case "小学", "小学肄业", "小学肆业", "小学毕业", "相当小学毕业", "文盲", "文盲或半文盲", "学龄前儿童" ->
5;// 小学
default -> 0;
};
}

17
src/main/java/com/biutag/supervisiondata/service/impl/RiskModelTaskClueServiceImpl.java

@ -106,20 +106,13 @@ public class RiskModelTaskClueServiceImpl implements RiskModelTaskClueService {
oldMap.put(tag.getSmallTag(), new Byte[0]);
}
for (RiskModelTaskClue clue : entry.getValue()) {
if (bigTag.equals(Default.BIG_TAG_SHWFR)) {
String[] strs = clue.getRiskReason().split(",");
for (int i = 0, len = strs.length; i < len; i++) {
if (oldMap.get(strs[i]) == null) {
tags.add(creatTag(bigTag, strs[i], clue));
oldMap.put(strs[i], new Byte[0]);
for (String tag : clue.getTags()) {
if (oldMap.get(tag) == null) {
tags.add(creatTag(bigTag, tag, clue));
oldMap.put(tag, new Byte[0]);
}
}
continue;
}
if (oldMap.get(clue.getRiskReason()) == null) {
tags.add(creatTag(bigTag, clue.getRiskReason(), clue));
oldMap.put(clue.getRiskReason(), new Byte[0]);
}
}
}
if (!tags.isEmpty()) {

36
src/main/java/com/biutag/supervisiondata/util/DataUtil.java

@ -0,0 +1,36 @@
package com.biutag.supervisiondata.util;
import com.biutag.supervisiondata.pojo.ClueData;
import com.biutag.supervisiondata.pojo.entity.mine.RiskModelTaskClue;
import com.biutag.supervisiondata.pojo.entity.mine.RiskTask;
import lombok.experimental.UtilityClass;
import java.time.LocalDateTime;
import java.util.Optional;
/**
* @author kami on 2024-12-13 16:30:46
* @version 0.0.1
* @since 1.8
*/
@UtilityClass
public class DataUtil {
public static RiskModelTaskClue createClueData(RiskTask task, ClueData data) {
RiskModelTaskClue clue = new RiskModelTaskClue();
clue.setModelId(task.getModelId());
clue.setScore(data.getScore());
clue.setName(data.getName());
clue.setIdCode(data.getIdCode());
clue.setTaskId(task.getId());
clue.setData(data.getSourceData());
clue.setEventTime(data.getEventTime());
clue.setCreateTime(LocalDateTime.now());
clue.setUpdateTime(LocalDateTime.now());
clue.setCaseIds(data.getId());
clue.setRiskReason(data.getTag());
clue.setEventTime(Optional.ofNullable(data.getEventTime()).orElse(LocalDateTime.now()));
clue.setTags(data.getTags());
return clue;
}
}
Loading…
Cancel
Save