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) {