From 6a075e56f1efcf1f08a805e9f5227b36b6484276 Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Mon, 19 Jun 2023 11:15:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E9=81=97=E7=95=99=E7=BC=BA=E9=99=B7=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1026929 --user=宋昌昌 【测试跟踪】首页-测试计划遗留缺陷统计-遗留缺陷数跳转链接是全部缺陷数 https://www.tapd.cn/55049933/s/1383063 --- .../track/dto/request/IssuesRequest.java | 2 +- .../io/metersphere/service/IssuesService.java | 27 ++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) 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) {