refactor(系统设置): 优化查询成员名称的方法
This commit is contained in:
parent
357d8df26e
commit
7ec75e8f92
|
@ -437,13 +437,6 @@ public class BaseUserService {
|
||||||
return baseUserMapper.getSelectOptionByIdsWithDeleted(ids);
|
return baseUserMapper.getSelectOptionByIdsWithDeleted(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getUserNameMap() {
|
|
||||||
List<OptionDTO> excludeSelectOption = getSelectOptionWithDeleted();
|
|
||||||
Map<String, String> nameMap = new HashMap<>();
|
|
||||||
excludeSelectOption.forEach(option -> nameMap.put(option.getId(), option.getName()));
|
|
||||||
return nameMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据用户ID列表,获取用户
|
* 根据用户ID列表,获取用户
|
||||||
*
|
*
|
||||||
|
|
|
@ -44,7 +44,12 @@ public class CleanProjectJob {
|
||||||
example.createCriteria().andDeletedEqualTo(true).andDeleteTimeLessThanOrEqualTo(timestamp);
|
example.createCriteria().andDeletedEqualTo(true).andDeleteTimeLessThanOrEqualTo(timestamp);
|
||||||
List<Project> projects = projectMapper.selectByExample(example);
|
List<Project> projects = projectMapper.selectByExample(example);
|
||||||
if (!CollectionUtils.isEmpty(projects)) {
|
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())));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,15 +176,20 @@ public class CommonProjectService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ProjectDTO> buildUserInfo(List<ProjectDTO> projectList) {
|
public List<ProjectDTO> buildUserInfo(List<ProjectDTO> projectList) {
|
||||||
Map<String, String> userMap = baseUserService.getUserNameMap();
|
//取项目的创建人 修改人 删除人到一个list中
|
||||||
|
List<String> 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<String, String> userMap = baseUserService.getUserNameMap(userIds.stream().distinct().toList());
|
||||||
projectList.forEach(projectDTO -> {
|
projectList.forEach(projectDTO -> {
|
||||||
if (StringUtils.isNotBlank(projectDTO.getModuleSetting())) {
|
if (StringUtils.isNotBlank(projectDTO.getModuleSetting())) {
|
||||||
projectDTO.setModuleIds(JSON.parseArray(projectDTO.getModuleSetting(), String.class));
|
projectDTO.setModuleIds(JSON.parseArray(projectDTO.getModuleSetting(), String.class));
|
||||||
}
|
}
|
||||||
List<User> users = extSystemProjectMapper.getProjectAdminList(projectDTO.getId());
|
List<User> users = extSystemProjectMapper.getProjectAdminList(projectDTO.getId());
|
||||||
projectDTO.setAdminList(users);
|
projectDTO.setAdminList(users);
|
||||||
List<String> userIds = users.stream().map(User::getId).collect(Collectors.toList());
|
List<String> userIdList = users.stream().map(User::getId).collect(Collectors.toList());
|
||||||
if (CollectionUtils.isNotEmpty(userIds) && userIds.contains(projectDTO.getCreateUser())) {
|
if (CollectionUtils.isNotEmpty(userIdList) && userIdList.contains(projectDTO.getCreateUser())) {
|
||||||
projectDTO.setProjectCreateUserIsAdmin(true);
|
projectDTO.setProjectCreateUserIsAdmin(true);
|
||||||
}
|
}
|
||||||
projectDTO.setCreateUser(userMap.get(projectDTO.getCreateUser()));
|
projectDTO.setCreateUser(userMap.get(projectDTO.getCreateUser()));
|
||||||
|
|
|
@ -800,7 +800,11 @@ public class OrganizationService {
|
||||||
* @return 组织集合
|
* @return 组织集合
|
||||||
*/
|
*/
|
||||||
private List<OrganizationDTO> buildUserInfo(List<OrganizationDTO> organizationDTOS) {
|
private List<OrganizationDTO> buildUserInfo(List<OrganizationDTO> organizationDTOS) {
|
||||||
Map<String, String> userMap = baseUserService.getUserNameMap();
|
List<String> 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<String, String> userMap = baseUserService.getUserNameMap(userIds.stream().distinct().toList());
|
||||||
organizationDTOS.forEach(organizationDTO -> {
|
organizationDTOS.forEach(organizationDTO -> {
|
||||||
organizationDTO.setCreateUser(userMap.get(organizationDTO.getCreateUser()));
|
organizationDTO.setCreateUser(userMap.get(organizationDTO.getCreateUser()));
|
||||||
organizationDTO.setDeleteUser(userMap.get(organizationDTO.getDeleteUser()));
|
organizationDTO.setDeleteUser(userMap.get(organizationDTO.getDeleteUser()));
|
||||||
|
|
Loading…
Reference in New Issue