From 39101f399ac797ef95cdb00f8c120d9611a86650 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Wed, 21 Feb 2024 13:53:43 +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=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1=E8=AF=A6?= =?UTF-8?q?=E6=83=85=EF=BC=8C=E6=88=91=E7=9A=84=E8=AF=84=E5=AE=A1=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=BB=93=E6=9E=9C=E6=98=BE=E7=A4=BA=E4=B8=8D=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1035883 --user=王旭 【用例评审】通过标准为多人通过的评审,用例详情页面我的评审状态开启后,用例的评审状态显示错误 https://www.tapd.cn/55049933/s/1463232 --- .../CaseReviewFunctionalCaseController.java | 13 +++++++---- .../CaseReviewFunctionalCaseService.java | 23 ++++++++----------- .../service/FunctionalCaseMinderService.java | 18 ++++++++------- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseController.java b/backend/services/case-management/src/main/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseController.java index 335d93d994..9b7ec7dd70 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseController.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseController.java @@ -57,8 +57,13 @@ public class CaseReviewFunctionalCaseController { if (request.isViewFlag()) { userId = SessionUtils.getUserId(); } + String viewStatusUserId = StringUtils.EMPTY; + if (request.isViewStatusFlag()) { + viewStatusUserId = SessionUtils.getUserId(); + } + Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize()); - return PageUtils.setPageInfo(page, caseReviewFunctionalCaseService.page(request, false, userId)); + return PageUtils.setPageInfo(page, caseReviewFunctionalCaseService.page(request, false, userId, viewStatusUserId)); } @@ -122,9 +127,9 @@ public class CaseReviewFunctionalCaseController { @Operation(summary = "用例管理-用例评审-评审列表-评审详情-评审结果的气泡数据") @RequiresPermissions(PermissionConstants.CASE_REVIEW_READ) @CheckOwner(resourceId = "#projectId", resourceType = "project") - public List getUserStatus(@Schema(description = "评审id", requiredMode = Schema.RequiredMode.REQUIRED) - @PathVariable("reviewId") String reviewId, @Schema(description = "用例id", requiredMode = Schema.RequiredMode.REQUIRED) - @PathVariable("caseId") String caseId) { + public List getUserStatus(@Schema(description = "评审id", requiredMode = Schema.RequiredMode.REQUIRED) + @PathVariable("reviewId") String reviewId, @Schema(description = "用例id", requiredMode = Schema.RequiredMode.REQUIRED) + @PathVariable("caseId") String caseId) { return caseReviewFunctionalCaseService.getUserStatus(reviewId, caseId); } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewFunctionalCaseService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewFunctionalCaseService.java index 6c0f2bfcc9..37c3e861cd 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewFunctionalCaseService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/CaseReviewFunctionalCaseService.java @@ -122,12 +122,12 @@ public class CaseReviewFunctionalCaseService { * @param deleted deleted * @return ReviewFunctionalCaseDTO */ - public List page(ReviewFunctionalCasePageRequest request, boolean deleted, String userId) { + public List page(ReviewFunctionalCasePageRequest request, boolean deleted, String userId, String viewStatusUserId) { List list = extCaseReviewFunctionalCaseMapper.page(request, deleted, userId, request.getSortString()); - return doHandleDTO(list, request, userId); + return doHandleDTO(list, request, viewStatusUserId); } - private List doHandleDTO(List list, ReviewFunctionalCasePageRequest request, String userId) { + private List doHandleDTO(List list, ReviewFunctionalCasePageRequest request, String viewStatusUserId) { if (CollectionUtils.isNotEmpty(list)) { List moduleIds = list.stream().map(ReviewFunctionalCaseDTO::getModuleId).toList(); List modules = extFunctionalCaseModuleMapper.selectBaseByIds(moduleIds); @@ -143,18 +143,12 @@ public class CaseReviewFunctionalCaseService { Map userNameMap = reviewers.stream().collect(Collectors.toMap(ReviewsDTO::getCaseId, ReviewsDTO::getUserNames)); LinkedHashMap> caseStatusMap; - LinkedHashMap> caseUserMap; if (request.isViewStatusFlag()) { List histories = extCaseReviewHistoryMapper.getReviewHistoryStatus(caseIds, request.getReviewId()); caseStatusMap = histories.stream().collect(Collectors.groupingBy(CaseReviewHistory::getCaseId, LinkedHashMap::new, Collectors.toList())); - caseUserMap = histories.stream().collect(Collectors.groupingBy(CaseReviewHistory::getCreateUser, LinkedHashMap::new, Collectors.toList())); } else { caseStatusMap = new LinkedHashMap<>(); - caseUserMap = new LinkedHashMap<>(); - } - //当前用户的评审历史 - List userHistory = caseUserMap.get(userId); list.forEach(item -> { item.setModuleName(moduleMap.get(item.getModuleId())); @@ -165,7 +159,7 @@ public class CaseReviewFunctionalCaseService { if (request.isViewStatusFlag()) { List histories = caseStatusMap.get(item.getCaseId()); if (CollectionUtils.isNotEmpty(histories)) { - item.setMyStatus(getMyStatus(histories, userHistory)); + item.setMyStatus(getMyStatus(histories, viewStatusUserId)); } else { //不存在评审历史 item.setMyStatus(FunctionalCaseReviewStatus.UNDER_REVIEWED.name()); @@ -176,11 +170,12 @@ public class CaseReviewFunctionalCaseService { return list; } - private String getMyStatus(List histories, List userHistory) { - if (CollectionUtils.isNotEmpty(userHistory)) { - //当前用户存在评审记录 - return userHistory.get(0).getStatus(); + private String getMyStatus(List histories, String viewStatusUserId) { + List list = histories.stream().filter(history -> StringUtils.equalsIgnoreCase(history.getCreateUser(), viewStatusUserId)).toList(); + if (CollectionUtils.isNotEmpty(list)) { + return list.get(0).getStatus(); } + //重新提审记录 List reReviewed = histories.stream().filter(history -> StringUtils.equalsIgnoreCase(history.getStatus(), FunctionalCaseReviewStatus.RE_REVIEWED.name())).toList(); if (CollectionUtils.isNotEmpty(reReviewed)) { diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java index be688cd01d..0be1d46a82 100644 --- a/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/service/FunctionalCaseMinderService.java @@ -43,6 +43,7 @@ public class FunctionalCaseMinderService { /** * 功能用例-脑图用例列表查询 + * * @param request FunctionalCasePageRequest * @param deleted 用例是否删除 * @return FunctionalMinderTreeDTO @@ -91,7 +92,7 @@ public class FunctionalCaseMinderService { //如果当前节点有用例,则用例是他的子节点 buildCaseChild(moduleCaseMap, t, children); //查询当前节点下的子模块节点 - buildModuleChild(moduleCaseMap,t, children); + buildModuleChild(moduleCaseMap, t, children); functionalMinderTreeDTO.setChildren(children); functionalMinderTreeNodeDTOs.add(functionalMinderTreeDTO); }); @@ -130,7 +131,7 @@ public class FunctionalCaseMinderService { private static void buildModuleChild(Map> moduleCaseMap, BaseTreeNode t, List children) { if (CollectionUtils.isNotEmpty(t.getChildren())) { - t.getChildren().forEach(child->{ + t.getChildren().forEach(child -> { FunctionalMinderTreeDTO functionalMinderTreeDTOChild = new FunctionalMinderTreeDTO(); FunctionalMinderTreeNodeDTO functionalMinderTreeNodeDTOChild = getFunctionalMinderTreeNodeDTO(child); functionalMinderTreeDTOChild.setData(functionalMinderTreeNodeDTOChild); @@ -139,7 +140,7 @@ public class FunctionalCaseMinderService { buildCaseChild(moduleCaseMap, child, childChildren); functionalMinderTreeDTOChild.setChildren(childChildren); children.add(functionalMinderTreeDTOChild); - buildModuleChild(moduleCaseMap,child, childChildren); + buildModuleChild(moduleCaseMap, child, childChildren); }); } @@ -147,14 +148,15 @@ public class FunctionalCaseMinderService { /** * 用例评审-脑图用例列表查询 + * * @param request MinderReviewFunctionalCasePageRequest * @param deleted 用例是否删除 - * @param userId userId 只看我的 + * @param userId userId 只看我的 * @return FunctionalMinderTreeDTO */ public FunctionalMinderTreeDTO getReviewFunctionalCasePage(MinderReviewFunctionalCasePageRequest request, boolean deleted, String userId) { CaseReview caseReview = caseReviewMapper.selectByPrimaryKey(request.getReviewId()); - List page = caseReviewFunctionalCaseService.page(request, deleted, userId); + List page = caseReviewFunctionalCaseService.page(request, deleted, userId, null); List caseIds = page.stream().map(ReviewFunctionalCaseDTO::getCaseId).toList(); List moduleIds = page.stream().map(ReviewFunctionalCaseDTO::getModuleId).toList(); List baseTreeNodes = getBaseTreeNodes(moduleIds); @@ -178,7 +180,7 @@ public class FunctionalCaseMinderService { } - private List buildReviewCaseTree(MinderSearchDTO minderSearchDTO) { + private List buildReviewCaseTree(MinderSearchDTO minderSearchDTO) { List functionalMinderTreeNodeDTOs = new ArrayList<>(); minderSearchDTO.getBaseTreeNodes().forEach(t -> { //构建根节点 @@ -201,7 +203,7 @@ public class FunctionalCaseMinderService { private void buildReviewModuleChild(MinderSearchDTO minderSearchDTO, List children) { List baseTreeNodes = minderSearchDTO.getBaseTreeNode().getChildren(); if (CollectionUtils.isNotEmpty(baseTreeNodes)) { - baseTreeNodes.forEach(child->{ + baseTreeNodes.forEach(child -> { FunctionalMinderTreeDTO functionalMinderTreeDTOChild = new FunctionalMinderTreeDTO(); FunctionalMinderTreeNodeDTO functionalMinderTreeNodeDTOChild = getFunctionalMinderTreeNodeDTO(child); functionalMinderTreeDTOChild.setData(functionalMinderTreeNodeDTOChild); @@ -234,7 +236,7 @@ public class FunctionalCaseMinderService { functionalMinderTreeNodeChild.setPriority(list.get(0).getDefaultValue()); } } - if (minderSearchDTO.isViewFlag()&& minderSearchDTO.isViewResult() && StringUtils.equalsIgnoreCase(minderSearchDTO.getReviewPassRule(), CaseReviewPassRule.MULTIPLE.toString()) ) { + if (minderSearchDTO.isViewFlag() && minderSearchDTO.isViewResult() && StringUtils.equalsIgnoreCase(minderSearchDTO.getReviewPassRule(), CaseReviewPassRule.MULTIPLE.toString())) { functionalMinderTreeNodeChild.setStatus(reviewFunctionalCaseDTO.getStatus()); } functionalMinderTreeNodeChild.setResource(List.of(MinderLabel.CASE.toString()));