联查部门修改

pull/21/MERGE^2
Chengliang 3 years ago
parent 93aa9e7db3
commit c3395b6509

@ -72,23 +72,28 @@ public class DepartmentBO {
.creator(employeeId).build(); .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)) { if (CollectionUtils.isEmpty(departmentPOs)) {
return Collections.emptyList(); return Collections.emptyList();
} }
List<SingleDeptTreeVO> singleDeptTreeVOS = departmentPOs.stream().map(e -> SingleDeptTreeVO.builder() List<SingleDeptTreeVO> singleDeptTreeVOS = departmentPOs.stream().map(e -> SingleDeptTreeVO.builder()
.id(e.getId()) .id(e.getId())
.deptName(e.getDeptName()) .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())) .deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal()))
.children(recursiveData(e.getId()))
.build() .build()
).collect(Collectors.toList()); ).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 @NoArgsConstructor
public class QuerySingleDeptListParam extends BaseQueryParam { public class QuerySingleDeptListParam extends BaseQueryParam {
private int parentComp; private Long parentComp;
} }

@ -29,6 +29,10 @@ public class SingleDeptTreeVO {
@TableTitle(title = "部门名称", dataIndex = "deptName", key = "deptName") @TableTitle(title = "部门名称", dataIndex = "deptName", key = "deptName")
private String deptName; private String deptName;
private Long parentComp; //上级分部
private Long parentDept; //上级部门id
@TableTitle(title = "上级部门", dataIndex = "parentDeptName", key = "parentDeptName") @TableTitle(title = "上级部门", dataIndex = "parentDeptName", key = "parentDeptName")
private String parentDeptName; //上级部门 private String parentDeptName; //上级部门

@ -14,7 +14,7 @@ import java.util.List;
**/ **/
public interface DepartmentMapper { public interface DepartmentMapper {
List<DepartmentPO> getDeptListByCompId(@Param("parentComp") int parentComp); List<DepartmentPO> getDeptListByCompId();
List<DepartmentPO> getDeptListByPId(@Param("PId") Long PId); List<DepartmentPO> getDeptListByPId(@Param("PId") Long PId);

@ -19,10 +19,9 @@
</resultMap> </resultMap>
<select id="getDeptListByCompId" resultType="com.engine.organization.entity.department.po.DepartmentPO"> <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 from jcl_org_dept t
where delete_type = 0 where delete_type = 0
and parent_comp = #{parentComp}
</select> </select>
<select id="getDeptListByPId" resultType="com.engine.organization.entity.department.po.DepartmentPO"> <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) { public PageInfo<SingleDeptTreeVO> getDeptListByPid(QuerySingleDeptListParam param) {
//1.查询分部下所有部门 //1.查询分部下所有部门
PageUtil.start(param.getCurrent(), param.getPageSize()); //PageUtil.start(param.getCurrent(), param.getPageSize());
List<DepartmentPO> departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByCompId(param.getParentComp()); List<DepartmentPO> departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByCompId();
PageInfo<DepartmentPO> pageInfo = new PageInfo<>(departmentPOS); 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); PageInfo<SingleDeptTreeVO> pageInfos = new PageInfo<>(singleDeptTreeVOS, SingleDeptTreeVO.class);
pageInfos.setTotal(pageInfo.getTotal()); pageInfos.setTotal(pageInfo.getTotal());
pageInfos.setPageNum(param.getCurrent()); pageInfos.setPageNum(param.getCurrent());

Loading…
Cancel
Save