diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanReportDetailResponse.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanReportDetailResponse.java index db2cd7f8de..771d3001f0 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanReportDetailResponse.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanReportDetailResponse.java @@ -39,9 +39,24 @@ public class TestPlanReportDetailResponse { @Schema(description = "计划总数") private Integer planCount; + /** + * 一键总结参数 + */ + @Schema(description = "通过的计划数量 - 计划组报告使用") + private Integer passCountOfPlan = 0; + @Schema(description = "未通过的计划数量 - 计划组报告使用") + private Integer failCountOfPlan = 0; + @Schema(description = "功能用例明细的缺陷数量") + private Integer functionalBugCount = 0; + @Schema(description = "功能用例明细的缺陷数量") + private Integer apiBugCount = 0; + @Schema(description = "功能用例明细的缺陷数量") + private Integer scenarioBugCount = 0; + @Schema(description = "用例总数") private Integer caseTotal = 0; + /** * 执行分析 */ @@ -63,6 +78,7 @@ public class TestPlanReportDetailResponse { @Schema(description = "接口场景用例分析-用例数") private CaseCount apiScenarioCount; + @Schema(description = "报告是否删除") private boolean deleted; @Schema(description = "报告状态") diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportFunctionalCaseMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportFunctionalCaseMapper.java index 3849f6a77f..52e387e89f 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportFunctionalCaseMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportFunctionalCaseMapper.java @@ -60,4 +60,11 @@ public interface ExtTestPlanReportFunctionalCaseMapper { * @return 关联的用例集合 */ List list(@Param("request") TestPlanReportDetailPageRequest request); + + /** + * 统计用例明细的关联缺陷数 + * @param reportId 报告ID + * @return 缺陷数量 + */ + Long countBug(@Param("id") String reportId); } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportFunctionalCaseMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportFunctionalCaseMapper.xml index 166f991ee3..94c4aeb1ee 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportFunctionalCaseMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanReportFunctionalCaseMapper.xml @@ -68,6 +68,11 @@ + + diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java index 02e9e4dd4c..d7a438901a 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java @@ -482,7 +482,19 @@ public class TestPlanReportService { int caseTotal = (int) (reportSummary.getFunctionalCaseCount() + reportSummary.getApiCaseCount() + reportSummary.getApiScenarioCount()); planReportDetail.setCaseTotal(caseTotal); planReportDetail.setBugCount(reportSummary.getBugCount().intValue()); - planReportDetail.setPlanCount(reportSummary.getPlanCount().intValue()); + // 暂时只有功能用例能关联缺陷 + Long functionalBugCount = extTestPlanReportFunctionalCaseMapper.countBug(reportId); + planReportDetail.setFunctionalBugCount(functionalBugCount.intValue()); + if (planReport.getIntegrated()) { + // 计划组报告, 需要统计计划的执行数据 + planReportDetail.setPlanCount(reportSummary.getPlanCount().intValue()); + TestPlanReportExample reportExample = new TestPlanReportExample(); + reportExample.createCriteria().andParentIdEqualTo(reportId); + List testPlanReports = testPlanReportMapper.selectByExample(reportExample); + long planPassCount = testPlanReports.stream().filter(report -> StringUtils.equals(ExecStatus.SUCCESS.name(), report.getResultStatus())).count(); + planReportDetail.setPassCountOfPlan((int) planPassCount); + planReportDetail.setFailCountOfPlan(planReportDetail.getPlanCount() - planReportDetail.getPassCountOfPlan()); + } planReportDetail.setSummary(reportSummary.getSummary()); /* * 统计用例执行数据