diff --git a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/service/DashboardService.java b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/service/DashboardService.java index 9c652e1c09..e214f43988 100644 --- a/backend/services/dashboard/src/main/java/io/metersphere/dashboard/service/DashboardService.java +++ b/backend/services/dashboard/src/main/java/io/metersphere/dashboard/service/DashboardService.java @@ -777,12 +777,7 @@ public class DashboardService { List headerHandlerOption = getHandlerOption(request.getHandleUsers(), projectId); //获取每个人每个状态有多少数据(已按照用户id排序) String platformName = projectApplicationService.getPlatformName(projectId); - List headerStatusOption = bugStatusService.getAllLocalStatusOptions(projectId); - if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { - List thirdStatusOptions = bugStatusService.getHeaderStatusOption(projectId); - headerStatusOption.addAll(thirdStatusOptions); - } - headerStatusOption = headerStatusOption.stream().distinct().toList(); + List headerStatusOption = getStatusOption(projectId, platformName); Set platforms = getPlatforms(platformName); List handleUserIds = headerHandlerOption.stream().sorted(Comparator.comparing(SelectOption::getValue)).map(SelectOption::getValue).collect(Collectors.toList()); List projectUserStatusCountDTOS = extBugMapper.projectUserBugStatusCount(projectId, toStartTime, toEndTime, handleUserIds, platforms); @@ -795,6 +790,18 @@ public class DashboardService { return getHandleUserCount(xaxis, statusMap, statusCountArrayMap); } + @NotNull + private List getStatusOption(String projectId, String platformName) { + List allLocalStatusOptions = bugStatusService.getAllLocalStatusOptions(projectId); + List headerStatusOption = new ArrayList<>(allLocalStatusOptions); + if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { + List thirdStatusOptions = bugStatusService.getHeaderStatusOption(projectId); + headerStatusOption.addAll(new ArrayList<>(thirdStatusOptions)); + } + headerStatusOption = headerStatusOption.stream().distinct().toList(); + return headerStatusOption; + } + @NotNull private static OverViewCountDTO getHandleUserCount(List xaxis, Map statusMap, Map> statusCountArrayMap) { OverViewCountDTO overViewCountDTO = new OverViewCountDTO(); @@ -889,19 +896,19 @@ public class DashboardService { */ private List getHandlerOption(List handleUsers, String projectId) { String platformName = projectApplicationService.getPlatformName(projectId); - List headerHandlerOption = bugCommonService.getLocalHandlerOption(projectId); - List thirdHandlerOption; + List localHandlerOption = bugCommonService.getLocalHandlerOption(projectId); + List headerHandlerOption = new ArrayList<>(localHandlerOption); if (CollectionUtils.isEmpty(handleUsers)) { if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { - thirdHandlerOption = bugCommonService.getHeaderHandlerOption(projectId); + List thirdHandlerOption = bugCommonService.getHeaderHandlerOption(projectId); if (CollectionUtils.isNotEmpty(thirdHandlerOption)) { - headerHandlerOption.addAll(thirdHandlerOption); + headerHandlerOption.addAll(new ArrayList<>(thirdHandlerOption)); } } } else { if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { List headerHandlerOptionList = bugCommonService.getHeaderHandlerOption(projectId); - headerHandlerOption.addAll(headerHandlerOptionList); + headerHandlerOption.addAll(new ArrayList<>(headerHandlerOptionList)); } headerHandlerOption = headerHandlerOption.stream().filter(t -> handleUsers.contains(t.getValue())).toList(); } @@ -1312,14 +1319,7 @@ public class DashboardService { List nameCountDTOS = buildBugRetentionRateList(totalSize, statusSize); Map> statusStatisticsMap = new HashMap<>(); statusStatisticsMap.put("retentionRate", nameCountDTOS); - List headerStatusOption = bugStatusService.getAllLocalStatusOptions(projectId); - if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { - List thirdStatusOptions = bugStatusService.getHeaderStatusOption(projectId); - if (CollectionUtils.isNotEmpty(thirdStatusOptions)) { - headerStatusOption.addAll(thirdStatusOptions); - } - } - headerStatusOption = headerStatusOption.stream().distinct().toList(); + List headerStatusOption = getHeaderStatusOption(projectId, platformName); Map> bugMap = allSimpleList.stream().collect(Collectors.groupingBy(Bug::getStatus)); List bugPercentList = bulidBugPercentList(headerStatusOption, bugMap, totalSize); statisticsDTO.setStatusStatisticsMap(statusStatisticsMap); @@ -1408,14 +1408,7 @@ public class DashboardService { List planBugList = extTestPlanMapper.getPlanBugList(projectId, TestPlanConstants.TEST_PLAN_TYPE_PLAN, new ArrayList<>(platforms), null); List localLastStepStatus = getBugEndStatus(projectId, platformName); List legacyBugList = planBugList.stream().filter(t -> !localLastStepStatus.contains(t.getText())).toList(); - List headerStatusOption = bugStatusService.getAllLocalStatusOptions(projectId); - if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { - List thirdStatusOptions = bugStatusService.getHeaderStatusOption(projectId); - if (CollectionUtils.isNotEmpty(thirdStatusOptions)) { - headerStatusOption.addAll(thirdStatusOptions); - } - } - headerStatusOption = headerStatusOption.stream().distinct().toList(); + List headerStatusOption = getHeaderStatusOption(projectId, platformName); int statusSize = CollectionUtils.isEmpty(legacyBugList) ? 0 : legacyBugList.size(); int totalSize = CollectionUtils.isEmpty(planBugList) ? 0 : planBugList.size(); List nameCountDTOS = buildBugRetentionRateList(totalSize, statusSize); @@ -1443,6 +1436,20 @@ public class DashboardService { return statisticsDTO; } + @NotNull + private List getHeaderStatusOption(String projectId, String platformName) { + List allLocalStatusOptions = bugStatusService.getAllLocalStatusOptions(projectId); + List headerStatusOption = new ArrayList<>(allLocalStatusOptions); + if (!StringUtils.equals(platformName, BugPlatform.LOCAL.getName())) { + List thirdStatusOptions = bugStatusService.getHeaderStatusOption(projectId); + if (CollectionUtils.isNotEmpty(thirdStatusOptions)) { + headerStatusOption.addAll(thirdStatusOptions); + } + } + headerStatusOption = headerStatusOption.stream().distinct().toList(); + return headerStatusOption; + } + public List getMemberOption(String projectId, String keyword) { Project project = projectMapper.selectByPrimaryKey(projectId); if (project == null) {