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 ab52016f27..6852518e04 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 @@ -730,16 +730,26 @@ public class DashboardService { // 计划-缺陷的关联数据 List planBugs = extTestPlanBugMapper.countBugByIds(planIds); //获取卡片数据 + boolean addDefaultUser = false; buildCountMap(planCount, planBugs, overViewCountDTO); List caseUserNullList = planFunctionalCases.stream().filter(t -> StringUtils.isBlank(t.getExecuteUser())).toList(); Map> caseUserMap = planFunctionalCases.stream().filter(t->StringUtils.isNotBlank(t.getExecuteUser())).collect(Collectors.groupingBy(TestPlanFunctionalCase::getExecuteUser)); - caseUserMap.put("NONE", caseUserNullList); + if (CollectionUtils.isNotEmpty(caseUserNullList)) { + addDefaultUser = true; + caseUserMap.put("NONE", caseUserNullList); + } List apiCaseUserNullList = planApiCases.stream().filter(t -> StringUtils.isBlank(t.getExecuteUser())).toList(); Map> apiCaseUserMap = planApiCases.stream().filter(t->StringUtils.isNotBlank(t.getExecuteUser())).collect(Collectors.groupingBy(TestPlanApiCase::getExecuteUser)); - apiCaseUserMap.put("NONE", apiCaseUserNullList); + if (CollectionUtils.isNotEmpty(apiCaseUserNullList)) { + addDefaultUser = true; + apiCaseUserMap.put("NONE", apiCaseUserNullList); + } List apiScenarioNullList = planApiScenarios.stream().filter(t -> StringUtils.isBlank(t.getExecuteUser())).toList(); Map> apiScenarioUserMap = planApiScenarios.stream().filter(t->StringUtils.isNotBlank(t.getExecuteUser())).collect(Collectors.groupingBy(TestPlanApiScenario::getExecuteUser)); - apiScenarioUserMap.put("NONE", apiScenarioNullList); + if (CollectionUtils.isNotEmpty(apiScenarioNullList)) { + addDefaultUser = true; + apiScenarioUserMap.put("NONE", apiScenarioNullList); + } Map> bugUserMap = planBugs.stream().collect(Collectors.groupingBy(TestPlanBugPageResponse::getCreateUser)); List users = getUsers(caseUserMap, apiCaseUserMap, apiScenarioUserMap, bugUserMap); Map userNameMap = users.stream().collect(Collectors.toMap(User::getId, User::getName)); @@ -751,6 +761,9 @@ public class DashboardService { userNameMap.put("NONE", Translator.get("plan_executor")); } } else { + if (addDefaultUser) { + userNameMap.put("NONE", Translator.get("plan_executor")); + } nameList = userNameMap.values().stream().toList(); } overViewCountDTO.setXAxis(nameList);