refactor(测试计划): 测试计划报告测试点展示优化

This commit is contained in:
WangXu10 2024-12-04 13:52:05 +08:00 committed by Craftsman
parent caf3b8c716
commit 56f78b42c8
8 changed files with 97 additions and 22 deletions

View File

@ -1,8 +1,11 @@
package io.metersphere.plan.dto.response;
import io.metersphere.plan.dto.ReportDetailCasePageDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;
@Data
public class TestPlanReportDetailCollectionResponse {
@ -16,4 +19,7 @@ public class TestPlanReportDetailCollectionResponse {
private String planName;
@Schema(description = "位置")
private Long pos;
@Schema(description = "用例数据")
List<ReportDetailCasePageDTO> reportDetailCaseList;
}

View File

@ -40,7 +40,7 @@ public interface ExtTestPlanReportApiCaseMapper {
* @param request 请求参数
* @return 关联的用例集合
*/
List<ReportDetailCasePageDTO> list(@Param("request") TestPlanReportDetailPageRequest request);
List<ReportDetailCasePageDTO> list(@Param("request") TestPlanReportDetailPageRequest request, @Param("sort") String sort);
/**
* 分页查询报告关联的测试集(接口)

View File

@ -54,6 +54,14 @@
and tprac.test_plan_collection_id = #{request.collectionId}
</if>
<include refid="filter"/>
<choose>
<when test="sort != null and sort != ''">
order by ${sort}
</when>
<otherwise>
order by tprac.pos desc
</otherwise>
</choose>
</select>
<select id="listCollection" resultType="io.metersphere.plan.dto.response.TestPlanReportDetailCollectionResponse">

View File

@ -41,7 +41,7 @@ public interface ExtTestPlanReportApiScenarioMapper {
* @param request 请求参数
* @return 关联的用例集合
*/
List<ReportDetailCasePageDTO> list(@Param("request") TestPlanReportDetailPageRequest request);
List<ReportDetailCasePageDTO> list(@Param("request") TestPlanReportDetailPageRequest request, @Param("sort") String sort);
/**
* 分页查询报告关联的测试集(场景)

View File

@ -53,6 +53,14 @@
and tpras.test_plan_collection_id = #{request.collectionId}
</if>
<include refid="filter"/>
<choose>
<when test="sort != null and sort != ''">
order by ${sort}
</when>
<otherwise>
order by tpras.pos desc
</otherwise>
</choose>
</select>
<select id="listCollection" resultType="io.metersphere.plan.dto.response.TestPlanReportDetailCollectionResponse">

View File

@ -53,7 +53,7 @@ public interface ExtTestPlanReportFunctionalCaseMapper {
* @param request 请求参数
* @return 关联的用例集合
*/
List<ReportDetailCasePageDTO> list(@Param("request") TestPlanReportDetailPageRequest request);
List<ReportDetailCasePageDTO> list(@Param("request") TestPlanReportDetailPageRequest request, @Param("sort") String sort);
/**
* 分页查询报告关联的测试集(功能)

View File

@ -74,6 +74,14 @@
and tprfc.test_plan_collection_id = #{request.collectionId}
</if>
<include refid="filter"/>
<choose>
<when test="sort != null and sort != ''">
order by ${sort}
</when>
<otherwise>
order by tprfc.pos desc
</otherwise>
</choose>
</select>
<select id="listCollection" resultType="io.metersphere.plan.dto.response.TestPlanReportDetailCollectionResponse">

View File

@ -480,6 +480,7 @@ public class TestPlanReportService {
/**
* 批量初始化报告关联功能用例数据
*
* @param sqlSession sql操作对象
* @param genParam 报告生成参数
* @param report 报告
@ -539,6 +540,7 @@ public class TestPlanReportService {
/**
* 批量初始化报告关联接口用例数据
*
* @param sqlSession sql操作对象
* @param genParam 报告生成参数
* @param report 报告
@ -590,6 +592,7 @@ public class TestPlanReportService {
/**
* 批量初始化报告关联场景用例数据
*
* @param sqlSession sql操作对象
* @param genParam 报告生成参数
* @param report 报告
@ -641,6 +644,7 @@ public class TestPlanReportService {
/**
* 批量初始化报告关联缺陷数据
*
* @param sqlSession sql操作对象
* @param genParam 报告生成参数
* @param report 报告
@ -819,6 +823,7 @@ public class TestPlanReportService {
/**
* 获取计划任务执行结果 (执行历史)
*
* @param taskId 任务ID
* @return 计划| 执行结果
*/
@ -851,6 +856,7 @@ public class TestPlanReportService {
/**
* 获取计划任务执行结果 (任务中心)
*
* @param taskId 任务ID
* @return 计划| 执行结果
*/
@ -924,9 +930,12 @@ public class TestPlanReportService {
public List<ReportDetailCasePageDTO> listReportDetailCases(TestPlanReportDetailPageRequest request, String caseType) {
List<ReportDetailCasePageDTO> detailCases;
switch (caseType) {
case AssociateCaseType.FUNCTIONAL -> detailCases = extTestPlanReportFunctionalCaseMapper.list(request);
case AssociateCaseType.API_CASE -> detailCases = extTestPlanReportApiCaseMapper.list(request);
case AssociateCaseType.API_SCENARIO -> detailCases = extTestPlanReportApiScenarioMapper.list(request);
case AssociateCaseType.FUNCTIONAL ->
detailCases = extTestPlanReportFunctionalCaseMapper.list(request, request.getSortString());
case AssociateCaseType.API_CASE ->
detailCases = extTestPlanReportApiCaseMapper.list(request, request.getSortString());
case AssociateCaseType.API_SCENARIO ->
detailCases = extTestPlanReportApiScenarioMapper.list(request, request.getSortString());
default -> detailCases = new ArrayList<>();
}
List<String> distinctUserIds = detailCases.stream().map(ReportDetailCasePageDTO::getExecuteUser).distinct().collect(Collectors.toList());
@ -1311,15 +1320,47 @@ public class TestPlanReportService {
public List<TestPlanReportDetailCollectionResponse> listReportCollection(TestPlanReportDetailPageRequest request, String caseType) {
List<TestPlanReportDetailCollectionResponse> collections;
switch (caseType) {
case CollectionQueryType.FUNCTIONAL -> collections = extTestPlanReportFunctionalCaseMapper.listCollection(request);
case CollectionQueryType.FUNCTIONAL ->
collections = extTestPlanReportFunctionalCaseMapper.listCollection(request);
case CollectionQueryType.API -> collections = extTestPlanReportApiCaseMapper.listCollection(request);
case CollectionQueryType.SCENARIO -> collections = extTestPlanReportApiScenarioMapper.listCollection(request);
case CollectionQueryType.SCENARIO ->
collections = extTestPlanReportApiScenarioMapper.listCollection(request);
default -> collections = new ArrayList<>();
}
collections.sort(Comparator.comparing(TestPlanReportDetailCollectionResponse::getPos));
handCollectionItemData(collections, caseType, request);
return collections;
}
/**
* 处理测试集子项数据
*
* @param collections
*/
private void handCollectionItemData(List<TestPlanReportDetailCollectionResponse> collections, String caseType, TestPlanReportDetailPageRequest request) {
if (CollectionUtils.isNotEmpty(collections)) {
TestPlanReportDetailPageRequest reportDetail = new TestPlanReportDetailPageRequest();
BeanUtils.copyBean(reportDetail, request);
collections.forEach(item -> {
reportDetail.setCollectionId(item.getId());
reportDetail.setDetailReportIds(getActualReportIds(request.getReportId()));
List<ReportDetailCasePageDTO> caseList = new ArrayList<>();
switch (caseType) {
case CollectionQueryType.FUNCTIONAL ->
caseList = listReportDetailCases(reportDetail, AssociateCaseType.FUNCTIONAL);
case CollectionQueryType.API ->
caseList = listReportDetailCases(reportDetail, AssociateCaseType.API_CASE);
case CollectionQueryType.SCENARIO ->
caseList = listReportDetailCases(reportDetail, AssociateCaseType.API_SCENARIO);
default -> caseList = new ArrayList<>();
}
item.setReportDetailCaseList(caseList);
});
}
}
/**
* 预览富文本文件
*
@ -1420,6 +1461,7 @@ public class TestPlanReportService {
/**
* 计算计划任务的用例执行情况(实时, 并不取计划报告的最终汇总)
*
* @return 用例执行情况
*/
private TestPlanTaskReportResponse calcTaskExecActual(String reportId, TestPlanTaskReportResponse testPlanTaskReportResponse) {
@ -1443,6 +1485,7 @@ public class TestPlanReportService {
/**
* 计算计划任务的用例执行情况(取计划报告的最终汇总)
*
* @return 用例执行情况
*/
private TestPlanReportDetailResponse calcTaskExecFinish(String reportId, String detailName, TestPlanReportDetailResponse detail) {
@ -1466,6 +1509,7 @@ public class TestPlanReportService {
/**
* 获取实际的报告ID集合 (计划组报告则会返回多个)
*
* @param reportId 报告ID
* @return 报告ID集合
*/
@ -1484,6 +1528,7 @@ public class TestPlanReportService {
/**
* 获取报告汇总详情
*
* @param reportId 报告ID
* @return 汇总详情
*/