diff --git a/backend/src/main/java/io/metersphere/performance/job/LoadTestReportDetailCleanJob.java b/backend/src/main/java/io/metersphere/performance/job/LoadTestReportDetailCleanJob.java index f05ccb25a9..6b66cf8e1d 100644 --- a/backend/src/main/java/io/metersphere/performance/job/LoadTestReportDetailCleanJob.java +++ b/backend/src/main/java/io/metersphere/performance/job/LoadTestReportDetailCleanJob.java @@ -1,6 +1,7 @@ package io.metersphere.performance.job; import com.fit2cloud.quartz.anno.QuartzScheduled; +import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.LoadTestReport; import io.metersphere.base.domain.LoadTestReportDetailExample; import io.metersphere.base.domain.LoadTestReportExample; @@ -26,12 +27,16 @@ public class LoadTestReportDetailCleanJob { public void cleanCompletedTestDetail() { LoadTestReportExample example = new LoadTestReportExample(); example.createCriteria().andStatusEqualTo(PerformanceTestStatus.Completed.name()); - List loadTestReports = loadTestReportMapper.selectByExample(example); - loadTestReports.forEach(report -> { - // 清理文件 - LoadTestReportDetailExample example2 = new LoadTestReportDetailExample(); - example2.createCriteria().andReportIdEqualTo(report.getId()); - loadTestReportDetailMapper.deleteByExample(example2); - }); + long count = loadTestReportMapper.countByExample(example); + for (int i = 0; i < count / 10; i++) { + PageHelper.startPage(i, 10); + List loadTestReports = loadTestReportMapper.selectByExample(example); + loadTestReports.forEach(report -> { + // 清理文件 + LoadTestReportDetailExample example2 = new LoadTestReportDetailExample(); + example2.createCriteria().andReportIdEqualTo(report.getId()); + loadTestReportDetailMapper.deleteByExample(example2); + }); + } } }