|
|
|
|
@ -1,21 +1,18 @@
|
|
|
|
|
package com.biutag.supervisiondata.service.impl; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON; |
|
|
|
|
import com.alibaba.fastjson2.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.biutag.supervisiondata.common.interfaces.CompletableFutureUtil; |
|
|
|
|
import com.biutag.supervisiondata.pojo.ClueData; |
|
|
|
|
import com.biutag.supervisiondata.pojo.constants.Area; |
|
|
|
|
import com.biutag.supervisiondata.pojo.constants.Default; |
|
|
|
|
import com.biutag.supervisiondata.pojo.database.PointOrg; |
|
|
|
|
import com.biutag.supervisiondata.pojo.domain.FightMan; |
|
|
|
|
import com.biutag.supervisiondata.pojo.domain.TaskParamDomain; |
|
|
|
|
import com.biutag.supervisiondata.pojo.entity.ads.GBaseSYRKXX; |
|
|
|
|
import com.biutag.supervisiondata.pojo.entity.dwd.GBaseJJD; |
|
|
|
|
import com.biutag.supervisiondata.pojo.entity.mine.*; |
|
|
|
|
import com.biutag.supervisiondata.pojo.enums.Edu; |
|
|
|
|
import com.biutag.supervisiondata.pojo.enums.Age; |
|
|
|
|
import com.biutag.supervisiondata.pojo.enums.EduType; |
|
|
|
|
import com.biutag.supervisiondata.repository.*; |
|
|
|
|
import com.biutag.supervisiondata.service.RiskModelTaskClueService; |
|
|
|
|
import com.biutag.supervisiondata.service.RiskPersonalService; |
|
|
|
|
import com.biutag.supervisiondata.service.RiskTaskService; |
|
|
|
|
import com.biutag.supervisiondata.util.*; |
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
|
@ -27,7 +24,6 @@ import java.time.LocalDateTime;
|
|
|
|
|
import java.time.ZoneId; |
|
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.concurrent.CompletableFuture; |
|
|
|
|
import java.util.function.Function; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
@ -51,95 +47,69 @@ public class RiskTaskServiceImpl implements RiskTaskService {
|
|
|
|
|
|
|
|
|
|
private final RiskModelTaskClueService riskModelTaskClueService; |
|
|
|
|
|
|
|
|
|
private final RiskPersonalService riskPersonalService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void infoModelTask(TaskParamDomain domain) { |
|
|
|
|
RiskTask genderTask = riskTaskRepository.create(domain.getPersons().size(), 32); |
|
|
|
|
RiskTask ageTask = riskTaskRepository.create(domain.getPersons().size(), 33); |
|
|
|
|
|
|
|
|
|
CompletableFuture.allOf( |
|
|
|
|
CompletableFutureUtil.runSyncObject(() -> ageModel(domain, ageTask)), |
|
|
|
|
CompletableFutureUtil.runSyncObject(() -> genderModel(domain, genderTask)) |
|
|
|
|
).join(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void eduModelTask(TaskParamDomain domain) { |
|
|
|
|
RiskTask eduTask = riskTaskRepository.create(domain.getPersons().size(), 34); |
|
|
|
|
Map<String, RiskModelTaskClue> oldAgeMap = domain.getOldMap(ageTask.getModelId(), true); |
|
|
|
|
Map<String, RiskModelTaskClue> oldGenderMap = domain.getOldMap(genderTask.getModelId(), true); |
|
|
|
|
|
|
|
|
|
List<GBaseSYRKXX> xxList = new ArrayList<>(); |
|
|
|
|
int count = 0; |
|
|
|
|
log.info("开始查学历 | {}", domain.getIdCards().size()); |
|
|
|
|
for (List<String> idCard : domain.getIdCards()) { |
|
|
|
|
count++; |
|
|
|
|
xxList.addAll(syrkxxRepository.list(new LambdaQueryWrapper<GBaseSYRKXX>() |
|
|
|
|
.select(GBaseSYRKXX::getGmsfhm, GBaseSYRKXX::getXlmc) |
|
|
|
|
.in(GBaseSYRKXX::getGmsfhm, idCard))); |
|
|
|
|
log.info("学历进度 | {}", count); |
|
|
|
|
} |
|
|
|
|
// 日常转map
|
|
|
|
|
Map<String, GBaseSYRKXX> xxMap = xxList.stream().collect(Collectors.toMap(GBaseSYRKXX::getGmsfhm, Function.identity(), (oldValue, newValue) -> newValue)); |
|
|
|
|
// 旧数据
|
|
|
|
|
Map<String, RiskModelTaskClue> oldMap = domain.getOldMap(34, true); |
|
|
|
|
|
|
|
|
|
List<RiskModelTaskClue> toUpdate = new ArrayList<>(); |
|
|
|
|
List<RiskModelTaskClue> toInsert = new ArrayList<>(); |
|
|
|
|
log.info("开始遍历学历"); |
|
|
|
|
LocalDate now = LocalDate.now(); |
|
|
|
|
List<RiskModelTaskClue> toInsertAge = new ArrayList<>(); |
|
|
|
|
List<RiskModelTaskClue> toInsertGender = new ArrayList<>(); |
|
|
|
|
List<RiskModelTaskClue> toDeletes = new ArrayList<>(); |
|
|
|
|
for (RiskPersonal person : domain.getPersons()) { |
|
|
|
|
if (xxMap.get(person.getIdCode()) == null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
GBaseSYRKXX xx = xxMap.get(person.getIdCode()); |
|
|
|
|
if (xx.getXlmc() == null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
String edu = switch (xx.getXlmc()) { |
|
|
|
|
case "小学教育", "文盲", "小学毕业", "小学肄业", "其他" -> "小学及以下"; |
|
|
|
|
case "初中毕业", "初级中等教育", "初中肄业" -> "初中"; |
|
|
|
|
case "普通高中结业", "普通高级中学教育", "普通高中毕业", "普通高中肄业", "中等专科结业", "中等专科教育", "中等专业毕业", "技工学校肄业" -> |
|
|
|
|
"高中/中专"; |
|
|
|
|
case "大学专科毕业", "大学专科结业", "大学本科/专科教育", "大学生本科结业", "大学生普通班毕业", "大学生本科肄业", "大学生本科毕业" -> |
|
|
|
|
"大学"; |
|
|
|
|
case "硕士研究生毕业", "研究生教育", "研究生班肄业" -> "大学以上"; |
|
|
|
|
default -> null; |
|
|
|
|
}; |
|
|
|
|
if (edu == null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
RiskModelTaskClue old = oldMap.get(person.getIdCode()); |
|
|
|
|
if (old != null && old.getRiskReason().equals(edu)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
Integer score = Edu.contains(edu); |
|
|
|
|
if (old == null) { |
|
|
|
|
//创建新的
|
|
|
|
|
toInsert.add(createClue(eduTask.getModelId(), score, eduTask.getId(), ClueData.builder() |
|
|
|
|
RiskModelTaskClue oldAge = oldAgeMap.get(person.getIdCode()); |
|
|
|
|
Integer age = IdCodeUtil.idCard2Age(person.getIdCode(), now); |
|
|
|
|
Age ageType = Age.contains(age); |
|
|
|
|
// 年龄过了阶段 删除
|
|
|
|
|
if (ageType == null && oldAge != null) { |
|
|
|
|
RiskModelTaskClue clue = new RiskModelTaskClue(); |
|
|
|
|
clue.setId(oldAge.getId()); |
|
|
|
|
clue.setDel(1); |
|
|
|
|
toDeletes.add(clue); |
|
|
|
|
} |
|
|
|
|
// 年龄属于阶段 增加
|
|
|
|
|
if (ageType != null && oldAge == null) { |
|
|
|
|
toInsertAge.add(DataUtil.createClueData(ageTask, ClueData.builder() |
|
|
|
|
.id("") |
|
|
|
|
.score(ageType.getScore()) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.tags(List.of(ageType.getName())) |
|
|
|
|
.sourceData("该人员年龄为" + age + "," + ageType.getName()) |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.tag(edu) |
|
|
|
|
.sourceData("该人员的学历为" + xx.getXlmc() + ",属于" + edu) |
|
|
|
|
.eventTime(LocalDateTime.now()) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.build(), "edu" + person.getId().toString())); |
|
|
|
|
continue; |
|
|
|
|
.eventTime(null) |
|
|
|
|
.build())); |
|
|
|
|
} |
|
|
|
|
RiskModelTaskClue tmp = new RiskModelTaskClue(); |
|
|
|
|
tmp.setId(old.getId()); |
|
|
|
|
tmp.setRiskReason(edu); |
|
|
|
|
tmp.setData("该人员的学历为" + xx.getXlmc() + ",属于" + edu); |
|
|
|
|
tmp.setScore(Edu.contains(edu)); |
|
|
|
|
toUpdate.add(tmp); |
|
|
|
|
if (person.getGender() == null || !person.getGender().equals("1") || oldGenderMap.get(person.getIdCode()) != null) |
|
|
|
|
continue; |
|
|
|
|
toInsertGender.add(DataUtil.createClueData(genderTask, ClueData.builder() |
|
|
|
|
.id("") |
|
|
|
|
.score(5) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.tags(List.of("男性")) |
|
|
|
|
.sourceData("该人员性别为男性") |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.eventTime(null) |
|
|
|
|
.build())); |
|
|
|
|
} |
|
|
|
|
if (!toInsert.isEmpty()) { |
|
|
|
|
riskModelTaskClueService.saveClues(toInsert, Default.EDU_IG); |
|
|
|
|
log.info("批量新增学历完成"); |
|
|
|
|
if (!toInsertAge.isEmpty()) { |
|
|
|
|
log.info("增加年龄数据{}条", toInsertAge.size()); |
|
|
|
|
riskModelTaskClueService.saveClues(toInsertAge, "B2年龄"); |
|
|
|
|
} |
|
|
|
|
if (!toDeletes.isEmpty()) { |
|
|
|
|
log.info("删除年龄数据{}条", toDeletes.size()); |
|
|
|
|
clueRepository.removeBatchByIds(toDeletes); |
|
|
|
|
} |
|
|
|
|
if (!toUpdate.isEmpty()) { |
|
|
|
|
clueRepository.updateBatchById(toUpdate, 10000); |
|
|
|
|
log.info("批量修改学历完成"); |
|
|
|
|
riskTaskRepository.updateTask(ageTask.getId(), toInsertAge.size(), toDeletes.size()); |
|
|
|
|
if (!toInsertGender.isEmpty()) { |
|
|
|
|
log.info("增加性别数据{}条", toInsertGender.size()); |
|
|
|
|
riskModelTaskClueService.saveClues(toInsertGender, "B1性别"); |
|
|
|
|
} |
|
|
|
|
riskTaskRepository.updateTask(eduTask.getId(), toInsert.size(), toUpdate.size()); |
|
|
|
|
riskTaskRepository.updateTask(genderTask.getId(), toInsertGender.size(), 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@ -157,66 +127,59 @@ public class RiskTaskServiceImpl implements RiskTaskService {
|
|
|
|
|
List<RiskModelTaskClue> toInsert1 = new ArrayList<>(); |
|
|
|
|
List<RiskModelTaskClue> toInsert2 = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
String areCode = "431122,431322,433127,431382,430525,430722"; |
|
|
|
|
for (RiskPersonal person : domain.getPersons()) { |
|
|
|
|
GBaseSYRKXX xx = xxMap.get(person.getIdCode()); |
|
|
|
|
if (xx == null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (xx.getXlmc() != null && oldEduMap.get(person.getIdCode()) == null) { |
|
|
|
|
String edu = switch (xx.getXlmc()) { |
|
|
|
|
case "小学教育", "文盲", "小学毕业", "小学肄业", "其他" -> "小学及以下"; |
|
|
|
|
case "初中毕业", "初级中等教育", "初中肄业" -> "初中"; |
|
|
|
|
case "普通高中结业", "普通高级中学教育", "普通高中毕业", "普通高中肄业", "中等专科结业", "中等专科教育", "中等专业毕业", "技工学校肄业" -> |
|
|
|
|
"高中/中专"; |
|
|
|
|
case "大学专科毕业", "大学专科结业", "大学本科/专科教育", "大学生本科结业", "大学生普通班毕业", "大学生本科肄业", "大学生本科毕业" -> |
|
|
|
|
"大学"; |
|
|
|
|
case "硕士研究生毕业", "研究生教育", "研究生班肄业" -> "大学以上"; |
|
|
|
|
default -> null; |
|
|
|
|
}; |
|
|
|
|
if (edu != null) { |
|
|
|
|
Integer score = Edu.contains(edu); |
|
|
|
|
//创建新的
|
|
|
|
|
toInsert1.add(DataUtil.createClueData(eduTask, ClueData.builder() |
|
|
|
|
.id("") |
|
|
|
|
.score(score) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.tags(List.of(edu)) |
|
|
|
|
.sourceData("该人员的学历为" + xx.getXlmc() + ",属于" + edu) |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.eventTime(null) |
|
|
|
|
.build())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(xx.getCsdxzqhdm() != null && oldAreaMap.get(person.getIdCode()) == null) { |
|
|
|
|
if(!areCode.contains(xx.getCsdxzqhdm())) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
toInsert2.add(DataUtil.createClueData(areaTask, ClueData.builder() |
|
|
|
|
.id(BhUtil.sfBh(person.getId().toString())) |
|
|
|
|
.score(5) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.tags(List.of(xx.getCsdxzqhmc())) |
|
|
|
|
.sourceData("发现该人员在" + xx.getCsdxzqhmc() + "成长,该地区暴力警情情况较多") |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.eventTime(null) |
|
|
|
|
.build())); |
|
|
|
|
} |
|
|
|
|
RiskModelTaskClue areaClue = area(xx, person, areaTask, oldAreaMap.get(person.getIdCode())); |
|
|
|
|
if (areaClue != null) toInsert2.add(areaClue); |
|
|
|
|
RiskModelTaskClue eudClue = edu(xx, person, eduTask, oldEduMap.get(person.getIdCode())); |
|
|
|
|
if (eudClue != null) toInsert1.add(eudClue); |
|
|
|
|
} |
|
|
|
|
if(!toInsert1.isEmpty()) { |
|
|
|
|
if (!toInsert1.isEmpty()) { |
|
|
|
|
log.info("保存学历:{}", toInsert1.size()); |
|
|
|
|
riskModelTaskClueService.saveClues(toInsert1, "B4文化程度"); |
|
|
|
|
} |
|
|
|
|
riskTaskRepository.updateTask(eduTask.getId(), toInsert1.size(), 0); |
|
|
|
|
if(!toInsert2.isEmpty()) { |
|
|
|
|
if (!toInsert2.isEmpty()) { |
|
|
|
|
log.info("保存风险区域:{}", toInsert2.size()); |
|
|
|
|
riskModelTaskClueService.saveClues(toInsert2, "B10民风习俗"); |
|
|
|
|
} |
|
|
|
|
riskTaskRepository.updateTask(areaTask.getId(), toInsert2.size(), 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RiskModelTaskClue edu(GBaseSYRKXX xx, RiskPersonal person, RiskTask task, RiskModelTaskClue oldClue) { |
|
|
|
|
if (xx.getXlmc() == null || oldClue != null) return null; |
|
|
|
|
EduType type = EduType.contains(xx.getXlmc()); |
|
|
|
|
if (type == null) return null; |
|
|
|
|
return DataUtil.createClueData(task, ClueData.builder() |
|
|
|
|
.id("") |
|
|
|
|
.score(type.getScore()) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.tags(List.of(type.getDesc())) |
|
|
|
|
.sourceData("该人员的学历为" + xx.getXlmc() + ",属于" + type.getDesc()) |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.eventTime(null) |
|
|
|
|
.build()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RiskModelTaskClue area(GBaseSYRKXX xx, RiskPersonal person, RiskTask task, RiskModelTaskClue oldClue) { |
|
|
|
|
if (xx.getCsdxzqhdm() == null || oldClue != null) return null; |
|
|
|
|
if (!Area.HEIGHT_RISK_AREA_CODE.contains(xx.getCsdxzqhdm())) return null; |
|
|
|
|
return DataUtil.createClueData(task, ClueData.builder() |
|
|
|
|
.id(BhUtil.sfBh(person.getId().toString())) |
|
|
|
|
.score(5) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.tags(List.of(xx.getCsdxzqhmc())) |
|
|
|
|
.sourceData("发现该人员在" + xx.getCsdxzqhmc() + "成长,该地区暴力警情情况较多") |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.eventTime(null) |
|
|
|
|
.build()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void behavior(TaskParamDomain domain) { |
|
|
|
|
RiskTask task = riskTaskRepository.create(domain.getPersons().size(), 20); |
|
|
|
|
@ -265,12 +228,12 @@ public class RiskTaskServiceImpl implements RiskTaskService {
|
|
|
|
|
person = idNumberMap.get(s); |
|
|
|
|
if (person != null) { |
|
|
|
|
clueData.add(ClueData.builder() |
|
|
|
|
.id(gBaseJJD.getJjdbh()) |
|
|
|
|
.id(BhUtil.jjdBh(gBaseJJD.getJjdbh())) |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.tag(JSONObject.of("jqxzmc", gBaseJJD.getJqxzmc(), "cjqk", gBaseJJD.getCjqk()).toJSONString()) |
|
|
|
|
.departName(gBaseJJD.getGxdwmc()) |
|
|
|
|
.departId(gBaseJJD.getGxdwdm()) |
|
|
|
|
.tags(List.of(gBaseJJD.getJqxzmc())) |
|
|
|
|
.sourceData("该人员存在个人极端警情,案件性质为:" + gBaseJJD.getJqxzmc() + ",接警单编号为" + gBaseJJD.getJjdbh()) |
|
|
|
|
.score(10) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.eventTime(gBaseJJD.getBjsj().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()) |
|
|
|
|
.build()); |
|
|
|
|
@ -279,18 +242,17 @@ public class RiskTaskServiceImpl implements RiskTaskService {
|
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
ClueData data = ClueData.builder() |
|
|
|
|
.id(gBaseJJD.getJjdbh()) |
|
|
|
|
.id(BhUtil.jjdBh(gBaseJJD.getJjdbh())) |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.tag(JSONObject.of("jqxzmc", gBaseJJD.getJqxzmc(), "cjqk", gBaseJJD.getCjqk()).toJSONString()) |
|
|
|
|
.departName(gBaseJJD.getGxdwmc()) |
|
|
|
|
.departId(gBaseJJD.getGxdwdm()) |
|
|
|
|
.tags(List.of(gBaseJJD.getJqxzmc())) |
|
|
|
|
.sourceData("该人员存在个人极端警情,案件性质为:" + gBaseJJD.getJqxzmc() + ",接警单编号为" + gBaseJJD.getJjdbh()) |
|
|
|
|
.score(10) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.build(); |
|
|
|
|
try { |
|
|
|
|
data.setEventTime(gBaseJJD.getBjsj().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("报案日期转LocalDateTime异常"); |
|
|
|
|
} catch (Exception ignored) { |
|
|
|
|
} |
|
|
|
|
clueData.add(data); |
|
|
|
|
} |
|
|
|
|
@ -301,7 +263,7 @@ public class RiskTaskServiceImpl implements RiskTaskService {
|
|
|
|
|
for (ClueData clueDatum : clueData) { |
|
|
|
|
List<RiskModelTaskClue> tmpList = oldMap.get(clueDatum.getIdCode()); |
|
|
|
|
if (tmpList == null || tmpList.isEmpty()) { |
|
|
|
|
toInsert.add(createClue(task.getId(), 10, task.getId(), clueDatum, BhUtil.jjdBh(clueDatum.getId()))); |
|
|
|
|
toInsert.add(DataUtil.createClueData(task, clueDatum)); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
boolean exist = false; |
|
|
|
|
@ -312,7 +274,7 @@ public class RiskTaskServiceImpl implements RiskTaskService {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (!exist) { |
|
|
|
|
toInsert.add(createClue(task.getId(), 10, task.getId(), clueDatum, BhUtil.jjdBh(clueDatum.getId()))); |
|
|
|
|
toInsert.add(DataUtil.createClueData(task, clueDatum)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
|
@ -322,150 +284,44 @@ public class RiskTaskServiceImpl implements RiskTaskService {
|
|
|
|
|
TxtUtil.write(sb.toString(), "/work/test.txt"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void riskAreaModelTask(TaskParamDomain domain) { |
|
|
|
|
RiskTask task = riskTaskRepository.create(domain.getPersons().size(), 41); |
|
|
|
|
List<List<String>> idCards = new ArrayList<>(); |
|
|
|
|
// 旧的clue
|
|
|
|
|
List<RiskModelTaskClue> oldClueList = Optional.ofNullable(domain.getMap().get(task.getModelId())).orElse(new ArrayList<>()); |
|
|
|
|
Map<String, String> map = oldClueList.stream().collect(Collectors.toMap(RiskModelTaskClue::getIdCode, RiskModelTaskClue::getIdCode, (oldValue, newValue) -> newValue)); |
|
|
|
|
Map<String, RiskPersonal> personMap = new HashMap<>(); |
|
|
|
|
// 将旧clue的人剔除出去,一个人的出生地一般不会变
|
|
|
|
|
for (RiskPersonal person : domain.getPersons()) { |
|
|
|
|
if (map.get(person.getIdCode()) != null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (idCards.isEmpty() || idCards.getLast().size() >= 10000) { |
|
|
|
|
idCards.add(new ArrayList<>()); |
|
|
|
|
} |
|
|
|
|
idCards.getLast().add(person.getIdCode()); |
|
|
|
|
personMap.put(person.getIdCode(), person); |
|
|
|
|
} |
|
|
|
|
if (idCards.isEmpty()) { |
|
|
|
|
riskTaskRepository.updateTask(task.getId(), 0, 0); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<GBaseSYRKXX> xxList = new ArrayList<>(); |
|
|
|
|
List<String> area = List.of("431122", "431322", "433127", "431382", "430525", "430722"); |
|
|
|
|
int count = idCards.size(); |
|
|
|
|
for (List<String> idCard : idCards) { |
|
|
|
|
count--; |
|
|
|
|
xxList.addAll(syrkxxRepository.list(new LambdaQueryWrapper<GBaseSYRKXX>() |
|
|
|
|
.select(GBaseSYRKXX::getXm, GBaseSYRKXX::getGmsfhm, GBaseSYRKXX::getCsdxzqhdm, GBaseSYRKXX::getCsdxzqhmc) |
|
|
|
|
.in(GBaseSYRKXX::getCsdxzqhdm, area) |
|
|
|
|
.in(GBaseSYRKXX::getGmsfhm, idCard))); |
|
|
|
|
log.info("地区进度 | {}", count); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (xxList.isEmpty()) { |
|
|
|
|
riskTaskRepository.updateTask(task.getId(), 0, 0); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<RiskModelTaskClue> toInsert = new ArrayList<>(); |
|
|
|
|
// 新增
|
|
|
|
|
for (GBaseSYRKXX gBaseSYRKXX : xxList) { |
|
|
|
|
RiskPersonal person = personMap.get(gBaseSYRKXX.getGmsfhm()); |
|
|
|
|
toInsert.add(createClue(task.getModelId(), 5, task.getId(), ClueData.builder() |
|
|
|
|
.id(BhUtil.sfBh(person.getId().toString())) |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.eventTime(LocalDateTime.now()) |
|
|
|
|
.sourceData("发现该人员在" + gBaseSYRKXX.getCsdxzqhmc() + "成长,该地区暴力警情情况较多") |
|
|
|
|
.tag(gBaseSYRKXX.getCsdxzqhmc()) |
|
|
|
|
.build(), "area___" + person.getId().toString())); |
|
|
|
|
} |
|
|
|
|
log.info("开始操作新增项:{}", toInsert.size()); |
|
|
|
|
riskModelTaskClueService.saveClues(toInsert, Default.FIGHT_IG); |
|
|
|
|
riskTaskRepository.updateTask(task.getId(), toInsert.size(), 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private final SupExternalDepartRepository externalDepartRepository; |
|
|
|
|
|
|
|
|
|
private final GBaseZDRYRepository zdryRepository; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void heightFight(TaskParamDomain domain) { |
|
|
|
|
// 战斗过的用户
|
|
|
|
|
List<GBaseSYRKXX> xxList = syrkxxRepository.getBaseMapper().selectHeightFight("2024-01-01 00:00:00"); |
|
|
|
|
log.info("用户数 : {}", xxList.size()); |
|
|
|
|
Map<String, GBaseSYRKXX> syrkxxMap = xxList.stream().collect(Collectors.toMap(GBaseSYRKXX::getGmsfhm, Function.identity(), (oldValue, newValue) -> newValue)); |
|
|
|
|
|
|
|
|
|
List<SupExternalDepart> supDeparts = externalDepartRepository.list(new LambdaQueryWrapper<SupExternalDepart>() |
|
|
|
|
.select(SupExternalDepart::getExternalId, SupExternalDepart::getInternalId, SupExternalDepart::getInternalShortName, SupExternalDepart::getSource) |
|
|
|
|
.eq(SupExternalDepart::getSource, "重点人员")); |
|
|
|
|
Map<String, SupExternalDepart> jqExternalDepart = supDeparts.stream().collect(Collectors.toMap(SupExternalDepart::getExternalId, Function.identity(), (val, old) -> val)); |
|
|
|
|
|
|
|
|
|
List<PointOrg> orgs = zdryRepository.getBaseMapper().selectOrg(); |
|
|
|
|
Map<String, PointOrg> orgIdMap = new WeakHashMap<>(); |
|
|
|
|
Map<String, PointOrg> orgCodeMap = new WeakHashMap<>(); |
|
|
|
|
for (PointOrg org : orgs) { |
|
|
|
|
orgIdMap.put(org.getId(), org); |
|
|
|
|
orgCodeMap.put(org.getDm(), org); |
|
|
|
|
} |
|
|
|
|
LocalDateTime time = LocalDateTime.now().minusYears(1); |
|
|
|
|
|
|
|
|
|
RiskTask task = riskTaskRepository.create(xxList.size(), 42); |
|
|
|
|
List<FightMan> fightMans = syrkxxRepository.getBaseMapper().selectFightMan(time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
|
|
|
|
|
|
|
|
|
List<String> idCodes = xxList.stream().map(GBaseSYRKXX::getGmsfhm).distinct().toList(); |
|
|
|
|
log.info("查询用户数 : {}", idCodes.size()); |
|
|
|
|
|
|
|
|
|
List<FightMan> fightMans = syrkxxRepository.getBaseMapper().selectListByIdCode(idCodes); |
|
|
|
|
log.info("fightman : {}", fightMans.size()); |
|
|
|
|
|
|
|
|
|
Map<String, RiskPersonal> personalMap = domain.getPersons().stream().collect(Collectors.toMap(RiskPersonal::getIdCode, Function.identity(), (oldValue, newValue) -> newValue)); |
|
|
|
|
RiskTask task = riskTaskRepository.create(fightMans.size(), 42); |
|
|
|
|
|
|
|
|
|
Map<String, RiskModelTaskClue> oldMap = domain.getOldMap(task.getModelId(), true); |
|
|
|
|
|
|
|
|
|
List<RiskModelTaskClue> toUpdates = new ArrayList<>(); |
|
|
|
|
List<RiskModelTaskClue> toInsert = new ArrayList<>(); |
|
|
|
|
List<RiskPersonal> toInsertPeople = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
Map<String, FightMan> fightManMap = new HashMap<>(); |
|
|
|
|
List<String> manList = new ArrayList<>(); |
|
|
|
|
int count = 0; |
|
|
|
|
for (FightMan fightMan : fightMans) { |
|
|
|
|
if (fightMan.getFightCount() < 5) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
count++; |
|
|
|
|
Map<String, FightMan> fightManMap = fightMans.stream().collect(Collectors.toMap(FightMan::getGmsfhm, Function.identity(), (val, old) -> val)); |
|
|
|
|
|
|
|
|
|
for (RiskPersonal person : domain.getPersons()) { |
|
|
|
|
FightMan fightMan = fightManMap.get(person.getIdCode()); |
|
|
|
|
if (fightMan == null) continue; |
|
|
|
|
|
|
|
|
|
RiskModelTaskClue old = oldMap.get(fightMan.getGmsfhm()); |
|
|
|
|
if (old != null) { |
|
|
|
|
RiskModelTaskClue update = new RiskModelTaskClue(); |
|
|
|
|
update.setId(old.getId()); |
|
|
|
|
update.setData("该人员在近期发生" + fightMan.getFightCount() + "起矛盾纠纷,属于高频次矛盾纠纷发生人员"); |
|
|
|
|
update.setEventTime(LocalDateTime.now()); |
|
|
|
|
toUpdates.add(update); |
|
|
|
|
// 剩下的是没有矛盾的人
|
|
|
|
|
oldMap.remove(fightMan.getGmsfhm()); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
// 看看人员信息是否存在,决定需要增加人员不
|
|
|
|
|
RiskPersonal person = personalMap.get(fightMan.getGmsfhm()); |
|
|
|
|
if (person == null) { |
|
|
|
|
fightManMap.put(fightMan.getGmsfhm(), fightMan); |
|
|
|
|
manList.add(fightMan.getGmsfhm()); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
RiskModelTaskClue clue = createClue(task.getModelId(), 3, person, task.getId(), fightMan.getFightCount() + "起纠纷", "该人员在近期发生" + fightMan.getFightCount() + "起矛盾纠纷,属于高频次矛盾纠纷发生人员"); |
|
|
|
|
toInsert.add(clue); |
|
|
|
|
person.setId(null); |
|
|
|
|
person.setTags(Default.FIGHT_MUCH); |
|
|
|
|
toInsertPeople.add(person); |
|
|
|
|
} |
|
|
|
|
log.info("大于等于5的个数 : {}", count); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<GBaseSYRKXX> list = syrkxxRepository.list(new LambdaQueryWrapper<GBaseSYRKXX>() |
|
|
|
|
.select(GBaseSYRKXX::getGmsfhm, GBaseSYRKXX::getXm, GBaseSYRKXX::getLxdh, GBaseSYRKXX::getSspcsdm) |
|
|
|
|
.in(GBaseSYRKXX::getGmsfhm, manList)); |
|
|
|
|
|
|
|
|
|
Map<String, GBaseSYRKXX> map = list.stream().collect(Collectors.toMap(GBaseSYRKXX::getGmsfhm, Function.identity(), (oldValue, newValue) -> newValue)); |
|
|
|
|
for (RiskPersonal person : domain.getPersons()) { |
|
|
|
|
FightMan fightMan = fightManMap.get(person.getIdCode()); |
|
|
|
|
if(fightMan == null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
RiskModelTaskClue clue = createClue(task.getModelId(), 3, person, task.getId(), fightMan.getFightCount() + "起纠纷", "该人员在近期发生" + fightMan.getFightCount() + "起矛盾纠纷,属于高频次矛盾纠纷发生人员"); |
|
|
|
|
toInsert.add(clue); |
|
|
|
|
toInsert.add(DataUtil.createClueData(task, ClueData.builder() |
|
|
|
|
.score(3) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.tags(List.of(fightMan.getFightCount() + "起纠纷")) |
|
|
|
|
.sourceData("该人员在近期发生" + fightMan.getFightCount() + "起矛盾纠纷,属于高频次矛盾纠纷发生人员") |
|
|
|
|
.build())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!toUpdates.isEmpty()) { |
|
|
|
|
@ -478,163 +334,4 @@ public class RiskTaskServiceImpl implements RiskTaskService {
|
|
|
|
|
} |
|
|
|
|
riskTaskRepository.updateTask(task.getId(), toInsert.size(), toUpdates.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 年龄模型 |
|
|
|
|
* |
|
|
|
|
* @param domain 参数 |
|
|
|
|
* @param task 任务 |
|
|
|
|
*/ |
|
|
|
|
void ageModel(TaskParamDomain domain, RiskTask task) { |
|
|
|
|
List<RiskModelTaskClue> taskClue = new ArrayList<>(); |
|
|
|
|
List<RiskModelTaskClue> toHidden = new ArrayList<>(); |
|
|
|
|
Map<String, RiskModelTaskClue> oldMap = domain.getOldMap(task.getModelId(), true); |
|
|
|
|
LocalDate now = LocalDate.now(); |
|
|
|
|
for (RiskPersonal person : domain.getPersons()) { |
|
|
|
|
if (person.getIdCode() == null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
RiskModelTaskClue old = oldMap.get(person.getIdCode()); |
|
|
|
|
Integer age = IdCodeUtil.idCard2Age(person.getIdCode(), now); |
|
|
|
|
if (age == null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (old != null) { |
|
|
|
|
RiskModelTaskClue hidden = new RiskModelTaskClue(); |
|
|
|
|
hidden.setId(old.getId()); |
|
|
|
|
hidden.setDel(0); |
|
|
|
|
toHidden.add(hidden); |
|
|
|
|
} |
|
|
|
|
// 符合条件但是又没有旧数据 | 新增
|
|
|
|
|
if (age >= 16 && age <= 24) { |
|
|
|
|
taskClue.add(DataUtil.createClueData(task, ClueData.builder() |
|
|
|
|
.id("") |
|
|
|
|
.score(1) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.tags(List.of("年龄处于16岁至24岁之间")) |
|
|
|
|
.sourceData("该人员年龄为" + age + ",属于16岁至24岁之间") |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.eventTime(null) |
|
|
|
|
.build())); |
|
|
|
|
} |
|
|
|
|
if (age >= 25 && age <= 34) { |
|
|
|
|
taskClue.add(DataUtil.createClueData(task, ClueData.builder() |
|
|
|
|
.id("") |
|
|
|
|
.score(3) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.tags(List.of("年龄处于25岁至34岁之间")) |
|
|
|
|
.sourceData("该人员年龄为" + age + ",属于25岁至34岁之间") |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.eventTime(null) |
|
|
|
|
.build())); |
|
|
|
|
} |
|
|
|
|
if (age >= 35 && age <= 55) { |
|
|
|
|
taskClue.add(DataUtil.createClueData(task, ClueData.builder() |
|
|
|
|
.id("") |
|
|
|
|
.score(5) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.tags(List.of("年龄处于35岁至55岁之间")) |
|
|
|
|
.sourceData("该人员年龄为" + age + ",属于35岁至55岁之间") |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.eventTime(null) |
|
|
|
|
.build())); |
|
|
|
|
} |
|
|
|
|
if (age >= 56 && age <= 65) { |
|
|
|
|
taskClue.add(DataUtil.createClueData(task, ClueData.builder() |
|
|
|
|
.id("") |
|
|
|
|
.score(3) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.tags(List.of("年龄处于56岁至66岁之间")) |
|
|
|
|
.sourceData("该人员年龄为" + age + ",属于56岁至66岁之间") |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.eventTime(null) |
|
|
|
|
.build())); |
|
|
|
|
} |
|
|
|
|
if (age >= 66 && age <= 75) { |
|
|
|
|
taskClue.add(DataUtil.createClueData(task, ClueData.builder() |
|
|
|
|
.id("") |
|
|
|
|
.score(1) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.tags(List.of("年龄处于66岁至75岁之间")) |
|
|
|
|
.sourceData("该人员年龄为" + age + ",属于66岁至75岁之间") |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.eventTime(null) |
|
|
|
|
.build())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
riskModelTaskClueService.saveClues(taskClue, "B2年龄"); |
|
|
|
|
if (!toHidden.isEmpty()) { |
|
|
|
|
clueRepository.updateBatchById(toHidden); |
|
|
|
|
} |
|
|
|
|
riskTaskRepository.updateTask(task.getId(), taskClue.size(), toHidden.size()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 性别模型 |
|
|
|
|
* |
|
|
|
|
* @param domain 参数 |
|
|
|
|
* @param task 任务 |
|
|
|
|
*/ |
|
|
|
|
void genderModel(TaskParamDomain domain, RiskTask task) { |
|
|
|
|
List<RiskModelTaskClue> taskClue = new ArrayList<>(); |
|
|
|
|
Map<String, RiskModelTaskClue> oldMap = domain.getOldMap(task.getModelId(), true); |
|
|
|
|
|
|
|
|
|
for (RiskPersonal person : domain.getPersons()) { |
|
|
|
|
if (person.getGender() == null || !person.getGender().equals("1")) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (oldMap.get(person.getIdCode()) != null) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
taskClue.add(DataUtil.createClueData(task, ClueData.builder() |
|
|
|
|
.id("") |
|
|
|
|
.score(5) |
|
|
|
|
.personId(person.getId()) |
|
|
|
|
.tags(List.of("男性")) |
|
|
|
|
.sourceData("该人员性别为男性") |
|
|
|
|
.name(person.getName()) |
|
|
|
|
.idCode(person.getIdCode()) |
|
|
|
|
.eventTime(null) |
|
|
|
|
.build())); |
|
|
|
|
} |
|
|
|
|
riskModelTaskClueService.saveClues(taskClue, "B1性别"); |
|
|
|
|
riskTaskRepository.updateTask(task.getId(), taskClue.size(), 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RiskModelTaskClue createClue(Integer modelId, Integer score, RiskPersonal person, Integer taskId, String reason, String data) { |
|
|
|
|
RiskModelTaskClue clue = new RiskModelTaskClue(); |
|
|
|
|
clue.setModelId(modelId); |
|
|
|
|
clue.setScore(score); |
|
|
|
|
clue.setName(person.getName()); |
|
|
|
|
clue.setIdCode(person.getIdCode()); |
|
|
|
|
clue.setTaskId(taskId); |
|
|
|
|
clue.setRiskReason(reason); |
|
|
|
|
clue.setData(data); |
|
|
|
|
clue.setCreateTime(LocalDateTime.now()); |
|
|
|
|
clue.setUpdateTime(LocalDateTime.now()); |
|
|
|
|
clue.setEventTime(LocalDateTime.now()); |
|
|
|
|
return clue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
RiskModelTaskClue createClue(Integer modelId, Integer score, Integer taskId, ClueData data, String caseId) { |
|
|
|
|
RiskModelTaskClue clue = new RiskModelTaskClue(); |
|
|
|
|
clue.setModelId(modelId); |
|
|
|
|
clue.setScore(score); |
|
|
|
|
clue.setName(data.getName()); |
|
|
|
|
clue.setIdCode(data.getIdCode()); |
|
|
|
|
clue.setTaskId(taskId); |
|
|
|
|
clue.setData(data.getSourceData()); |
|
|
|
|
clue.setEventTime(data.getEventTime()); |
|
|
|
|
clue.setCreateTime(LocalDateTime.now()); |
|
|
|
|
clue.setUpdateTime(LocalDateTime.now()); |
|
|
|
|
clue.setCaseIds(caseId); |
|
|
|
|
data.setPersonId(null); |
|
|
|
|
clue.setRiskReason(data.getTag()); |
|
|
|
|
return clue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|