From 99221b0673797a7464bf4e7ff97f542e16dd2d79 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 10 Sep 2024 17:47:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=94=A8=E4=BE=8B=E8=84=91=E5=9B=BE):?= =?UTF-8?q?=20=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E4=B8=8E=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E8=AF=84=E5=AE=A1=E7=9A=84=E8=84=91=E5=9B=BE=E4=B8=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=94=A8=E4=BE=8B=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/FunctionalCaseMinderService.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java index 0b2985a2f8..9a825e0b0b 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java @@ -141,7 +141,7 @@ public class FunctionalCaseMinderService { Map priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue)); //构造父子级数据 - buildList(functionalCaseMindDTOList, list, priorityMap, false); + buildList(functionalCaseMindDTOList, list, priorityMap, "FUNCTIONAL"); return list; } @@ -152,7 +152,7 @@ public class FunctionalCaseMinderService { return customFields.stream().map(TemplateCustomFieldDTO::getFieldId).toList(); } - private void buildList(List functionalCaseMindDTOList, List list, Map priorityMap, boolean addActualResult) { + private void buildList(List functionalCaseMindDTOList, List list, Map priorityMap, String sourceType) { //构造父子级数据 for (FunctionalCaseMindDTO functionalCaseMindDTO : functionalCaseMindDTOList) { FunctionalMinderTreeDTO root = new FunctionalMinderTreeDTO(); @@ -163,15 +163,17 @@ public class FunctionalCaseMinderService { rootData.setCaseId(functionalCaseMindDTO.getCaseId()); rootData.setPriority(StringUtils.isNotBlank(priorityMap.get(functionalCaseMindDTO.getCaseId())) ? Integer.parseInt(priorityMap.get(functionalCaseMindDTO.getCaseId()).substring(1)) + 1 : 1); rootData.setStatus(functionalCaseMindDTO.getReviewStatus()); - rootData.setResource(List.of(Translator.get("minder_extra_node.case"))); - List children = buildChildren(functionalCaseMindDTO, addActualResult); + if (StringUtils.equalsIgnoreCase(sourceType, "FUNCTIONAL")) { + rootData.setResource(List.of(Translator.get("minder_extra_node.case"))); + } + List children = buildChildren(functionalCaseMindDTO, sourceType); root.setChildren(children); root.setData(rootData); list.add(root); } } - private List buildChildren(FunctionalCaseMindDTO functionalCaseMindDTO, boolean addActualResult) { + private List buildChildren(FunctionalCaseMindDTO functionalCaseMindDTO, String sourceType) { List children = new ArrayList<>(); if (functionalCaseMindDTO.getPrerequisite() != null) { String prerequisiteText = new String(functionalCaseMindDTO.getPrerequisite(), StandardCharsets.UTF_8); @@ -203,7 +205,7 @@ public class FunctionalCaseMinderService { String stepText = new String(functionalCaseMindDTO.getSteps(), StandardCharsets.UTF_8); if (StringUtils.isNotBlank(stepText)) { List functionalCaseStepDTOS = JSON.parseArray(stepText, FunctionalCaseStepDTO.class); - if (addActualResult) { + if (StringUtils.equalsIgnoreCase(sourceType, "TEST_PLAN")) { compareStep(functionalCaseMindDTO.getExecuteSteps(), functionalCaseStepDTOS); } for (FunctionalCaseStepDTO functionalCaseStepDTO : functionalCaseStepDTOS) { @@ -219,7 +221,7 @@ public class FunctionalCaseMinderService { } else { expectedResultFunctionalMinderTreeDTO = getFunctionalMinderTreeDTO(result, Translator.get("minder_extra_node.steps_expected_result"), Long.valueOf(functionalCaseStepDTO.getNum())); } - if (addActualResult) { + if (StringUtils.equalsIgnoreCase(sourceType, "TEST_PLAN")) { Map statusMap = new HashMap<>(); statusMap.put(ResultStatus.SUCCESS.name(), Translator.get("case.minder.status.success")); statusMap.put(ResultStatus.ERROR.name(), Translator.get("case.minder.status.error")); @@ -256,7 +258,7 @@ public class FunctionalCaseMinderService { } } - if (addActualResult) { + if (StringUtils.equalsIgnoreCase(sourceType, "TEST_PLAN")) { String contentText = StringUtils.EMPTY; if (functionalCaseMindDTO.getContent() != null) { contentText = new String(functionalCaseMindDTO.getContent(), StandardCharsets.UTF_8); @@ -1231,7 +1233,7 @@ public class FunctionalCaseMinderService { List caseCustomFieldList = extFunctionalCaseMapper.getCaseCustomFieldList(request, deleted, fieldIds); Map priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue)); //构造父子级数据 - buildList(functionalCaseMindDTOList, list, priorityMap, false); + buildList(functionalCaseMindDTOList, list, priorityMap, "REVIEW"); return list; } @@ -1248,7 +1250,7 @@ public class FunctionalCaseMinderService { List caseCustomFieldList = extFunctionalCaseMapper.getCaseCustomFieldList(request, deleted, fieldIds); Map priorityMap = caseCustomFieldList.stream().collect(Collectors.toMap(FunctionalCaseCustomField::getCaseId, FunctionalCaseCustomField::getValue)); //构造父子级数据 - buildList(functionalCaseMindDTOList, list, priorityMap, true); + buildList(functionalCaseMindDTOList, list, priorityMap, "TEST_PLAN"); return list; }