fix(报告明细): 报告明细查询补充测试点

This commit is contained in:
song-cc-rock 2024-10-23 10:56:48 +08:00 committed by Craftsman
parent a1f64278ef
commit 977e73a63a
5 changed files with 33 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import lombok.Data;
/** /**
* 报告详情用例分页返回对象 (功能, 接口, 场景) * 报告详情用例分页返回对象 (功能, 接口, 场景)
* @author song-cc-rock
*/ */
@Data @Data
@ -32,4 +33,8 @@ public class ReportDetailCasePageDTO {
private String reportId; private String reportId;
@Schema(description = "项目ID") @Schema(description = "项目ID")
private String projectId; private String projectId;
@Schema(description = "测试点ID")
private String collectionId;
@Schema(description = "测试点名称")
private String collectionName;
} }

View File

@ -33,7 +33,7 @@
<select id="list" resultType="io.metersphere.plan.dto.ReportDetailCasePageDTO"> <select id="list" resultType="io.metersphere.plan.dto.ReportDetailCasePageDTO">
<!-- ID、用例名称、所属模块、用例等级、执行人、执行结果、缺陷数、接口报告ID --> <!-- ID、用例名称、所属模块、用例等级、执行人、执行结果、缺陷数、接口报告ID -->
select tprac.api_case_id as id, tprac.api_case_num as num, tprac.api_case_name as name, tprac.test_plan_name as planName, select tprac.api_case_id as id, tprac.api_case_num as num, tprac.api_case_name as name, tprac.test_plan_name as planName, tprac.test_plan_collection_id collectionId,
tprac.api_case_module as moduleName, tprac.api_case_priority as priority, tprac.api_case_execute_report_id reportId, ifnull(tprac.api_case_bug_count, 0) as bugCount, tprac.api_case_module as moduleName, tprac.api_case_priority as priority, tprac.api_case_execute_report_id reportId, ifnull(tprac.api_case_bug_count, 0) as bugCount,
ifnull(tprac.api_case_execute_result, 'PENDING') as executeResult, tprac.api_case_execute_user as executeUser, atc.project_id projectId ifnull(tprac.api_case_execute_result, 'PENDING') as executeResult, tprac.api_case_execute_user as executeUser, atc.project_id projectId
from test_plan_report_api_case tprac left join api_test_case atc on tprac.api_case_id = atc.id from test_plan_report_api_case tprac left join api_test_case atc on tprac.api_case_id = atc.id

View File

@ -32,7 +32,7 @@
<select id="list" resultType="io.metersphere.plan.dto.ReportDetailCasePageDTO"> <select id="list" resultType="io.metersphere.plan.dto.ReportDetailCasePageDTO">
<!-- ID、用例名称、所属模块、用例等级、执行人、执行结果、缺陷数、报告ID --> <!-- ID、用例名称、所属模块、用例等级、执行人、执行结果、缺陷数、报告ID -->
select distinct tpras.api_scenario_id as id, tpras.api_scenario_num as num, tpras.api_scenario_name as name, tpras.test_plan_name as planName, select distinct tpras.api_scenario_id as id, tpras.api_scenario_num as num, tpras.api_scenario_name as name, tpras.test_plan_name as planName, tpras.test_plan_collection_id collectionId,
tpras.api_scenario_module as moduleName, tpras.api_scenario_priority as priority, tpras.api_scenario_execute_report_id reportId, ifnull(tpras.api_scenario_bug_count, 0) as bugCount, tpras.api_scenario_module as moduleName, tpras.api_scenario_priority as priority, tpras.api_scenario_execute_report_id reportId, ifnull(tpras.api_scenario_bug_count, 0) as bugCount,
ifnull(tpras.api_scenario_execute_result, 'PENDING') as executeResult, tpras.api_scenario_execute_user as executeUser, aso.project_id projectId ifnull(tpras.api_scenario_execute_result, 'PENDING') as executeResult, tpras.api_scenario_execute_user as executeUser, aso.project_id projectId
from test_plan_report_api_scenario tpras left join api_scenario aso on tpras.api_scenario_id = aso.id from test_plan_report_api_scenario tpras left join api_scenario aso on tpras.api_scenario_id = aso.id

View File

