|
|
|
@ -95,16 +95,22 @@ public class DingUserSyncUtil { |
|
|
|
try { |
|
|
|
List<DepartmentDTO> allDepartment = dingUtil.getAllDepartment(); |
|
|
|
allDepartment.forEach(dto -> dto.setDeptIdPath(new ArrayList<>(Collections.singletonList(dto.getId())))); |
|
|
|
allDepartment.forEach(dto -> dto.setDeptNamePath(new ArrayList<>(Collections.singletonList(dto.getName())))); |
|
|
|
|
|
|
|
// 转树
|
|
|
|
List<DepartmentDTO> departmentDTOtreeList = TreeUtils.buildLongTree(allDepartment, DepartmentDTO::getId, DepartmentDTO::getParentId, (parentDTO, childrenList) -> { |
|
|
|
parentDTO.setChildrenList(childrenList); |
|
|
|
parentDTO.setLeaf(Boolean.FALSE); |
|
|
|
childrenList.forEach(childDTO -> childDTO.getDeptIdPath().addAll(0, parentDTO.getDeptIdPath())); |
|
|
|
childrenList.forEach(childDTO -> childDTO.getDeptNamePath().addAll(0, parentDTO.getDeptNamePath())); |
|
|
|
}); |
|
|
|
// 树转回列表
|
|
|
|
List<DepartmentDTO> departmentDTOList = TreeUtils.tree2List(departmentDTOtreeList, DepartmentDTO::getChildrenList); |
|
|
|
Map<String , List<Long>> depIdPathMap = new HashMap<>(); |
|
|
|
Map<String , List<String>> depNamePathMap = new HashMap<>(); |
|
|
|
|
|
|
|
departmentDTOList.forEach(dto -> depIdPathMap.put(dto.getId().toString() , dto.getDeptIdPath())); |
|
|
|
departmentDTOList.forEach(dto -> depNamePathMap.put(dto.getId().toString() , dto.getDeptNamePath())); |
|
|
|
|
|
|
|
|
|
|
|
List<List<DepartmentDTO>> departmentPartitions = ListUtil.partition(departmentDTOList, 300); |
|
|
|
@ -117,12 +123,15 @@ public class DingUserSyncUtil { |
|
|
|
List<UserDTO> allUserDTOList = dingUtil.getAllUserDTO(); |
|
|
|
allUserDTOList.forEach(user -> { |
|
|
|
Set<Long> depIdPathSet = new HashSet<>(); |
|
|
|
Set<String> depNamePathSet = new HashSet<>(); |
|
|
|
if (StrUtil.isNotBlank(user.getDeptIdStr())) { |
|
|
|
for (String idStr : user.getDeptIdStr().split(",")) { |
|
|
|
depIdPathSet.addAll(depIdPathMap.get(idStr)); |
|
|
|
depNamePathSet.addAll(depNamePathMap.get(idStr)); |
|
|
|
} |
|
|
|
} |
|
|
|
user.setDeptIdList(depIdPathSet.stream().toList()); |
|
|
|
user.setDeptPathNameStr(String.join("," , depNamePathSet)); |
|
|
|
}); |
|
|
|
List<List<UserDTO>> userPartitions = ListUtil.partition(allUserDTOList, 300); |
|
|
|
for (List<UserDTO> batch : userPartitions) { |
|
|
|
|