|
|
@ -9,7 +9,6 @@ import com.engine.organization.mapper.department.DepartmentMapper;
|
|
|
|
import com.engine.organization.mapper.employee.EmployeeMapper;
|
|
|
|
import com.engine.organization.mapper.employee.EmployeeMapper;
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
@ -27,19 +26,8 @@ public class DepartmentBO {
|
|
|
|
// 递归添加父级数据
|
|
|
|
// 递归添加父级数据
|
|
|
|
Map<Long, DepartmentPO> poMaps = list.stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item));
|
|
|
|
Map<Long, DepartmentPO> poMaps = list.stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item));
|
|
|
|
|
|
|
|
|
|
|
|
List<DepartmentListDTO> dtoList = list.stream().map(e -> DepartmentListDTO.builder()
|
|
|
|
List<DepartmentListDTO> dtoList = list.stream().map(e -> DepartmentListDTO.builder().id(e.getId()).deptNo(e.getDeptNo()).deptName(e.getDeptName()).deptNameShort(e.getDeptNameShort()).parentComp(e.getParentComp() + "")// 命名
|
|
|
|
.id(e.getId())
|
|
|
|
.parentDept(e.getParentDept()).parentDeptName(null == poMaps.get(e.getParentDept()) ? "" : poMaps.get(e.getParentDept()).getDeptName()).deptPrincipal(getEmployeeNameById(e.getDeptPrincipal())).showOrder(e.getShowOrder()).forbiddenTag(e.getForbiddenTag()).build()).collect(Collectors.toList());
|
|
|
|
.deptNo(e.getDeptNo())
|
|
|
|
|
|
|
|
.deptName(e.getDeptName())
|
|
|
|
|
|
|
|
.deptNameShort(e.getDeptNameShort())
|
|
|
|
|
|
|
|
.parentComp(e.getParentComp() + "")// 命名
|
|
|
|
|
|
|
|
.parentDept(e.getParentDept())
|
|
|
|
|
|
|
|
.parentDeptName(null == poMaps.get(e.getParentDept()) ? "" : poMaps.get(e.getParentDept()).getDeptName())
|
|
|
|
|
|
|
|
.deptPrincipal(getEmployeeNameById(e.getDeptPrincipal()))
|
|
|
|
|
|
|
|
.showOrder(e.getShowOrder())
|
|
|
|
|
|
|
|
.forbiddenTag(e.getForbiddenTag())
|
|
|
|
|
|
|
|
.build()
|
|
|
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
|
|
Map<Long, List<DepartmentListDTO>> collects = dtoList.stream().filter(item -> null != item.getParentDept() && 0 != item.getParentDept()).collect(Collectors.groupingBy(DepartmentListDTO::getParentDept));
|
|
|
|
Map<Long, List<DepartmentListDTO>> collects = dtoList.stream().filter(item -> null != item.getParentDept() && 0 != item.getParentDept()).collect(Collectors.groupingBy(DepartmentListDTO::getParentDept));
|
|
|
|
return dtoList.stream().peek(e -> e.setChildren(collects.get(e.getId()))).filter(item -> null == item.getParentDept() || 0 == item.getParentDept()).collect(Collectors.toList());
|
|
|
|
return dtoList.stream().peek(e -> e.setChildren(collects.get(e.getId()))).filter(item -> null == item.getParentDept() || 0 == item.getParentDept()).collect(Collectors.toList());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -56,19 +44,8 @@ public class DepartmentBO {
|
|
|
|
dealParentData(addedList, po, poMaps);
|
|
|
|
dealParentData(addedList, po, poMaps);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<DepartmentListDTO> dtoList = addedList.stream().map(e -> DepartmentListDTO.builder()
|
|
|
|
List<DepartmentListDTO> dtoList = addedList.stream().map(e -> DepartmentListDTO.builder().id(e.getId()).deptNo(e.getDeptNo()).deptName(e.getDeptName()).deptNameShort(e.getDeptNameShort()).parentComp(e.getParentComp() + "")// 命名
|
|
|
|
.id(e.getId())
|
|
|
|
.parentDept(e.getParentDept()).parentDeptName(null == poMaps.get(e.getParentDept()) ? "" : poMaps.get(e.getParentDept()).getDeptName()).deptPrincipal(getEmployeeNameById(e.getDeptPrincipal())).showOrder(e.getShowOrder()).forbiddenTag(e.getForbiddenTag()).build()).collect(Collectors.toList());
|
|
|
|
.deptNo(e.getDeptNo())
|
|
|
|
|
|
|
|
.deptName(e.getDeptName())
|
|
|
|
|
|
|
|
.deptNameShort(e.getDeptNameShort())
|
|
|
|
|
|
|
|
.parentComp(e.getParentComp() + "")// 命名
|
|
|
|
|
|
|
|
.parentDept(e.getParentDept())
|
|
|
|
|
|
|
|
.parentDeptName(null == poMaps.get(e.getParentDept()) ? "" : poMaps.get(e.getParentDept()).getDeptName())
|
|
|
|
|
|
|
|
.deptPrincipal(getEmployeeNameById(e.getDeptPrincipal()))
|
|
|
|
|
|
|
|
.showOrder(e.getShowOrder())
|
|
|
|
|
|
|
|
.forbiddenTag(e.getForbiddenTag())
|
|
|
|
|
|
|
|
.build()
|
|
|
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
|
|
Map<Long, List<DepartmentListDTO>> collects = dtoList.stream().filter(item -> null != item.getParentDept() && 0 != item.getParentDept()).collect(Collectors.groupingBy(DepartmentListDTO::getParentDept));
|
|
|
|
Map<Long, List<DepartmentListDTO>> collects = dtoList.stream().filter(item -> null != item.getParentDept() && 0 != item.getParentDept()).collect(Collectors.groupingBy(DepartmentListDTO::getParentDept));
|
|
|
|
return dtoList.stream().peek(e -> e.setChildren(collects.get(e.getId()))).filter(item -> null == item.getParentDept() || 0 == item.getParentDept()).collect(Collectors.toList());
|
|
|
|
return dtoList.stream().peek(e -> e.setChildren(collects.get(e.getId()))).filter(item -> null == item.getParentDept() || 0 == item.getParentDept()).collect(Collectors.toList());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -77,38 +54,23 @@ public class DepartmentBO {
|
|
|
|
if (null == param) {
|
|
|
|
if (null == param) {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return DepartmentPO.builder()
|
|
|
|
return DepartmentPO.builder().id(param.getId() == null ? 0 : param.getId()).deptNo(param.getDeptNo()).deptName(param.getDeptName()).deptNameShort(param.getDeptNameShort()).parentComp(param.getParentComp()).parentDept(param.getParentDept()).deptPrincipal(param.getDeptPrincipal()).showOrder(param.getShowOrder()).forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1).description(param.getDescription()).deleteType(0).createTime(new Date()).updateTime(new Date()).creator(employeeId).build();
|
|
|
|
.id(param.getId() == null ? 0 : param.getId())
|
|
|
|
}
|
|
|
|
.deptNo(param.getDeptNo())
|
|
|
|
|
|
|
|
.deptName(param.getDeptName())
|
|
|
|
public static List<SingleDeptTreeVO> buildSingleDeptTreeVOS(List<DepartmentPO> departmentPOs, Long parentComp) {
|
|
|
|
.deptNameShort(param.getDeptNameShort())
|
|
|
|
|
|
|
|
.parentComp(param.getParentComp())
|
|
|
|
|
|
|
|
.parentDept(param.getParentDept())
|
|
|
|
|
|
|
|
.deptPrincipal(param.getDeptPrincipal())
|
|
|
|
|
|
|
|
.showOrder(param.getShowOrder())
|
|
|
|
|
|
|
|
.forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1)
|
|
|
|
|
|
|
|
.description(param.getDescription())
|
|
|
|
|
|
|
|
.deleteType(0)
|
|
|
|
|
|
|
|
.createTime(new Date())
|
|
|
|
|
|
|
|
.updateTime(new Date())
|
|
|
|
|
|
|
|
.creator(employeeId).build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static List<SingleDeptTreeVO> buildSingleDeptTreeVOS(List<DepartmentPO> departmentPOs) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(departmentPOs)) {
|
|
|
|
if (CollectionUtils.isEmpty(departmentPOs)) {
|
|
|
|
return Collections.emptyList();
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return departmentPOs.stream().map(e -> SingleDeptTreeVO.builder()
|
|
|
|
List<SingleDeptTreeVO> singleDeptTreeVOS = departmentPOs.stream().map(e -> SingleDeptTreeVO.builder().id(e.getId()).deptName(e.getDeptName()).parentComp(e.getParentComp()).parentDept(e.getParentDept()).parentDeptName(e.getParentDept() == null ? "" : getDeptNameById(e.getParentDept().intValue())).deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal())).build()).collect(Collectors.toList());
|
|
|
|
.id(e.getId())
|
|
|
|
//获取非一级部门
|
|
|
|
.deptName(e.getDeptName())
|
|
|
|
Map<Long, List<SingleDeptTreeVO>> collects = singleDeptTreeVOS.stream().filter(item -> !parentComp.equals(item.getParentComp()) && null != item.getParentDept()).collect(Collectors.groupingBy(SingleDeptTreeVO::getParentDept));
|
|
|
|
.parentDeptName(null == e.getParentDept() ? null : getDeptNameById(e.getParentDept().intValue()))
|
|
|
|
|
|
|
|
.deptPrincipalName(getEmployeeNameById(e.getDeptPrincipal()))
|
|
|
|
|
|
|
|
.children(recursiveData(e.getId()))
|
|
|
|
|
|
|
|
.build()
|
|
|
|
|
|
|
|
).filter(item -> StringUtil.isEmpty(item.getParentDeptName())).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return singleDeptTreeVOS.stream().map(e -> {
|
|
|
|
|
|
|
|
e.setChildren(collects.get(e.getId()));
|
|
|
|
|
|
|
|
return e;
|
|
|
|
|
|
|
|
}).filter(item -> parentComp.equals(item.getParentComp())).collect(Collectors.toList());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static List<SearchTree> buildListToSearchTree(List<DepartmentPO> departmentPOS) {
|
|
|
|
public static List<SearchTree> buildListToSearchTree(List<DepartmentPO> departmentPOS) {
|
|
|
@ -173,27 +135,5 @@ 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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return departmentPOS.stream().map(e -> SingleDeptTreeVO.builder()
|
|
|
|
|
|
|
|
.id(e.getId())
|
|
|
|
|
|
|
|
.deptName(e.getDeptName())
|
|
|
|
|
|
|
|
.parentDeptName(getDeptNameById(e.getParentDept().intValue()))
|
|
|
|
|
|
|
|
.deptPrincipalName(getEmployeeNameById(e.getDeptPrincipal()))
|
|
|
|
|
|
|
|
.children(recursiveData(e.getId()))
|
|
|
|
|
|
|
|
.build()
|
|
|
|
|
|
|
|
).collect(Collectors.toList());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|