fix(测试跟踪): 缺陷关联用例统计了回收站用例

--bug=1014485 --user=陈建星 【测试跟踪】缺陷管理页面用例数,删除后列表页和编辑页面没有同步删除 https://www.tapd.cn/55049933/s/1194698
This commit is contained in:
chenjianxing 2022-07-05 11:13:19 +08:00 committed by jianxing
parent 902e32b9ee
commit 879dcfae1a
2 changed files with 35 additions and 21 deletions

View File

@ -859,6 +859,7 @@
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
and test_case.status != 'Trash'
</where>
</select>
<select id="selectRelateIdsByQuery" resultType="java.lang.String">

View File

@ -428,14 +428,26 @@ public class IssuesService {
return map;
}
TestCaseIssuesExample example = new TestCaseIssuesExample();
example.createCriteria().andIssuesIdIn(ids);
example.createCriteria()
.andIssuesIdIn(ids);
List<TestCaseIssues> testCaseIssues = testCaseIssuesMapper.selectByExample(example);
List<String> caseIds = testCaseIssues.stream().map(x ->
x.getRefType().equals(IssueRefType.PLAN_FUNCTIONAL.name()) ? x.getRefId() : x.getResourceId())
.collect(Collectors.toList());
List<TestCaseDTO> notInTrashCase = testCaseService.getTestCaseByIds(caseIds);
if (CollectionUtils.isNotEmpty(notInTrashCase)) {
Set<String> notInTrashCaseSet = notInTrashCase.stream()
.map(TestCaseDTO::getId)
.collect(Collectors.toSet());
testCaseIssues.forEach(i -> {
Set<String> caseIdSet = new HashSet<>();
if (i.getRefType().equals(IssueRefType.PLAN_FUNCTIONAL.name())) {
caseIdSet.add(i.getRefId());
} else {
caseIdSet.add(i.getResourceId());
String caseId = i.getRefType().equals(IssueRefType.PLAN_FUNCTIONAL.name()) ? i.getRefId() : i.getResourceId();
if (notInTrashCaseSet.contains(caseId)) {
caseIdSet.add(caseId);
}
if (map.get(i.getIssuesId()) != null) {
map.get(i.getIssuesId()).addAll(caseIdSet);
@ -443,6 +455,7 @@ public class IssuesService {
map.put(i.getIssuesId(), caseIdSet);
}
});
}
return map;
}