From 592b2a7cd01c90fd43acf56a0f530980b3250641 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Thu, 4 Feb 2021 15:49:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=AF=8F=E5=A4=A9=E5=AE=9A=E6=97=B6=E6=B8=85=E7=90=86?= =?UTF-8?q?=E5=B7=B2=E7=BB=8F=E6=89=A7=E8=A1=8C=E5=AE=8C=E6=88=90=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=B8=AD=E9=97=B4=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../job/LoadTestReportDetailCleanJob.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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); + }); + } } }