mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-05 05:29:29 +08:00
fix(用例管理): 修复评审批量取消关联用例有一个用例关联多个评审导致用例最后结果计算错误问题
--bug=1036899 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001036899
This commit is contained in:
parent
ab678d48c9
commit
cad05038c3
@ -83,7 +83,7 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
|
||||
Map<String, Integer> mapCount = getCaseCountMap(beforeCaseReviewFunctionalCases);
|
||||
//新关联的都是未评审的,这里加上
|
||||
Integer i = mapCount.get(UN_REVIEWED_COUNT);
|
||||
mapCount.put(UN_REVIEWED_COUNT,i+caseIdList.size());
|
||||
mapCount.put(UN_REVIEWED_COUNT, i + caseIdList.size());
|
||||
updateCaseReview(reviewId, caseCount, mapCount, paramMap.get(CaseEvent.Param.USER_ID).toString());
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(CaseEvent.Event.ASSOCIATE + "事件更新失败:{}", e.getMessage());
|
||||
@ -136,11 +136,18 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
|
||||
}
|
||||
} else {
|
||||
Map<String, List<CaseReviewFunctionalCase>> collect = otherReviewFunctionalCases.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCase::getCaseId));
|
||||
collect.forEach((caseId,caseList)->{
|
||||
collect.forEach((caseId, caseList) -> {
|
||||
if (!caseIdList.contains(caseId)) {
|
||||
FunctionalCase functionalCase = new FunctionalCase();
|
||||
functionalCase.setId(caseId);
|
||||
functionalCase.setReviewStatus(FunctionalCaseReviewStatus.UN_REVIEWED.toString());
|
||||
mapper.updateByPrimaryKeySelective(functionalCase);
|
||||
} else {
|
||||
FunctionalCase functionalCase = new FunctionalCase();
|
||||
functionalCase.setId(caseId);
|
||||
functionalCase.setReviewStatus(caseList.get(0).getStatus());
|
||||
mapper.updateByPrimaryKeySelective(functionalCase);
|
||||
}
|
||||
});
|
||||
}
|
||||
sqlSession.flushStatements();
|
||||
@ -195,7 +202,7 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
|
||||
try {
|
||||
Object caseIds = paramMap.get(CaseEvent.Param.CASE_IDS);
|
||||
List<String> caseIdList = JSON.parseArray(JSON.toJSONString(caseIds), String.class);
|
||||
if(CollectionUtils.isEmpty(caseIdList)){
|
||||
if (CollectionUtils.isEmpty(caseIdList)) {
|
||||
return;
|
||||
}
|
||||
CaseReviewFunctionalCaseExample functionalCaseExample = new CaseReviewFunctionalCaseExample();
|
||||
@ -242,28 +249,28 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
|
||||
}
|
||||
Object caseIds = paramMap.get(CaseEvent.Param.CASE_IDS);
|
||||
List<String> caseIdList = JSON.parseArray(JSON.toJSONString(caseIds), String.class);
|
||||
if(CollectionUtils.isEmpty(caseIdList)){
|
||||
if (CollectionUtils.isEmpty(caseIdList)) {
|
||||
return;
|
||||
}
|
||||
Object statusObjMap = paramMap.get(CaseEvent.Param.STATUS_MAP);
|
||||
Map<String,String> statusMap = JSON.parseMap(JSON.toJSONString(statusObjMap));
|
||||
Map<String, String> statusMap = JSON.parseMap(JSON.toJSONString(statusObjMap));
|
||||
updateFunctionalCase(statusMap);
|
||||
List<CaseReviewFunctionalCase> caseReviewFunctionalCases = extCaseReviewFunctionalCaseMapper.getListExcludes(List.of(reviewId), caseIdList, false);
|
||||
Map<String, Integer> caseCountMap = getCaseCountMap(caseReviewFunctionalCases);
|
||||
Object mapCount = paramMap.get(CaseEvent.Param.COUNT_MAP);
|
||||
Map<String,Integer> map = JSON.parseMap(JSON.toJSONString(mapCount));
|
||||
Map<String, Integer> map = JSON.parseMap(JSON.toJSONString(mapCount));
|
||||
updateMapCount(map, caseCountMap);
|
||||
updateCaseReview(reviewId, caseReviewFunctionalCases.size()+caseIdList.size(), caseCountMap, paramMap.get(CaseEvent.Param.USER_ID).toString());
|
||||
updateCaseReview(reviewId, caseReviewFunctionalCases.size() + caseIdList.size(), caseCountMap, paramMap.get(CaseEvent.Param.USER_ID).toString());
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.error(CaseEvent.Event.REVIEW_FUNCTIONAL_CASE + "事件更新失败:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateFunctionalCase(Map<String,String> statusMap) {
|
||||
private void updateFunctionalCase(Map<String, String> statusMap) {
|
||||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
FunctionalCaseMapper mapper = sqlSession.getMapper(FunctionalCaseMapper.class);
|
||||
statusMap.forEach((castId,status)->{
|
||||
statusMap.forEach((castId, status) -> {
|
||||
FunctionalCase functionalCase = new FunctionalCase();
|
||||
functionalCase.setId(castId);
|
||||
functionalCase.setReviewStatus(status);
|
||||
@ -277,23 +284,23 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
|
||||
private static void updateMapCount(Map<String, Integer> map, Map<String, Integer> caseCountMap) {
|
||||
if (map.get(FunctionalCaseReviewStatus.UN_REVIEWED.toString()) != null) {
|
||||
Integer i = caseCountMap.get(UN_REVIEWED_COUNT);
|
||||
caseCountMap.put(UN_REVIEWED_COUNT, map.get(FunctionalCaseReviewStatus.UN_REVIEWED.toString())+i);
|
||||
caseCountMap.put(UN_REVIEWED_COUNT, map.get(FunctionalCaseReviewStatus.UN_REVIEWED.toString()) + i);
|
||||
}
|
||||
if (map.get(FunctionalCaseReviewStatus.UNDER_REVIEWED.toString()) != null) {
|
||||
Integer i = caseCountMap.get(UNDER_REVIEWED_COUNT);
|
||||
caseCountMap.put(UNDER_REVIEWED_COUNT, map.get(FunctionalCaseReviewStatus.UNDER_REVIEWED.toString())+i);
|
||||
caseCountMap.put(UNDER_REVIEWED_COUNT, map.get(FunctionalCaseReviewStatus.UNDER_REVIEWED.toString()) + i);
|
||||
}
|
||||
if (map.get(FunctionalCaseReviewStatus.PASS.toString()) != null) {
|
||||
Integer i = caseCountMap.get(PASS_COUNT);
|
||||
caseCountMap.put(PASS_COUNT, map.get(FunctionalCaseReviewStatus.PASS.toString())+i);
|
||||
caseCountMap.put(PASS_COUNT, map.get(FunctionalCaseReviewStatus.PASS.toString()) + i);
|
||||
}
|
||||
if (map.get(FunctionalCaseReviewStatus.UN_PASS.toString()) != null) {
|
||||
Integer i = caseCountMap.get(UN_PASS_COUNT);
|
||||
caseCountMap.put(UN_PASS_COUNT, map.get(FunctionalCaseReviewStatus.UN_PASS.toString())+i);
|
||||
caseCountMap.put(UN_PASS_COUNT, map.get(FunctionalCaseReviewStatus.UN_PASS.toString()) + i);
|
||||
}
|
||||
if (map.get(FunctionalCaseReviewStatus.RE_REVIEWED.toString()) != null) {
|
||||
Integer i = caseCountMap.get(RE_REVIEWED_COUNT);
|
||||
caseCountMap.put(RE_REVIEWED_COUNT, map.get(FunctionalCaseReviewStatus.RE_REVIEWED.toString())+i);
|
||||
caseCountMap.put(RE_REVIEWED_COUNT, map.get(FunctionalCaseReviewStatus.RE_REVIEWED.toString()) + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user