From 14bd29d33ca373936fe1aacbf73a1f7338aab493 Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 8 Mar 2024 09:25:56 +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=E8=AF=84=E5=AE=A1=E6=89=B9=E9=87=8F=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E5=85=B3=E8=81=94=E7=94=A8=E4=BE=8B=E6=9C=89=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E7=94=A8=E4=BE=8B=E5=85=B3=E8=81=94=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E8=AF=84=E5=AE=A1=E5=AF=BC=E8=87=B4=E7=94=A8=E4=BE=8B=E6=9C=80?= =?UTF-8?q?=E5=90=8E=E7=BB=93=E6=9E=9C=E8=AE=A1=E7=AE=97=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1036899 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001036899 --- .../provider/CaseReviewCaseProvider.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) 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 339608898a..614806b534 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 @@ -128,32 +128,35 @@ public class CaseReviewCaseProvider implements BaseCaseProvider { 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); - } + setUnReviewCase(caseIdList, mapper); } else { + //如果不为空,那就把不为空的设置为上一次的结果,再取caseIdList的id,与map的key的差集,则为要置为未评审的 Map> collect = otherReviewFunctionalCases.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCase::getCaseId)); + ListhasMoreReviewCaseIds = new ArrayList<>(collect.keySet()); + caseIdList.removeAll(hasMoreReviewCaseIds); + if (CollectionUtils.isNotEmpty(caseIdList)) { + setUnReviewCase(caseIdList, mapper); + } collect.forEach((caseId, caseList) -> { - if (!caseIdList.contains(caseId)) { - FunctionalCase functionalCase = new FunctionalCase(); - functionalCase.setId(caseId); - functionalCase.setReviewStatus(FunctionalCaseReviewStatus.UN_REVIEWED.toString()); - mapper.updateByPrimaryKeySelective(functionalCase); - } else { - FunctionalCase functionalCase = new FunctionalCase(); - functionalCase.setId(caseId); - functionalCase.setReviewStatus(caseList.get(0).getStatus()); - mapper.updateByPrimaryKeySelective(functionalCase); - } + FunctionalCase functionalCase = new FunctionalCase(); + functionalCase.setId(caseId); + functionalCase.setReviewStatus(caseList.get(0).getStatus()); + mapper.updateByPrimaryKeySelective(functionalCase); }); } sqlSession.flushStatements(); SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory); } + private static void setUnReviewCase(List caseIdList, FunctionalCaseMapper mapper) { + for (String id : caseIdList) { + FunctionalCase functionalCase = new FunctionalCase(); + functionalCase.setId(id); + functionalCase.setReviewStatus(FunctionalCaseReviewStatus.UN_REVIEWED.toString()); + mapper.updateByPrimaryKeySelective(functionalCase); + } + } + /** * 3.功能用例的删除/批量删除重新计算用例评审的通过率和用例数 */