refactor(工作台): 调整项目概览和我的创建卡片数据结果

This commit is contained in:
guoyuqi 2024-11-26 16:55:56 +08:00 committed by 刘瑞斌
parent 9767ed007e
commit d4446742ce
1 changed files with 16 additions and 1 deletions

View File

@ -181,7 +181,7 @@ public class DashboardService {
@NotNull @NotNull
private OverViewCountDTO getModuleCountMap(Map<String, Set<String>> permissionModuleProjectIdMap, List<Project> projects, Long toStartTime, Long toEndTime, String userId) { private OverViewCountDTO getModuleCountMap(Map<String, Set<String>> permissionModuleProjectIdMap, List<Project> projects, Long toStartTime, Long toEndTime, String userId) {
Map<String, String> projectNameMap = projects.stream().collect(Collectors.toMap(Project::getId, Project::getName)); Map<String, String> projectNameMap = projects.stream().collect(Collectors.toMap(Project::getId, Project::getName));
Map<String, Integer> map = new HashMap<>();
Map<String, Integer> projectCaseCountMap; Map<String, Integer> projectCaseCountMap;
Map<String, Integer> projectReviewCountMap; Map<String, Integer> projectReviewCountMap;
Map<String, Integer> projectApiCountMap; Map<String, Integer> projectApiCountMap;
@ -194,6 +194,8 @@ public class DashboardService {
if (CollectionUtils.isNotEmpty(caseProjectIds)) { if (CollectionUtils.isNotEmpty(caseProjectIds)) {
//有权限 //有权限
List<ProjectCountDTO> projectCaseCount = extFunctionalCaseMapper.projectCaseCount(caseProjectIds, toStartTime, toEndTime, userId); List<ProjectCountDTO> projectCaseCount = extFunctionalCaseMapper.projectCaseCount(caseProjectIds, toStartTime, toEndTime, userId);
int caseCount = projectCaseCount.stream().mapToInt(ProjectCountDTO::getCount).sum();
map.put(FUNCTIONAL, caseCount);
projectCaseCountMap = projectCaseCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount)); projectCaseCountMap = projectCaseCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount));
} else { } else {
projectCaseCountMap = new HashMap<>(); projectCaseCountMap = new HashMap<>();
@ -202,6 +204,8 @@ public class DashboardService {
Set<String> reviewProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.CASE_REVIEW_READ); Set<String> reviewProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.CASE_REVIEW_READ);
if (CollectionUtils.isNotEmpty(reviewProjectIds)) { if (CollectionUtils.isNotEmpty(reviewProjectIds)) {
List<ProjectCountDTO> projectReviewCount = extCaseReviewMapper.projectReviewCount(reviewProjectIds, toStartTime, toEndTime, userId); List<ProjectCountDTO> projectReviewCount = extCaseReviewMapper.projectReviewCount(reviewProjectIds, toStartTime, toEndTime, userId);
int reviewCount = projectReviewCount.stream().mapToInt(ProjectCountDTO::getCount).sum();
map.put(CASE_REVIEW, reviewCount);
projectReviewCountMap = projectReviewCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount)); projectReviewCountMap = projectReviewCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount));
} else { } else {
projectReviewCountMap = new HashMap<>(); projectReviewCountMap = new HashMap<>();
@ -210,6 +214,8 @@ public class DashboardService {
Set<String> apiProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.PROJECT_API_DEFINITION_READ); Set<String> apiProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.PROJECT_API_DEFINITION_READ);
if (CollectionUtils.isNotEmpty(apiProjectIds)) { if (CollectionUtils.isNotEmpty(apiProjectIds)) {
List<ProjectCountDTO> projectApiCount = extApiDefinitionMapper.projectApiCount(apiProjectIds, toStartTime, toEndTime, userId); List<ProjectCountDTO> projectApiCount = extApiDefinitionMapper.projectApiCount(apiProjectIds, toStartTime, toEndTime, userId);
int apiCount = projectApiCount.stream().mapToInt(ProjectCountDTO::getCount).sum();
map.put(API, apiCount);
projectApiCountMap = projectApiCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount)); projectApiCountMap = projectApiCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount));
} else { } else {
projectApiCountMap = new HashMap<>(); projectApiCountMap = new HashMap<>();
@ -218,6 +224,8 @@ public class DashboardService {
Set<String> apiCaseProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.PROJECT_API_DEFINITION_CASE_READ); Set<String> apiCaseProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.PROJECT_API_DEFINITION_CASE_READ);
if (CollectionUtils.isNotEmpty(apiCaseProjectIds)) { if (CollectionUtils.isNotEmpty(apiCaseProjectIds)) {
List<ProjectCountDTO> projectApiCaseCount = extApiTestCaseMapper.projectApiCaseCount(apiCaseProjectIds, toStartTime, toEndTime, userId); List<ProjectCountDTO> projectApiCaseCount = extApiTestCaseMapper.projectApiCaseCount(apiCaseProjectIds, toStartTime, toEndTime, userId);
int apiCaseCount = projectApiCaseCount.stream().mapToInt(ProjectCountDTO::getCount).sum();
map.put(API_CASE, apiCaseCount);
projectApiCaseCountMap = projectApiCaseCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount)); projectApiCaseCountMap = projectApiCaseCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount));
} else { } else {
projectApiCaseCountMap = new HashMap<>(); projectApiCaseCountMap = new HashMap<>();
@ -226,6 +234,8 @@ public class DashboardService {
Set<String> scenarioProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.PROJECT_API_SCENARIO_READ); Set<String> scenarioProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.PROJECT_API_SCENARIO_READ);
if (CollectionUtils.isNotEmpty(scenarioProjectIds)) { if (CollectionUtils.isNotEmpty(scenarioProjectIds)) {
List<ProjectCountDTO> projectApiScenarioCount = extApiScenarioMapper.projectApiScenarioCount(scenarioProjectIds, toStartTime, toEndTime, userId); List<ProjectCountDTO> projectApiScenarioCount = extApiScenarioMapper.projectApiScenarioCount(scenarioProjectIds, toStartTime, toEndTime, userId);
int apiScenarioCount = projectApiScenarioCount.stream().mapToInt(ProjectCountDTO::getCount).sum();
map.put(API_SCENARIO, apiScenarioCount);
projectApiScenarioCountMap = projectApiScenarioCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount)); projectApiScenarioCountMap = projectApiScenarioCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount));
} else { } else {
projectApiScenarioCountMap = new HashMap<>(); projectApiScenarioCountMap = new HashMap<>();
@ -234,6 +244,8 @@ public class DashboardService {
Set<String> planProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.TEST_PLAN_READ); Set<String> planProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.TEST_PLAN_READ);
if (CollectionUtils.isNotEmpty(planProjectIds)) { if (CollectionUtils.isNotEmpty(planProjectIds)) {
List<ProjectCountDTO> projectPlanCount = extTestPlanMapper.projectPlanCount(planProjectIds, toStartTime, toEndTime, userId); List<ProjectCountDTO> projectPlanCount = extTestPlanMapper.projectPlanCount(planProjectIds, toStartTime, toEndTime, userId);
int testPlanCount = projectPlanCount.stream().mapToInt(ProjectCountDTO::getCount).sum();
map.put(TEST_PLAN, testPlanCount);
projectPlanCountMap = projectPlanCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount)); projectPlanCountMap = projectPlanCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount));
} else { } else {
projectPlanCountMap = new HashMap<>(); projectPlanCountMap = new HashMap<>();
@ -242,6 +254,8 @@ public class DashboardService {
Set<String> bugProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.PROJECT_BUG_READ); Set<String> bugProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.PROJECT_BUG_READ);
if (CollectionUtils.isNotEmpty(bugProjectIds)) { if (CollectionUtils.isNotEmpty(bugProjectIds)) {
List<ProjectCountDTO> projectBugCount = extBugMapper.projectBugCount(bugProjectIds, toStartTime, toEndTime, userId); List<ProjectCountDTO> projectBugCount = extBugMapper.projectBugCount(bugProjectIds, toStartTime, toEndTime, userId);
int bugCount = projectBugCount.stream().mapToInt(ProjectCountDTO::getCount).sum();
map.put(BUG_COUNT, bugCount);
projectBugCountMap = projectBugCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount)); projectBugCountMap = projectBugCount.stream().collect(Collectors.toMap(ProjectCountDTO::getProjectId, ProjectCountDTO::getCount));
}else { }else {
@ -326,6 +340,7 @@ public class DashboardService {
OverViewCountDTO overViewCountDTO = new OverViewCountDTO(); OverViewCountDTO overViewCountDTO = new OverViewCountDTO();
overViewCountDTO.setXAxis(xaxis); overViewCountDTO.setXAxis(xaxis);
overViewCountDTO.setCaseCountMap(map);
overViewCountDTO.setProjectCountList(nameArrayDTOList); overViewCountDTO.setProjectCountList(nameArrayDTOList);
if (CollectionUtils.isEmpty(xaxis)) { if (CollectionUtils.isEmpty(xaxis)) {
overViewCountDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode()); overViewCountDTO.setErrorCode(NO_PROJECT_PERMISSION.getCode());