fix(测试跟踪): 遗留缺陷状态字段不存在时平台状态统计有误

--bug=1020184 --user=宋昌昌 【测试跟踪】首页-遗留缺陷统计了关闭状态的缺陷 https://www.tapd.cn/55049933/s/1303318
This commit is contained in:
song-cc-rock 2022-11-23 19:39:37 +08:00 committed by jianxing
parent 14936c3c93
commit 7ffd3699b9
3 changed files with 36 additions and 5 deletions

View File

@ -4,6 +4,7 @@ import org.apache.commons.lang3.StringUtils;
public enum IssueStatus {
status_new("new", "new"),
status_created("created", "new"),
status_resolved("resolved", "resolved"),
status_closed("closed", "closed"),
status_active("active", "active"),

View File

@ -1699,12 +1699,22 @@ public class IssuesService {
}
Map<String, String> statusMap = customFieldIssuesService.getIssueStatusMap(issueIds, request.getProjectId());
if (MapUtils.isEmpty(statusMap)) {
// 未找到自定义字段状态, 则获取平台状态
IssuesRequest issuesRequest = new IssuesRequest();
issuesRequest.setProjectId(SessionUtils.getCurrentProjectId());
issuesRequest.setFilterIds(issueIds);
List<IssuesDao> issues = extIssuesMapper.getIssues(issuesRequest);
statusMap = issues.stream().collect(Collectors.toMap(IssuesDao::getId, IssuesDao::getPlatformStatus));
}
if (MapUtils.isEmpty(statusMap)) {
request.setFilterIds(issueIds);
} else {
if (request.getThisWeekUnClosedTestPlanIssue() || request.getUnClosedTestPlanIssue()) {
Map<String, String> tmpStatusMap = statusMap;
List<String> unClosedIds = issueIds.stream()
.filter(id -> !StringUtils.equals(statusMap.getOrDefault(id, StringUtils.EMPTY).replaceAll("\"", StringUtils.EMPTY), "closed"))
.filter(id -> !StringUtils.equals(tmpStatusMap.getOrDefault(id, StringUtils.EMPTY).replaceAll("\"", StringUtils.EMPTY), "closed"))
.collect(Collectors.toList());
request.setFilterIds(unClosedIds);
} else {

View File

@ -199,12 +199,22 @@ public class TrackService {
bugSizeMap.put("total", issueIds.size());
// 缺陷是否有状态
List<String> unClosedIds;
if (MapUtils.isEmpty(statusMap)) {
// 未找到自定义字段状态, 则获取平台状态
IssuesRequest issuesRequest = new IssuesRequest();
issuesRequest.setProjectId(SessionUtils.getCurrentProjectId());
issuesRequest.setFilterIds(issueIds);
List<IssuesDao> issues = extIssuesMapper.getIssues(issuesRequest);
statusMap = issues.stream().collect(Collectors.toMap(IssuesDao::getId, IssuesDao::getPlatformStatus));
}
if (MapUtils.isEmpty(statusMap)) {
unClosedIds = issueIds;
bugSizeMap.put("unClosed", issueIds.size());
} else {
Map<String, String> tmpStatusMap = statusMap;
unClosedIds = issueIds.stream()
.filter(id -> !StringUtils.equals(statusMap.getOrDefault(id, StringUtils.EMPTY).replaceAll("\"", StringUtils.EMPTY), "closed"))
.filter(id -> !StringUtils.equals(tmpStatusMap.getOrDefault(id, StringUtils.EMPTY).replaceAll("\"", StringUtils.EMPTY), "closed"))
.collect(Collectors.toList());
bugSizeMap.put("unClosed", unClosedIds.size());
}
@ -222,9 +232,18 @@ public class TrackService {
JSONArray statusArray = JSONArray.parseArray(customField.getOptions());
Map<String, Integer> bugStatusMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(planIds)) {
planIds.forEach(planId -> {
for (String planId : planIds) {
List<String> issueIds = extTestCaseMapper.getTestPlanBug(planId);
Map<String, String> statusMap = customFieldIssuesService.getIssueStatusMap(issueIds, projectId);
if (MapUtils.isEmpty(statusMap)) {
// 未找到自定义字段状态, 则获取平台状态
IssuesRequest issuesRequest = new IssuesRequest();
issuesRequest.setProjectId(SessionUtils.getCurrentProjectId());
issuesRequest.setFilterIds(issueIds);
List<IssuesDao> issues = extIssuesMapper.getIssues(issuesRequest);
statusMap = issues.stream().collect(Collectors.toMap(IssuesDao::getId, IssuesDao::getPlatformStatus));
}
if (MapUtils.isEmpty(statusMap)) {
Integer count = bugStatusMap.get(Translator.get("new"));
if (count == null) {
@ -234,8 +253,9 @@ public class TrackService {
bugStatusMap.put(Translator.get("new"), count);
}
} else {
Map<String, String> tmpStatusMap = statusMap;
List<String> unClosedIds = issueIds.stream()
.filter(id -> !StringUtils.equals(statusMap.getOrDefault(id, StringUtils.EMPTY).replaceAll("\"", StringUtils.EMPTY), "closed"))
.filter(id -> !StringUtils.equals(tmpStatusMap.getOrDefault(id, StringUtils.EMPTY).replaceAll("\"", StringUtils.EMPTY), "closed"))
.collect(Collectors.toList());
for (String unClosedId : unClosedIds) {
String status = statusMap.getOrDefault(unClosedId, StringUtils.EMPTY).replaceAll("\"", StringUtils.EMPTY);
@ -264,7 +284,7 @@ public class TrackService {
}
}
}
});
}
}
if (MapUtils.isEmpty(bugStatusMap)) {
for (IssueStatus statusEnum : IssueStatus.values()) {