From a4e4bb60b9b328d9ec0b213ba9186b38e9e92d92 Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 20 Jul 2022 17:39:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E7=8E=AF=E5=A2=83=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=A8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1015084 --user=宋天阳 【测试跟踪】测试计划-报告列表,报告里的运行环境少了一个 https://www.tapd.cn/55049933/s/1205607 --- .../testplan/TestPlanReportRunInfoDTO.java | 36 +++++++++++----- .../track/service/TestPlanReportService.java | 42 +++++++++++++++---- .../report/detail/TestPlanOverviewReport.vue | 4 +- 3 files changed, 62 insertions(+), 20 deletions(-) diff --git a/backend/src/main/java/io/metersphere/track/dto/testplan/TestPlanReportRunInfoDTO.java b/backend/src/main/java/io/metersphere/track/dto/testplan/TestPlanReportRunInfoDTO.java index 382a0d5747..d88da1f5d8 100644 --- a/backend/src/main/java/io/metersphere/track/dto/testplan/TestPlanReportRunInfoDTO.java +++ b/backend/src/main/java/io/metersphere/track/dto/testplan/TestPlanReportRunInfoDTO.java @@ -3,7 +3,9 @@ package io.metersphere.track.dto.testplan; import lombok.Getter; import lombok.Setter; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; @Getter @@ -14,24 +16,38 @@ public class TestPlanReportRunInfoDTO { private String runMode; // <测试计划场景关联表ID, <项目ID,环境ID>> - private Map> scenarioRunInfo; + private Map>> scenarioRunInfo; // <测试计划用例关联表ID, <项目ID,环境ID>> - private Map> apiCaseRunInfo; + private Map> apiCaseRunInfo; - public TestPlanReportRunInfoDTO(){ + public TestPlanReportRunInfoDTO() { scenarioRunInfo = new HashMap<>(); apiCaseRunInfo = new HashMap<>(); } - public void putScenarioRunInfo(String scenarioResourceId,String projectId,String environmentId){ - scenarioRunInfo.put(scenarioResourceId,new HashMap<>(){{ - this.put(projectId,environmentId); - }}); + public void putScenarioRunInfo(String scenarioResourceId, String projectId, String environmentId) { + if (scenarioRunInfo.containsKey(scenarioResourceId)) { + if (scenarioRunInfo.get(scenarioResourceId).containsKey(projectId)) { + if (!scenarioRunInfo.get(scenarioResourceId).get(projectId).contains(environmentId)) { + scenarioRunInfo.get(scenarioResourceId).get(projectId).add(environmentId); + } + } else { + scenarioRunInfo.get(scenarioResourceId).put(projectId, new ArrayList<>() {{ + this.add(environmentId); + }}); + } + } else { + scenarioRunInfo.put(scenarioResourceId, new HashMap<>() {{ + this.put(projectId, new ArrayList<>() {{ + this.add(environmentId); + }}); + }}); + } } - public void putApiCaseRunInfo(String apiCaseResourceId,String projectId,String environmentId){ - apiCaseRunInfo.put(apiCaseResourceId,new HashMap<>(){{ - this.put(projectId,environmentId); + public void putApiCaseRunInfo(String apiCaseResourceId, String projectId, String environmentId) { + apiCaseRunInfo.put(apiCaseResourceId, new HashMap<>() {{ + this.put(projectId, environmentId); }}); } } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index 595da1db02..b072422644 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -226,7 +226,7 @@ public class TestPlanReportService { } public TestPlanScheduleReportInfoDTO genTestPlanReportBySchedule(String planReportId, String planId, String userId, String triggerMode, RunModeConfigDTO runModeConfigDTO) { - TestPlanReport testPlanReport = this.getTestPlanReport(planReportId); + TestPlanReport testPlanReport = this.getTestPlanReport(planReportId); TestPlanScheduleReportInfoDTO returnDTO = new TestPlanScheduleReportInfoDTO(); if (testPlanReport != null) { returnDTO.setTestPlanReport(testPlanReport); @@ -305,11 +305,11 @@ public class TestPlanReportService { try { Map envMap = JSONObject.parseObject(model.getEnvironment(), Map.class); if (MapUtils.isNotEmpty(envMap)) { - String envId = null; - for (String envIdStr : envMap.values()) { - envId = envIdStr; + for (Map.Entry entry : envMap.entrySet()) { + String projectId = entry.getKey(); + String envIdStr = entry.getValue(); + runInfoDTO.putScenarioRunInfo(model.getId(), projectId, envIdStr); } - runInfoDTO.putScenarioRunInfo(model.getId(), model.getProjectId(), envId); } } catch (Exception ignore) { } @@ -991,10 +991,10 @@ public class TestPlanReportService { testPlanReportDTO.setRunMode(StringUtils.equalsIgnoreCase(runInfoDTO.getRunMode(), "serial") ? Translator.get("serial") : Translator.get("parallel")); Map> projectEnvMap = new LinkedHashMap<>(); if (MapUtils.isNotEmpty(runInfoDTO.getApiCaseRunInfo())) { - this.setProjectEnvMap(projectEnvMap, runInfoDTO.getApiCaseRunInfo()); + this.setApiCaseProjectEnvMap(projectEnvMap, runInfoDTO.getApiCaseRunInfo()); } if (MapUtils.isNotEmpty(runInfoDTO.getScenarioRunInfo())) { - this.setProjectEnvMap(projectEnvMap, runInfoDTO.getScenarioRunInfo()); + this.setScenarioProjectEnvMap(projectEnvMap, runInfoDTO.getScenarioRunInfo()); } Map> showProjectEnvMap = new LinkedHashMap<>(); for (Map.Entry> entry : projectEnvMap.entrySet()) { @@ -1012,7 +1012,33 @@ public class TestPlanReportService { } } - private void setProjectEnvMap(Map> projectEnvMap, Map> caseEnvironmentMap) { + private void setScenarioProjectEnvMap(Map> projectEnvMap, Map>> caseEnvironmentMap) { + if (projectEnvMap == null || caseEnvironmentMap == null) { + return; + } + for (Map> map : caseEnvironmentMap.values()) { + if (MapUtils.isEmpty(map)) { + continue; + } + for (Map.Entry> entry : map.entrySet()) { + String projectId = entry.getKey(); + List envIdList = entry.getValue(); + if (CollectionUtils.isNotEmpty(envIdList)) { + envIdList.forEach(envId -> { + if (projectEnvMap.containsKey(projectId)) { + projectEnvMap.get(projectId).add(envId); + } else { + projectEnvMap.put(projectId, new LinkedHashSet<>() {{ + this.add(envId); + }}); + } + }); + } + } + } + } + + private void setApiCaseProjectEnvMap(Map> projectEnvMap, Map> caseEnvironmentMap) { if (projectEnvMap == null || caseEnvironmentMap == null) { return; } diff --git a/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanOverviewReport.vue b/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanOverviewReport.vue index d116c0b5df..3a9eceb8d2 100644 --- a/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanOverviewReport.vue +++ b/frontend/src/business/components/track/plan/view/comonents/report/detail/TestPlanOverviewReport.vue @@ -8,11 +8,11 @@ v-if="report.envGroupName || report.projectEnvMap" style="display:inline-block">
- {{$t('commons.environment') + ':'}} + {{ $t('commons.environment') + ':' }}
- + {{ report.envGroupName }}