feat(功能用例): 修改用例触发重新提审&评审创建用例-更新评审状态

This commit is contained in:
WangXu10 2024-01-25 17:42:05 +08:00 committed by 刘瑞斌
parent 797929cea4
commit 43f8bfd268
6 changed files with 75 additions and 22 deletions

View File

@ -84,7 +84,8 @@ public class CaseReviewFunctionalCaseService {
private FunctionalCaseModuleService functionalCaseModuleService;
@Resource
private ExtCaseReviewHistoryMapper extCaseReviewHistoryMapper;
@Resource
private CaseReviewUserMapper caseReviewUserMapper;
private static final String CASE_MODULE_COUNT_ALL = "all";
@ -157,7 +158,6 @@ public class CaseReviewFunctionalCaseService {
}
public List<String> doSelectIds(BaseReviewCaseBatchRequest request) {
if (request.isSelectAll()) {
List<String> ids = extCaseReviewFunctionalCaseMapper.getIds(request, request.getUserId(), false);
@ -200,13 +200,41 @@ public class CaseReviewFunctionalCaseService {
reviewFunctionalCase.setPos(caseReviewService.getCaseFunctionalCaseNextPos(reviewId));
caseReviewFunctionalCaseMapper.insertSelective(reviewFunctionalCase);
//评审人
CaseReviewUserExample caseReviewUserExample = new CaseReviewUserExample();
caseReviewUserExample.createCriteria().andReviewIdEqualTo(reviewId);
List<CaseReviewUser> caseReviewUsers = caseReviewUserMapper.selectByExample(caseReviewUserExample);
if (CollectionUtils.isNotEmpty(caseReviewUsers)) {
List<CaseReviewFunctionalCaseUser> list = new ArrayList<>();
caseReviewUsers.forEach(item -> {
CaseReviewFunctionalCaseUser caseUser = new CaseReviewFunctionalCaseUser();
caseUser.setCaseId(caseId);
caseUser.setReviewId(reviewId);
caseUser.setUserId(item.getUserId());
list.add(caseUser);
});
caseReviewFunctionalCaseUserMapper.batchInsert(list);
//更新评审的整体状态
Map<String, Integer> countMap = new HashMap<>();
countMap.put(reviewFunctionalCase.getStatus(), 1);
Map<String, String> statusMap = new HashMap<>();
statusMap.put(caseId, reviewFunctionalCase.getStatus());
Map<String, Object> param = new HashMap<>();
param.put(CaseEvent.Param.REVIEW_ID, reviewId);
param.put(CaseEvent.Param.USER_ID, userId);
param.put(CaseEvent.Param.CASE_IDS, List.of(caseId));
param.put(CaseEvent.Param.COUNT_MAP, countMap);
param.put(CaseEvent.Param.STATUS_MAP, statusMap);
param.put(CaseEvent.Param.EVENT_NAME, CaseEvent.Event.REVIEW_FUNCTIONAL_CASE);
provider.updateCaseReview(param);
}
}
/**
* 用例更新 更新状态为重新评审
*/
public void reReviewedCase(FunctionalCaseEditRequest request, FunctionalCaseBlob blob, String name) {
public void reReviewedCase(FunctionalCaseEditRequest request, FunctionalCaseBlob blob, String name, String userId) {
ProjectApplicationExample example = new ProjectApplicationExample();
example.createCriteria().andProjectIdEqualTo(request.getProjectId()).andTypeEqualTo(ProjectApplicationType.CASE.CASE_RE_REVIEW.name());
List<ProjectApplication> projectApplications = projectApplicationMapper.selectByExample(example);
@ -215,12 +243,12 @@ public class CaseReviewFunctionalCaseService {
|| !StringUtils.equals(new String(blob.getSteps(), StandardCharsets.UTF_8), request.getSteps())
|| !StringUtils.equals(new String(blob.getTextDescription(), StandardCharsets.UTF_8), request.getTextDescription())
|| !StringUtils.equals(new String(blob.getExpectedResult(), StandardCharsets.UTF_8), request.getExpectedResult())) {
doHandleStatusAndHistory(request, blob, name);
doHandleStatusAndHistory(blob, userId);
}
}
}
private void doHandleStatusAndHistory(FunctionalCaseEditRequest request, FunctionalCaseBlob blob, String name) {
private void doHandleStatusAndHistory(FunctionalCaseBlob blob, String userId) {
CaseReviewFunctionalCaseExample reviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
reviewFunctionalCaseExample.createCriteria().andCaseIdEqualTo(blob.getId());
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(reviewFunctionalCaseExample);
@ -228,6 +256,20 @@ public class CaseReviewFunctionalCaseService {
caseReviewFunctionalCases.forEach(item -> {
updateReviewCaseAndCaseStatus(item);
insertHistory(item);
//更新用例触发重新提审-需要重新计算评审的整体状态
Map<String, Integer> countMap = new HashMap<>();
countMap.put(item.getStatus(), 1);
Map<String, String> statusMap = new HashMap<>();
statusMap.put(item.getCaseId(), item.getStatus());
Map<String, Object> param = new HashMap<>();
param.put(CaseEvent.Param.REVIEW_ID, item.getReviewId());
param.put(CaseEvent.Param.USER_ID, userId);
param.put(CaseEvent.Param.CASE_IDS, List.of(item.getCaseId()));
param.put(CaseEvent.Param.COUNT_MAP, countMap);
param.put(CaseEvent.Param.STATUS_MAP, statusMap);
param.put(CaseEvent.Param.EVENT_NAME, CaseEvent.Event.REVIEW_FUNCTIONAL_CASE);
provider.updateCaseReview(param);
});
}
}
@ -563,7 +605,6 @@ public class CaseReviewFunctionalCaseService {
/**
* 查找当前项目下模块每个节点对应的资源统计
*
*/
public Map<String, Long> getModuleCountMap(String projectId, String reviewId, List<ModuleCountDTO> moduleCountDTOList) {
//构建模块树并计算每个节点下的所有数量包含子节点

View File

@ -395,14 +395,14 @@ public class FunctionalCaseService {
}
//处理评审状态
handleReviewStatus(request, functionalCaseBlob, checked.getName());
handleReviewStatus(request, functionalCaseBlob, checked.getName(), userId);
return functionalCase;
}
private void handleReviewStatus(FunctionalCaseEditRequest request, FunctionalCaseBlob blob, String name) {
caseReviewFunctionalCaseService.reReviewedCase(request, blob, name);
private void handleReviewStatus(FunctionalCaseEditRequest request, FunctionalCaseBlob blob, String name, String userId) {
caseReviewFunctionalCaseService.reReviewedCase(request, blob, name, userId);
}

View File

@ -198,6 +198,12 @@ public class CaseReviewFunctionalCaseControllerTests extends BaseTest {
ResultHolder resultHolder = JSON.parseObject(returnData, ResultHolder.class);
// 返回请求正常
Assertions.assertNotNull(resultHolder);
request.setReviewId("wx_review_id_4");
paramMap = new LinkedMultiValueMap<>();
paramMap.add("request", JSON.toJSONString(request));
paramMap.add("files", files);
this.requestMultipartWithOkAndReturn(FUNCTIONAL_CASE_ADD_URL, paramMap);
}
@Test

View File

@ -102,3 +102,5 @@ VALUES ('wx_history', 'wx_review_id_3', 'wx_case_id_1', NULL, 'PASS', b'0', NULL
('wx_history_6', 'wx_review_id_1', 'gyq_case_id_5', NULL, 'PASS', b'0', NULL, 'gyq_case_review', 1669174143999),
('wx_history_7', 'wx_review_id_1', 'gyq_case_id_5', NULL, 'UN_PASS', b'0', NULL, 'GGG', 1669174143999);
INSERT INTO case_review_user(review_id, user_id)
VALUES ('wx_review_id_4', 'admin')

View File

@ -41,4 +41,7 @@ public class TemplateCustomFieldDTO {
@Schema(title = "搜索调用方法")
private String optionMethod;
@Schema(description = "是否内置字段")
private Boolean internal;
}

View File

@ -122,6 +122,7 @@ public class BaseTemplateService {
BeanUtils.copyBean(templateCustomFieldDTO, i);
templateCustomFieldDTO.setFieldName(customField.getName());
templateCustomFieldDTO.setType(customField.getType());
templateCustomFieldDTO.setInternal(customField.getInternal());
AbstractCustomFieldResolver customFieldResolver = CustomFieldResolverFactory.getResolver(customField.getType());
Object defaultValue = null;
try {