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. 103
      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;
/**
* 逻辑删除键
*/

103
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;
@ -121,15 +121,26 @@ public class PointServiceImpl implements PointService {
for (RiskPersonal personal : personals) {
sb.append(personal.getTags()).append(",");
}
if(sb.isEmpty()){
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,10 +167,10 @@ 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) {
if (person == null) {
continue;
}
List<String> codes = PatternUtil.takeMarkPositionToString(ry.getZdrylbbj());
@ -171,7 +182,7 @@ public class PointServiceImpl implements PointService {
codes = codes.stream().distinct().toList();
for (String index : codes) {
WdpcGrjdZblx zblx = map.get(index);
if(oldClue.get(index) != null || zblx == null) {
if (oldClue.get(index) != null || zblx == null) {
continue;
}
ClueData data = ClueData.builder()
@ -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());
@ -330,7 +366,7 @@ public class PointServiceImpl implements PointService {
.tag("受到行政处罚")
.eventTime(LocalDateTime.now())
.personId(personal.getId())
.sourceData("发现该人员涉及" + wfrwfxxList.size() + "个行政处罚,案件编号为:“" + context + "”" )
.sourceData("发现该人员涉及" + wfrwfxxList.size() + "个行政处罚,案件编号为:“" + context + "”")
.build();
toInsert.add(createClue(task.getModelId(), score, task.getId(), data));
}
@ -378,7 +414,7 @@ public class PointServiceImpl implements PointService {
.tag("受到刑事处罚")
.eventTime(LocalDateTime.now())
.personId(personal.getId())
.sourceData("发现该人员涉及" + wfrwfxxList.size() + "个刑事案件,案件编号为:“" + context + "”" )
.sourceData("发现该人员涉及" + wfrwfxxList.size() + "个刑事案件,案件编号为:“" + context + "”")
.build();
toInsert.add(createClue(task.getModelId(), score, task.getId(), data));
}
@ -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();
@ -999,7 +1037,7 @@ public class PointServiceImpl implements PointService {
.tag("父母关系状况")
.eventTime(LocalDateTime.now())
.personId(personal.getId())
.sourceData("发现该人员父母关系状况不佳,关联接警单单号为" + domicileType.get("jjdbh") )
.sourceData("发现该人员父母关系状况不佳,关联接警单单号为" + domicileType.get("jjdbh"))
.build();
toInsert.add(createClue(task.getModelId(), 5, task.getId(), data));
}
@ -1274,7 +1312,7 @@ public class PointServiceImpl implements PointService {
if (oldMap.get(domicileType.getGmsfhm()) != null) continue;
idCode.put(domicileType.getGmsfhm(), 1);
if (domicileType.getScore() == 0){
if (domicileType.getScore() == 0) {
continue;
}
int realScore = 0;
@ -1292,7 +1330,7 @@ public class PointServiceImpl implements PointService {
.tag("行为人子女数")
.eventTime(LocalDateTime.now())
.personId(personal.getId())
.sourceData("发现该人员子女数为" + domicileType.getScore() )
.sourceData("发现该人员子女数为" + domicileType.getScore())
.build();
toInsert.add(createClue(task.getModelId(), realScore, task.getId(), data));
}
@ -1391,7 +1429,7 @@ public class PointServiceImpl implements PointService {
.tag("户籍类型")
.eventTime(LocalDateTime.now())
.personId(personal.getId())
.sourceData("发现该人员户籍类型为" + domicileType.getHlxmc() )
.sourceData("发现该人员户籍类型为" + domicileType.getHlxmc())
.build();
toInsert.add(createClue(task.getModelId(), 5, task.getId(), data));
}
@ -1433,7 +1471,7 @@ public class PointServiceImpl implements PointService {
.tag("父亲文化程度")
.eventTime(LocalDateTime.now())
.personId(personal.getId())
.sourceData("发现该人员父亲文化程度为" + fatherEducation.getFatherEducation() )
.sourceData("发现该人员父亲文化程度为" + fatherEducation.getFatherEducation())
.build();
toInsert.add(createClue(task.getModelId(), eduScore, task.getId(), data));
}
@ -1505,7 +1543,8 @@ public class PointServiceImpl implements PointService {
"中技毕业", "中等专科学校", "高中", "高中毕业", "农业高中毕业" -> 3;// 高中中专
case "农业初中毕业", "技工学校", "技工学校肄业", "技工学校毕业", "初中", "职业初中毕业", "初中毕业",
"初中肆业", "相当初中毕业" -> 4;// 初中
case "小学", "小学肄业", "小学肆业", "小学毕业", "相当小学毕业", "文盲", "文盲或半文盲", "学龄前儿童" -> 5;// 小学
case "小学", "小学肄业", "小学肆业", "小学毕业", "相当小学毕业", "文盲", "文盲或半文盲", "学龄前儿童" ->
5;// 小学
default -> 0;
};
}
@ -1843,7 +1882,7 @@ public class PointServiceImpl implements PointService {
}
data.setTag(Default.NO_CAR_OIL_BUY);
data.setSourceData("发现该人员属于无车人员,于" + item.getTime() + "在" + item.getCompanyName() + "购买容量为" + item.getNumber() + "L的" + item.getType() + ",用作" + item.getUseTo() );
data.setSourceData("发现该人员属于无车人员,于" + item.getTime() + "在" + item.getCompanyName() + "购买容量为" + item.getNumber() + "L的" + item.getType() + ",用作" + item.getUseTo());
toInsert.add(createClue(task.getModelId(), 5, task.getId(), data));
}
}
@ -1977,7 +2016,7 @@ public class PointServiceImpl implements PointService {
List<String> idCodes = new ArrayList<>();
for (RiskPersonal person : domain.getPersons()) {
// 增加
if(exist.get(person.getIdCode())!=null && clueMap.get(person.getIdCode()) == null) {
if (exist.get(person.getIdCode()) != null && clueMap.get(person.getIdCode()) == null) {
ClueData data = ClueData.builder()
.name(person.getName())
.id("car_man")
@ -1992,7 +2031,7 @@ public class PointServiceImpl implements PointService {
toInsert.add(createClue(task.getModelId(), 5, task.getId(), data));
}
// 减少
if(exist.get(person.getIdCode())==null && clueMap.get(person.getIdCode())!=null) {
if (exist.get(person.getIdCode()) == null && clueMap.get(person.getIdCode()) != null) {
RiskModelTaskClue old = clueMap.get(person.getIdCode());
RiskModelTaskClue delete = new RiskModelTaskClue();
delete.setId(old.getId());
@ -2093,7 +2132,7 @@ public class PointServiceImpl implements PointService {
}
Map<Integer, String> lbMap = new WeakHashMap<>();
Map<String, SupExternalDepart> supExternalDepartMap = supDeparts.stream().collect(Collectors.toMap(SupExternalDepart::getExternalId, Function.identity(), (val,old) -> val));
Map<String, SupExternalDepart> supExternalDepartMap = supDeparts.stream().collect(Collectors.toMap(SupExternalDepart::getExternalId, Function.identity(), (val, old) -> val));
for (GBaseTbDZdrylb lb : lbList) {
@ -2133,7 +2172,7 @@ public class PointServiceImpl implements PointService {
Map<String, Integer> tmp = Optional.ofNullable(map.get(ry.getSfzh())).orElse(new HashMap<>());
PointOrg org = orgCodeMap.get(ry.getGxdwjgdm());
org = findOrg(org, orgIdMap);
if(org == null) {
if (org == null) {
noOrgCount++;
continue;
}
@ -2191,10 +2230,10 @@ public class PointServiceImpl implements PointService {
}
PointOrg findOrg(PointOrg org, Map<String, PointOrg> orgIdMap) {
if(org == null) {
if (org == null) {
return null;
}
if(org.getPcs() == null || !org.getPcs().equals("1")) {
if (org.getPcs() == null || !org.getPcs().equals("1")) {
return findOrg(orgIdMap.get(org.getPid()), orgIdMap);
}
return org;

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