From 2846e8461b9b63d4786676f226ae972a5f372312 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Tue, 20 Aug 2024 13:51:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):?= =?UTF-8?q?=20=E5=88=A0=E9=99=A4=E8=AF=84=E5=AE=A1=E5=90=8E=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E8=AF=84=E5=AE=A1=E4=B8=AD=E7=94=A8=E4=BE=8B=E7=9A=84?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../metersphere/service/TestCaseReviewService.java | 5 +++++ .../service/TestReviewTestCaseService.java | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestCaseReviewService.java b/test-track/backend/src/main/java/io/metersphere/service/TestCaseReviewService.java index 2091ae16d7..03d3de2f83 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestCaseReviewService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestCaseReviewService.java @@ -437,6 +437,11 @@ public class TestCaseReviewService { deleteCaseReviewProject(reviewId); deleteCaseReviewUsers(reviewId); deleteCaseReviewFollow(reviewId); + // 批量刷新该评审下用例的评审状态(异步) + TestCaseReviewTestCaseExample example = new TestCaseReviewTestCaseExample(); + example.createCriteria().andReviewIdEqualTo(reviewId); + List testCaseReviewTestCases = testCaseReviewTestCaseMapper.selectByExample(example); + testReviewTestCaseService.refreshReviewCaseStatus(testCaseReviewTestCases); deleteCaseReviewTestCase(reviewId); testCaseReviewMapper.deleteByPrimaryKey(reviewId); } diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java index b1f69a3c27..24fdb4352b 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestReviewTestCaseService.java @@ -34,6 +34,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.SqlSession; import org.springframework.context.annotation.Lazy; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -173,6 +174,15 @@ public class TestReviewTestCaseService { return testCaseReviewTestCaseMapper.updateByExampleSelective(record, example); } + @Async + public void refreshReviewCaseStatus(List testCaseReviewTestCases) { + if (CollectionUtils.isNotEmpty(testCaseReviewTestCases)) { + testCaseReviewTestCases.forEach(testCaseReviewTestCase -> { + rollBackCaseReviewStatus(testCaseReviewTestCase.getCaseId(), testCaseReviewTestCase.getId()); + }); + } + } + private void rollBackCaseReviewStatus(String caseId, String relevanceId) { TestCaseReviewTestCaseExample example = new TestCaseReviewTestCaseExample(); example.createCriteria().andCaseIdEqualTo(caseId); @@ -182,7 +192,7 @@ public class TestReviewTestCaseService { .sorted(Comparator.comparing(TestCaseReviewTestCase::getUpdateTime).reversed()) .map(TestCaseReviewTestCase::getStatus) .toList(); - if (remainReviewCaseStatusOrderByUpdate.size() > 0) { + if (!remainReviewCaseStatusOrderByUpdate.isEmpty()) { // 回退到最近的一次评审状态 String latestStatus = remainReviewCaseStatusOrderByUpdate.get(0); TestCaseWithBLOBs testCase = new TestCaseWithBLOBs();