From fe71d183a05fd9dc8b6c4ba62bbdb6a944ddccfe Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Wed, 23 Nov 2022 11:47:11 +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=E7=94=A8=E4=BE=8B=E7=BB=9F=E8=AE=A1=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=94=A8=E4=BE=8B=E7=AD=89=E7=BA=A7=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=9C=89=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../constants/SystemCustomField.java | 1 + .../io/metersphere/service/TrackService.java | 25 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/test-track/backend/src/main/java/io/metersphere/constants/SystemCustomField.java b/test-track/backend/src/main/java/io/metersphere/constants/SystemCustomField.java index ff8602daab..a90a1c9b86 100644 --- a/test-track/backend/src/main/java/io/metersphere/constants/SystemCustomField.java +++ b/test-track/backend/src/main/java/io/metersphere/constants/SystemCustomField.java @@ -7,4 +7,5 @@ package io.metersphere.constants; public class SystemCustomField { public static final String ISSUE_STATUS = "状态"; public static final String ISSUE_DEGREE = "严重程度"; + public static final String CASE_PRIORITY = "用例等级"; } diff --git a/test-track/backend/src/main/java/io/metersphere/service/TrackService.java b/test-track/backend/src/main/java/io/metersphere/service/TrackService.java index 447782f244..e142e179d6 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TrackService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TrackService.java @@ -8,7 +8,9 @@ import io.metersphere.base.domain.TestPlanExample; import io.metersphere.base.mapper.TestPlanMapper; import io.metersphere.base.mapper.ext.ExtIssuesMapper; import io.metersphere.base.mapper.ext.ExtTestCaseMapper; +import io.metersphere.commons.constants.CustomFieldScene; import io.metersphere.commons.utils.DateUtils; +import io.metersphere.commons.utils.SessionUtils; import io.metersphere.constants.IssueStatus; import io.metersphere.constants.SystemCustomField; import io.metersphere.dto.BugStatistics; @@ -18,6 +20,7 @@ import io.metersphere.dto.TrackCountResult; import io.metersphere.i18n.Translator; import io.metersphere.plan.dto.ChartsData; import io.metersphere.plan.service.TestPlanService; +import io.metersphere.request.testcase.TrackCount; import io.metersphere.xpack.track.dto.IssuesDao; import io.metersphere.xpack.track.dto.request.IssuesRequest; import org.apache.commons.collections.CollectionUtils; @@ -51,7 +54,27 @@ public class TrackService { private ExtIssuesMapper extIssuesMapper; public List countPriority(String projectId) { - return extTestCaseMapper.countPriority(projectId); + List trackCountResults = extTestCaseMapper.countPriority(projectId); + trackCountResults.forEach(trackCountResult -> { + String groupField = trackCountResult.getGroupField(); + if (StringUtils.isNotEmpty(groupField) && !StringUtils.equalsAnyIgnoreCase(groupField, + TrackCount.P0, TrackCount.P1, TrackCount.P2, TrackCount.P3)) { + // 系统字段自定义选项值 + CustomField priorityField = baseCustomFieldService.getCustomFieldByName(SessionUtils.getCurrentProjectId(), SystemCustomField.CASE_PRIORITY); + if (priorityField != null && StringUtils.equals(priorityField.getScene(), CustomFieldScene.TEST_CASE.name())) { + String options = priorityField.getOptions(); + List optionMapList = JSONArray.parseArray(options, Map.class); + optionMapList.forEach(optionMap -> { + String text = optionMap.get("text").toString(); + String value = optionMap.get("value").toString(); + if (StringUtils.equals(groupField, value)) { + trackCountResult.setGroupField(text); + } + }); + } + } + }); + return trackCountResults; } public long countCreatedThisWeek(String projectId) {