From a349e3f52af84cd7a18151c8edb9960b8cc87193 Mon Sep 17 00:00:00 2001 From: wenyann Date: Fri, 25 Jun 2021 18:40:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=AE=9A=E6=97=B6=E6=8F=92=E5=85=A5?= =?UTF-8?q?=E7=BC=BA=E9=99=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/job/sechedule/IssuesJob.java | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/backend/src/main/java/io/metersphere/job/sechedule/IssuesJob.java b/backend/src/main/java/io/metersphere/job/sechedule/IssuesJob.java index 76f1f26c66..75f2c21733 100644 --- a/backend/src/main/java/io/metersphere/job/sechedule/IssuesJob.java +++ b/backend/src/main/java/io/metersphere/job/sechedule/IssuesJob.java @@ -1,11 +1,16 @@ package io.metersphere.job.sechedule; import com.fit2cloud.quartz.anno.QuartzScheduled; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.IssuesDao; +import io.metersphere.base.domain.TestPlanTestCase; import io.metersphere.base.domain.TestPlanTestCaseWithBLOBs; +import io.metersphere.commons.utils.LogUtil; import io.metersphere.track.service.IssuesService; import io.metersphere.track.service.TestPlanTestCaseService; import org.springframework.stereotype.Component; + import javax.annotation.Resource; import java.util.List; @@ -19,17 +24,22 @@ public class IssuesJob { @QuartzScheduled(fixedDelay = 3600 * 1000) //@Scheduled(fixedDelay = 120 * 1000) public void IssuesCount() { - /*int pageSize = 100; - int pages = 0; - Page> page = PageHelper.startPage(pages, pageSize, true); - pages = page.getPages(); - for (int i = 0; i < pages; i++) {*/ - List list = testPlanTestCaseService.listAll(); - list.forEach(l -> { - List issues = issuesService.getIssues(l.getCaseId()); - int issuesCount = issues.size(); - testPlanTestCaseService.updateIssues(issuesCount, l.getPlanId(), l.getCaseId(), issues.toString()); - }); - } + int pageSize = 100; + int pages = 1; + for (int i = 0; i < pages; i++) { + Page> page = PageHelper.startPage(i, pageSize, true); + List list = testPlanTestCaseService.listAll(); + pages = page.getPages();// 替换成真实的值 + list.forEach(l -> { + try { + List issues = issuesService.getIssues(l.getCaseId()); + int issuesCount = issues.size(); + testPlanTestCaseService.updateIssues(issuesCount, l.getPlanId(), l.getCaseId(), issues.toString()); + } catch (Exception e) { + LogUtil.error("定时任务处理bug数量报错planId: " + l.getPlanId(), e); + } + }); + } } +}