Browse Source

fix: 身份证为空报错

master
buaixuexideshitongxue 3 weeks ago
parent
commit
81cd17f1bd
  1. 19
      src/main/java/com/biutag/supervision/service/NegativeScoreService.java

19
src/main/java/com/biutag/supervision/service/NegativeScoreService.java

@ -171,6 +171,7 @@ public class NegativeScoreService {
String formula = "%s + (%s * %s) + (%s * %s)";
Map<PoliceScoreKey, NegativeScorePolice> scorePolices = new LinkedHashMap<>();
Map<String, NegativeScoreDepart> scoreDeparts = new LinkedHashMap<>();
int missingIdCodeCount = 0;
for (int i = 0; i < total; i++) {
if (i > 0 && i % 1000 == 0) {
log.info("风险指数优化重算:已处理 {}/{} 条,耗时 {} 秒", i, total, (System.currentTimeMillis() - startTime) / 1000);
@ -192,7 +193,9 @@ public class NegativeScoreService {
// 保留原来的逐条查字典和一年内次数规则。
SupDictProblemType problemType = supDictContentMapper.selectOneByMaxScore(codes);
LocalDateTime endTime = negative.getDiscoveryTime();
int frequency = blameService.countByTrue(blame.getBlameIdCode(),
String idCode = blame.getBlameIdCode();
boolean missingIdCode = idCode == null || idCode.isBlank();
int frequency = missingIdCode ? 0 : blameService.countByTrue(idCode,
problemType.getParentCode(), endTime.minusYears(1), endTime);
String expression = String.format(formula,
problemType.getScore(), problemType.getScore(),
@ -202,15 +205,19 @@ public class NegativeScoreService {
NegativeScorePolice policeScore = new NegativeScorePolice()
.setNegativeId(blame.getNegativeId())
.setIdCode(blame.getBlameIdCode())
.setIdCode(idCode)
.setDiscoveryTime(endTime)
.setBusinessTypeCode(negative.getBusinessTypeCode())
.setDepartGroupId(depart.getStatisticsGroupId())
.setCreateTime(LocalDateTime.now())
.setScore(score)
.setExpression(expression);
scorePolices.merge(new PoliceScoreKey(blame.getNegativeId(), blame.getBlameIdCode()),
policeScore, (oldScore, newScore) -> oldScore.getScore() < newScore.getScore() ? newScore : oldScore);
if (missingIdCode) {
missingIdCodeCount++;
} else {
scorePolices.merge(new PoliceScoreKey(blame.getNegativeId(), idCode),
policeScore, (oldScore, newScore) -> oldScore.getScore() < newScore.getScore() ? newScore : oldScore);
}
NegativeScoreDepart departScore = scoreDeparts.get(negative.getId());
if (departScore == null) {
@ -224,8 +231,8 @@ public class NegativeScoreService {
}
}
log.info("风险指数优化重算:处理完 {} 条,开始写入个人 {} 条、单位 {} 条,耗时 {} 秒",
total, scorePolices.size(), scoreDeparts.size(),
log.info("风险指数优化重算:处理完 {} 条,缺身份证号跳过个人 {} 条,开始写入个人 {} 条、单位 {} 条,耗时 {} 秒",
total, missingIdCodeCount, scorePolices.size(), scoreDeparts.size(),
(System.currentTimeMillis() - startTime) / 1000);
negativeScorePoliceService.saveBatch(scorePolices.values());
negativeScoreDepartService.saveBatch(scoreDeparts.values());

Loading…
Cancel
Save