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