diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/BaseUserService.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/BaseUserService.java index bfa243e7c5..d283dd8638 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/BaseUserService.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/service/BaseUserService.java @@ -437,13 +437,6 @@ public class BaseUserService { return baseUserMapper.getSelectOptionByIdsWithDeleted(ids); } - public Map getUserNameMap() { - List excludeSelectOption = getSelectOptionWithDeleted(); - Map nameMap = new HashMap<>(); - excludeSelectOption.forEach(option -> nameMap.put(option.getId(), option.getName())); - return nameMap; - } - /** * 根据用户ID列表,获取用户 * diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/job/CleanProjectJob.java b/backend/services/system-setting/src/main/java/io/metersphere/system/job/CleanProjectJob.java index e9a9de8e34..c8150fbb8b 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/job/CleanProjectJob.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/job/CleanProjectJob.java @@ -44,7 +44,12 @@ public class CleanProjectJob { example.createCriteria().andDeletedEqualTo(true).andDeleteTimeLessThanOrEqualTo(timestamp); List projects = projectMapper.selectByExample(example); if (!CollectionUtils.isEmpty(projects)) { - commonProjectService.deleteProject(projects); + for (int i = 0; i < projects.size(); i++) { + //对项目进行分批处理 + if (i % 100 == 0) { + commonProjectService.deleteProject(projects.subList(i, Math.min(i + 100, projects.size()))); + } + } } } } diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonProjectService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonProjectService.java index b563c97436..b0c5d74838 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonProjectService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/CommonProjectService.java @@ -176,15 +176,20 @@ public class CommonProjectService { } public List buildUserInfo(List projectList) { - Map userMap = baseUserService.getUserNameMap(); + //取项目的创建人 修改人 删除人到一个list中 + List userIds = new ArrayList<>(); + userIds.addAll(projectList.stream().map(ProjectDTO::getCreateUser).toList()); + userIds.addAll(projectList.stream().map(ProjectDTO::getUpdateUser).toList()); + userIds.addAll(projectList.stream().map(ProjectDTO::getDeleteUser).toList()); + Map userMap = baseUserService.getUserNameMap(userIds.stream().distinct().toList()); projectList.forEach(projectDTO -> { if (StringUtils.isNotBlank(projectDTO.getModuleSetting())) { projectDTO.setModuleIds(JSON.parseArray(projectDTO.getModuleSetting(), String.class)); } List users = extSystemProjectMapper.getProjectAdminList(projectDTO.getId()); projectDTO.setAdminList(users); - List userIds = users.stream().map(User::getId).collect(Collectors.toList()); - if (CollectionUtils.isNotEmpty(userIds) && userIds.contains(projectDTO.getCreateUser())) { + List userIdList = users.stream().map(User::getId).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(userIdList) && userIdList.contains(projectDTO.getCreateUser())) { projectDTO.setProjectCreateUserIsAdmin(true); } projectDTO.setCreateUser(userMap.get(projectDTO.getCreateUser())); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java index 249f92bc7b..4290771e78 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/OrganizationService.java @@ -800,7 +800,11 @@ public class OrganizationService { * @return 组织集合 */ private List buildUserInfo(List organizationDTOS) { - Map userMap = baseUserService.getUserNameMap(); + List userIds = new ArrayList<>(); + userIds.addAll(organizationDTOS.stream().map(OrganizationDTO::getCreateUser).toList()); + userIds.addAll(organizationDTOS.stream().map(OrganizationDTO::getUpdateUser).toList()); + userIds.addAll(organizationDTOS.stream().map(OrganizationDTO::getDeleteUser).toList()); + Map userMap = baseUserService.getUserNameMap(userIds.stream().distinct().toList()); organizationDTOS.forEach(organizationDTO -> { organizationDTO.setCreateUser(userMap.get(organizationDTO.getCreateUser())); organizationDTO.setDeleteUser(userMap.get(organizationDTO.getDeleteUser()));