diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseDemandService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseDemandService.java index 3bebdde09c..dc1d9455d9 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseDemandService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseDemandService.java @@ -271,15 +271,18 @@ public class FunctionalCaseDemandService { for (DemandDTO demandDTO : demandDTOList) { FunctionalCaseDemand functionalCaseDemand = buildFunctionalCaseDemand(request.getCaseId(), request.getDemandPlatform(), userId, demandDTO); //校验重复 - List list = existDemands.stream().filter(t -> StringUtils.equalsIgnoreCase(t.getDemandId(), functionalCaseDemand.getDemandId()) && StringUtils.equalsIgnoreCase(t.getParent(), functionalCaseDemand.getParent()) - && StringUtils.equalsIgnoreCase(t.getDemandName(), functionalCaseDemand.getDemandName()) && StringUtils.equalsIgnoreCase(t.getDemandUrl(), functionalCaseDemand.getDemandUrl())).toList(); - if (CollectionUtils.isNotEmpty(list)) { - continue; + List functionalCaseDemands = existMap.get(demandDTO.getDemandId()); + if (CollectionUtils.isNotEmpty(functionalCaseDemands)) { + List list = functionalCaseDemands.stream().filter(t -> StringUtils.equalsIgnoreCase(t.getDemandId(), functionalCaseDemand.getDemandId()) && StringUtils.equalsIgnoreCase(t.getParent(), functionalCaseDemand.getParent()) + && StringUtils.equalsIgnoreCase(t.getDemandName(), functionalCaseDemand.getDemandName()) && StringUtils.equalsIgnoreCase(t.getDemandUrl(), functionalCaseDemand.getDemandUrl())).toList(); + if (CollectionUtils.isNotEmpty(list)) { + continue; + } } //校验当前关联的需求在系统或传入的数据结构中是否带有父节点,如果有置为true,用来做查询的root节点 - List functionalCaseDemands = existMap.get(demandDTO.getParent()); + List functionalCaseDemandParents = existMap.get(demandDTO.getParent()); List demandDTOList1 = insertMap.get(demandDTO.getParent()); - if (CollectionUtils.isNotEmpty(functionalCaseDemands) || CollectionUtils.isNotEmpty(demandDTOList1)) { + if (CollectionUtils.isNotEmpty(functionalCaseDemandParents) || CollectionUtils.isNotEmpty(demandDTOList1)) { functionalCaseDemand.setWithParent(Boolean.TRUE); } else { functionalCaseDemand.setWithParent(Boolean.FALSE);