联查部门修改
This commit is contained in:
parent
93aa9e7db3
commit
c3395b6509
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@ import lombok.NoArgsConstructor;
|
|||
@NoArgsConstructor
|
||||
public class QuerySingleDeptListParam extends BaseQueryParam {
|
||||
|
||||
private int parentComp;
|
||||
private Long parentComp;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ public class SingleDeptTreeVO {
|
|||
@TableTitle(title = "部门名称", dataIndex = "deptName", key = "deptName")
|
||||
private String deptName;
|
||||
|
||||
private Long parentComp; //上级分部
|
||||
|
||||
private Long parentDept; //上级部门id
|
||||
|
||||
@TableTitle(title = "上级部门", dataIndex = "parentDeptName", key = "parentDeptName")
|
||||
private String parentDeptName; //上级部门
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
**/
|
||||
public interface DepartmentMapper {
|
||||
|
||||
List<DepartmentPO> getDeptListByCompId(@Param("parentComp") int parentComp);
|
||||
List<DepartmentPO> getDeptListByCompId();
|
||||
|
||||
List<DepartmentPO> getDeptListByPId(@Param("PId") Long PId);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,10 +19,9 @@
|
|||
</resultMap>
|
||||
|
||||
<select id="getDeptListByCompId" resultType="com.engine.organization.entity.department.po.DepartmentPO">
|
||||
select t.id, t.dept_name, t.parent_dept, t.dept_principal
|
||||
select t.id, t.dept_name, t.parent_dept, t.dept_principal,t.parent_dept,t.parent_comp
|
||||
from jcl_org_dept t
|
||||
where delete_type = 0
|
||||
and parent_comp = #{parentComp}
|
||||
</select>
|
||||
|
||||
<select id="getDeptListByPId" resultType="com.engine.organization.entity.department.po.DepartmentPO">
|
||||
|
|
|
|||
|
|
@ -41,10 +41,10 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
|
|||
public PageInfo<SingleDeptTreeVO> getDeptListByPid(QuerySingleDeptListParam param) {
|
||||
|
||||
//1.查询分部下所有部门
|
||||
PageUtil.start(param.getCurrent(), param.getPageSize());
|
||||
List<DepartmentPO> departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByCompId(param.getParentComp());
|
||||
//PageUtil.start(param.getCurrent(), param.getPageSize());
|
||||
List<DepartmentPO> departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByCompId();
|
||||
PageInfo<DepartmentPO> pageInfo = new PageInfo<>(departmentPOS);
|
||||
List<SingleDeptTreeVO> singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS);
|
||||
List<SingleDeptTreeVO> singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS,param.getParentComp());
|
||||
PageInfo<SingleDeptTreeVO> pageInfos = new PageInfo<>(singleDeptTreeVOS, SingleDeptTreeVO.class);
|
||||
pageInfos.setTotal(pageInfo.getTotal());
|
||||
pageInfos.setPageNum(param.getCurrent());
|
||||
|
|
|
|||
Loading…
Reference in New Issue