fix(测试计划): 子计划删除报告明细清理问题
--bug=1042776 --user=宋昌昌 【测试计划】计划组-删除子计划-集合报告-报告明细-子计划被删除了 https://www.tapd.cn/55049933/s/1552190
This commit is contained in:
parent
2599daeee2
commit
9df8359874
|
@ -173,7 +173,7 @@ public class TestPlanController {
|
||||||
@Operation(summary = "测试计划-批量复制测试计划")
|
@Operation(summary = "测试计划-批量复制测试计划")
|
||||||
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_ADD)
|
@RequiresPermissions(PermissionConstants.TEST_PLAN_READ_ADD)
|
||||||
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
@CheckOwner(resourceId = "#request.getProjectId()", resourceType = "project")
|
||||||
public TestPlanOperationResponse TestPlanOperationResponse(@Validated @RequestBody TestPlanBatchRequest request) {
|
public TestPlanOperationResponse batchCopy(@Validated @RequestBody TestPlanBatchRequest request) {
|
||||||
testPlanManagementService.checkModuleIsOpen(request.getProjectId(), TestPlanResourceConfig.CHECK_TYPE_PROJECT, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN));
|
testPlanManagementService.checkModuleIsOpen(request.getProjectId(), TestPlanResourceConfig.CHECK_TYPE_PROJECT, Collections.singletonList(TestPlanResourceConfig.CONFIG_TEST_PLAN));
|
||||||
testPlanService.filterArchivedIds(request);
|
testPlanService.filterArchivedIds(request);
|
||||||
return new TestPlanOperationResponse(
|
return new TestPlanOperationResponse(
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class TestPlanReportDetailResponse {
|
||||||
@Schema(description = "报告内容")
|
@Schema(description = "报告内容")
|
||||||
private String summary;
|
private String summary;
|
||||||
@Schema(description = "用例总数")
|
@Schema(description = "用例总数")
|
||||||
private Integer caseTotal = 0;
|
private Integer caseTotal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报告分析
|
* 报告分析
|
||||||
|
|
|
@ -65,4 +65,6 @@ public interface ExtTestPlanReportMapper {
|
||||||
void batchUpdateExecuteTimeAndStatus(@Param("startTime") long startTime, @Param("ids") List<String> ids);
|
void batchUpdateExecuteTimeAndStatus(@Param("startTime") long startTime, @Param("ids") List<String> ids);
|
||||||
|
|
||||||
List<ReportDTO> getReportsByIds(@Param("ids") List<String> ids);
|
List<ReportDTO> getReportsByIds(@Param("ids") List<String> ids);
|
||||||
|
|
||||||
|
void deleteGroupReport(@Param("id") String id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,8 +142,7 @@
|
||||||
tpr.deleted
|
tpr.deleted
|
||||||
|
|
||||||
from test_plan_report tpr
|
from test_plan_report tpr
|
||||||
INNER JOIN test_plan_report_summary tprs on tpr.id = tprs.test_plan_report_id
|
LEFT JOIN test_plan_report_summary tprs on tpr.id = tprs.test_plan_report_id
|
||||||
|
|
||||||
<include refid="queryWhereConditionByParentId"/>
|
<include refid="queryWhereConditionByParentId"/>
|
||||||
</select>
|
</select>
|
||||||
<select id="getReports" resultType="io.metersphere.api.dto.report.ReportDTO">
|
<select id="getReports" resultType="io.metersphere.api.dto.report.ReportDTO">
|
||||||
|
@ -260,6 +259,10 @@
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteGroupReport" parameterType="java.lang.String">
|
||||||
|
delete from test_plan_report where id = #{id} or parent_id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
<update id="batchUpdateExecuteTimeAndStatus" parameterType="java.lang.String">
|
<update id="batchUpdateExecuteTimeAndStatus" parameterType="java.lang.String">
|
||||||
update test_plan_report
|
update test_plan_report
|
||||||
set start_time = #{startTime}, exec_status = 'RUNNING'
|
set start_time = #{startTime}, exec_status = 'RUNNING'
|
||||||
|
|
|
@ -184,19 +184,33 @@ public class TestPlanReportService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除测试计划报告(包括summary
|
* 删除测试计划报告(包括汇总, 明细)
|
||||||
*/
|
*/
|
||||||
public void deleteByTestPlanIds(List<String> testPlanIds) {
|
public void deleteByTestPlanIds(List<String> testPlanIds) {
|
||||||
if (CollectionUtils.isNotEmpty(testPlanIds)) {
|
if (CollectionUtils.isNotEmpty(testPlanIds)) {
|
||||||
List<String> reportIdList = extTestPlanReportMapper.selectReportIdTestPlanIds(testPlanIds);
|
TestPlanReportExample reportExample = new TestPlanReportExample();
|
||||||
|
reportExample.createCriteria().andTestPlanIdIn(testPlanIds);
|
||||||
SubListUtils.dealForSubList(reportIdList, SubListUtils.DEFAULT_BATCH_SIZE, subList -> {
|
List<TestPlanReport> testPlanReports = testPlanReportMapper.selectByExample(reportExample);
|
||||||
TestPlanReportExample example = new TestPlanReportExample();
|
if (CollectionUtils.isNotEmpty(testPlanReports)) {
|
||||||
example.createCriteria().andIdIn(subList);
|
Map<String, TestPlanReport> reportMap = testPlanReports.stream().collect(Collectors.toMap(TestPlanReport::getId, r -> r));
|
||||||
testPlanReportMapper.deleteByExample(example);
|
List<String> reportIdList = testPlanReports.stream().map(TestPlanReport::getId).toList();
|
||||||
|
reportIdList.forEach(reportId -> {
|
||||||
this.deleteTestPlanReportBlobs(subList);
|
/**
|
||||||
});
|
* 独立计划直接删除; 子计划的报告删除时, 保留报告记录
|
||||||
|
*/
|
||||||
|
TestPlanReport report = reportMap.get(reportId);
|
||||||
|
if (StringUtils.isNotBlank(report.getParentId()) && !report.getIntegrated() && !report.getDeleted()) {
|
||||||
|
TestPlanReport record = new TestPlanReport();
|
||||||
|
record.setId(reportId);
|
||||||
|
record.setDeleted(true);
|
||||||
|
testPlanReportMapper.updateByPrimaryKeySelective(record);
|
||||||
|
} else {
|
||||||
|
extTestPlanReportMapper.deleteGroupReport(reportId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// 清除汇总, 明细数据
|
||||||
|
this.deleteTestPlanReportBlobs(reportIdList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,11 +105,12 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
||||||
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
|
private TestPlanApiScenarioMapper testPlanApiScenarioMapper;
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanReportCaseService testPlanReportCaseService;
|
private TestPlanReportCaseService testPlanReportCaseService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanReportService testPlanReportService;
|
private TestPlanReportService testPlanReportService;
|
||||||
@Resource
|
@Resource
|
||||||
private TestPlanReportMapper testPlanReportMapper;
|
private TestPlanReportMapper testPlanReportMapper;
|
||||||
|
@Resource
|
||||||
|
private ExtTestPlanReportMapper extTestPlanReportMapper;
|
||||||
|
|
||||||
public void autoUpdateFunctionalCase(String testPlanReportId) {
|
public void autoUpdateFunctionalCase(String testPlanReportId) {
|
||||||
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportId);
|
TestPlanReport testPlanReport = testPlanReportMapper.selectByPrimaryKey(testPlanReportId);
|
||||||
|
@ -276,7 +277,6 @@ public class TestPlanService extends TestPlanBaseUtilsService {
|
||||||
/*
|
/*
|
||||||
* 计划组删除逻辑{第一版需求: 删除组, 组下的子计划Group置为None}:
|
* 计划组删除逻辑{第一版需求: 删除组, 组下的子计划Group置为None}:
|
||||||
* 1. 查询计划组下的全部子计划并删除(级联删除这些子计划的关联资源)
|
* 1. 查询计划组下的全部子计划并删除(级联删除这些子计划的关联资源)
|
||||||
* 2. 删除所有计划组
|
|
||||||
*/
|
*/
|
||||||
TestPlanExample testPlanExample = new TestPlanExample();
|
TestPlanExample testPlanExample = new TestPlanExample();
|
||||||
testPlanExample.createCriteria().andGroupIdIn(deleteGroupIds);
|
testPlanExample.createCriteria().andGroupIdIn(deleteGroupIds);
|
||||||
|
|
Loading…
Reference in New Issue