refactor(测试计划): 执行历史列表返回参数

This commit is contained in:
song-cc-rock 2024-11-15 14:09:53 +08:00 committed by Craftsman
parent a9c13e6a19
commit 2c9cbea98c
2 changed files with 28 additions and 1 deletions

View File

@ -6,12 +6,21 @@ import io.metersphere.system.serializer.CustomRateSerializer;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.io.Serializable;
import java.util.List;
/** /**
* @author song-cc-rock * @author song-cc-rock
*/ */
@Data @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 = "执行结果") @Schema(description = "执行结果")
private String result; private String result;
@Schema(description = "执行状态") @Schema(description = "执行状态")
@ -24,10 +33,17 @@ public class TestPlanTaskReportResponse {
private Long startTime; private Long startTime;
@Schema(description = "任务结束时间") @Schema(description = "任务结束时间")
private Long endTime; private Long endTime;
@Schema(description = "子计划列表")
private List<ChildPlan> childPlans;
@Schema(description = "执行用例统计(实时)") @Schema(description = "执行用例统计(实时)")
private CaseCount executeCaseCount; private CaseCount executeCaseCount;
@Schema(description = "执行完成率(实时)") @Schema(description = "执行完成率(实时)")
@JsonSerialize(using = CustomRateSerializer.class) @JsonSerialize(using = CustomRateSerializer.class)
private Double executeRate; private Double executeRate;
@Data
public static class ChildPlan {
private String id;
private String name;
}
} }

View File

@ -803,6 +803,16 @@ public class TestPlanReportService {
TestPlanTaskReportResponse testPlanTaskReportResponse = new TestPlanTaskReportResponse(); TestPlanTaskReportResponse testPlanTaskReportResponse = new TestPlanTaskReportResponse();
ExecTask task = execTaskMapper.selectByPrimaryKey(taskId); ExecTask task = execTaskMapper.selectByPrimaryKey(taskId);
BeanUtils.copyBean(testPlanTaskReportResponse, task); BeanUtils.copyBean(testPlanTaskReportResponse, task);
TestPlanExample planExample = new TestPlanExample();
planExample.createCriteria().andGroupIdEqualTo(task.getResourceId());
List<TestPlan> testPlans = testPlanMapper.selectByExample(planExample);
List<TestPlanTaskReportResponse.ChildPlan> 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(); ApiReportRelateTaskExample example = new ApiReportRelateTaskExample();
example.createCriteria().andTaskResourceIdEqualTo(taskId); example.createCriteria().andTaskResourceIdEqualTo(taskId);
List<ApiReportRelateTask> taskReports = apiReportRelateTaskMapper.selectByExample(example); List<ApiReportRelateTask> taskReports = apiReportRelateTaskMapper.selectByExample(example);
@ -1425,6 +1435,7 @@ public class TestPlanReportService {
* @return 用例执行情况 * @return 用例执行情况
*/ */
private TestPlanTaskReportResponse calcTaskExecActual(String reportId, TestPlanTaskReportResponse testPlanTaskReportResponse) { private TestPlanTaskReportResponse calcTaskExecActual(String reportId, TestPlanTaskReportResponse testPlanTaskReportResponse) {
testPlanTaskReportResponse.setReportId(reportId);
// 计算接口用例 // 计算接口用例
List<CaseStatusCountMap> apiCountMapList = extTestPlanReportApiCaseMapper.countExecuteResult(reportId); List<CaseStatusCountMap> apiCountMapList = extTestPlanReportApiCaseMapper.countExecuteResult(reportId);
CaseCount apiCaseCount = countMap(apiCountMapList); CaseCount apiCaseCount = countMap(apiCountMapList);