|
|
|
@ -72,23 +72,28 @@ public class DepartmentBO {
|
|
|
|
|
.creator(employeeId).build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<SingleDeptTreeVO> buildSingleDeptTreeVOS(List<DepartmentPO> departmentPOs) {
|
|
|
|
|
public static List<SingleDeptTreeVO> buildSingleDeptTreeVOS(List<DepartmentPO> departmentPOs,Long parentComp) {
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(departmentPOs)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<SingleDeptTreeVO> singleDeptTreeVOS = departmentPOs.stream().map(e -> SingleDeptTreeVO.builder()
|
|
|
|
|
.id(e.getId())
|
|
|
|
|
.deptName(e.getDeptName())
|
|
|
|
|
.parentDeptName(getDeptNameById(e.getParentDept().intValue()))
|
|
|
|
|
.parentComp(e.getParentComp())
|
|
|
|
|
.parentDept(e.getParentDept())
|
|
|
|
|
.parentDeptName(e.getParentDept() == null ? "" : getDeptNameById(e.getParentDept().intValue()))
|
|
|
|
|
.deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal()))
|
|
|
|
|
.children(recursiveData(e.getId()))
|
|
|
|
|
.build()
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
//获取非一级部门
|
|
|
|
|
Map<Long, List<SingleDeptTreeVO>> collects = singleDeptTreeVOS.stream().filter(item -> !parentComp.equals(item.getParentComp()) && null != item.getParentDept()).collect(Collectors.groupingBy(SingleDeptTreeVO :: getParentDept));
|
|
|
|
|
|
|
|
|
|
return singleDeptTreeVOS;
|
|
|
|
|
return singleDeptTreeVOS.stream().map(e -> {
|
|
|
|
|
e.setChildren(collects.get(e.getId()));
|
|
|
|
|
return e;
|
|
|
|
|
}).filter(item -> parentComp.equals(item.getParentComp())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -119,29 +124,7 @@ public class DepartmentBO {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 递归获取
|
|
|
|
|
*
|
|
|
|
|
* @param parentDeptId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public static List<SingleDeptTreeVO> recursiveData(long parentDeptId) {
|
|
|
|
|
List<DepartmentPO> departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByPId(parentDeptId);
|
|
|
|
|
if (CollectionUtils.isEmpty(departmentPOS)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<SingleDeptTreeVO> singleDeptTreeVOS = departmentPOS.stream().map(e -> SingleDeptTreeVO.builder()
|
|
|
|
|
.id(e.getId())
|
|
|
|
|
.deptName(e.getDeptName())
|
|
|
|
|
.parentDeptName(getDeptNameById(e.getParentDept().intValue()))
|
|
|
|
|
.deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal()))
|
|
|
|
|
.children(recursiveData(e.getId()))
|
|
|
|
|
.build()
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
return singleDeptTreeVOS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|