refactor(工作台): 缺陷处理人统计状态名称处理

This commit is contained in:
guoyuqi 2024-11-15 14:40:51 +08:00 committed by Craftsman
parent 7fa8185aaa
commit 0f7fb329bb
1 changed files with 22 additions and 14 deletions

View File

@ -317,10 +317,13 @@ public class DashboardService {
UserLayoutExample userLayoutExample = new UserLayoutExample(); UserLayoutExample userLayoutExample = new UserLayoutExample();
userLayoutExample.createCriteria().andUserIdEqualTo(userId).andOrgIdEqualTo(organizationId); userLayoutExample.createCriteria().andUserIdEqualTo(userId).andOrgIdEqualTo(organizationId);
List<UserLayout> userLayouts = userLayoutMapper.selectByExample(userLayoutExample); List<UserLayout> userLayouts = userLayoutMapper.selectByExample(userLayoutExample);
Map<String, List<LayoutDTO>> getKeyMap = layoutDTO.stream().collect(Collectors.groupingBy(LayoutDTO::getKey));
List<LayoutDTO> saveList = new ArrayList<>();
getKeyMap.forEach((k, v) -> saveList.add(v.get(0)));
UserLayout userLayout = new UserLayout(); UserLayout userLayout = new UserLayout();
userLayout.setUserId(userId); userLayout.setUserId(userId);
userLayout.setOrgId(organizationId); userLayout.setOrgId(organizationId);
String configuration = JSON.toJSONString(layoutDTO); String configuration = JSON.toJSONString(saveList);
userLayout.setConfiguration(configuration.getBytes()); userLayout.setConfiguration(configuration.getBytes());
if (CollectionUtils.isEmpty(userLayouts)) { if (CollectionUtils.isEmpty(userLayouts)) {
userLayout.setId(IDGenerator.nextStr()); userLayout.setId(IDGenerator.nextStr());
@ -355,6 +358,7 @@ public class DashboardService {
/** /**
* 过滤用户在当前项目是否有移除或者项目是否被禁用以及用户是否被删除禁用 * 过滤用户在当前项目是否有移除或者项目是否被禁用以及用户是否被删除禁用
*
* @param layoutDTOS 用户保存的布局 * @param layoutDTOS 用户保存的布局
* @param allPermissionProjects 用户有任意权限的所有在役项目 * @param allPermissionProjects 用户有任意权限的所有在役项目
* @param orgProjectMemberList 当前组织下所有有项目权限的成员 * @param orgProjectMemberList 当前组织下所有有项目权限的成员
@ -394,8 +398,7 @@ public class DashboardService {
} else if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.SCENARIO_COUNT.toString())) { } else if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.SCENARIO_COUNT.toString())) {
Set<String> hasReadProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.PROJECT_API_SCENARIO_READ); Set<String> hasReadProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.PROJECT_API_SCENARIO_READ);
checkHasPermissionProject(layoutDTO, hasReadProjectIds); checkHasPermissionProject(layoutDTO, hasReadProjectIds);
} } else if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.TEST_PLAN_COUNT.toString())
else if (StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.TEST_PLAN_COUNT.toString())
|| StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PLAN_LEGACY_BUG.toString())) { || StringUtils.equalsIgnoreCase(layoutDTO.getKey(), DashboardUserLayoutKeys.PLAN_LEGACY_BUG.toString())) {
Set<String> hasReadProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.TEST_PLAN_READ); Set<String> hasReadProjectIds = permissionModuleProjectIdMap.get(PermissionConstants.TEST_PLAN_READ);
checkHasPermissionProject(layoutDTO, hasReadProjectIds); checkHasPermissionProject(layoutDTO, hasReadProjectIds);
@ -761,7 +764,12 @@ public class DashboardService {
List<NameArrayDTO> projectCountList = new ArrayList<>(); List<NameArrayDTO> projectCountList = new ArrayList<>();
statusCountArrayMap.forEach((status, countArray) -> { statusCountArrayMap.forEach((status, countArray) -> {
NameArrayDTO nameArrayDTO = new NameArrayDTO(); NameArrayDTO nameArrayDTO = new NameArrayDTO();
nameArrayDTO.setName(statusMap.get(status).getText()); SelectOption selectOption = statusMap.get(status);
if (selectOption != null) {
nameArrayDTO.setName(selectOption.getText());
} else {
nameArrayDTO.setName(status);
}
nameArrayDTO.setCount(countArray); nameArrayDTO.setCount(countArray);
projectCountList.add(nameArrayDTO); projectCountList.add(nameArrayDTO);
}); });