diff --git a/backend/src/main/java/io/metersphere/dto/TestPlanExecuteReportDTO.java b/backend/src/main/java/io/metersphere/dto/TestPlanExecuteReportDTO.java index e35861066e..0666333445 100644 --- a/backend/src/main/java/io/metersphere/dto/TestPlanExecuteReportDTO.java +++ b/backend/src/main/java/io/metersphere/dto/TestPlanExecuteReportDTO.java @@ -16,4 +16,6 @@ public class TestPlanExecuteReportDTO { private Map testPlanApiCaseIdAndReportIdMap; private Map testPlanScenarioIdAndReportIdMap; private Map testPlanLoadCaseIdAndReportIdMap; + private Map apiCaseInfoDTOMap; + private Map scenarioInfoDTOMap; } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java index ed3f640530..52bf21125c 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java @@ -428,15 +428,15 @@ public class TestPlanApiCaseService { testPlanApiCaseMapper::updateByPrimaryKeySelective); } - public List getByApiExecReportIds(Map testPlanApiCaseReportMap) { + public List getByApiExecReportIds(Map testPlanApiCaseReportMap, Map apiCaseInfoDTOMap) { if (testPlanApiCaseReportMap.isEmpty()) { return new ArrayList<>(); } String defaultStatus = "error"; - List apiTestCases = extTestPlanApiCaseMapper.getFailureListByIds(testPlanApiCaseReportMap.keySet(), null); Map reportResult = apiDefinitionExecResultService.selectReportResultByReportIds(testPlanApiCaseReportMap.values()); Map savedReportMap = new HashMap<>(testPlanApiCaseReportMap); - for (TestPlanFailureApiDTO dto : apiTestCases) { + List apiTestCases = new ArrayList<>(); + for (TestPlanFailureApiDTO dto : apiCaseInfoDTOMap.values()) { String testPlanApiCaseId = dto.getId(); String reportId = savedReportMap.get(testPlanApiCaseId); savedReportMap.remove(testPlanApiCaseId); @@ -450,27 +450,7 @@ public class TestPlanApiCaseService { } dto.setExecResult(status); } - } - if (!MapUtils.isEmpty(savedReportMap)) { - for (Map.Entry entry : savedReportMap.entrySet()) { - String testPlanApiCaseId = entry.getKey(); - String reportId = entry.getValue(); - TestPlanFailureApiDTO dto = new TestPlanFailureApiDTO(); - dto.setId(testPlanApiCaseId); - dto.setReportId(reportId); - dto.setName("DELETED"); - dto.setNum(0); - if (StringUtils.isEmpty(reportId)) { - dto.setExecResult(defaultStatus); - } else { - String status = reportResult.get(reportId); - if (status == null) { - status = defaultStatus; - } - dto.setExecResult(status); - } - apiTestCases.add(dto); - } + apiTestCases.add(dto); } return buildCases(apiTestCases); } 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 2ff8b4049c..e02c247775 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -961,10 +961,12 @@ public class TestPlanReportService { Map testPlanApiCaseIdAndReportIdMap = new HashMap<>(); Map testPlanScenarioIdAndReportIdMap = new HashMap<>(); Map testPlanLoadCaseIdAndReportIdMap = new HashMap<>(); - List apiCaseInfoDTOList = null; - List scenarioInfoDTOList = null; + Map apiCaseInfoDTOMap = new HashMap<>(); + Map scenarioInfoDTOMap = new HashMap<>(); + if (testPlanReportContentWithBLOBs != null) { if (StringUtils.isNotEmpty(testPlanReportContentWithBLOBs.getPlanApiCaseReportStruct())) { + List apiCaseInfoDTOList = null; try { apiCaseInfoDTOList = JSONArray.parseArray(testPlanReportContentWithBLOBs.getPlanApiCaseReportStruct(), TestPlanFailureApiDTO.class); } catch (Exception ignored) { @@ -977,10 +979,12 @@ public class TestPlanReportService { } else { for (TestPlanFailureApiDTO item : apiCaseInfoDTOList) { testPlanApiCaseIdAndReportIdMap.put(item.getId(), item.getReportId()); + apiCaseInfoDTOMap.put(item.getId(),item); } } } if (StringUtils.isNotEmpty(testPlanReportContentWithBLOBs.getPlanScenarioReportStruct())) { + List scenarioInfoDTOList = null; try { scenarioInfoDTOList = JSONArray.parseArray(testPlanReportContentWithBLOBs.getPlanScenarioReportStruct(), TestPlanFailureScenarioDTO.class); } catch (Exception ignored) { @@ -993,6 +997,7 @@ public class TestPlanReportService { } else { for (TestPlanFailureScenarioDTO item : scenarioInfoDTOList) { testPlanScenarioIdAndReportIdMap.put(item.getId(), item.getReportId()); + scenarioInfoDTOMap.put(item.getId(),item); } } } @@ -1003,7 +1008,7 @@ public class TestPlanReportService { } } } - TestPlanExecuteReportDTO returnDTO = new TestPlanExecuteReportDTO(testPlanApiCaseIdAndReportIdMap, testPlanScenarioIdAndReportIdMap, testPlanLoadCaseIdAndReportIdMap); + TestPlanExecuteReportDTO returnDTO = new TestPlanExecuteReportDTO(testPlanApiCaseIdAndReportIdMap, testPlanScenarioIdAndReportIdMap, testPlanLoadCaseIdAndReportIdMap, apiCaseInfoDTOMap, scenarioInfoDTOMap); return returnDTO; } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java index 8c924723f8..a831a3bfb1 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java @@ -100,8 +100,8 @@ public class TestPlanScenarioCaseService { Project project = projectMap.get(item.getProjectId()); if(project != null){ ProjectConfig config = projectApplicationService.getSpecificTypeValue(project.getId(), ProjectApplicationType.SCENARIO_CUSTOM_NUM.name()); - boolean custom = config.getCaseCustomNum(); - if(custom){ + boolean custom = config.getScenarioCustomNum(); + if (custom) { item.setCustomNum(item.getCustomNum()); }else { item.setCustomNum(item.getNum().toString()); @@ -528,15 +528,12 @@ public class TestPlanScenarioCaseService { return buildCases(apiTestCases); } - public List getAllCases(Map idMap) { - List apiTestCases = - extTestPlanScenarioCaseMapper.getFailureListByIds(idMap.keySet(), null); - + public List getAllCases(Map idMap, Map scenarioInfoDTOMap) { String defaultStatus = "Fail"; Map reportStatus = apiScenarioReportService.getReportStatusByReportIds(idMap.values()); Map savedReportMap = new HashMap<>(idMap); - - for (TestPlanFailureScenarioDTO dto : apiTestCases) { + List apiTestCases = new ArrayList<>(); + for (TestPlanFailureScenarioDTO dto : scenarioInfoDTOMap.values()) { String reportId = savedReportMap.get(dto.getId()); savedReportMap.remove(dto.getId()); dto.setReportId(reportId); @@ -552,33 +549,8 @@ public class TestPlanScenarioCaseService { dto.setLastResult(status); dto.setStatus(status); } + apiTestCases.add(dto); } - - if (!MapUtils.isEmpty(savedReportMap)) { - for (Map.Entry entry : savedReportMap.entrySet()) { - String testPlanApiCaseId = entry.getKey(); - String reportId = entry.getValue(); - TestPlanFailureScenarioDTO dto = new TestPlanFailureScenarioDTO(); - dto.setId(testPlanApiCaseId); - dto.setReportId(reportId); - dto.setName("DELETED"); - dto.setNum(0); - if (StringUtils.isNotEmpty(reportId)) { - String status = reportStatus.get(reportId); - if (status == null) { - status = defaultStatus; - } else { - if (StringUtils.equalsIgnoreCase(status, "Error")) { - status = "Fail"; - } - } - dto.setLastResult(status); - dto.setStatus(status); - } - apiTestCases.add(dto); - } - } - return buildCases(apiTestCases); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index ef49de0f7a..e0f4cd196f 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -1544,9 +1544,9 @@ public class TestPlanService { List scenarioAllCases = null; if (checkReportConfig(config, "api", "all")) { // 接口 - apiAllCases = testPlanApiCaseService.getByApiExecReportIds(testPlanExecuteReportDTO.getTestPlanApiCaseIdAndReportIdMap()); + apiAllCases = testPlanApiCaseService.getByApiExecReportIds(testPlanExecuteReportDTO.getTestPlanApiCaseIdAndReportIdMap(),testPlanExecuteReportDTO.getApiCaseInfoDTOMap()); //场景 - scenarioAllCases = testPlanScenarioCaseService.getAllCases(testPlanExecuteReportDTO.getTestPlanScenarioIdAndReportIdMap()); + scenarioAllCases = testPlanScenarioCaseService.getAllCases(testPlanExecuteReportDTO.getTestPlanScenarioIdAndReportIdMap(),testPlanExecuteReportDTO.getScenarioInfoDTOMap()); this.checkApiCaseCreatorName(apiAllCases, scenarioAllCases); report.setApiAllCases(apiAllCases); report.setScenarioAllCases(scenarioAllCases);