diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanCollectionMinderService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanCollectionMinderService.java index 093cfe29c7..b220f6e13a 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanCollectionMinderService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanCollectionMinderService.java @@ -258,7 +258,6 @@ public class TestPlanCollectionMinderService { private void dealEditList(TestPlanCollectionMinderEditRequest request, String userId, Map> associateMap) { if (CollectionUtils.isNotEmpty(request.getEditList())) { Map> parentMap = getParentMap(request); - Map> childrenMap = getChildrenMap(request); SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); TestPlanCollectionMapper collectionMapper = sqlSession.getMapper(TestPlanCollectionMapper.class); //新增 @@ -266,33 +265,19 @@ public class TestPlanCollectionMinderService { //更新 Map> updateTypeNameMap = dealUpdateList(request, userId, associateMap, parentMap, collectionMapper); //检查同一类型名称重复 - checkNameRepeat(updateTypeNameMap, addTypeNameMap, childrenMap); + checkNameRepeat(updateTypeNameMap, addTypeNameMap); sqlSession.flushStatements(); SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); } } - private static void checkNameRepeat(Map> updateTypeNameMap, Map> addTypeNameMap, Map> childrenMap) { + private static void checkNameRepeat(Map> updateTypeNameMap, Map> addTypeNameMap) { updateTypeNameMap.forEach((k, v)->{ List nameList = addTypeNameMap.get(k); if (CollectionUtils.isNotEmpty(nameList)) { List repeatList = v.stream().filter(nameList::contains).collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(repeatList)) { throw new MSException(Translator.get("test_plan.mind.collection_name_repeat")); - } else { - nameList.addAll(v); - addTypeNameMap.put(k, nameList); - } - } else { - addTypeNameMap.put(k,v); - } - }); - childrenMap.forEach((k, v)->{ - List nameList = addTypeNameMap.get(k); - if (CollectionUtils.isNotEmpty(nameList)) { - List list = v.stream().filter(t -> nameList.contains(t.getName())).toList(); - if (CollectionUtils.isNotEmpty(list)) { - throw new MSException(Translator.get("test_plan.mind.collection_name_repeat")); } } }); @@ -307,7 +292,7 @@ public class TestPlanCollectionMinderService { //处理更新 for (TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO : updateList) { TestPlanCollection testPlanCollection = updateCollection(request, userId, testPlanCollectionMinderEditDTO, parentMap, collectionMapper); - checkChangeDataReapet(typeNamesMap, testPlanCollection); + checkChangeDataRepeat(typeNamesMap, testPlanCollection); setAssociateMap(testPlanCollectionMinderEditDTO, associateMap, testPlanCollection); } } @@ -331,14 +316,14 @@ public class TestPlanCollectionMinderService { if (CollectionUtils.isNotEmpty(addList)) { for (TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO : addList) { TestPlanCollection testPlanCollection = addCollection(request, userId, testPlanCollectionMinderEditDTO, parentMap, collectionMapper); - checkChangeDataReapet(typeNamesMap, testPlanCollection); + checkChangeDataRepeat(typeNamesMap, testPlanCollection); setAssociateMap(testPlanCollectionMinderEditDTO, associateMap, testPlanCollection); } } return typeNamesMap; } - private static void checkChangeDataReapet(Map> typeNamesMap, TestPlanCollection testPlanCollection) { + private static void checkChangeDataRepeat(Map> typeNamesMap, TestPlanCollection testPlanCollection) { List nameList = typeNamesMap.get(testPlanCollection.getType()); if (CollectionUtils.isNotEmpty(nameList)) { if (nameList.contains(testPlanCollection.getName())) {