fix(测试计划): 修复执行生成报告SQL时导致的关联用例查不到问题
This commit is contained in:
parent
63c7dfdaf6
commit
2586b73b9a
|
@ -0,0 +1,13 @@
|
||||||
|
package io.metersphere.plan.dto;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ReportBugCountDTO {
|
||||||
|
|
||||||
|
@Schema(description = "关联用例ID")
|
||||||
|
private String refCaseId;
|
||||||
|
@Schema(description = "缺陷数量")
|
||||||
|
private Long bugCount;
|
||||||
|
}
|
|
@ -9,15 +9,13 @@
|
||||||
|
|
||||||
<select id="getPlanExecuteCases" resultType="io.metersphere.plan.domain.TestPlanReportApiCase">
|
<select id="getPlanExecuteCases" resultType="io.metersphere.plan.domain.TestPlanReportApiCase">
|
||||||
select tpac.id as testPlanApiCaseId, atc.id as apiCaseId, atc.num as apiCaseNum, atc.name as apiCaseName, atc.priority as apiCasePriority,
|
select tpac.id as testPlanApiCaseId, atc.id as apiCaseId, atc.num as apiCaseNum, atc.name as apiCaseName, atc.priority as apiCasePriority,
|
||||||
tpac.test_plan_collection_id testPlanCollectionId, tpac.environment_id as environmentId, count(b.id) as apiCaseBugCount,
|
tpac.test_plan_collection_id testPlanCollectionId, tpac.environment_id as environmentId,
|
||||||
if(ad.module_id = 'root','未规划用例', ad.module_id) as apiCaseModule, tpac.execute_user as apiCaseExecuteUser,
|
if(ad.module_id = 'root','未规划用例', ad.module_id) as apiCaseModule, tpac.execute_user as apiCaseExecuteUser,
|
||||||
ifnull(tpac.last_exec_result, 'PENDING') as apiCaseExecuteResult, tpac.last_exec_report_id apiCaseExecuteReportId, tpac.pos as pos
|
ifnull(tpac.last_exec_result, 'PENDING') as apiCaseExecuteResult, tpac.last_exec_report_id apiCaseExecuteReportId, tpac.pos as pos
|
||||||
from test_plan_api_case tpac join api_test_case atc on atc.id = tpac.api_case_id
|
from test_plan_api_case tpac join api_test_case atc on atc.id = tpac.api_case_id
|
||||||
left join api_definition ad on atc.api_definition_id = ad.id
|
left join api_definition ad on atc.api_definition_id = ad.id
|
||||||
left join api_definition_module adm on ad.module_id = adm.id
|
left join api_definition_module adm on ad.module_id = adm.id
|
||||||
left join bug_relation_case brc on brc.test_plan_case_id = tpac.id
|
where tpac.test_plan_id = #{id} and atc.deleted = false
|
||||||
left join bug b on b.id = brc.bug_id
|
|
||||||
where tpac.test_plan_id = #{id} and atc.deleted = false and b.deleted = false
|
|
||||||
group by tpac.id
|
group by tpac.id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,12 @@
|
||||||
|
|
||||||
<select id="getPlanExecuteCases" resultType="io.metersphere.plan.domain.TestPlanReportApiScenario">
|
<select id="getPlanExecuteCases" resultType="io.metersphere.plan.domain.TestPlanReportApiScenario">
|
||||||
select tpas.id as testPlanApiScenarioId, aso.id as apiScenarioId, aso.num as apiScenarioNum, aso.name as apiScenarioName, aso.priority as apiScenarioPriority,
|
select tpas.id as testPlanApiScenarioId, aso.id as apiScenarioId, aso.num as apiScenarioNum, aso.name as apiScenarioName, aso.priority as apiScenarioPriority,
|
||||||
tpas.test_plan_collection_id testPlanCollectionId, tpas.grouped as grouped, tpas.environment_id environmentId, count(b.id) as apiScenarioBugCount,
|
tpas.test_plan_collection_id testPlanCollectionId, tpas.grouped as grouped, tpas.environment_id environmentId,
|
||||||
if(aso.module_id = 'root','未规划用例', aso.module_id) as apiScenarioModule, tpas.execute_user as apiScenarioExecuteUser,
|
if(aso.module_id = 'root','未规划用例', aso.module_id) as apiScenarioModule, tpas.execute_user as apiScenarioExecuteUser,
|
||||||
ifnull(tpas.last_exec_result, 'PENDING') as apiScenarioExecuteResult, tpas.last_exec_report_id apiScenarioExecuteReportId, tpas.pos as pos
|
ifnull(tpas.last_exec_result, 'PENDING') as apiScenarioExecuteResult, tpas.last_exec_report_id apiScenarioExecuteReportId, tpas.pos as pos
|
||||||
from test_plan_api_scenario tpas join api_scenario aso on aso.id = tpas.api_scenario_id
|
from test_plan_api_scenario tpas join api_scenario aso on aso.id = tpas.api_scenario_id
|
||||||
left join api_scenario_module asm on aso.module_id = asm.id
|
left join api_scenario_module asm on aso.module_id = asm.id
|
||||||
left join bug_relation_case brc on brc.test_plan_case_id = tpas.id
|
where tpas.test_plan_id = #{id} and aso.deleted = false
|
||||||
left join bug b on b.id = brc.bug_id
|
|
||||||
where tpas.test_plan_id = #{id} and aso.deleted = false and b.deleted = false
|
|
||||||
group by tpas.id
|
group by tpas.id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package io.metersphere.plan.mapper;
|
||||||
|
|
||||||
import io.metersphere.bug.dto.response.BugDTO;
|
import io.metersphere.bug.dto.response.BugDTO;
|
||||||
import io.metersphere.plan.domain.TestPlanReportBug;
|
import io.metersphere.plan.domain.TestPlanReportBug;
|
||||||
|
import io.metersphere.plan.dto.ReportBugCountDTO;
|
||||||
import io.metersphere.plan.dto.ReportBugSumDTO;
|
import io.metersphere.plan.dto.ReportBugSumDTO;
|
||||||
import io.metersphere.plan.dto.request.TestPlanReportDetailPageRequest;
|
import io.metersphere.plan.dto.request.TestPlanReportDetailPageRequest;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
@ -30,4 +31,11 @@ public interface ExtTestPlanReportBugMapper {
|
||||||
* @return 缺陷数量
|
* @return 缺陷数量
|
||||||
*/
|
*/
|
||||||
List<ReportBugSumDTO> countBug(@Param("id") String reportId);
|
List<ReportBugSumDTO> countBug(@Param("id") String reportId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计计划下的关联用例的缺陷数目
|
||||||
|
* @param planId 计划ID
|
||||||
|
* @return 缺陷数目
|
||||||
|
*/
|
||||||
|
List<ReportBugCountDTO> countPlanBug(@Param("id") String planId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,4 +27,10 @@
|
||||||
select 'SCENARIO' as caseType, ifnull(sum(tpras.api_scenario_bug_count), 0) as bugCount from test_plan_report_api_scenario tpras
|
select 'SCENARIO' as caseType, ifnull(sum(tpras.api_scenario_bug_count), 0) as bugCount from test_plan_report_api_scenario tpras
|
||||||
where tpras.test_plan_report_id = #{id}
|
where tpras.test_plan_report_id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="countPlanBug" resultType="io.metersphere.plan.dto.ReportBugCountDTO">
|
||||||
|
select brc.test_plan_case_id as refCaseId, count(brc.id) as bugCount from bug_relation_case brc join bug b on brc.bug_id = b.id
|
||||||
|
where brc.test_plan_id = #{id} and b.deleted = false
|
||||||
|
group by brc.test_plan_case_id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
|
@ -5,12 +5,10 @@
|
||||||
<select id="getPlanExecuteCases" resultType="io.metersphere.plan.domain.TestPlanReportFunctionCase">
|
<select id="getPlanExecuteCases" resultType="io.metersphere.plan.domain.TestPlanReportFunctionCase">
|
||||||
select tpfc.id as testPlanFunctionCaseId, fc.id as functionCaseId, fc.num as functionCaseNum, fc.name as functionCaseName, tpfc.test_plan_collection_id testPlanCollectionId,
|
select tpfc.id as testPlanFunctionCaseId, fc.id as functionCaseId, fc.num as functionCaseNum, fc.name as functionCaseName, tpfc.test_plan_collection_id testPlanCollectionId,
|
||||||
if(fc.module_id = 'root','未规划用例', fc.module_id) as functionCaseModule, tpfc.execute_user as functionCaseExecuteUser,
|
if(fc.module_id = 'root','未规划用例', fc.module_id) as functionCaseModule, tpfc.execute_user as functionCaseExecuteUser,
|
||||||
count(b.id) as functionCaseBugCount, ifnull(tpfc.last_exec_result, 'PENDING') as functionCaseExecuteResult, tpfc.pos as pos
|
ifnull(tpfc.last_exec_result, 'PENDING') as functionCaseExecuteResult, tpfc.pos as pos
|
||||||
from test_plan_functional_case tpfc join functional_case fc on tpfc.functional_case_id = fc.id
|
from test_plan_functional_case tpfc join functional_case fc on tpfc.functional_case_id = fc.id
|
||||||
left join functional_case_module fcm on fcm.id = fc.module_id
|
left join functional_case_module fcm on fcm.id = fc.module_id
|
||||||
left join bug_relation_case brc on brc.test_plan_case_id = tpfc.id
|
where tpfc.test_plan_id = #{id} and fc.deleted = false
|
||||||
left join bug b on b.id = brc.bug_id
|
|
||||||
where tpfc.test_plan_id = #{id} and fc.deleted = false and b.deleted = false
|
|
||||||
group by tpfc.id
|
group by tpfc.id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
|
@ -430,6 +430,9 @@ public class TestPlanReportService {
|
||||||
*/
|
*/
|
||||||
private TestPlanReportDetailCaseDTO genReportDetail(TestPlanReportGenPreParam genParam, TestPlanReport report) {
|
private TestPlanReportDetailCaseDTO genReportDetail(TestPlanReportGenPreParam genParam, TestPlanReport report) {
|
||||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||||
|
// 缺陷数
|
||||||
|
List<ReportBugCountDTO> bugCountList = extTestPlanReportBugMapper.countPlanBug(genParam.getTestPlanId());
|
||||||
|
Map<String, Long> bugCountMap = bugCountList.stream().collect(Collectors.toMap(ReportBugCountDTO::getRefCaseId, ReportBugCountDTO::getBugCount));
|
||||||
// 功能用例
|
// 功能用例
|
||||||
List<TestPlanReportFunctionCase> reportFunctionCases = extTestPlanReportFunctionalCaseMapper.getPlanExecuteCases(genParam.getTestPlanId());
|
List<TestPlanReportFunctionCase> reportFunctionCases = extTestPlanReportFunctionalCaseMapper.getPlanExecuteCases(genParam.getTestPlanId());
|
||||||
if (CollectionUtils.isNotEmpty(reportFunctionCases)) {
|
if (CollectionUtils.isNotEmpty(reportFunctionCases)) {
|
||||||
|
@ -462,6 +465,7 @@ public class TestPlanReportService {
|
||||||
} else {
|
} else {
|
||||||
reportFunctionalCase.setFunctionCaseExecuteReportId(null);
|
reportFunctionalCase.setFunctionCaseExecuteReportId(null);
|
||||||
}
|
}
|
||||||
|
reportFunctionalCase.setFunctionCaseBugCount(bugCountMap.containsKey(reportFunctionalCase.getTestPlanFunctionCaseId()) ? bugCountMap.get(reportFunctionalCase.getTestPlanFunctionCaseId()) : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 插入计划功能用例关联数据 -> 报告内容
|
// 插入计划功能用例关联数据 -> 报告内容
|
||||||
|
@ -491,6 +495,7 @@ public class TestPlanReportService {
|
||||||
reportApiCase.setApiCaseExecuteUser(null);
|
reportApiCase.setApiCaseExecuteUser(null);
|
||||||
reportApiCase.setApiCaseExecuteReportId(IDGenerator.nextStr());
|
reportApiCase.setApiCaseExecuteReportId(IDGenerator.nextStr());
|
||||||
}
|
}
|
||||||
|
reportApiCase.setApiCaseBugCount(bugCountMap.containsKey(reportApiCase.getTestPlanApiCaseId()) ? bugCountMap.get(reportApiCase.getTestPlanApiCaseId()) : 0);
|
||||||
}
|
}
|
||||||
// 插入计划接口用例关联数据 -> 报告内容
|
// 插入计划接口用例关联数据 -> 报告内容
|
||||||
TestPlanReportApiCaseMapper batchMapper = sqlSession.getMapper(TestPlanReportApiCaseMapper.class);
|
TestPlanReportApiCaseMapper batchMapper = sqlSession.getMapper(TestPlanReportApiCaseMapper.class);
|
||||||
|
@ -519,6 +524,7 @@ public class TestPlanReportService {
|
||||||
reportApiScenario.setApiScenarioExecuteUser(null);
|
reportApiScenario.setApiScenarioExecuteUser(null);
|
||||||
reportApiScenario.setApiScenarioExecuteReportId(IDGenerator.nextStr());
|
reportApiScenario.setApiScenarioExecuteReportId(IDGenerator.nextStr());
|
||||||
}
|
}
|
||||||
|
reportApiScenario.setApiScenarioBugCount(bugCountMap.containsKey(reportApiScenario.getTestPlanApiScenarioId()) ? bugCountMap.get(reportApiScenario.getTestPlanApiScenarioId()) : 0);
|
||||||
}
|
}
|
||||||
// 插入计划场景用例关联数据 -> 报告内容
|
// 插入计划场景用例关联数据 -> 报告内容
|
||||||
TestPlanReportApiScenarioMapper batchMapper = sqlSession.getMapper(TestPlanReportApiScenarioMapper.class);
|
TestPlanReportApiScenarioMapper batchMapper = sqlSession.getMapper(TestPlanReportApiScenarioMapper.class);
|
||||||
|
|
Loading…
Reference in New Issue