From cf0f556f7000845c5ed7cb4bdc7a60c5de55ed7f Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Mon, 9 Dec 2024 11:47:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=B7=A5=E4=BD=9C=E5=8F=B0):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92=E6=97=A0=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E4=BA=BA=EF=BC=8C=E6=98=BE=E7=A4=BA=E4=B8=BA=E6=9C=AA=E5=88=86?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/service/DashboardService.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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);