From ebfe7786bace7935cf8faaaf16771f837482fcc5 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Fri, 10 Nov 2023 17:25:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E7=BB=93=E6=9E=9C=E7=BB=9F=E8=AE=A1=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=97=B6=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1032633 --user=宋昌昌 【测试跟踪】测试计划报告一直处于Running状态,日志中有空指针异常 https://www.tapd.cn/55049933/s/1435241 --- .../plan/service/TestPlanService.java | 144 +++++++++--------- .../io/metersphere/service/IssuesService.java | 13 +- 2 files changed, 78 insertions(+), 79 deletions(-) diff --git a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java index a2681c72f6..2b8290f81b 100644 --- a/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java +++ b/test-track/backend/src/main/java/io/metersphere/plan/service/TestPlanService.java @@ -165,7 +165,11 @@ public class TestPlanService { @Resource private BaseTestResourcePoolService baseTestResourcePoolService; - private static void buildCaseIdList + public static final String PLAN_ERROR = "error"; + public static final String PLAN_FAKE_ERROR = "fakeError"; + public static final String PLAN_UN_EXECUTE = "unExecute"; + + private void buildCaseIdList (List list, List apiCaseIds, List scenarioIds, List performanceIds, List uiScenarioIds) { for (TestCaseTest l : list) { if (StringUtils.equals(l.getTestType(), TestCaseTestStatus.performance.name())) { @@ -269,7 +273,7 @@ public class TestPlanService { } } } - return this.editTestPlan(request); + return editTestPlan(request); } public void editTestFollows(String planId, List follows) { @@ -585,7 +589,7 @@ public class TestPlanService { } // 关注人这里查出来。 是因为编辑的时候需要有这个字段。 - List planPrincipal = this.getPlanPrincipal(item.getId()); + List planPrincipal = getPlanPrincipal(item.getId()); item.setPrincipalUsers(planPrincipal); // 还没有结束的计划,如果设置了结束时间,并且已经到了结束时间,则将状态改为已结束 @@ -624,18 +628,18 @@ public class TestPlanService { } public List selectTestPlanMetricById(List idList) { - List testPlanMetricList = this.calcTestPlanRateByIdList(idList); + List testPlanMetricList = calcTestPlanRateByIdList(idList); for (TestPlanDTOWithMetric testPlanMetric : testPlanMetricList) { - List followUsers = this.getPlanFollow(testPlanMetric.getId()); + List followUsers = getPlanFollow(testPlanMetric.getId()); testPlanMetric.setFollowUsers(followUsers); } return testPlanMetricList; } public void checkTestPlanStatusWhenExecuteOver(String testPlanId) { - TestPlan testPlan = this.testPlanMapper.selectByPrimaryKey(testPlanId); + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(testPlanId); if (testPlan != null && !StringUtils.equalsIgnoreCase(testPlan.getStatus(), "Completed")) { - this.checkTestPlanStatus(testPlanId); + checkTestPlanStatus(testPlanId); } } @@ -689,7 +693,7 @@ public class TestPlanService { } else if (prepareNum == 0 && passNum + failNum == statusList.size()) { // 如果全部都执行完了改为已完成,如果已完成之后到结束时间了,走上面逻辑改成已结束 testPlanWithBLOBs.setStatus(TestPlanStatus.Completed.name()); - this.editTestPlan(testPlanWithBLOBs); + editTestPlan(testPlanWithBLOBs); } else if (prepareNum != 0) { // 用例没有执行完,并且结束时间没到,改为进行中 testPlanWithBLOBs.setStatus(TestPlanStatus.Underway.name()); @@ -1031,7 +1035,7 @@ public class TestPlanService { request.setUserId(userId); request.setTestPlanId(testPlanId); List dtoList = planTestPlanApiCaseService.run(request); - return this.parseMsExecResponseDTOToTestIdReportMap(dtoList); + return parseMsExecResponseDTOToTestIdReportMap(dtoList); } public Map executeScenarioCase(String planReportId, String testPlanID, String @@ -1065,8 +1069,8 @@ public class TestPlanService { scenarioRequest.setTestPlanReportId(planReportId); scenarioRequest.setConfig(runModeConfig); scenarioRequest.setType("api"); - List dtoList = this.scenarioRunModeConfig(scenarioRequest); - return this.parseMsExecResponseDTOToTestIdReportMap(dtoList); + List dtoList = scenarioRunModeConfig(scenarioRequest); + return parseMsExecResponseDTOToTestIdReportMap(dtoList); } else { return new HashMap<>(); } @@ -1100,8 +1104,8 @@ public class TestPlanService { scenarioRequest.setTestPlanReportId(planReportId); scenarioRequest.setConfig(runModeConfig); scenarioRequest.setType("ui"); - List dtoList = this.scenarioRunModeConfig(scenarioRequest); - return this.parseMsExecResponseDTOToTestIdReportMap(dtoList); + List dtoList = scenarioRunModeConfig(scenarioRequest); + return parseMsExecResponseDTOToTestIdReportMap(dtoList); } else { return new HashMap<>(); } @@ -1275,7 +1279,7 @@ public class TestPlanService { * 实现跨服务访问报告 */ public String replaceSharReport(Object microServices) { - try (InputStreamReader isr = new InputStreamReader(getClass().getResourceAsStream("/public/share-plan-report.html"), StandardCharsets.UTF_8);) { + try (InputStreamReader isr = new InputStreamReader(getClass().getResourceAsStream("/public/share-plan-report.html"), StandardCharsets.UTF_8)) { BufferedReader bufferedReader = new BufferedReader(isr); StringBuilder reportStr = new StringBuilder(); String line; @@ -1393,7 +1397,7 @@ public class TestPlanService { if (StringUtils.isNotBlank(testPlan.getReportConfig())) { config = JSON.parseMap(testPlan.getReportConfig()); } - testPlanReportStruct = this.getTestPlanReportStructByCreated(testPlanReportContentWithBLOBs); + testPlanReportStruct = getTestPlanReportStructByCreated(testPlanReportContentWithBLOBs); //检查是否有已经生成过的测试计划报告内容。如若没有则进行动态计算 if (rebuildReport || testPlanReportStruct == null) { //查询测试计划内的用例信息,然后进行测试计划报告的结果统计 @@ -1411,7 +1415,7 @@ public class TestPlanService { testPlanReportStruct.setEndTime(testPlanReportContentWithBLOBs.getEndTime()); } - this.dealOldVersionData(testPlanReportStruct); + dealOldVersionData(testPlanReportStruct); } //查找运行环境 testPlanReportService.initRunInformation(testPlanReportStruct, testPlanReport); @@ -1423,20 +1427,20 @@ public class TestPlanService { * 处理旧版本数据(例如版本升级过程中由于统一了状态字段的数据) 或者是由旧版本fastJson解析的,无法被Jackson解析出来的数据 */ private void dealOldVersionData(TestPlanReportDataStruct testPlanReportStruct) { - List validScenarioList = this.getValidScenarioList(testPlanReportStruct); + List validScenarioList = getValidScenarioList(testPlanReportStruct); testPlanReportStruct.setScenarioAllCases(validScenarioList); - List errorScenarioList = this.getScenarioListByStatus(testPlanReportStruct, "error"); - List fakeErrorScenarioList = this.getScenarioListByStatus(testPlanReportStruct, "fakeError"); - List unExecuteScenarioList = this.getScenarioListByStatus(testPlanReportStruct, "unExecute"); + List errorScenarioList = getScenarioListByStatus(testPlanReportStruct, PLAN_ERROR); + List fakeErrorScenarioList = getScenarioListByStatus(testPlanReportStruct, PLAN_FAKE_ERROR); + List unExecuteScenarioList = getScenarioListByStatus(testPlanReportStruct, PLAN_UN_EXECUTE); testPlanReportStruct.setScenarioFailureCases(errorScenarioList); testPlanReportStruct.setErrorReportScenarios(fakeErrorScenarioList); testPlanReportStruct.setUnExecuteScenarios(unExecuteScenarioList); - List validApiList = this.getValidApiList(testPlanReportStruct); + List validApiList = getValidApiList(testPlanReportStruct); testPlanReportStruct.setApiAllCases(validApiList); - List errorApiList = this.getApiListByStatus(testPlanReportStruct, "error"); - List fakeErrorApiList = this.getApiListByStatus(testPlanReportStruct, "fakeError"); - List unExecuteApiList = this.getApiListByStatus(testPlanReportStruct, "unExecute"); + List errorApiList = getApiListByStatus(testPlanReportStruct, PLAN_ERROR); + List fakeErrorApiList = getApiListByStatus(testPlanReportStruct, PLAN_FAKE_ERROR); + List unExecuteApiList = getApiListByStatus(testPlanReportStruct, PLAN_UN_EXECUTE); testPlanReportStruct.setApiFailureCases(errorApiList); testPlanReportStruct.setErrorReportCases(fakeErrorApiList); testPlanReportStruct.setUnExecuteCases(unExecuteApiList); @@ -1447,21 +1451,21 @@ public class TestPlanService { List allApiList = new ArrayList<>(testPlanReportStruct.getApiAllCases().stream().filter(item -> item.getReportId() != null).toList()); if (CollectionUtils.isNotEmpty(testPlanReportStruct.getApiFailureCases())) { for (TestPlanApiDTO item : testPlanReportStruct.getApiFailureCases()) { - if (StringUtils.isNotEmpty(item.getReportId()) && !this.isApiListContainsByReportId(allApiList, item)) { + if (StringUtils.isNotEmpty(item.getReportId()) && !isApiListContainsByReportId(allApiList, item)) { allApiList.add(item); } } } if (CollectionUtils.isNotEmpty(testPlanReportStruct.getErrorReportCases())) { testPlanReportStruct.getErrorReportCases().forEach(item -> { - if (StringUtils.isNotEmpty(item.getReportId()) && !this.isApiListContainsByReportId(allApiList, item)) { + if (StringUtils.isNotEmpty(item.getReportId()) && !isApiListContainsByReportId(allApiList, item)) { allApiList.add(item); } }); } if (CollectionUtils.isNotEmpty(testPlanReportStruct.getUnExecuteScenarios())) { testPlanReportStruct.getUnExecuteCases().forEach(item -> { - if (StringUtils.isNotEmpty(item.getReportId()) && !this.isApiListContainsByReportId(allApiList, item)) { + if (StringUtils.isNotEmpty(item.getReportId()) && !isApiListContainsByReportId(allApiList, item)) { allApiList.add(item); } }); @@ -1479,21 +1483,21 @@ public class TestPlanService { if (CollectionUtils.isNotEmpty(testPlanReportStruct.getScenarioFailureCases())) { testPlanReportStruct.getScenarioFailureCases().forEach(item -> { - if (StringUtils.isNotEmpty(item.getReportId()) && !this.isScenarioListContainsByReportId(allTestPlanScenariODTOList, item)) { + if (StringUtils.isNotEmpty(item.getReportId()) && !isScenarioListContainsByReportId(allTestPlanScenariODTOList, item)) { allTestPlanScenariODTOList.add(item); } }); } if (CollectionUtils.isNotEmpty(testPlanReportStruct.getErrorReportScenarios())) { testPlanReportStruct.getErrorReportScenarios().forEach(item -> { - if (StringUtils.isNotEmpty(item.getReportId()) && !this.isScenarioListContainsByReportId(allTestPlanScenariODTOList, item)) { + if (StringUtils.isNotEmpty(item.getReportId()) && !isScenarioListContainsByReportId(allTestPlanScenariODTOList, item)) { allTestPlanScenariODTOList.add(item); } }); } if (CollectionUtils.isNotEmpty(testPlanReportStruct.getUnExecuteScenarios())) { testPlanReportStruct.getUnExecuteScenarios().forEach(item -> { - if (StringUtils.isNotEmpty(item.getReportId()) && !this.isScenarioListContainsByReportId(allTestPlanScenariODTOList, item)) { + if (StringUtils.isNotEmpty(item.getReportId()) && !isScenarioListContainsByReportId(allTestPlanScenariODTOList, item)) { allTestPlanScenariODTOList.add(item); } }); @@ -1511,22 +1515,19 @@ public class TestPlanService { List checkStatusList; List statusApiList = null; - if (StringUtils.equalsIgnoreCase(status, "fakeError")) { - checkStatusList = new ArrayList<>() {{ - this.add("errorReport".toLowerCase()); - this.add("errorReportResult".toLowerCase()); - }}; + if (StringUtils.equalsIgnoreCase(status, PLAN_FAKE_ERROR)) { + checkStatusList = new ArrayList<>(); + checkStatusList.add("errorReport".toLowerCase()); + checkStatusList.add("errorReportResult".toLowerCase()); statusApiList = testPlanReportStruct.getErrorReportCases().stream().filter(item -> item.getReportId() != null).toList(); - } else if (StringUtils.equalsIgnoreCase(status, "unExecute")) { - checkStatusList = new ArrayList<>() {{ - this.add("stop".toLowerCase()); - this.add("unExecute".toLowerCase()); - }}; + } else if (StringUtils.equalsIgnoreCase(status, PLAN_UN_EXECUTE)) { + checkStatusList = new ArrayList<>(); + checkStatusList.add("stop".toLowerCase()); + checkStatusList.add(PLAN_UN_EXECUTE.toLowerCase()); statusApiList = testPlanReportStruct.getUnExecuteCases().stream().filter(item -> item.getReportId() != null).toList(); - } else if (StringUtils.equalsIgnoreCase(status, "error")) { - checkStatusList = new ArrayList<>() {{ - this.add("Error".toLowerCase()); - }}; + } else if (StringUtils.equalsIgnoreCase(status, PLAN_ERROR)) { + checkStatusList = new ArrayList<>(); + checkStatusList.add("Error".toLowerCase()); statusApiList = testPlanReportStruct.getApiFailureCases().stream().filter(item -> item.getReportId() != null).toList(); } else { checkStatusList = null; @@ -1559,23 +1560,20 @@ public class TestPlanService { List checkStatusList; List statusScenarioList = null; - if (StringUtils.equalsIgnoreCase(status, "fakeError")) { - checkStatusList = new ArrayList<>() {{ - this.add("errorReport".toLowerCase()); - this.add("errorReportResult".toLowerCase()); - }}; + if (StringUtils.equalsIgnoreCase(status, PLAN_FAKE_ERROR)) { + checkStatusList = new ArrayList<>(); + checkStatusList.add("errorReport".toLowerCase()); + checkStatusList.add("errorReportResult".toLowerCase()); statusScenarioList = testPlanReportStruct.getErrorReportScenarios().stream().filter(item -> item.getReportId() != null).toList(); - } else if (StringUtils.equalsIgnoreCase(status, "unExecute")) { - checkStatusList = new ArrayList<>() {{ - this.add("unExecute".toLowerCase()); - this.add("stop".toLowerCase()); - }}; + } else if (StringUtils.equalsIgnoreCase(status, PLAN_UN_EXECUTE)) { + checkStatusList = new ArrayList<>(); + checkStatusList.add(PLAN_UN_EXECUTE.toLowerCase()); + checkStatusList.add("stop".toLowerCase()); statusScenarioList = testPlanReportStruct.getUnExecuteScenarios().stream().filter(item -> item.getReportId() != null).toList(); - } else if (StringUtils.equalsIgnoreCase(status, "error")) { - checkStatusList = new ArrayList<>() {{ - this.add("Fail".toLowerCase()); - this.add("Error".toLowerCase()); - }}; + } else if (StringUtils.equalsIgnoreCase(status, PLAN_ERROR)) { + checkStatusList = new ArrayList<>(); + checkStatusList.add("Fail".toLowerCase()); + checkStatusList.add("Error".toLowerCase()); statusScenarioList = testPlanReportStruct.getScenarioFailureCases().stream().filter(item -> item.getReportId() != null).toList(); } else { checkStatusList = null; @@ -1761,7 +1759,7 @@ public class TestPlanService { BeanUtils.copyBean(report, testPlanCaseReportResultDTO.getApiPlanReportDTO()); planTestPlanApiCaseService.calculateReportByApiCase(testPlanCaseReportResultDTO.getApiPlanReportDTO().getApiAllCases(), report); planTestPlanScenarioCaseService.calculateReportByScenario(testPlanCaseReportResultDTO.getApiPlanReportDTO().getScenarioAllCases(), report); - this.sortApiCaseResultCount(report.getApiResult()); + sortApiCaseResultCount(report.getApiResult()); } if (testPlanCaseReportResultDTO.getLoadPlanReportDTO() != null) { BeanUtils.copyBean(report, testPlanCaseReportResultDTO.getLoadPlanReportDTO()); @@ -1780,9 +1778,9 @@ public class TestPlanService { testPlanCaseReportResultDTO.getFunctionCaseList(), report); if (report.getFunctionAllCases() == null || report.getIssueList() == null) { //构建功能用例和issue - this.buildFunctionalReport(report, reportConfig, testPlan.getId()); + buildFunctionalReport(report, reportConfig, testPlan.getId()); } - issuesService.calculateReportByIssueList(testPlanCaseReportResultDTO.getIssueList(), report); + issuesService.calculateReportByIssueList(testPlanCaseReportResultDTO.getIssueList(), report, testPlan.getProjectId()); DecimalFormat rateFormat = new DecimalFormat("#0.0000"); rateFormat.setMinimumFractionDigits(4); @@ -1941,7 +1939,7 @@ public class TestPlanService { runModeConfig.setTestPlanDefaultEnvMap(testplanRunRequest.getTestPlanDefaultEnvMap()); //执行测试计划行为,要更新TestPlan状态为进行中,并重置实际结束时间 - this.updateTestPlanExecuteInfo(testPlanId, TestPlanStatus.Underway.name()); + updateTestPlanExecuteInfo(testPlanId, TestPlanStatus.Underway.name()); String apiRunConfig = JSON.toJSONString(runModeConfig); return testPlanExecuteService.runTestPlan(testPlanId, testplanRunRequest.getProjectId(), @@ -1962,12 +1960,12 @@ public class TestPlanService { if (StringUtils.equals(envType, "JSON") && !envMap.isEmpty()) { runModeConfig.setEnvMap(testplanRunRequest.getEnvMap()); if (!StringUtils.equals(testplanRunRequest.getExecutionWay(), ExecutionWay.RUN.name())) { - this.setPlanCaseEnv(testPlanId, runModeConfig); + setPlanCaseEnv(testPlanId, runModeConfig); } } else if (StringUtils.equals(envType, "GROUP") && StringUtils.isNotBlank(environmentGroupId)) { runModeConfig.setEnvironmentGroupId(testplanRunRequest.getEnvironmentGroupId()); if (!StringUtils.equals(testplanRunRequest.getExecutionWay(), ExecutionWay.RUN.name())) { - this.setPlanCaseEnv(testPlanId, runModeConfig); + setPlanCaseEnv(testPlanId, runModeConfig); } } runModeConfig.setMode(testplanRunRequest.getMode()); @@ -2140,7 +2138,7 @@ public class TestPlanService { LoggerUtil.info("开始查询测试计划"); List planList = new ArrayList<>(); if (request.getIsAll() != null && request.getIsAll()) { - List testPlanDTOWithMetrics = this.listTestPlan(request.getQueryTestPlanRequest()); + List testPlanDTOWithMetrics = listTestPlan(request.getQueryTestPlanRequest()); planList.addAll(testPlanDTOWithMetrics); } else { TestPlanExample example = new TestPlanExample(); @@ -2184,7 +2182,7 @@ public class TestPlanService { RunModeConfigDTO runModeConfigDTO = JSON.parseObject(testPlan.getRunModeConfig(), RunModeConfigDTO.class); runModeConfigDTO = ObjectUtils.isEmpty(runModeConfigDTO) ? new RunModeConfigDTO() : runModeConfigDTO; if (haveExecCase(testPlan.getId(), true)) { - this.verifyPool(testPlan.getProjectId(), runModeConfigDTO); + verifyPool(testPlan.getProjectId(), runModeConfigDTO); } //测试计划准备执行,取消测试计划的实际结束时间 extTestPlanMapper.updateStatusAndActStartTimeAndSetActEndTimeNullById(testPlan.getId(), System.currentTimeMillis(), TestPlanStatus.Underway.name()); @@ -2265,10 +2263,10 @@ public class TestPlanService { runModeConfig.setEnvironmentType(testplanRunRequest.getEnvironmentType()); if (StringUtils.equals(testplanRunRequest.getEnvironmentType(), "JSON") && !testplanRunRequest.getEnvMap().isEmpty()) { runModeConfig.setEnvMap(testplanRunRequest.getEnvMap()); - this.setPlanCaseEnv(testPlanId, runModeConfig); + setPlanCaseEnv(testPlanId, runModeConfig); } else if (StringUtils.equals(testplanRunRequest.getEnvironmentType(), "GROUP") && StringUtils.isNotBlank(testplanRunRequest.getEnvironmentGroupId())) { runModeConfig.setEnvironmentGroupId(testplanRunRequest.getEnvironmentGroupId()); - this.setPlanCaseEnv(testPlanId, runModeConfig); + setPlanCaseEnv(testPlanId, runModeConfig); } } @@ -2324,7 +2322,7 @@ public class TestPlanService { if (testPlanReportService.hasRunningReport(ids)) { MSException.throwException(Translator.get("test_plan_delete_exec_error")); } - this.deleteTestPlans(ids); + deleteTestPlans(ids); } public List getRelevanceProjectIds(String planId) { @@ -2354,10 +2352,10 @@ public class TestPlanService { public TestPlanReportDataStruct buildOldVersionTestPlanReport(TestPlanReport testPlanReport, TestPlanReportContentWithBLOBs testPlanReportContent) { - TestPlanWithBLOBs testPlanWithBLOBs = this.testPlanMapper.selectByPrimaryKey(testPlanReport.getTestPlanId()); + TestPlanWithBLOBs testPlanWithBLOBs = testPlanMapper.selectByPrimaryKey(testPlanReport.getTestPlanId()); TestPlanReportDataStruct testPlanReportDataStruct = new TestPlanReportDataStruct(); try { - testPlanReportDataStruct = this.generateReportStruct(testPlanWithBLOBs, testPlanReport, testPlanReportContent, false); + testPlanReportDataStruct = generateReportStruct(testPlanWithBLOBs, testPlanReport, testPlanReportContent, false); if (testPlanReportContent != null && StringUtils.isBlank(testPlanReportContent.getApiBaseCount()) && !testPlanReportDataStruct.hasRunningCase() && StringUtils.equalsAnyIgnoreCase(testPlanReport.getStatus(), TestPlanReportStatus.FAILED.name(), TestPlanReportStatus.COMPLETED.name(), TestPlanReportStatus.SUCCESS.name())) { @@ -2385,7 +2383,7 @@ public class TestPlanService { if (testPlan != null && !StringUtils.equalsAny(testPlan.getStatus(), TestPlanStatus.Completed.name(), TestPlanStatus.Finished.name())) { testPlan.setStatus(calcTestPlanStatusWithPassRate(testPlan)); - this.editTestPlan(testPlan); + editTestPlan(testPlan); } return testPlan; } diff --git a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java index 2b14d28493..b1c0792f05 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java @@ -1331,7 +1331,7 @@ public class IssuesService { } - public void calculateReportByIssueList(List issueList, TestPlanReportDataStruct report) { + public void calculateReportByIssueList(List issueList, TestPlanReportDataStruct report, String projectId) { if (CollectionUtils.isNotEmpty(issueList)) { List planReportIssueDTOList = new ArrayList<>(); issueList.forEach(issue -> { @@ -1342,21 +1342,22 @@ public class IssuesService { issueDTO.setPlatformStatus(issue.getPlatformStatus()); planReportIssueDTOList.add(issueDTO); }); - calculatePlanReport(planReportIssueDTOList, report); + calculatePlanReport(planReportIssueDTOList, report, projectId); } } public void calculatePlanReport(String planId, TestPlanReportDataStruct report) { + TestPlan testPlan = testPlanService.getTestPlan(planId); List planReportIssueDTOList = extIssuesMapper.selectForPlanReport(planId); - calculatePlanReport(planReportIssueDTOList, report); + calculatePlanReport(planReportIssueDTOList, report, testPlan.getProjectId()); } - public void calculatePlanReport(List planReportIssueDTOList, TestPlanReportDataStruct report) { + public void calculatePlanReport(List planReportIssueDTOList, TestPlanReportDataStruct report, String planProjectId) { planReportIssueDTOList = DistinctKeyUtil.distinctByKey(planReportIssueDTOList, PlanReportIssueDTO::getId); // 缺陷状态为自定义字段 List issueIds = planReportIssueDTOList.stream().map(PlanReportIssueDTO::getId).collect(Collectors.toList()); - Map customStatusMap = customFieldIssuesService.getIssueStatusMap(issueIds, SessionUtils.getCurrentProjectId()); - CustomField customField = baseCustomFieldService.getCustomFieldByName(SessionUtils.getCurrentProjectId(), SystemCustomField.ISSUE_STATUS); + Map customStatusMap = customFieldIssuesService.getIssueStatusMap(issueIds, planProjectId); + CustomField customField = baseCustomFieldService.getCustomFieldByName(planProjectId, SystemCustomField.ISSUE_STATUS); JSONArray statusArray = JSONArray.parseArray(customField.getOptions()); TestPlanFunctionResultReportDTO functionResult = report.getFunctionResult();