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(); }); } }