fix(测试跟踪): 遗留缺陷统计加载有误
--bug=1020216,1020228 --user=宋昌昌 【测试跟踪】首页-测试计划遗留缺陷统计-加载失败 https://www.tapd.cn/55049933/s/1304145
This commit is contained in:
parent
2bcd6c5089
commit
eaa1f9dd26
|
@ -2,8 +2,11 @@ package io.metersphere.service;
|
|||
|
||||
import com.alibaba.excel.EasyExcelFactory;
|
||||
import com.alibaba.excel.util.DateUtils;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import io.metersphere.constants.IssueStatus;
|
||||
import io.metersphere.platform.api.Platform;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.*;
|
||||
|
@ -1705,17 +1708,37 @@ public class IssuesService {
|
|||
issuesRequest.setProjectId(SessionUtils.getCurrentProjectId());
|
||||
issuesRequest.setFilterIds(issueIds);
|
||||
List<IssuesDao> issues = extIssuesMapper.getIssues(issuesRequest);
|
||||
statusMap = issues.stream().collect(Collectors.toMap(IssuesDao::getId, IssuesDao::getPlatformStatus));
|
||||
statusMap = issues.stream().collect(Collectors.toMap(IssuesDao::getId, i -> Optional.ofNullable(i.getPlatformStatus()).orElse("new")));
|
||||
}
|
||||
|
||||
if (MapUtils.isEmpty(statusMap)) {
|
||||
request.setFilterIds(issueIds);
|
||||
} else {
|
||||
if (request.getThisWeekUnClosedTestPlanIssue() || request.getUnClosedTestPlanIssue()) {
|
||||
CustomField customField = baseCustomFieldService.getCustomFieldByName(SessionUtils.getCurrentProjectId(), SystemCustomField.ISSUE_STATUS);
|
||||
JSONArray statusArray = JSONArray.parseArray(customField.getOptions());
|
||||
Map<String, String> tmpStatusMap = statusMap;
|
||||
List<String> unClosedIds = issueIds.stream()
|
||||
.filter(id -> !StringUtils.equals(tmpStatusMap.getOrDefault(id, StringUtils.EMPTY).replaceAll("\"", StringUtils.EMPTY), "closed"))
|
||||
.collect(Collectors.toList());
|
||||
Iterator<String> iterator = unClosedIds.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String unClosedId = iterator.next();
|
||||
String status = statusMap.getOrDefault(unClosedId, StringUtils.EMPTY).replaceAll("\"", StringUtils.EMPTY);
|
||||
IssueStatus statusEnum = IssueStatus.getEnumByName(status);
|
||||
if (statusEnum == null) {
|
||||
boolean exist = false;
|
||||
for (int i = 0; i < statusArray.size(); i++) {
|
||||
JSONObject statusObj = (JSONObject) statusArray.get(i);
|
||||
if (StringUtils.equals(status, statusObj.get("value").toString())) {
|
||||
exist = true;
|
||||
}
|
||||
}
|
||||
if (!exist) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
request.setFilterIds(unClosedIds);
|
||||
} else {
|
||||
request.setFilterIds(issueIds);
|
||||
|
|
|
@ -193,6 +193,8 @@ public class TrackService {
|
|||
}
|
||||
|
||||
private Map<String, Integer> getPlanBugSize(String planId, String projectId) {
|
||||
CustomField customField = baseCustomFieldService.getCustomFieldByName(projectId, SystemCustomField.ISSUE_STATUS);
|
||||
JSONArray statusArray = JSONArray.parseArray(customField.getOptions());
|
||||
List<String> issueIds = extTestCaseMapper.getTestPlanBug(planId);
|
||||
Map<String, String> statusMap = customFieldIssuesService.getIssueStatusMap(issueIds, projectId);
|
||||
Map<String, Integer> bugSizeMap = new HashMap<>();
|
||||
|
@ -205,7 +207,7 @@ public class TrackService {
|
|||
issuesRequest.setProjectId(SessionUtils.getCurrentProjectId());
|
||||
issuesRequest.setFilterIds(issueIds);
|
||||
List<IssuesDao> issues = extIssuesMapper.getIssues(issuesRequest);
|
||||
statusMap = issues.stream().collect(Collectors.toMap(IssuesDao::getId, IssuesDao::getPlatformStatus));
|
||||
statusMap = issues.stream().collect(Collectors.toMap(IssuesDao::getId, i -> Optional.ofNullable(i.getPlatformStatus()).orElse("new")));
|
||||
}
|
||||
|
||||
if (MapUtils.isEmpty(statusMap)) {
|
||||
|
@ -216,6 +218,24 @@ public class TrackService {
|
|||
unClosedIds = issueIds.stream()
|
||||
.filter(id -> !StringUtils.equals(tmpStatusMap.getOrDefault(id, StringUtils.EMPTY).replaceAll("\"", StringUtils.EMPTY), "closed"))
|
||||
.collect(Collectors.toList());
|
||||
Iterator<String> iterator = unClosedIds.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String unClosedId = iterator.next();
|
||||
String status = statusMap.getOrDefault(unClosedId, StringUtils.EMPTY).replaceAll("\"", StringUtils.EMPTY);
|
||||
IssueStatus statusEnum = IssueStatus.getEnumByName(status);
|
||||
if (statusEnum == null) {
|
||||
boolean exist = false;
|
||||
for (int i = 0; i < statusArray.size(); i++) {
|
||||
JSONObject statusObj = (JSONObject) statusArray.get(i);
|
||||
if (StringUtils.equals(status, statusObj.get("value").toString())) {
|
||||
exist = true;
|
||||
}
|
||||
}
|
||||
if (!exist) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
bugSizeMap.put("unClosed", unClosedIds.size());
|
||||
}
|
||||
|
||||
|
@ -235,13 +255,13 @@ public class TrackService {
|
|||
for (String planId : planIds) {
|
||||
List<String> issueIds = extTestCaseMapper.getTestPlanBug(planId);
|
||||
Map<String, String> statusMap = customFieldIssuesService.getIssueStatusMap(issueIds, projectId);
|
||||
if (MapUtils.isEmpty(statusMap)) {
|
||||
if (MapUtils.isEmpty(statusMap) && CollectionUtils.isNotEmpty(issueIds)) {
|
||||
// 未找到自定义字段状态, 则获取平台状态
|
||||
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));
|
||||
statusMap = issues.stream().collect(Collectors.toMap(IssuesDao::getId, i -> Optional.ofNullable(i.getPlatformStatus()).orElse("new")));
|
||||
}
|
||||
|
||||
if (MapUtils.isEmpty(statusMap)) {
|
||||
|
|
Loading…
Reference in New Issue