From 82fc924888cf4a3308a8a990af65742cb9cd456c Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Wed, 27 Nov 2024 14:58:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E6=B8=85=E7=90=86=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1049022 --user=宋昌昌 【任务中心】-系统任务保留时间不生效,超出保留时间的任务没有被清理 https://www.tapd.cn/55049933/s/1618815 --- .../api/service/CleanupApiReportServiceImpl.java | 9 +++++++-- .../metersphere/plan/service/TestPlanReportService.java | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiReportServiceImpl.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiReportServiceImpl.java index fc5fd344ee..fe314d5be1 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiReportServiceImpl.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/CleanupApiReportServiceImpl.java @@ -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 taskReportIds = getTaskReportIds(ids); ids.removeAll(taskReportIds); - deleteApiReport(ids); + 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 taskReportIds = getTaskReportIds(ids); ids.removeAll(taskReportIds); - deleteScenarioReport(ids); + if (CollectionUtils.isNotEmpty(ids)) { + deleteScenarioReport(ids); + } scenarioReportCount = extApiScenarioReportMapper.countScenarioReportByTime(timeMills, projectId); } } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java index d4841368c5..20e2453745 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanReportService.java @@ -211,7 +211,10 @@ public class TestPlanReportService { testPlanReportMapper.updateByExampleSelective(testPlanReport, example); // 任务执行结果存在报告,明细做保留 subList.removeAll(taskReportIds); - this.deleteTestPlanReportBlobs(subList); + if (CollectionUtils.isNotEmpty(subList)) { + this.deleteTestPlanReportBlobs(subList); + } + subList.clear(); }); } }