diff --git a/laws-modules/src/main/java/com/jero/modules/laws/oldSystem/service/impl/OldSystemServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/oldSystem/service/impl/OldSystemServiceImpl.java index f68cc1c6..df2ebedc 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/oldSystem/service/impl/OldSystemServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/oldSystem/service/impl/OldSystemServiceImpl.java @@ -25,10 +25,7 @@ import com.jero.modules.laws.home.service.ILawsHomeSearchService; import com.jero.modules.laws.oldSystem.entity.*; import com.jero.modules.laws.oldSystem.service.OldSystemDepartRelationService; import com.jero.modules.laws.oldSystem.service.OldSystemService; -import com.jero.modules.laws.standard.entity.LawsDomesticStandard; -import com.jero.modules.laws.standard.entity.LawsEnterpriseStandard; -import com.jero.modules.laws.standard.entity.LawsOverseasStandard; -import com.jero.modules.laws.standard.entity.LawsTreeNode; +import com.jero.modules.laws.standard.entity.*; import com.jero.modules.laws.standard.mapper.LawsEnterpriseStandardMapper; import com.jero.modules.laws.standard.service.*; import com.jero.modules.laws.standard.util.StandardSplitUtils; @@ -282,6 +279,16 @@ public class OldSystemServiceImpl implements OldSystemService { List existingEntities = overseasStandardService.list(); Map dataMap = existingEntities.stream() .collect(Collectors.toMap(LawsOverseasStandard::getStandardNumber, d -> d)); + // 获取所有相关标准号 + List replaceStandardNoList = fbList.stream().map(LawsOverseasStandard::getStandardNumber).collect(Collectors.toList()); + replaceStandardNoList.addAll(fbList.stream().map(LawsOverseasStandard::getSubstituteStandardNumber).collect(Collectors.toList())); + replaceStandardNoList.addAll(fbList.stream().map(LawsOverseasStandard::getReplacedByStandardNumber).collect(Collectors.toList())); + // 清除所有外标 + LambdaQueryWrapper replacedStandardWrapper = new LambdaQueryWrapper<>(); + replacedStandardWrapper + .in(LawsReplacedStandard::getReplaced, replaceStandardNoList).or() + .in(LawsReplacedStandard::getReplacedBy, replaceStandardNoList); + lawsReplacedStandardService.remove(replacedStandardWrapper); for (LawsOverseasStandard fb : fbList) { LawsOverseasStandard dbData = dataMap.get(fb.getStandardNumber()); dbData.setStandardState(fb.getStandardState()); @@ -290,7 +297,6 @@ public class OldSystemServiceImpl implements OldSystemService { // 代替标准号 // 先删除已经存储的关联 String standardNumber = dbData.getStandardNumber(); - lawsReplacedStandardService.removeRelation(standardNumber, 1); if (StringUtils.isNotBlank(tdbzh)) { lawsReplacedStandardService.addRelationOldSystemSync(tdbzh, standardNumber, 1); } @@ -298,7 +304,6 @@ public class OldSystemServiceImpl implements OldSystemService { if (StringUtils.isNotBlank(btdbzh)) { List replaceCodeList = Arrays.asList(btdbzh.split(",")); replaceCodeList.forEach(replaceCode -> { - lawsReplacedStandardService.removeRelation(replaceCode, 1); lawsReplacedStandardService.addRelationOldSystemSync(standardNumber, replaceCode, 1); }); } @@ -365,6 +370,16 @@ public class OldSystemServiceImpl implements OldSystemService { List existingEntities = domesticStandardService.list(); Map dataMap = existingEntities.stream() .collect(Collectors.toMap(LawsDomesticStandard::getStandardNumber, d -> d)); + // 获取所有相关标准号 + List replaceStandardNoList = gbList.stream().map(LawsDomesticStandard::getStandardNumber).collect(Collectors.toList()); + replaceStandardNoList.addAll(gbList.stream().map(LawsDomesticStandard::getSubstituteStandardNumber).collect(Collectors.toList())); + replaceStandardNoList.addAll(gbList.stream().map(LawsDomesticStandard::getReplacedByStandardNumber).collect(Collectors.toList())); + // 清除所有国标 + LambdaQueryWrapper replacedStandardWrapper = new LambdaQueryWrapper<>(); + replacedStandardWrapper + .in(LawsReplacedStandard::getReplaced, replaceStandardNoList).or() + .in(LawsReplacedStandard::getReplacedBy, replaceStandardNoList); + lawsReplacedStandardService.remove(replacedStandardWrapper); for (LawsDomesticStandard gb : gbList) { LawsDomesticStandard dbData = dataMap.get(gb.getStandardNumber()); dbData.setStandardState(gb.getStandardState()); @@ -443,6 +458,16 @@ public class OldSystemServiceImpl implements OldSystemService { List existingEntities = esService.list(); Map dataMap = existingEntities.stream() .collect(Collectors.toMap(LawsEnterpriseStandard::getOldSystemId, d -> d)); + // 获取所有相关标准号 + List replaceStandardNoList = esList.stream().map(LawsEnterpriseStandard::getStandardNumber).collect(Collectors.toList()); + replaceStandardNoList.addAll(esList.stream().map(LawsEnterpriseStandard::getSubstituteStandardNumber).collect(Collectors.toList())); + replaceStandardNoList.addAll(esList.stream().map(LawsEnterpriseStandard::getReplacedByStandardNumber).collect(Collectors.toList())); + // 清除所有企标标 + LambdaQueryWrapper replacedStandardWrapper = new LambdaQueryWrapper<>(); + replacedStandardWrapper + .in(LawsReplacedStandard::getReplaced, replaceStandardNoList).or() + .in(LawsReplacedStandard::getReplacedBy, replaceStandardNoList); + lawsReplacedStandardService.remove(replacedStandardWrapper); for (LawsEnterpriseStandard es : esList) { LawsEnterpriseStandard dbData = dataMap.get(es.getOldSystemId()); dbData.setStandardState(es.getStandardState()); @@ -451,7 +476,6 @@ public class OldSystemServiceImpl implements OldSystemService { // 代替标准号 // 先删除已经存储的关联 String standardNumber = dbData.getStandardNumber(); - lawsReplacedStandardService.removeRelation(standardNumber, 1); if (StringUtils.isNotBlank(tdbzh)) { lawsReplacedStandardService.addRelationOldSystemSync(tdbzh, standardNumber, 1); } @@ -459,7 +483,6 @@ public class OldSystemServiceImpl implements OldSystemService { if (StringUtils.isNotBlank(btdbzh)) { List replaceCodeList = Arrays.asList(btdbzh.split(",")); replaceCodeList.forEach(replaceCode -> { - lawsReplacedStandardService.removeRelation(replaceCode, 1); lawsReplacedStandardService.addRelationOldSystemSync(standardNumber, replaceCode, 1); }); }