Browse Source

fix: 同步

master
buaixuexideshitongxue 2 weeks ago
parent
commit
912644f02f
  1. 34
      src/main/java/com/biutag/supervision/service/MailBoxCaptureService.java

34
src/main/java/com/biutag/supervision/service/MailBoxCaptureService.java

@ -398,44 +398,44 @@ public class MailBoxCaptureService {
* 同步涉及人 * 同步涉及人
*/ */
private List<NegativeBlame> syncBlame(Mail mail, String negativeId, List<MailBlame> mailBlames) { private List<NegativeBlame> syncBlame(Mail mail, String negativeId, List<MailBlame> mailBlames) {
// 幂等性检查:已存在则跳过
LambdaQueryWrapper<NegativeBlame> existWrapper = new LambdaQueryWrapper<>();
existWrapper.eq(NegativeBlame::getNegativeId, negativeId);
if (blameService.count(existWrapper) > 0) {
log.info("【阶段2同步】涉及人已存在,跳过: negativeId={}", negativeId);
return Collections.emptyList();
}
// mailBlames 已由调用方在事务外查询好 // mailBlames 已由调用方在事务外查询好
if (CollectionUtil.isEmpty(mailBlames)) { if (CollectionUtil.isEmpty(mailBlames)) {
return Collections.emptyList(); return Collections.emptyList();
} }
// 全量覆盖同步:先删除问题关联,再删除涉及人员
negativeProblemRelationService.remove(negativeId);
blameService.remove(negativeId);
List<NegativeBlame> result = new ArrayList<>(); List<NegativeBlame> result = new ArrayList<>();
for (MailBlame blame : mailBlames) { for (MailBlame blame : mailBlames) {
// 通过姓名+警号查询 SupPolice 获取完整信息 // 通过身份证号或警号查询 SupPolice 获取完整信息
LambdaQueryWrapper<SupPolice> supPoliceLambdaQueryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<SupPolice> supPoliceLambdaQueryWrapper = new LambdaQueryWrapper<>();
supPoliceLambdaQueryWrapper.eq(SupPolice::getIdCode, blame.getBlameIdCode()); supPoliceLambdaQueryWrapper
supPoliceLambdaQueryWrapper.last("limit 1"); .eq(StrUtil.isNotBlank(blame.getBlameIdCode()), SupPolice::getIdCode, blame.getBlameIdCode())
.or()
.eq(StrUtil.isNotBlank(blame.getBlameEmpNo()), SupPolice::getEmpNo, blame.getBlameEmpNo())
.last("limit 1");
SupPolice police = supPoliceService.getOne(supPoliceLambdaQueryWrapper); SupPolice police = supPoliceService.getOne(supPoliceLambdaQueryWrapper);
if (Objects.isNull(police)) { if (Objects.isNull(police)) {
log.warn("【阶段2同步】未找到该警员的数据! blameName={}, blameEmpNo={}", blame.getBlameName(), blame.getBlameEmpNo()); log.warn("【阶段2同步】未找到该警员的数据,使用MailBlame数据补充! blameName={}, blameEmpNo={}", blame.getBlameName(), blame.getBlameEmpNo());
continue;
} }
NegativeBlame negativeBlame = new NegativeBlame(); NegativeBlame negativeBlame = new NegativeBlame();
negativeBlame.setBlameId(IdUtil.getSnowflakeNextIdStr()); negativeBlame.setBlameId(IdUtil.getSnowflakeNextIdStr());
negativeBlame.setNegativeId(negativeId); negativeBlame.setNegativeId(negativeId);
negativeBlame.setType("personal"); negativeBlame.setType("personal");
negativeBlame.setBlameEmpNo(police.getEmpNo()); negativeBlame.setBlameEmpNo(Objects.nonNull(police) ? police.getEmpNo() : blame.getBlameEmpNo());
negativeBlame.setBlameIdCode(police.getIdCode()); negativeBlame.setBlameIdCode(Objects.nonNull(police) ? police.getIdCode() : blame.getBlameIdCode());
negativeBlame.setBlameName(police.getName()); negativeBlame.setBlameName(Objects.nonNull(police) ? police.getName() : blame.getBlameName());
negativeBlame.setCrtTime(LocalDateTime.now()); negativeBlame.setCrtTime(LocalDateTime.now());
negativeBlame.setUpdTime(LocalDateTime.now()); negativeBlame.setUpdTime(LocalDateTime.now());
negativeBlame.setLeadEmpNo(blame.getLeaderEmpNo()); negativeBlame.setLeadEmpNo(blame.getLeaderEmpNo());
negativeBlame.setLeadName(blame.getLeaderName()); negativeBlame.setLeadName(blame.getLeaderName());
negativeBlame.setLeadIdCode(blame.getLeaderIdCode()); negativeBlame.setLeadIdCode(blame.getLeaderIdCode());
negativeBlame.setIvPersonType(police.getPersonType()); if (Objects.nonNull(police)) {
negativeBlame.setIvPersonType(police.getPersonType());
}
// 责任追究映射 // 责任追究映射
if (StrUtil.isNotBlank(blame.getVerifyPunish())) { if (StrUtil.isNotBlank(blame.getVerifyPunish())) {

Loading…
Cancel
Save