fix(项目管理): 报告清理报错问题

--bug=1049022 --user=宋昌昌 【任务中心】-系统任务保留时间不生效,超出保留时间的任务没有被清理 https://www.tapd.cn/55049933/s/1618815
This commit is contained in:
song-cc-rock 2024-11-27 14:58:57 +08:00 committed by 刘瑞斌
parent 53cf2d2d82
commit 82fc924888
2 changed files with 11 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import io.metersphere.sdk.constants.ProjectApplicationType;
import io.metersphere.sdk.util.LogUtils;
import io.metersphere.system.service.BaseCleanUpReport;
import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -59,7 +60,9 @@ public class CleanupApiReportServiceImpl implements BaseCleanUpReport {
// 任务执行结果存在报告明细做保留
List<String> taskReportIds = getTaskReportIds(ids);
ids.removeAll(taskReportIds);
if (CollectionUtils.isNotEmpty(ids)) {
deleteApiReport(ids);
}
apiReportCount = extApiReportMapper.countApiReportByTime(timeMills, projectId);
}
int scenarioReportCount = extApiScenarioReportMapper.countScenarioReportByTime(timeMills, projectId);
@ -73,7 +76,9 @@ public class CleanupApiReportServiceImpl implements BaseCleanUpReport {
// 任务执行结果存在报告明细做保留
List<String> taskReportIds = getTaskReportIds(ids);
ids.removeAll(taskReportIds);
if (CollectionUtils.isNotEmpty(ids)) {
deleteScenarioReport(ids);
}
scenarioReportCount = extApiScenarioReportMapper.countScenarioReportByTime(timeMills, projectId);
}
}

View File

@ -211,7 +211,10 @@ public class TestPlanReportService {
testPlanReportMapper.updateByExampleSelective(testPlanReport, example);
// 任务执行结果存在报告明细做保留
subList.removeAll(taskReportIds);
if (CollectionUtils.isNotEmpty(subList)) {
this.deleteTestPlanReportBlobs(subList);
}
subList.clear();
});
}
}