fix(用例管理): 修复取消关联时用例的评审状态没有对应改变问题

--bug=1035848 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001035848
This commit is contained in:
guoyuqi 2024-02-20 11:41:38 +08:00 committed by 刘瑞斌
parent bbc897a280
commit 4062a01c3a
1 changed files with 29 additions and 0 deletions

View File

@ -113,11 +113,40 @@ public class CaseReviewCaseProvider implements BaseCaseProvider {
deleteCaseReviewFunctionalCaseUser(paramMap);
//将评审历史状态置为true
extCaseReviewHistoryMapper.updateDelete(caseIdList, reviewId, true);
//检查更新用例的评审状态如果用例没有任何评审关联就置为未评审, 否则置为更新建时间最晚的那个
updateCaseStatus(caseIdList);
} catch (Exception e) {
LogUtils.error(CaseEvent.Event.DISASSOCIATE + "事件更新失败", e.getMessage());
}
}
private void updateCaseStatus(List<String> caseIdList) {
CaseReviewFunctionalCaseExample caseReviewFunctionalCaseExample = new CaseReviewFunctionalCaseExample();
caseReviewFunctionalCaseExample.createCriteria().andCaseIdIn(caseIdList);
caseReviewFunctionalCaseExample.setOrderByClause("update_time DESC");
List<CaseReviewFunctionalCase> otherReviewFunctionalCases = caseReviewFunctionalCaseMapper.selectByExample(caseReviewFunctionalCaseExample);
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
FunctionalCaseMapper mapper = sqlSession.getMapper(FunctionalCaseMapper.class);
if (CollectionUtils.isEmpty(otherReviewFunctionalCases)) {
for (String id : caseIdList) {
FunctionalCase functionalCase = new FunctionalCase();
functionalCase.setId(id);
functionalCase.setReviewStatus(FunctionalCaseReviewStatus.UN_REVIEWED.toString());
mapper.updateByPrimaryKeySelective(functionalCase);
}
} else {
Map<String, List<CaseReviewFunctionalCase>> collect = otherReviewFunctionalCases.stream().collect(Collectors.groupingBy(CaseReviewFunctionalCase::getCaseId));
collect.forEach((caseId,caseList)->{
FunctionalCase functionalCase = new FunctionalCase();
functionalCase.setId(caseId);
functionalCase.setReviewStatus(caseList.get(0).getStatus());
mapper.updateByPrimaryKeySelective(functionalCase);
});
}
sqlSession.flushStatements();
SqlSessionUtils.closeSqlSession(sqlSession, sqlSessionFactory);
}
/**
* 3.功能用例的删除/批量删除重新计算用例评审的通过率和用例数
*/