Browse Source

定时任务

master
kami 1 year ago
parent
commit
c8bdfe886c
  1. 471
      src/main/java/com/biutag/supervisiondata/service/impl/GBaseJJDServiceImpl.java
  2. 112
      src/main/java/com/biutag/supervisiondata/service/impl/GBaseSHRWFRServiceImpl.java
  3. 7
      src/main/java/com/biutag/supervisiondata/task/TaskService.java

471
src/main/java/com/biutag/supervisiondata/service/impl/GBaseJJDServiceImpl.java

@ -482,15 +482,15 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
LocalDateTime maxTime = null;
for (GBaseJJD gBaseJJD : list) {
LocalDateTime tmp = DateTimeUtil.date2LocalDateTime(gBaseJJD.getBjsj());
if(maxTime == null) {
if (maxTime == null) {
maxTime = tmp;
continue;
}
if(tmp.isAfter(maxTime)) {
if (tmp.isAfter(maxTime)) {
maxTime = tmp;
}
}
if(maxTime == null) {
if (maxTime == null) {
maxTime = LocalDateTime.now();
}
@ -500,13 +500,13 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
sb.append(list.get(i).getJjdbh()).append(",");
}
String desc = sb.substring(0, sb.length() - 1);
if(list.size() > 3) {
if (list.size() > 3) {
desc += "等";
}
RiskModelTaskClue old = oldMap.get(entry.getKey());
if(old != null) {
if (old != null) {
oldMap.remove(entry.getKey());
if(!desc.equals(desc)) {
if (!desc.equals(desc)) {
RiskModelTaskClue update = new RiskModelTaskClue();
update.setId(old.getId());
update.setTags(List.of(list.size() + "起平台涉警事件"));
@ -549,15 +549,14 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
log.info("删除平台涉警事件数据:{}", toDelete.size());
clueService.deleteCluesAndDeleteTag(toDelete, deleteIds, task.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toDelete.size()+toUpdate.size());
taskRepository.updateTask(task.getId(), toInsert.size(), toDelete.size() + toUpdate.size());
}
@Override
public void syncHomeViolence(TaskParamDomain domain) {
String startTime = LocalDateTime.of(2023, 12, 6, 0, 0, 0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime limit = LocalDateTime.now().minusYears(1);
List<GBaseJJD> result = gBaseJJDRepository.getBaseMapper().selectHomeViolence(startTime);
List<GBaseJJD> result = gBaseJJDRepository.getBaseMapper().selectHomeViolence(limit.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
// 被家暴
RiskTask task = taskRepository.create(result.size(), 65);
// 家暴
@ -622,69 +621,92 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
}
}
List<RiskModelTaskClue> oldList = Optional.ofNullable(domain.getMap().get(task.getModelId())).orElse(new ArrayList<>());
List<RiskModelTaskClue> oldList2 = Optional.ofNullable(domain.getMap().get(task2.getModelId())).orElse(new ArrayList<>());
// 按人分
Map<String, List<RiskModelTaskClue>> personOldMap = oldList.stream().collect(Collectors.groupingBy(RiskModelTaskClue::getIdCode));
Map<String, List<RiskModelTaskClue>> personOldMap2 = oldList2.stream().collect(Collectors.groupingBy(RiskModelTaskClue::getIdCode));
Map<String, RiskModelTaskClue> personOldMap = domain.getOldMap(task.getModelId(), true);
Map<String, RiskModelTaskClue> personOldMap2 = domain.getOldMap(task2.getModelId(), true);
List<RiskModelTaskClue> toInsert = new ArrayList<>();
List<RiskModelTaskClue> toUpdate = new ArrayList<>();
List<RiskModelTaskClue> toInsert2 = new ArrayList<>();
List<RiskModelTaskClue> toUpdate2 = new ArrayList<>();
for (RiskPersonal person : domain.getPersons()) {
// 被家暴
toInsert.addAll(collectionClue(shIdCodeMap, shMobileMap, person, personOldMap, task, "被家暴"));
toInsert2.addAll(collectionClue(wfIdCodeMap, wfMobileMap, person, personOldMap2, task2, "家暴"));
RiskModelTaskClue clue1 = collectionClue(shIdCodeMap, shMobileMap, person, task, "被家暴");
if (clue1 != null) {
RiskModelTaskClue old1 = personOldMap.get(person.getIdCode());
if (old1 != null) {
personOldMap.remove(person.getIdCode());
if (!old1.getData().equals(clue1.getData())) {
clue1.setId(old1.getId());
toUpdate.add(clue1);
}
} else {
toInsert.add(clue1);
}
}
// 家暴
RiskModelTaskClue clue2 = collectionClue(wfIdCodeMap, wfMobileMap, person, task2, "家暴");
if (clue2 == null) continue;
RiskModelTaskClue old2 = personOldMap2.get(person.getIdCode());
if (old2 == null) {
toInsert2.add(clue2);
continue;
}
personOldMap2.remove(person.getIdCode());
if (!old2.getData().equals(clue2.getData())) {
clue2.setId(old2.getId());
toUpdate2.add(clue2);
}
}
List<RiskModelTaskClue> toUpdate = new ArrayList<>();
List<RiskModelTaskClue> toUpdate2 = new ArrayList<>();
List<RiskModelTaskClue> toDelete = new ArrayList<>();
List<RiskModelTaskClue> toDelete2 = new ArrayList<>();
List<String> deleteIdCards = new ArrayList<>();
List<String> deleteIdCards2 = new ArrayList<>();
for (RiskModelTaskClue clue : oldList) {
if (clue.getEventTime().isBefore(limit)) {
RiskModelTaskClue update = new RiskModelTaskClue();
update.setId(update.getId());
update.setDel(1);
toUpdate.add(update);
deleteIdCards.add(clue.getIdCode());
}
for (Map.Entry<String, RiskModelTaskClue> entry : personOldMap.entrySet()) {
RiskModelTaskClue delete = new RiskModelTaskClue();
delete.setId(entry.getValue().getId());
delete.setDel(1);
toDelete.add(delete);
deleteIdCards.add(entry.getKey());
}
for (RiskModelTaskClue clue : oldList2) {
if (clue.getEventTime().isBefore(limit)) {
RiskModelTaskClue update = new RiskModelTaskClue();
update.setId(update.getId());
update.setDel(1);
toUpdate2.add(update);
deleteIdCards2.add(clue.getIdCode());
}
for (Map.Entry<String, RiskModelTaskClue> entry : personOldMap2.entrySet()) {
RiskModelTaskClue delete = new RiskModelTaskClue();
delete.setId(entry.getValue().getId());
delete.setDel(1);
toDelete2.add(delete);
deleteIdCards2.add(entry.getKey());
}
log.info("被家暴:{} | {}", toInsert.size(), toUpdate.size());
log.info("被家暴:{} | {} | {}", toInsert.size(), toUpdate.size(), toDelete.size());
if (!toInsert.isEmpty()) {
clueService.saveClues(toInsert, "B53被他人家暴");
}
if (!toUpdate.isEmpty()) {
clueService.deleteCluesAndDeleteTag(toUpdate, deleteIdCards, task.getModelId());
clueService.updateClues(toUpdate, task.getModelId());
}
if (!toDelete.isEmpty()) {
clueService.deleteCluesAndDeleteTag(toDelete, deleteIdCards, task.getModelId());
}
log.info("家暴:{} | {}", toInsert2.size(), toUpdate2.size());
log.info("家暴:{} | {} | {}", toInsert2.size(), toUpdate2.size(), toDelete2.size());
if (!toInsert.isEmpty()) {
clueService.saveClues(toInsert2, "B52对他人家暴");
}
if (!toUpdate2.isEmpty()) {
clueService.deleteCluesAndDeleteTag(toUpdate2, deleteIdCards2, task2.getModelId());
clueService.updateClues(toUpdate2, task2.getModelId());
}
if (!toDelete2.isEmpty()) {
clueService.deleteCluesAndDeleteTag(toDelete2, deleteIdCards2, task2.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size());
taskRepository.updateTask(task2.getId(), toInsert.size(), toUpdate2.size());
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size() + toDelete.size());
taskRepository.updateTask(task2.getId(), toInsert.size(), toUpdate2.size() + toDelete2.size());
}
@Override
public void syncParentRelation(TaskParamDomain domain) {
String startTime = LocalDateTime.of(2023, 12, 6, 0, 0, 0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
// LocalDateTime limit = LocalDateTime.now().minusYears(1);
LocalDateTime startTime = LocalDateTime.now().minusYears(1);
List<GBaseJJD> fathers = gBaseJJDRepository.getBaseMapper().selectFatherRelation(startTime);
List<GBaseJJD> fathers = gBaseJJDRepository.getBaseMapper().selectFatherRelation(startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
List<GBaseJJD> mothers = gBaseJJDRepository.getBaseMapper().selectMotherRelation(startTime);
List<GBaseJJD> mothers = gBaseJJDRepository.getBaseMapper().selectMotherRelation(startTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
RiskTask task = taskRepository.create(fathers.size(), 69);
RiskTask task2 = taskRepository.create(mothers.size(), 70);
@ -696,28 +718,98 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
log.info("父亲条数:{} | 母亲条数:{}", fatherIdCodeMap.size(), motherIdCodeMap.size());
List<RiskModelTaskClue> toInsert = eachClue2Save(domain, task, fatherIdCodeMap, "父亲");
List<RiskModelTaskClue> tmp1 = eachClue2Save(domain, task, fatherIdCodeMap, "父亲");
List<RiskModelTaskClue> tmp2 = eachClue2Save(domain, task2, motherIdCodeMap, "母亲");
List<RiskModelTaskClue> toInsert = new ArrayList<>();
List<RiskModelTaskClue> toUpdate = new ArrayList<>();
List<RiskModelTaskClue> toDelete = new ArrayList<>();
List<String> deleteIdCards = new ArrayList<>();
Map<String, RiskModelTaskClue> oldMap = domain.getOldMap(task.getModelId(), true);
for (RiskModelTaskClue riskModelTaskClue : tmp1) {
RiskModelTaskClue old = oldMap.get(riskModelTaskClue.getIdCode());
if (old == null) {
toInsert.add(riskModelTaskClue);
continue;
}
oldMap.remove(riskModelTaskClue.getIdCode());
if (!old.getData().equals(riskModelTaskClue.getData())) {
riskModelTaskClue.setId(old.getId());
toUpdate.add(riskModelTaskClue);
}
}
List<RiskModelTaskClue> toInsert2 = eachClue2Save(domain, task2, motherIdCodeMap, "母亲");
for (Map.Entry<String, RiskModelTaskClue> entry : oldMap.entrySet()) {
RiskModelTaskClue delete = new RiskModelTaskClue();
delete.setId(entry.getValue().getId());
delete.setDel(1);
toDelete.add(delete);
deleteIdCards.add(entry.getKey());
}
if (!toInsert.isEmpty()) {
log.info("父亲矛盾增加 {}", toInsert.size());
clueService.saveClues(toInsert, "B48与父亲关系");
}
if (!toUpdate.isEmpty()) {
log.info("父亲矛盾修改 {}", toUpdate.size());
clueService.updateClues(toUpdate, task.getModelId());
}
if (!toDelete.isEmpty()) {
log.info("父亲矛盾删除 {}", toDelete.size());
clueService.deleteCluesAndDeleteTag(toDelete, deleteIdCards, task.getModelId());
}
List<RiskModelTaskClue> toInsert2 = new ArrayList<>();
List<RiskModelTaskClue> toUpdate2 = new ArrayList<>();
List<RiskModelTaskClue> toDelete2 = new ArrayList<>();
List<String> deleteIdCards2 = new ArrayList<>();
Map<String, RiskModelTaskClue> oldMap2 = domain.getOldMap(task2.getModelId(), true);
for (RiskModelTaskClue riskModelTaskClue : tmp2) {
RiskModelTaskClue old = oldMap2.get(riskModelTaskClue.getIdCode());
if (old == null) {
toInsert2.add(riskModelTaskClue);
continue;
}
oldMap2.remove(riskModelTaskClue.getIdCode());
if (!old.getData().equals(riskModelTaskClue.getData())) {
riskModelTaskClue.setId(old.getId());
toUpdate2.add(riskModelTaskClue);
}
}
for (Map.Entry<String, RiskModelTaskClue> entry : oldMap2.entrySet()) {
RiskModelTaskClue delete = new RiskModelTaskClue();
delete.setId(entry.getValue().getId());
delete.setDel(1);
toDelete2.add(delete);
deleteIdCards2.add(entry.getKey());
}
if (!toInsert2.isEmpty()) {
log.info("母亲矛盾增加 {}", toInsert2.size());
clueService.saveClues(toInsert2, "B49与母亲关系");
}
taskRepository.updateTask(task.getId(), toInsert.size(), 0);
taskRepository.updateTask(task2.getId(), toInsert2.size(), 0);
if (!toUpdate2.isEmpty()) {
log.info("母亲矛盾修改 {}", toUpdate2.size());
clueService.updateClues(toUpdate2, task2.getModelId());
}
if (!toDelete2.isEmpty()) {
log.info("母亲矛盾删除 {}", toDelete2.size());
clueService.deleteCluesAndDeleteTag(toDelete2, deleteIdCards2, task2.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size() + toDelete.size());
taskRepository.updateTask(task2.getId(), toInsert2.size(), toUpdate2.size() + toDelete2.size());
}
@Override
public void syncLove(TaskParamDomain domain) {
String startTime = LocalDateTime.of(2023, 12, 6, 0, 0, 0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime limit = LocalDateTime.now().minusYears(1);
List<GBaseJJD> result = gBaseJJDRepository.getBaseMapper().selectLoveDispute(startTime);
List<GBaseJJD> result = gBaseJJDRepository.getBaseMapper().selectLoveDispute(limit.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
// 恋爱创伤
RiskTask task = taskRepository.create(result.size(), 71);
@ -772,42 +864,52 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
}
}
}
List<RiskModelTaskClue> oldList = Optional.ofNullable(domain.getMap().get(task.getModelId())).orElse(new ArrayList<>());
// 按人分
Map<String, List<RiskModelTaskClue>> personOldMap = oldList.stream().collect(Collectors.groupingBy(RiskModelTaskClue::getIdCode));
Map<String, RiskModelTaskClue> oldMap = domain.getOldMap(task.getModelId(), true);
List<RiskModelTaskClue> toInsert = new ArrayList<>();
for (RiskPersonal person : domain.getPersons()) {
toInsert.addAll(collectionClue(idCodesMap, mobilesMap, person, personOldMap, task, "个人恋爱创伤"));
}
List<RiskModelTaskClue> toUpdate = new ArrayList<>();
List<RiskModelTaskClue> toDelete = new ArrayList<>();
List<String> deleteIdCards = new ArrayList<>();
for (RiskModelTaskClue clue : oldList) {
if (clue.getEventTime().isBefore(limit)) {
RiskModelTaskClue update = new RiskModelTaskClue();
update.setId(update.getId());
update.setDel(1);
toUpdate.add(update);
deleteIdCards.add(clue.getIdCode());
for (RiskPersonal person : domain.getPersons()) {
RiskModelTaskClue clue = collectionClue(idCodesMap, mobilesMap, person, task, "个人恋爱创伤");
if (clue == null) continue;
RiskModelTaskClue old = oldMap.get(person.getIdCode());
if (old == null) {
toInsert.add(clue);
continue;
}
oldMap.remove(person.getIdCode());
if (!old.getData().equals(clue.getData())) {
clue.setId(old.getId());
toUpdate.add(clue);
}
}
for (Map.Entry<String, RiskModelTaskClue> entry : oldMap.entrySet()) {
RiskModelTaskClue delete = new RiskModelTaskClue();
delete.setId(entry.getValue().getId());
delete.setDel(1);
toDelete.add(delete);
deleteIdCards.add(entry.getValue().getIdCode());
}
log.info("恋爱创伤:{} | {}", toInsert.size(), toUpdate.size());
log.info("恋爱创伤:{} | {} | {}", toInsert.size(), toUpdate.size(), toDelete.size());
if (!toInsert.isEmpty()) {
clueService.saveClues(toInsert, "B68个人恋爱创伤");
}
if (!toUpdate.isEmpty()) {
clueService.deleteCluesAndDeleteTag(toUpdate, deleteIdCards, task.getModelId());
clueService.updateClues(toUpdate, task.getModelId());
}
if (!toDelete.isEmpty()) {
clueService.deleteCluesAndDeleteTag(toDelete, deleteIdCards, task.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size());
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size() + toDelete.size());
}
@Override
public void syncMarryDispute(TaskParamDomain domain) {
String startTime = LocalDateTime.of(2023, 12, 6, 0, 0, 0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime limit = LocalDateTime.now().minusYears(1);
List<GBaseJJD> result = gBaseJJDRepository.getBaseMapper().selectMarryDispute(startTime);
// 恋爱创伤
List<GBaseJJD> result = gBaseJJDRepository.getBaseMapper().selectMarryDispute(limit.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
// 婚姻矛盾
RiskTask task = taskRepository.create(result.size(), 72);
Map<String, List<GBaseJJD>> idCodesMap = new WeakHashMap<>();
@ -861,42 +963,51 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
}
}
}
List<RiskModelTaskClue> oldList = Optional.ofNullable(domain.getMap().get(task.getModelId())).orElse(new ArrayList<>());
// 按人分
Map<String, List<RiskModelTaskClue>> personOldMap = oldList.stream().collect(Collectors.groupingBy(RiskModelTaskClue::getIdCode));
Map<String, RiskModelTaskClue> oldMap = domain.getOldMap(task.getModelId(), true);
List<RiskModelTaskClue> toInsert = new ArrayList<>();
for (RiskPersonal person : domain.getPersons()) {
toInsert.addAll(collectionClue(idCodesMap, mobilesMap, person, personOldMap, task, "与配偶关系不和"));
}
List<RiskModelTaskClue> toUpdate = new ArrayList<>();
List<RiskModelTaskClue> toDelete = new ArrayList<>();
List<String> deleteIdCards = new ArrayList<>();
for (RiskModelTaskClue clue : oldList) {
if (clue.getEventTime().isBefore(limit)) {
RiskModelTaskClue update = new RiskModelTaskClue();
update.setId(update.getId());
update.setDel(1);
toUpdate.add(update);
deleteIdCards.add(clue.getIdCode());
for (RiskPersonal person : domain.getPersons()) {
RiskModelTaskClue clue = collectionClue(idCodesMap, mobilesMap, person, task, "与配偶关系不和");
if (clue == null) continue;
RiskModelTaskClue old = oldMap.get(person.getIdCode());
if (old == null) {
toInsert.add(clue);
continue;
}
oldMap.remove(person.getIdCode());
if (!old.getData().equals(clue.getData())) {
clue.setId(old.getId());
toUpdate.add(clue);
}
}
log.info("与配偶关系不和:{} | {}", toInsert.size(), toUpdate.size());
for (Map.Entry<String, RiskModelTaskClue> entry : oldMap.entrySet()) {
RiskModelTaskClue delete = new RiskModelTaskClue();
delete.setId(entry.getValue().getId());
delete.setDel(1);
toDelete.add(delete);
deleteIdCards.add(entry.getValue().getIdCode());
}
log.info("与配偶关系不和:{} | {} | {}", toInsert.size(), toUpdate.size(), toDelete.size());
if (!toInsert.isEmpty()) {
clueService.saveClues(toInsert, "B55与配偶关系");
}
if (!toUpdate.isEmpty()) {
clueService.deleteCluesAndDeleteTag(toUpdate, deleteIdCards, task.getModelId());
clueService.updateClues(toUpdate, task.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size());
if (!toDelete.isEmpty()) {
clueService.deleteCluesAndDeleteTag(toDelete, deleteIdCards, task.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size() + toDelete.size());
}
@Override
public void syncNeighborAndColleagueDispute(TaskParamDomain domain) {
String startTime = LocalDateTime.of(2023, 12, 6, 0, 0, 0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
LocalDateTime limit = LocalDateTime.now().minusYears(1);
List<GBaseJJD> result = gBaseJJDRepository.getBaseMapper().selectNeighborAndColleagueDispute(startTime);
// 恋爱创伤
List<GBaseJJD> result = gBaseJJDRepository.getBaseMapper().selectNeighborAndColleagueDispute(limit.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
// 邻居同事
RiskTask task = taskRepository.create(result.size(), 73);
Map<String, List<GBaseJJD>> idCodesMap = new WeakHashMap<>();
@ -950,43 +1061,54 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
}
}
}
List<RiskModelTaskClue> oldList = Optional.ofNullable(domain.getMap().get(task.getModelId())).orElse(new ArrayList<>());
// 按人分
Map<String, List<RiskModelTaskClue>> personOldMap = oldList.stream().collect(Collectors.groupingBy(RiskModelTaskClue::getIdCode));
Map<String, RiskModelTaskClue> oldMap = domain.getOldMap(task.getModelId(), true);
List<RiskModelTaskClue> toInsert = new ArrayList<>();
for (RiskPersonal person : domain.getPersons()) {
toInsert.addAll(collectionClue(idCodesMap, mobilesMap, person, personOldMap, task, "与邻居或同事纠纷"));
}
List<RiskModelTaskClue> toUpdate = new ArrayList<>();
List<RiskModelTaskClue> toDelete = new ArrayList<>();
List<String> deleteIdCards = new ArrayList<>();
for (RiskModelTaskClue clue : oldList) {
if (clue.getEventTime().isBefore(limit)) {
RiskModelTaskClue update = new RiskModelTaskClue();
update.setId(update.getId());
update.setDel(1);
toUpdate.add(update);
deleteIdCards.add(clue.getIdCode());
for (RiskPersonal person : domain.getPersons()) {
RiskModelTaskClue clue = collectionClue(idCodesMap, mobilesMap, person, task, "与邻居或同事纠纷");
if (clue == null) continue;
RiskModelTaskClue old = oldMap.get(person.getIdCode());
if (old == null) {
toInsert.add(clue);
continue;
}
oldMap.remove(person.getIdCode());
if (!old.getData().equals(clue.getData())) {
clue.setId(old.getId());
toUpdate.add(clue);
}
}
log.info("邻里和同事:{} | {}", toInsert.size(), toUpdate.size());
for (Map.Entry<String, RiskModelTaskClue> entry : oldMap.entrySet()) {
RiskModelTaskClue delete = new RiskModelTaskClue();
delete.setId(entry.getValue().getId());
delete.setDel(1);
toDelete.add(delete);
deleteIdCards.add(entry.getValue().getIdCode());
}
log.info("邻里和同事:{} | {} | {}", toInsert.size(), toUpdate.size(), toDelete.size());
if (!toInsert.isEmpty()) {
clueService.saveClues(toInsert, "B55同事与邻居关系");
}
if (!toUpdate.isEmpty()) {
clueService.deleteCluesAndDeleteTag(toUpdate, deleteIdCards, task.getModelId());
clueService.updateClues(toUpdate, task.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size());
if (!toDelete.isEmpty()) {
clueService.deleteCluesAndDeleteTag(toDelete, deleteIdCards, task.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size() + toDelete.size());
}
@Override
public void syncBullying(TaskParamDomain domain) {
String startTime = LocalDateTime.of(2023, 12, 6, 0, 0, 0).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
String startTime = LocalDateTime.now().minusYears(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
List<GBaseJJD> result = gBaseJJDRepository.getBaseMapper().selectBullying(startTime);
// 恋爱创伤
// 遭遇霸凌
RiskTask task = taskRepository.create(result.size(), 74);
Map<String, List<GBaseJJD>> idCodesMap = new WeakHashMap<>();
List<String> mobiles = new ArrayList<>();
LocalDate today = LocalDate.now();
@ -1046,51 +1168,75 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
}
}
}
List<RiskModelTaskClue> oldList = Optional.ofNullable(domain.getMap().get(task.getModelId())).orElse(new ArrayList<>());
Map<String, List<RiskModelTaskClue>> personMap = oldList.stream().collect(Collectors.groupingBy(RiskModelTaskClue::getIdCode));
Map<String, RiskModelTaskClue> oldMap = domain.getOldMap(task.getModelId(), true);
List<RiskModelTaskClue> toInsert = new ArrayList<>();
List<RiskModelTaskClue> toUpdate = new ArrayList<>();
List<RiskModelTaskClue> toDelete = new ArrayList<>();
List<String> deleteIdCards = new ArrayList<>();
for (RiskPersonal person : domain.getPersons()) {
List<GBaseJJD> jjdList = Optional.ofNullable(idCodesMap.get(person.getIdCode())).orElse(new ArrayList<>());
jjdList = jjdList.stream().filter(StreamUtil.distinctByKey(GBaseJJD::getJjdbh)).toList();
jjdList = jjdList.stream().filter(StreamUtil.distinctByKey(GBaseJJD::getJjdbh)).sorted().toList();
if (jjdList.isEmpty()) {
continue;
}
List<RiskModelTaskClue> olds = personMap.get(person.getIdCode());
if (olds != null) {
continue;
}
StringBuilder sb = new StringBuilder("该人员存在" + jjdList.size() + "起被欺凌警情,接警单编号:");
LocalDateTime time = null;
for (GBaseJJD jjd : jjdList) {
sb.append(jjd.getJjdbh()).append(",");
try {
LocalDateTime tmp = jjd.getBjsj().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
if (time == null) {
time = tmp;
continue;
}
if (time.isBefore(tmp)) {
time = tmp;
}
} catch (Exception ignored) {
LocalDateTime tmp = DateTimeUtil.date2LocalDateTime(jjd.getBjsj());
if (time == null || (tmp!= null && time.isBefore(tmp))) {
time = tmp;
}
}
ClueData data = ClueData.builder()
String desc = sb.substring(0, sb.length() - 1);
RiskModelTaskClue old = oldMap.get(person.getIdCode());
if (old == null) {
toInsert.add(DataUtil.createClueData(task, ClueData.builder()
.name(person.getName())
.idCode(person.getIdCode())
.tags(List.of("被欺凌"))
.score(Math.min(jjdList.size(), 5))
.sourceData(desc)
.personId(person.getId())
.eventTime(time)
.build()));
continue;
}
oldMap.remove(person.getIdCode());
if(old.getData().equals(desc)) continue;
RiskModelTaskClue update = DataUtil.createClueData(task, ClueData.builder()
.name(person.getName())
.idCode(person.getIdCode())
.tags(List.of("被欺凌"))
.score(Math.min(jjdList.size(), 5))
.sourceData(sb.substring(0, sb.length() - 1))
.sourceData(desc)
.personId(person.getId())
.eventTime(time)
.build();
toInsert.add(DataUtil.createClueData(task, data));
.build());
update.setId(old.getId());
toUpdate.add(update);
}
for (Map.Entry<String, RiskModelTaskClue> entry : oldMap.entrySet()) {
RiskModelTaskClue delete = new RiskModelTaskClue();
delete.setId(entry.getValue().getId());
delete.setDel(1);
toDelete.add(delete);
deleteIdCards.add(entry.getValue().getIdCode());
}
log.info("欺凌:{}", toInsert.size());
log.info("欺凌:{} | {} | {}", toInsert.size(), toUpdate.size(), toDelete.size());
if (!toInsert.isEmpty()) {
clueService.saveClues(toInsert, "B73遭遇暴力欺凌");
}
taskRepository.updateTask(task.getId(), toInsert.size(), 0);
if (!toUpdate.isEmpty()) {
clueService.updateClues(toUpdate, task.getModelId());
}
if (!toDelete.isEmpty()) {
clueService.deleteCluesAndDeleteTag(toDelete, deleteIdCards, task.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size()+toDelete.size());
}
@Override
@ -1172,7 +1318,7 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
clueService.deleteCluesAndDeleteTag(toDelete, deleteIdCodes, task.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size()+toDelete.size());
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size() + toDelete.size());
}
/**
@ -1240,7 +1386,6 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
}
Map<String, List<GBaseJJD>> findTargetJJD(List<GBaseJJD> jjdList) {
Map<String, List<GBaseJJD>> fatherIdCodeMap = new WeakHashMap<>();
List<GBaseJJD> others = new ArrayList<>();
@ -1304,34 +1449,19 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
}
List<RiskModelTaskClue> eachClue2Save(TaskParamDomain domain, RiskTask task, Map<String, List<GBaseJJD>> idCodeMap, String tag) {
List<RiskModelTaskClue> oldList = Optional.ofNullable(domain.getMap().get(task.getModelId())).orElse(new ArrayList<>());
Map<String, List<RiskModelTaskClue>> personMap = oldList.stream().collect(Collectors.groupingBy(RiskModelTaskClue::getIdCode));
List<RiskModelTaskClue> toInsert = new ArrayList<>();
for (RiskPersonal person : domain.getPersons()) {
List<GBaseJJD> jjdList = Optional.ofNullable(idCodeMap.get(person.getIdCode())).orElse(new ArrayList<>());
jjdList = jjdList.stream().filter(StreamUtil.distinctByKey(GBaseJJD::getJjdbh)).toList();
jjdList = jjdList.stream().filter(StreamUtil.distinctByKey(GBaseJJD::getJjdbh)).sorted().toList();
if (jjdList.isEmpty()) {
continue;
}
List<RiskModelTaskClue> olds = personMap.get(person.getIdCode());
if (olds != null) {
continue;
}
LocalDateTime time = null;
StringBuilder sb = new StringBuilder("该人员与" + tag + "存在" + jjdList.size() + "起矛盾,接警单编号:");
for (GBaseJJD jjd : jjdList) {
sb.append(jjd.getJjdbh()).append(",");
try {
LocalDateTime tmp = jjd.getBjsj().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
if (time == null) {
time = tmp;
continue;
}
if (time.isBefore(tmp)) {
time = tmp;
}
} catch (Exception ignored) {
}
LocalDateTime tmp = DateTimeUtil.date2LocalDateTime(jjd.getBjsj());
if (time == null || (tmp!= null && time.isBefore(tmp))) time = tmp;
}
toInsert.add(DataUtil.createClueData(task, ClueData.builder()
.name(person.getName())
@ -1417,6 +1547,41 @@ public class GBaseJJDServiceImpl implements GBaseJJDService {
return toInsert;
}
/**
* 手机要搜索的clue数据
*
* @param idCode 身份证Map
* @param mobile 手机号map
* @param personal 人员
* @param task 任务
* @param tag 标签
* @return 要新增的clue
*/
RiskModelTaskClue collectionClue(Map<String, List<GBaseJJD>> idCode, Map<String, List<GBaseJJD>> mobile, RiskPersonal personal, RiskTask task, String tag) {
List<GBaseJJD> jjdList = Optional.ofNullable(idCode.get(personal.getIdCode())).orElse(new ArrayList<>());
jjdList.addAll(Optional.ofNullable(mobile.get(personal.getMobileNumber())).orElse(new ArrayList<>()));
if (jjdList.isEmpty()) return null;
jjdList = jjdList.stream().filter(StreamUtil.distinctByKey(GBaseJJD::getJjdbh)).sorted().toList();
StringBuilder sb = new StringBuilder("该人员存在" + jjdList.size() + "起" + tag + "警情,接警单编号:");
LocalDateTime time = null;
for (GBaseJJD gBaseJJD : jjdList) {
sb.append(gBaseJJD.getJjdbh()).append(",");
LocalDateTime tmp = DateTimeUtil.date2LocalDateTime(gBaseJJD.getBjsj());
if (time == null || (tmp!= null && time.isBefore(tmp))) {
time = tmp;
}
}
return DataUtil.createClueData(task, ClueData.builder()
.name(personal.getName())
.idCode(personal.getIdCode())
.tags(List.of(tag))
.personId(personal.getId())
.eventTime(time)
.sourceData(sb.substring(0, sb.length() - 1))
.score(Math.min(jjdList.size(), 5))
.build());
}
/**
* 多身份证对比名称
*

112
src/main/java/com/biutag/supervisiondata/service/impl/GBaseSHRWFRServiceImpl.java

@ -173,7 +173,7 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
oldMap.remove(person.getIdCode());
continue;
}
if(old != null) {
if (old != null) {
oldMap.remove(person.getIdCode());
RiskModelTaskClue update = new RiskModelTaskClue();
update.setId(old.getId());
@ -212,7 +212,7 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
log.info("删除被打击处理{}条", toDelete.size());
clueService.deleteCluesAndDeleteTag(toDelete, deleteIdCodes, task.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size()+toDelete.size());
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size() + toDelete.size());
}
@Override
@ -241,7 +241,7 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
StringBuilder sb = new StringBuilder();
int size = 0;
for (GBaseWFRXX xx : wfxxList) {
String [] str = xx.getSxzmdm().split(",");
String[] str = xx.getSxzmdm().split(",");
for (String s : str) {
WdpcGrjdZblx zblx = map.get(s);
if (zblx == null) {
@ -256,7 +256,7 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
size++;
}
RiskModelTaskClue old = oldMap.get(person.getIdCode());
if(zblxList.isEmpty()) {
if (zblxList.isEmpty()) {
continue;
}
zblxList = zblxList.stream().filter(StreamUtil.distinctByKey(WdpcGrjdZblx::getDmmc)).sorted().toList();
@ -270,11 +270,11 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
zm.append(wdpcGrjdZblx.getDmmc()).append(",");
}
if(old != null && old.getData().contentEquals(sb)) {
if (old != null && old.getData().contentEquals(sb)) {
oldMap.remove(person.getIdCode());
continue;
}
if(old != null) {
if (old != null) {
oldMap.remove(person.getIdCode());
RiskModelTaskClue update = new RiskModelTaskClue();
update.setId(old.getId());
@ -315,7 +315,7 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
log.info("删除刑事处罚罪名{}条", toDelete.size());
clueService.deleteCluesAndDeleteTag(toDelete, deleteIdCodes, task.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size()+toDelete.size());
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size() + toDelete.size());
}
private final WdpcGrjdZblxRepository zblxRepository;
@ -337,15 +337,14 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
for (GBaseWFRXX gBaseWFRXX : tmp) {
wfrMap.put(gBaseWFRXX.getZjhm(), gBaseWFRXX.getZydm());
}
// 担心和保安、涉药模型混搭
Map<String, RiskModelTaskClue> oldMap = domain.getOldMap(task.getModelId(), true);
Map<String, RiskModelTaskClue> oldMap2 = domain.getOldMap(task2.getModelId(), true);
List<WdpcGrjdZblx> wfzyList = Optional.ofNullable(lxMap.get("12")).orElse(new ArrayList<>());
Map<String, WdpcGrjdZblx> wfzyMap = wfzyList.stream().collect(Collectors.toMap(WdpcGrjdZblx::getDmbh, Function.identity(), (val, old) -> val));
// 职业登记划分
List<RiskModelTaskClue> toInsert = new ArrayList<>();
// 有无职业
List<RiskModelTaskClue> toInsert2 = new ArrayList<>();
List<RiskModelTaskClue> tmpList = new ArrayList<>();
// 涉药
Map<String, List<Drug>> drugMap = drug();
Map<String, List<SecurityMan>> securityMenMap = security();
@ -354,12 +353,9 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
List<RiskPersonal> personalList = new ArrayList<>();
Map<String, RiskPersonal> noJob = new WeakHashMap<>();
for (RiskPersonal person : domain.getPersons()) {
if (oldMap.get(person.getIdCode()) != null) {
continue;
}
// 先看是不是涉药或保安
List<Drug> drugMan = drugMap.get(person.getIdCode());
if(drugMan != null) {
if (drugMan != null) {
ClueData data = ClueData.builder()
.name(person.getName())
.id("zy")
@ -370,11 +366,11 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
.eventTime(LocalDateTime.now())
.personId(person.getId())
.build();
toInsert.add(DataUtil.createClueData(task, data));
tmpList.add(DataUtil.createClueData(task, data));
continue;
}
List<SecurityMan> securityMen = securityMenMap.get(person.getIdCode());
if(securityMen != null) {
if (securityMen != null) {
ClueData data = ClueData.builder()
.name(person.getName())
.id("zy")
@ -385,7 +381,7 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
.eventTime(LocalDateTime.now())
.personId(person.getId())
.build();
toInsert.add(DataUtil.createClueData(task, data));
tmpList.add(DataUtil.createClueData(task, data));
continue;
}
@ -399,18 +395,17 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
personalList.add(person);
continue;
}
if(zblx.getScore() < 5.0) {
ClueData data = ClueData.builder()
if (zblx.getScore() < 5.0) {
tmpList.add(DataUtil.createClueData(task, ClueData.builder()
.name(person.getName())
.id("zy")
.idCode(person.getIdCode())
.score(zblx.getScore().intValue())
.sourceData("该人员从事"+zblx.getDmmc()+"工作")
.sourceData("该人员从事" + zblx.getDmmc() + "工作")
.tags(List.of(zblx.getDmmc()))
.eventTime(LocalDateTime.now())
.personId(person.getId())
.build();
toInsert.add(DataUtil.createClueData(task, data));
.build()));
} else {
noJob.put(person.getIdCode(), person);
}
@ -424,28 +419,66 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
WdpcGrjdZblx zblx = wfzyMap.get(zydm);
if (zblx == null) continue;
if (zblx.getScore() < 5.0) {
ClueData data = ClueData.builder()
tmpList.add(DataUtil.createClueData(task, ClueData.builder()
.name(person.getName())
.id("zy")
.id("")
.idCode(person.getIdCode())
.score(zblx.getScore().intValue())
.sourceData("该人员从事"+zblx.getDmmc()+"工作")
.sourceData("该人员从事" + zblx.getDmmc() + "工作")
.tags(List.of(zblx.getDmmc()))
.eventTime(LocalDateTime.now())
.personId(person.getId())
.build();
toInsert.add(DataUtil.createClueData(task, data));
.build()));
} else {
noJob.put(person.getIdCode(), person);
}
}
List<RiskModelTaskClue> toInsert = new ArrayList<>();
List<RiskModelTaskClue> toUpdate = new ArrayList<>();
for (RiskModelTaskClue clue : tmpList) {
RiskModelTaskClue old = oldMap.get(clue.getIdCode());
if(old == null) {
toInsert.add(clue);
continue;
}
oldMap.remove(clue.getIdCode());
if(old.getData().equals(clue.getData())) continue;
clue.setId(old.getId());
toUpdate.add(clue);
}
List<RiskModelTaskClue> toDelete = new ArrayList<>();
List<String> toDeleteIds = new ArrayList<>();
for (Map.Entry<String, RiskModelTaskClue> entry : oldMap.entrySet()) {
RiskModelTaskClue delete = new RiskModelTaskClue();
delete.setId(entry.getValue().getId());
delete.setDel(1);
toDelete.add(delete);
toDeleteIds.add(entry.getKey());
}
if (!toInsert.isEmpty()) {
log.info("保存职业类型: {}", toInsert.size());
clueService.saveClues(toInsert, Default.IMPORT_IG);
}
if (!toUpdate.isEmpty()) {
log.info("修改职业类型: {}", toUpdate.size());
clueService.updateClues(toUpdate, task.getModelId());
}
if (!toDelete.isEmpty()) {
log.info("删除职业类型: {}", toDelete.size());
clueService.deleteCluesAndDeleteTag(toDelete, toDeleteIds, task.getModelId());
}
// 有无职业
List<RiskModelTaskClue> toInsert2 = new ArrayList<>();
for (Map.Entry<String, RiskPersonal> entry : noJob.entrySet()) {
ClueData data = ClueData.builder()
RiskModelTaskClue old = oldMap2.get(entry.getValue().getIdCode());
if(old != null) {
oldMap2.remove(entry.getValue().getIdCode());
continue;
}
toInsert2.add(DataUtil.createClueData(task2, ClueData.builder()
.name(entry.getValue().getName())
.id("zy")
.idCode(entry.getValue().getIdCode())
@ -454,16 +487,29 @@ public class GBaseSHRWFRServiceImpl implements GBaseSHRWFRService {
.tags(List.of("无固定职业"))
.eventTime(LocalDateTime.now())
.personId(entry.getValue().getId())
.build();
toInsert2.add(DataUtil.createClueData(task2, data));
.build()));
}
List<RiskModelTaskClue> toDelete2 = new ArrayList<>();
List<String> toDeleteIds2 = new ArrayList<>();
for (Map.Entry<String, RiskModelTaskClue> entry : oldMap2.entrySet()) {
RiskModelTaskClue delete = new RiskModelTaskClue();
delete.setId(entry.getValue().getId());
delete.setDel(1);
toDelete2.add(delete);
toDeleteIds2.add(entry.getKey());
}
if (!toInsert2.isEmpty()) {
log.info("保存无职业: {}", toInsert2.size());
clueService.saveClues(toInsert2, Default.IMPORT_IG);
}
taskRepository.updateTask(task.getId(), toInsert.size(), 0);
taskRepository.updateTask(task2.getId(), toInsert2.size(), 0);
if (!toDelete2.isEmpty()) {
log.info("删除无职业: {}", toDelete2.size());
clueService.deleteCluesAndDeleteTag(toDelete2, toDeleteIds2, task2.getModelId());
}
taskRepository.updateTask(task.getId(), toInsert.size(), toUpdate.size()+toDelete.size());
taskRepository.updateTask(task2.getId(), toInsert2.size(), toDelete2.size());
}
Map<String, List<SecurityMan>> security() {

7
src/main/java/com/biutag/supervisiondata/task/TaskService.java

@ -123,7 +123,14 @@ public class TaskService {
jsbryService.syncPys(initDomain(List.of(59)));
gBaseSHRWFRService.combatCrime(initDomain(List.of(63)));
gBaseJJDService.warningInstance(initDomain(List.of(64)));
gBaseJJDService.syncHomeViolence(initDomain(List.of(65,66)));
pointService.syncPointType(initDomain(List.of(67)));
gBaseSHRWFRService.hadWork(initDomain(List.of(68)));
gBaseJJDService.syncParentRelation(initDomain(List.of(69,70)));
gBaseJJDService.syncLove(initDomain(List.of(71)));
gBaseJJDService.syncMarryDispute(initDomain(List.of(72)));
gBaseJJDService.syncNeighborAndColleagueDispute(initDomain(List.of(73)));
gBaseJJDService.syncBullying(initDomain(List.of(74)));
gBaseJJDService.syncOtherContradict(initDomain(List.of(75)));
gBaseSHRWFRService.crimeName(initDomain(List.of(76)));
});

Loading…
Cancel
Save