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 abb9c6e564..b0503976c3 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 @@ -6,6 +6,7 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.functional.domain.CaseReviewFunctionalCaseUser; import io.metersphere.functional.dto.ReviewFunctionalCaseDTO; +import io.metersphere.functional.dto.ReviewerAndStatusDTO; import io.metersphere.functional.request.*; import io.metersphere.functional.service.CaseReviewFunctionalCaseService; import io.metersphere.functional.service.CaseReviewLogService; @@ -147,4 +148,15 @@ public class CaseReviewFunctionalCaseController { return caseReviewFunctionalCaseService.getReviewerList(reviewId, caseId); } + + @GetMapping("/reviewer/status/total/{reviewId}/{caseId}") + @Operation(summary = "用例管理-用例评审-评审列表-评审详情-评审总结过结果和每个评审人最后结果气泡数据") + @RequiresPermissions(PermissionConstants.CASE_REVIEW_READ) + @CheckOwner(resourceId = "#reviewId", resourceType = "case_review") + public ReviewerAndStatusDTO getUserAndStatus(@Schema(description = "评审id", requiredMode = Schema.RequiredMode.REQUIRED) + @PathVariable("reviewId") String reviewId, @Schema(description = "用例id", requiredMode = Schema.RequiredMode.REQUIRED) + @PathVariable("caseId") String caseId) { + return caseReviewFunctionalCaseService.getUserAndStatus(reviewId, caseId); + } + } diff --git a/backend/services/case-management/src/main/java/io/metersphere/functional/dto/ReviewerAndStatusDTO.java b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/ReviewerAndStatusDTO.java new file mode 100644 index 0000000000..a416ff1f56 --- /dev/null +++ b/backend/services/case-management/src/main/java/io/metersphere/functional/dto/ReviewerAndStatusDTO.java @@ -0,0 +1,25 @@ +package io.metersphere.functional.dto; + +import io.metersphere.system.dto.sdk.OptionDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +@Data +public class ReviewerAndStatusDTO implements Serializable { + @Serial + private static final long serialVersionUID = 1L; + + @Schema(description = "用例id") + private String caseId; + + @Schema(description = "用例评审最终结果") + private String status; + + @Schema(description = "每个评审人最终的评审结果") + private ListreviewerStatus; + +} 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 e604de15b7..d68e1eaa96 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 @@ -26,11 +26,10 @@ import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.LogUtils; import io.metersphere.sdk.util.Translator; -import io.metersphere.system.domain.CustomFieldOption; -import io.metersphere.system.domain.UserRoleRelation; -import io.metersphere.system.domain.UserRoleRelationExample; +import io.metersphere.system.domain.*; import io.metersphere.system.dto.sdk.BaseTreeNode; import io.metersphere.system.dto.sdk.OptionDTO; +import io.metersphere.system.mapper.UserMapper; import io.metersphere.system.mapper.UserRoleRelationMapper; import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.service.BaseCustomFieldOptionService; @@ -110,6 +109,8 @@ public class CaseReviewFunctionalCaseService { private BaseCustomFieldService baseCustomFieldService; @Resource private BaseCustomFieldOptionService baseCustomFieldOptionService; + @Resource + private UserMapper userMapper; private static final String CASE_MODULE_COUNT_ALL = "all"; @@ -802,12 +803,28 @@ public class CaseReviewFunctionalCaseService { List list = extCaseReviewHistoryMapper.list(caseId, reviewId); Map> collect = list.stream().sorted(Comparator.comparingLong(CaseReviewHistoryDTO::getCreateTime).reversed()).collect(Collectors.groupingBy(CaseReviewHistoryDTO::getCreateUser, Collectors.toList())); List optionDTOS = new ArrayList<>(); + List reviewerList = getReviewerList(reviewId, caseId); + List reviewerIds = reviewerList.stream().map(CaseReviewFunctionalCaseUser::getUserId).filter(t -> !collect.containsKey(t)).collect(Collectors.toList()); + List users = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(reviewerIds)) { + UserExample userExample = new UserExample(); + userExample.createCriteria().andIdIn(reviewerIds); + users = userMapper.selectByExample(userExample); + } collect.forEach((k, v) -> { OptionDTO optionDTO = new OptionDTO(); optionDTO.setId(v.getFirst().getUserName()); optionDTO.setName(v.getFirst().getStatus()); optionDTOS.add(optionDTO); }); + if (CollectionUtils.isNotEmpty(users)) { + users.forEach(t->{ + OptionDTO optionDTO = new OptionDTO(); + optionDTO.setId(t.getName()); + optionDTO.setName(FunctionalCaseReviewStatus.UN_REVIEWED.toString()); + optionDTOS.add(optionDTO); + }); + } return optionDTOS; } @@ -861,4 +878,16 @@ public class CaseReviewFunctionalCaseService { caseReviewFunctionalCaseUserExample.createCriteria().andCaseIdEqualTo(caseId).andReviewIdEqualTo(reviewId); return caseReviewFunctionalCaseUserMapper.selectByExample(caseReviewFunctionalCaseUserExample); } + + public ReviewerAndStatusDTO getUserAndStatus(String reviewId, String caseId) { + ReviewerAndStatusDTO reviewerAndStatusDTO = new ReviewerAndStatusDTO(); + CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample(); + caseReviewFunctionalCaseExample.createCriteria().andReviewIdEqualTo(reviewId).andCaseIdEqualTo(caseId); + List caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample); + reviewerAndStatusDTO.setCaseId(caseId); + reviewerAndStatusDTO.setStatus(caseReviewFunctionalCases.get(0).getStatus()); + List userStatus = getUserStatus(reviewId, caseId); + reviewerAndStatusDTO.setReviewerStatus(userStatus); + return reviewerAndStatusDTO; + } } \ No newline at end of file diff --git a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseControllerTests.java b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseControllerTests.java index 04ea454c84..be6ae65eb1 100644 --- a/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseControllerTests.java +++ b/backend/services/case-management/src/test/java/io/metersphere/functional/controller/CaseReviewFunctionalCaseControllerTests.java @@ -4,6 +4,7 @@ import io.metersphere.functional.constants.CaseReviewPassRule; import io.metersphere.functional.constants.FunctionalCaseReviewStatus; import io.metersphere.functional.domain.*; import io.metersphere.functional.dto.ReviewFunctionalCaseDTO; +import io.metersphere.functional.dto.ReviewerAndStatusDTO; import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper; import io.metersphere.functional.mapper.CaseReviewHistoryMapper; import io.metersphere.functional.request.*; @@ -61,6 +62,9 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest { public static final String GET_CASE_REVIEWER_LIST = "/case/review/detail/reviewer/list"; + public static final String GET_CASE_REVIEWER_AND_STATUS = "/case/review/detail/reviewer/status/total/"; + + @Resource private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper; @Resource @@ -574,6 +578,23 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest { Assertions.assertTrue(CollectionUtils.isNotEmpty(optionDTOS)); } + @Test + @Order(14) + public void getReviewerWidthTotalList() throws Exception { + MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get(GET_CASE_REVIEWER_AND_STATUS + "/wx_review_id_1/gyq_case_id_5").header(SessionConstants.HEADER_TOKEN, sessionId) + .header(SessionConstants.CSRF_TOKEN, csrfToken) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)).andReturn(); + String returnData = result.getResponse().getContentAsString(StandardCharsets.UTF_8); + ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class); + ReviewerAndStatusDTO reviewerAndStatusDTO = JSON.parseObject(JSON.toJSONString(resultHolder.getData()), ReviewerAndStatusDTO.class); + System.out.println(reviewerAndStatusDTO); + Assertions.assertTrue(CollectionUtils.isNotEmpty(reviewerAndStatusDTO.getReviewerStatus())); + } + + + private List getOptionDTOS(String reviewId, String caseId) throws Exception { MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get(REVIEW_FUNCTIONAL_CASE_REVIEWER_STATUS + "/" + reviewId + "/" + caseId).header(SessionConstants.HEADER_TOKEN, sessionId) .header(SessionConstants.CSRF_TOKEN, csrfToken)