feat(功能用例): 新增评审脑图获取总结果和每个评审人的最后结果接口

This commit is contained in:
guoyuqi 2024-07-12 15:46:06 +08:00 committed by 刘瑞斌
parent 675a86226f
commit 551f88546a
4 changed files with 90 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import io.metersphere.functional.domain.CaseReviewFunctionalCaseUser; import io.metersphere.functional.domain.CaseReviewFunctionalCaseUser;
import io.metersphere.functional.dto.ReviewFunctionalCaseDTO; import io.metersphere.functional.dto.ReviewFunctionalCaseDTO;
import io.metersphere.functional.dto.ReviewerAndStatusDTO;
import io.metersphere.functional.request.*; import io.metersphere.functional.request.*;
import io.metersphere.functional.service.CaseReviewFunctionalCaseService; import io.metersphere.functional.service.CaseReviewFunctionalCaseService;
import io.metersphere.functional.service.CaseReviewLogService; import io.metersphere.functional.service.CaseReviewLogService;
@ -147,4 +148,15 @@ public class CaseReviewFunctionalCaseController {
return caseReviewFunctionalCaseService.getReviewerList(reviewId, caseId); 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);
}
} }

View File

@ -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 List<OptionDTO>reviewerStatus;
}

View File

@ -26,11 +26,10 @@ import io.metersphere.sdk.exception.MSException;
import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.BeanUtils;
import io.metersphere.sdk.util.LogUtils; import io.metersphere.sdk.util.LogUtils;
import io.metersphere.sdk.util.Translator; import io.metersphere.sdk.util.Translator;
import io.metersphere.system.domain.CustomFieldOption; import io.metersphere.system.domain.*;
import io.metersphere.system.domain.UserRoleRelation;
import io.metersphere.system.domain.UserRoleRelationExample;
import io.metersphere.system.dto.sdk.BaseTreeNode; import io.metersphere.system.dto.sdk.BaseTreeNode;
import io.metersphere.system.dto.sdk.OptionDTO; import io.metersphere.system.dto.sdk.OptionDTO;
import io.metersphere.system.mapper.UserMapper;
import io.metersphere.system.mapper.UserRoleRelationMapper; import io.metersphere.system.mapper.UserRoleRelationMapper;
import io.metersphere.system.notice.constants.NoticeConstants; import io.metersphere.system.notice.constants.NoticeConstants;
import io.metersphere.system.service.BaseCustomFieldOptionService; import io.metersphere.system.service.BaseCustomFieldOptionService;
@ -110,6 +109,8 @@ public class CaseReviewFunctionalCaseService {
private BaseCustomFieldService baseCustomFieldService; private BaseCustomFieldService baseCustomFieldService;
@Resource @Resource
private BaseCustomFieldOptionService baseCustomFieldOptionService; private BaseCustomFieldOptionService baseCustomFieldOptionService;
@Resource
private UserMapper userMapper;
private static final String CASE_MODULE_COUNT_ALL = "all"; private static final String CASE_MODULE_COUNT_ALL = "all";
@ -802,12 +803,28 @@ public class CaseReviewFunctionalCaseService {
List<CaseReviewHistoryDTO> list = extCaseReviewHistoryMapper.list(caseId, reviewId); List<CaseReviewHistoryDTO> list = extCaseReviewHistoryMapper.list(caseId, reviewId);
Map<String, List<CaseReviewHistoryDTO>> collect = list.stream().sorted(Comparator.comparingLong(CaseReviewHistoryDTO::getCreateTime).reversed()).collect(Collectors.groupingBy(CaseReviewHistoryDTO::getCreateUser, Collectors.toList())); Map<String, List<CaseReviewHistoryDTO>> collect = list.stream().sorted(Comparator.comparingLong(CaseReviewHistoryDTO::getCreateTime).reversed()).collect(Collectors.groupingBy(CaseReviewHistoryDTO::getCreateUser, Collectors.toList()));
List<OptionDTO> optionDTOS = new ArrayList<>(); List<OptionDTO> optionDTOS = new ArrayList<>();
List<CaseReviewFunctionalCaseUser> reviewerList = getReviewerList(reviewId, caseId);
List<String> reviewerIds = reviewerList.stream().map(CaseReviewFunctionalCaseUser::getUserId).filter(t -> !collect.containsKey(t)).collect(Collectors.toList());
List<User> users = new ArrayList<>();
if (CollectionUtils.isNotEmpty(reviewerIds)) {
UserExample userExample = new UserExample();
userExample.createCriteria().andIdIn(reviewerIds);
users = userMapper.selectByExample(userExample);
}
collect.forEach((k, v) -> { collect.forEach((k, v) -> {
OptionDTO optionDTO = new OptionDTO(); OptionDTO optionDTO = new OptionDTO();
optionDTO.setId(v.getFirst().getUserName()); optionDTO.setId(v.getFirst().getUserName());
optionDTO.setName(v.getFirst().getStatus()); optionDTO.setName(v.getFirst().getStatus());
optionDTOS.add(optionDTO); 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; return optionDTOS;
} }
@ -861,4 +878,16 @@ public class CaseReviewFunctionalCaseService {
caseReviewFunctionalCaseUserExample.createCriteria().andCaseIdEqualTo(caseId).andReviewIdEqualTo(reviewId); caseReviewFunctionalCaseUserExample.createCriteria().andCaseIdEqualTo(caseId).andReviewIdEqualTo(reviewId);
return caseReviewFunctionalCaseUserMapper.selectByExample(caseReviewFunctionalCaseUserExample); 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<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
reviewerAndStatusDTO.setCaseId(caseId);
reviewerAndStatusDTO.setStatus(caseReviewFunctionalCases.get(0).getStatus());
List<OptionDTO> userStatus = getUserStatus(reviewId, caseId);
reviewerAndStatusDTO.setReviewerStatus(userStatus);
return reviewerAndStatusDTO;
}
} }

View File

@ -4,6 +4,7 @@ import io.metersphere.functional.constants.CaseReviewPassRule;
import io.metersphere.functional.constants.FunctionalCaseReviewStatus; import io.metersphere.functional.constants.FunctionalCaseReviewStatus;
import io.metersphere.functional.domain.*; import io.metersphere.functional.domain.*;
import io.metersphere.functional.dto.ReviewFunctionalCaseDTO; import io.metersphere.functional.dto.ReviewFunctionalCaseDTO;
import io.metersphere.functional.dto.ReviewerAndStatusDTO;
import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper; import io.metersphere.functional.mapper.CaseReviewFunctionalCaseMapper;
import io.metersphere.functional.mapper.CaseReviewHistoryMapper; import io.metersphere.functional.mapper.CaseReviewHistoryMapper;
import io.metersphere.functional.request.*; 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_LIST = "/case/review/detail/reviewer/list";
public static final String GET_CASE_REVIEWER_AND_STATUS = "/case/review/detail/reviewer/status/total/";
@Resource @Resource
private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper; private CaseReviewFunctionalCaseMapper caseReviewFunctionalCaseMapper;
@Resource @Resource
@ -574,6 +578,23 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
Assertions.assertTrue(CollectionUtils.isNotEmpty(optionDTOS)); 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<OptionDTO> getOptionDTOS(String reviewId, String caseId) throws Exception { private List<OptionDTO> 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) MvcResult result = mockMvc.perform(MockMvcRequestBuilders.get(REVIEW_FUNCTIONAL_CASE_REVIEWER_STATUS + "/" + reviewId + "/" + caseId).header(SessionConstants.HEADER_TOKEN, sessionId)
.header(SessionConstants.CSRF_TOKEN, csrfToken) .header(SessionConstants.CSRF_TOKEN, csrfToken)