refactor(工作台): 测试计划无执行人,显示为未分配

This commit is contained in:
guoyuqi 2024-12-09 11:47:24 +08:00 committed by Craftsman
parent 4d3eee679b
commit cf0f556f70
1 changed files with 16 additions and 3 deletions

View File

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