@ -51,7 +51,7 @@
<select id="list" resultType="io.metersphere.plan.dto.ReportDetailCasePageDTO"> <select id="list" resultType="io.metersphere.plan.dto.ReportDetailCasePageDTO">
<!-- ID、用例名称、所属模块、用例等级、执行人、执行结果、缺陷数、报告ID --> <!-- ID、用例名称、所属模块、用例等级、执行人、执行结果、缺陷数、报告ID -->
select tprfc.function_case_id as id, tprfc.function_case_num as num, tprfc.function_case_name as name, select tprfc.function_case_id as id, tprfc.function_case_num as num, tprfc.function_case_name as name, tprfc.test_plan_collection_id collectionId,
tprfc.function_case_module as moduleName, tprfc.function_case_priority as priority, tprfc.test_plan_name as planName, tprfc.function_case_module as moduleName, tprfc.function_case_priority as priority, tprfc.test_plan_name as planName,
ifnull(tprfc.function_case_execute_result, 'PENDING') as executeResult, tprfc.function_case_execute_user as executeUser, ifnull(tprfc.function_case_execute_result, 'PENDING') as executeResult, tprfc.function_case_execute_user as executeUser,
ifnull(tprfc.function_case_bug_count, 0) as bugCount, tprfc.function_case_execute_report_id reportId, fc.project_id projectId ifnull(tprfc.function_case_bug_count, 0) as bugCount, tprfc.function_case_execute_report_id reportId, fc.project_id projectId

View File

@ -126,6 +126,8 @@ public class TestPlanReportService {
private ProjectMapper projectMapper; private ProjectMapper projectMapper;
@Resource @Resource
private ApiReportRelateTaskMapper apiReportRelateTaskMapper; private ApiReportRelateTaskMapper apiReportRelateTaskMapper;
@Resource
private TestPlanCollectionMapper testPlanCollectionMapper;
private static final int MAX_REPORT_NAME_LENGTH = 300; private static final int MAX_REPORT_NAME_LENGTH = 300;
@ -841,7 +843,14 @@ public class TestPlanReportService {
List<String> distinctUserIds = detailCases.stream().map(ReportDetailCasePageDTO::getExecuteUser).distinct().collect(Collectors.toList()); List<String> distinctUserIds = detailCases.stream().map(ReportDetailCasePageDTO::getExecuteUser).distinct().collect(Collectors.toList());
distinctUserIds.removeIf(StringUtils::isEmpty); distinctUserIds.removeIf(StringUtils::isEmpty);
Map<String, String> userMap = getUserMap(distinctUserIds); Map<String, String> userMap = getUserMap(distinctUserIds);
detailCases.forEach(detailCase -> detailCase.setExecuteUser(userMap.getOrDefault(detailCase.getExecuteUser(), detailCase.getExecuteUser()))); // 测试集
List<String> collectionIds = detailCases.stream().map(ReportDetailCasePageDTO::getCollectionId).distinct().collect(Collectors.toList());
collectionIds.removeIf(StringUtils::isEmpty);
Map<String, String> collectionMap = getCollectionMap(collectionIds);
detailCases.forEach(detailCase -> {
detailCase.setExecuteUser(userMap.getOrDefault(detailCase.getExecuteUser(), detailCase.getExecuteUser()));
detailCase.setCollectionName(collectionMap.get(detailCase.getCollectionId()));
});
return detailCases; return detailCases;
} }
@ -1242,6 +1251,21 @@ public class TestPlanReportService {
return userOptions.stream().collect(Collectors.toMap(OptionDTO::getId, OptionDTO::getName)); return userOptions.stream().collect(Collectors.toMap(OptionDTO::getId, OptionDTO::getName));
} }
/**
* 获取测试点集合
* @param collectionIds 测试点ID集合
* @return 测试点集合
*/
private Map<String, String> getCollectionMap(List<String> collectionIds) {
if (CollectionUtils.isEmpty(collectionIds)) {
return new HashMap<>(16);
}
TestPlanCollectionExample example = new TestPlanCollectionExample();
example.createCriteria().andIdIn(collectionIds);
List<TestPlanCollection> collections = testPlanCollectionMapper.selectByExample(example);
return collections.stream().collect(Collectors.toMap(TestPlanCollection::getId, TestPlanCollection::getName));
}
/** /**
* 计划报告列表 * 计划报告列表
* *