From 4062a01c3ace4eaedca616b1288388ed90c5aabb Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 20 Feb 2024 11:41:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=94=A8=E4=BE=8B=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=96=E6=B6=88=E5=85=B3=E8=81=94=E6=97=B6?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E7=9A=84=E8=AF=84=E5=AE=A1=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E5=AF=B9=E5=BA=94=E6=94=B9=E5=8F=98=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1035848 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001035848 --- .../provider/CaseReviewCaseProvider.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/provider/CaseReviewCaseProvider.java b/backend/services/case-management/src/main/java/io/metersphere/functional/provider/CaseReviewCaseProvider.java index 1897c8926a..366ee48a0e 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/provider/CaseReviewCaseProvider.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/provider/CaseReviewCaseProvider.java @@ -113,11 +113,40 @@ public class CaseReviewCaseProvider implements BaseCaseProvider { deleteCaseReviewFunctionalCaseUser(paramMap); //将评审历史状态置为true extCaseReviewHistoryMapper.updateDelete(caseIdList, reviewId, true); + //检查更新用例的评审状态。如果用例没有任何评审关联,就置为未评审, 否则置为更新建时间最晚的那个 + updateCaseStatus(caseIdList); } catch (Exception e) { LogUtils.error(CaseEvent.Event.DISASSOCIATE + "事件更新失败", e.getMessage()); } } + private void updateCaseStatus(List caseIdList) { + CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); + caseReviewFunctionalCaseExample.createCriteria().andCaseIdIn(caseIdList); + caseReviewFunctionalCaseExample.setOrderByClause("update_time DESC"); + List otherReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); + SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH); + FunctionalCaseMapper mapper = sqlSession.getMapper(FunctionalCaseMapper.class); + if (CollectionUtils.isEmpty(otherReviewFunctionalCases)) { + for (String id : caseIdList) { + FunctionalCase functionalCase = new FunctionalCase(); + functionalCase.setId(id); + functionalCase.setReviewStatus(FunctionalCaseReviewStatus.UN_REVIEWED.toString()); + mapper.updateByPrimaryKeySelective(functionalCase); + } + } else { + Map> collect = otherReviewFunctionalCases.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCase::getCaseId)); + collect.forEach((caseId,caseList)->{ + FunctionalCase functionalCase = new FunctionalCase(); + functionalCase.setId(caseId); + functionalCase.setReviewStatus(caseList.get(0).getStatus()); + mapper.updateByPrimaryKeySelective(functionalCase); + }); + } + sqlSession.flushStatements(); + SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); + } + /** * 3.功能用例的删除/批量删除重新计算用例评审的通过率和用例数 */