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);