diff --git a/framework/sdk-parent/xpack-interface/src/main/java/io/metersphere/xpack/track/dto/request/IssuesRequest.java b/framework/sdk-parent/xpack-interface/src/main/java/io/metersphere/xpack/track/dto/request/IssuesRequest.java index d4622d04a6..f67008b31c 100644 --- a/framework/sdk-parent/xpack-interface/src/main/java/io/metersphere/xpack/track/dto/request/IssuesRequest.java +++ b/framework/sdk-parent/xpack-interface/src/main/java/io/metersphere/xpack/track/dto/request/IssuesRequest.java @@ -58,7 +58,7 @@ public class IssuesRequest extends BaseQueryRequest { private List exportIds; /** - * 本周测试计划遗留缺陷 + * 本周测试计划关联缺陷 */ private Boolean thisWeekUnClosedTestPlanIssue = false; /** diff --git a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java index ff55296746..0e25dd83d8 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/IssuesService.java @@ -1960,7 +1960,32 @@ public class IssuesService { } else { issueIds = Collections.EMPTY_LIST; } - request.setFilterIds(issueIds); + + Map statusMap = customFieldIssuesService.getIssueStatusMap(issueIds, request.getProjectId()); + if (MapUtils.isEmpty(statusMap) && CollectionUtils.isNotEmpty(issueIds)) { + // 未找到自定义字段状态, 则获取平台状态 + IssuesRequest issuesRequest = new IssuesRequest(); + issuesRequest.setProjectId(SessionUtils.getCurrentProjectId()); + issuesRequest.setFilterIds(issueIds); + List issues = extIssuesMapper.getIssues(issuesRequest); + 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.getUnClosedTestPlanIssue()) { + CustomField customField = baseCustomFieldService.getCustomFieldByName(SessionUtils.getCurrentProjectId(), SystemCustomField.ISSUE_STATUS); + JSONArray statusArray = JSONArray.parseArray(customField.getOptions()); + Map tmpStatusMap = statusMap; + List unClosedIds = issueIds.stream() + .filter(id -> !StringUtils.equals(tmpStatusMap.getOrDefault(id, StringUtils.EMPTY).replaceAll("\"", StringUtils.EMPTY), "closed")) + .collect(Collectors.toList()); + request.setFilterIds(unClosedIds); + } else { + request.setFilterIds(issueIds); + } + } } public boolean thirdPartTemplateEnable(String projectId) {