From 2c9cbea98c57733eeaa8a567be58b9dd6613550c Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Fri, 15 Nov 2024 14:09:53 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):?= =?UTF-8?q?=20=E6=89=A7=E8=A1=8C=E5=8E=86=E5=8F=B2=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../response/TestPlanTaskReportResponse.java | 18 +++++++++++++++++- .../plan/service/TestPlanReportService.java | 11 +++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanTaskReportResponse.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanTaskReportResponse.java index 03b57cfbe1..238bb31fe4 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanTaskReportResponse.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanTaskReportResponse.java @@ -6,12 +6,21 @@ import io.metersphere.system.serializer.CustomRateSerializer; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.io.Serializable; +import java.util.List; + /** * @author song-cc-rock */ @Data -public class TestPlanTaskReportResponse { +public class TestPlanTaskReportResponse implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(description = "报告ID") + private String reportId; + @Schema(description = "任务名称") + private String taskName; @Schema(description = "执行结果") private String result; @Schema(description = "执行状态") @@ -24,10 +33,17 @@ public class TestPlanTaskReportResponse { private Long startTime; @Schema(description = "任务结束时间") private Long endTime; + @Schema(description = "子计划列表") + private List childPlans; @Schema(description = "执行用例统计(实时)") private CaseCount executeCaseCount; @Schema(description = "执行完成率(实时)") @JsonSerialize(using = CustomRateSerializer.class) private Double executeRate; + @Data + public static class ChildPlan { + private String id; + private String name; + } } 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 987a02a705..4ae7543775 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 @@ -803,6 +803,16 @@ public class TestPlanReportService { TestPlanTaskReportResponse testPlanTaskReportResponse = new TestPlanTaskReportResponse(); ExecTask task = execTaskMapper.selectByPrimaryKey(taskId); BeanUtils.copyBean(testPlanTaskReportResponse, task); + TestPlanExample planExample = new TestPlanExample(); + planExample.createCriteria().andGroupIdEqualTo(task.getResourceId()); + List testPlans = testPlanMapper.selectByExample(planExample); + List childPlans = testPlans.stream().map(plan -> { + TestPlanTaskReportResponse.ChildPlan childPlan = new TestPlanTaskReportResponse.ChildPlan(); + childPlan.setId(plan.getId()); + childPlan.setName(plan.getName()); + return childPlan; + }).toList(); + testPlanTaskReportResponse.setChildPlans(childPlans); ApiReportRelateTaskExample example = new ApiReportRelateTaskExample(); example.createCriteria().andTaskResourceIdEqualTo(taskId); List taskReports = apiReportRelateTaskMapper.selectByExample(example); @@ -1425,6 +1435,7 @@ public class TestPlanReportService { * @return 用例执行情况 */ private TestPlanTaskReportResponse calcTaskExecActual(String reportId, TestPlanTaskReportResponse testPlanTaskReportResponse) { + testPlanTaskReportResponse.setReportId(reportId); // 计算接口用例 List apiCountMapList = extTestPlanReportApiCaseMapper.countExecuteResult(reportId); CaseCount apiCaseCount = countMap(apiCountMapList);