diff --git a/laws-modules/src/main/java/com/jero/modules/laws/businessSupport/service/impl/LawsRegulationsQuestionLibraryServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/businessSupport/service/impl/LawsRegulationsQuestionLibraryServiceImpl.java
index fc8807ab..94677b86 100644
--- a/laws-modules/src/main/java/com/jero/modules/laws/businessSupport/service/impl/LawsRegulationsQuestionLibraryServiceImpl.java
+++ b/laws-modules/src/main/java/com/jero/modules/laws/businessSupport/service/impl/LawsRegulationsQuestionLibraryServiceImpl.java
@@ -25,6 +25,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
+import java.util.stream.Collectors;
/**
*
@@ -73,12 +74,35 @@ public class LawsRegulationsQuestionLibraryServiceImpl extends ServiceImpl resList = Arrays.asList(res.split(","));
+ List regulationIdList = StringUtils.isNotBlank(lawsRegulationsQuestionLibrary.getRegulationId())
+ ? new ArrayList<>(Arrays.asList(lawsRegulationsQuestionLibrary.getRegulationId().split(",")))
+ : new ArrayList<>();
+ List regulationNumberList = StringUtils.isNotBlank(lawsRegulationsQuestionLibrary.getRegulationNumber())
+ ? new ArrayList<>(Arrays.asList(lawsRegulationsQuestionLibrary.getRegulationNumber().split(",")))
+ : new ArrayList<>();
+ // 使用Iterator避免ConcurrentModificationException
+ Iterator numberIterator = regulationNumberList.iterator();
+ Iterator idIterator = regulationIdList.iterator();
+ while (numberIterator.hasNext() && idIterator.hasNext()) {
+ String regulationNumber = numberIterator.next();
+ idIterator.next(); // 移动idIterator,保证同步
+ if (resList.contains(regulationNumber)) {
+ numberIterator.remove();
+ idIterator.remove();
+ }
+ }
+ lawsRegulationsQuestionLibrary.setRegulationId(String.join(",", regulationIdList));
+ lawsRegulationsQuestionLibrary.setRegulationNumber(String.join(",", regulationNumberList));
+ }
saveOrUpdate(lawsRegulationsQuestionLibrary); // 不影响数据的正常保存或更新
return Result.OK(ResultCommon.OK);
}
- @Override
- public Result> check(LawsRegulationsQuestionLibrary lawsRegulationsQuestionLibrary) {
+ private String checkStandardAndRegulation(LawsRegulationsQuestionLibrary lawsRegulationsQuestionLibrary) {
// 校验标准编号和条款号是否存在,并给出提示信息
List regulationList = lawsRegulationsQuestionLibrary.getRegulationList();
List lawsSplitByStandardNumbers = new ArrayList<>();
@@ -89,7 +113,12 @@ public class LawsRegulationsQuestionLibraryServiceImpl extends ServiceImpl check(LawsRegulationsQuestionLibrary lawsRegulationsQuestionLibrary) {
+ String res = checkStandardAndRegulation(lawsRegulationsQuestionLibrary);
StringBuilder msg = new StringBuilder();
if (StringUtils.isNotBlank(res)) {
List resList = Arrays.asList(res.split(","));