fix(用例管理): 修复用例评审详情,我的评审状态结果显示不正确问题

--bug=1035883 --user=王旭 【用例评审】通过标准为多人通过的评审,用例详情页面我的评审状态开启后,用例的评审状态显示错误 https://www.tapd.cn/55049933/s/1463232
This commit is contained in:
WangXu10 2024-02-21 13:53:43 +08:00 committed by 刘瑞斌
parent 538865fd5a
commit 39101f399a
3 changed files with 28 additions and 26 deletions

View File

@ -57,8 +57,13 @@ public class CaseReviewFunctionalCaseController {
if (request.isViewFlag()) {
userId = SessionUtils.getUserId();
}
String viewStatusUserId = StringUtils.EMPTY;
if (request.isViewStatusFlag()) {
viewStatusUserId = SessionUtils.getUserId();
}
Page<Object> 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<OptionDTO> 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<OptionDTO> 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);
}

View File

@ -122,12 +122,12 @@ public class CaseReviewFunctionalCaseService {
* @param deleted deleted
* @return ReviewFunctionalCaseDTO
*/
public List<ReviewFunctionalCaseDTO> page(ReviewFunctionalCasePageRequest request, boolean deleted, String userId) {
public List<ReviewFunctionalCaseDTO> page(ReviewFunctionalCasePageRequest request, boolean deleted, String userId, String viewStatusUserId) {
List<ReviewFunctionalCaseDTO> list = extCaseReviewFunctionalCaseMapper.page(request, deleted, userId, request.getSortString());
return doHandleDTO(list, request, userId);
return doHandleDTO(list, request, viewStatusUserId);
}
private List<ReviewFunctionalCaseDTO> doHandleDTO(List<ReviewFunctionalCaseDTO> list, ReviewFunctionalCasePageRequest request, String userId) {
private List<ReviewFunctionalCaseDTO> doHandleDTO(List<ReviewFunctionalCaseDTO> list, ReviewFunctionalCasePageRequest request, String viewStatusUserId) {
if (CollectionUtils.isNotEmpty(list)) {
List<String> moduleIds = list.stream().map(ReviewFunctionalCaseDTO::getModuleId).toList();
List<BaseTreeNode> modules = extFunctionalCaseModuleMapper.selectBaseByIds(moduleIds);
@ -143,18 +143,12 @@ public class CaseReviewFunctionalCaseService {
Map<String, String> userNameMap = reviewers.stream().collect(Collectors.toMap(ReviewsDTO::getCaseId, ReviewsDTO::getUserNames));
LinkedHashMap<String, List<CaseReviewHistory>> caseStatusMap;
LinkedHashMap<String, List<CaseReviewHistory>> caseUserMap;
if (request.isViewStatusFlag()) {
List<CaseReviewHistory> 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<CaseReviewHistory> userHistory = caseUserMap.get(userId);
list.forEach(item -> {
item.setModuleName(moduleMap.get(item.getModuleId()));
@ -165,7 +159,7 @@ public class CaseReviewFunctionalCaseService {
if (request.isViewStatusFlag()) {
List<CaseReviewHistory> 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<CaseReviewHistory> histories, List<CaseReviewHistory> userHistory) {
if (CollectionUtils.isNotEmpty(userHistory)) {
//当前用户存在评审记录
return userHistory.get(0).getStatus();
private String getMyStatus(List<CaseReviewHistory> histories, String viewStatusUserId) {
List<CaseReviewHistory> list = histories.stream().filter(history -> StringUtils.equalsIgnoreCase(history.getCreateUser(), viewStatusUserId)).toList();
if (CollectionUtils.isNotEmpty(list)) {
return list.get(0).getStatus();
}
//重新提审记录
List<CaseReviewHistory> reReviewed = histories.stream().filter(history -> StringUtils.equalsIgnoreCase(history.getStatus(), FunctionalCaseReviewStatus.RE_REVIEWED.name())).toList();
if (CollectionUtils.isNotEmpty(reReviewed)) {

View File

@ -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<String, List<FunctionalCasePageDTO>> moduleCaseMap, BaseTreeNode t, List<FunctionalMinderTreeDTO> 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<ReviewFunctionalCaseDTO> page = caseReviewFunctionalCaseService.page(request, deleted, userId);
List<ReviewFunctionalCaseDTO> page = caseReviewFunctionalCaseService.page(request, deleted, userId, null);
List<String> caseIds = page.stream().map(ReviewFunctionalCaseDTO::getCaseId).toList();
List<String> moduleIds = page.stream().map(ReviewFunctionalCaseDTO::getModuleId).toList();
List<BaseTreeNode> baseTreeNodes = getBaseTreeNodes(moduleIds);
@ -178,7 +180,7 @@ public class FunctionalCaseMinderService {
}
private List<FunctionalMinderTreeDTO> buildReviewCaseTree(MinderSearchDTO minderSearchDTO) {
private List<FunctionalMinderTreeDTO> buildReviewCaseTree(MinderSearchDTO minderSearchDTO) {
List<FunctionalMinderTreeDTO> functionalMinderTreeNodeDTOs = new ArrayList<>();
minderSearchDTO.getBaseTreeNodes().forEach(t -> {
//构建根节点
@ -201,7 +203,7 @@ public class FunctionalCaseMinderService {
private void buildReviewModuleChild(MinderSearchDTO minderSearchDTO, List<FunctionalMinderTreeDTO> children) {
List<BaseTreeNode> 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()));