commit
009ce6f876
@ -0,0 +1,13 @@
|
|||||||
|
package com.api.organization.web;
|
||||||
|
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description: TODO
|
||||||
|
* @Date 2022/5/20
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
@Path("/bs/hrmorganization/dept")
|
||||||
|
public class DepartmentController extends com.engine.organization.web.DepartmentController {
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
package com.engine.organization.entity.department.bo;
|
||||||
|
|
||||||
|
import com.engine.organization.entity.department.po.DepartmentPO;
|
||||||
|
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
|
||||||
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
||||||
|
import com.engine.organization.mapper.employee.EmployeeMapper;
|
||||||
|
import com.engine.organization.util.db.MapperProxyFactory;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description: TODO
|
||||||
|
* @Date 2022/5/20
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public class DepartmentBO {
|
||||||
|
|
||||||
|
public static List<SingleDeptTreeVO> buildSingleDeptTreeVOS(List<DepartmentPO> departmentPOs) {
|
||||||
|
|
||||||
|
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()))
|
||||||
|
.deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal()))
|
||||||
|
.children(recursiveData(e.getId()))
|
||||||
|
.build()
|
||||||
|
).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return singleDeptTreeVOS;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String getDeptNameById(int id) {
|
||||||
|
return MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptNameById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getEmployeeNameById(Long id) {
|
||||||
|
return MapperProxyFactory.getProxy(EmployeeMapper.class).getEmployeeNameById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递归获取
|
||||||
|
* @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()))
|
||||||
|
.deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal()))
|
||||||
|
.children(recursiveData(e.getId()))
|
||||||
|
.build()
|
||||||
|
).collect(Collectors.toList());
|
||||||
|
|
||||||
|
return singleDeptTreeVOS;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.engine.organization.entity.department.param;
|
||||||
|
|
||||||
|
import com.engine.organization.common.BaseQueryParam;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description: TODO
|
||||||
|
* @Date 2022/5/20
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class QuerySingleDeptListParam extends BaseQueryParam {
|
||||||
|
|
||||||
|
private int parentComp;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.engine.organization.entity.department.po;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description: TODO
|
||||||
|
* @Date 2022/5/19
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class DepartmentPO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private String deptNo;
|
||||||
|
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
private String deptNameShort;
|
||||||
|
|
||||||
|
private int parentComp;
|
||||||
|
|
||||||
|
private int parentDept;
|
||||||
|
|
||||||
|
private int deptPrincipal; //部门负责人
|
||||||
|
|
||||||
|
private int showOrder;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private int forbiddenTag;
|
||||||
|
|
||||||
|
private Long creator;
|
||||||
|
|
||||||
|
private int deleteType;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.engine.organization.entity.department.vo;
|
||||||
|
|
||||||
|
import com.cloudstore.eccom.pc.table.WeaTableType;
|
||||||
|
import com.engine.organization.annotation.OrganizationTable;
|
||||||
|
import com.engine.organization.annotation.TableTitle;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description: TODO
|
||||||
|
* @Date 2022/5/20
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@OrganizationTable(pageId = "01b397a9-638b-4d58-89c7-4a1d17f98656",
|
||||||
|
tableType = WeaTableType.NONE)
|
||||||
|
public class SingleDeptTreeVO {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@TableTitle(title = "部门名称", dataIndex = "deptName", key = "deptName")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
@TableTitle(title = "上级部门", dataIndex = "parentDeptName", key = "parentDeptName")
|
||||||
|
private String parentDeptName; //上级部门
|
||||||
|
|
||||||
|
@TableTitle(title = "部门负责人", dataIndex = "deptPrincipalName", key = "deptPrincipalName")
|
||||||
|
private String deptPrincipalName; //部门负责人
|
||||||
|
|
||||||
|
//子节点
|
||||||
|
private List<SingleDeptTreeVO> children;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package com.engine.organization.entity.employee;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description: TODO
|
||||||
|
* @Date 2022/5/20
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Employee {
|
||||||
|
|
||||||
|
private Long employeeId;
|
||||||
|
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private Long departmentId;
|
||||||
|
|
||||||
|
//....
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.engine.organization.mapper.department;
|
||||||
|
|
||||||
|
import com.engine.organization.entity.department.po.DepartmentPO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description: TODO
|
||||||
|
* @Date 2022/5/20
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public interface DepartmentMapper {
|
||||||
|
|
||||||
|
List<DepartmentPO> getDeptListByCompId(@Param("parentComp") int parentComp);
|
||||||
|
|
||||||
|
List<DepartmentPO> getDeptListByPId(@Param("PId")Long PId);
|
||||||
|
|
||||||
|
String getDeptNameById(@Param("id")int id);
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.engine.organization.mapper.department.DepartmentMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getDeptListByCompId" resultType="com.engine.organization.entity.department.po.DepartmentPO">
|
||||||
|
select t.id,t.dept_name,t.parent_dept,t.dept_principal
|
||||||
|
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">
|
||||||
|
select t.id,t.dept_name,t.parent_dept,t.dept_principal
|
||||||
|
from jcl_org_dept t
|
||||||
|
where delete_type = 0
|
||||||
|
and parent_dept = #{PId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getDeptNameById" resultType="string">
|
||||||
|
select t.dept_name
|
||||||
|
from jcl_org_dept t
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.engine.organization.mapper.employee;
|
||||||
|
|
||||||
|
import com.engine.organization.entity.department.po.DepartmentPO;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description: TODO
|
||||||
|
* @Date 2022/5/20
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public interface EmployeeMapper {
|
||||||
|
|
||||||
|
String getEmployeeNameById(@Param("employeeId") Long id);
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.engine.organization.mapper.employee.EmployeeMapper">
|
||||||
|
|
||||||
|
<select id="getEmployeeNameById" resultType="string">
|
||||||
|
select t.lastname
|
||||||
|
from hrmresource t
|
||||||
|
where id = #{employeeId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,22 @@
|
|||||||
|
package com.engine.organization.service;
|
||||||
|
|
||||||
|
import com.engine.organization.entity.department.param.QuerySingleDeptListParam;
|
||||||
|
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
|
||||||
|
import com.engine.organization.util.page.PageInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description: TODO
|
||||||
|
* @Date 2022/5/20
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public interface DepartmentService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分部id获取部门tree
|
||||||
|
* 联查部门
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
PageInfo<SingleDeptTreeVO> getDeptListByPid(QuerySingleDeptListParam param);
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package com.engine.organization.service.impl;
|
||||||
|
|
||||||
|
import com.engine.core.impl.Service;
|
||||||
|
import com.engine.organization.entity.department.bo.DepartmentBO;
|
||||||
|
import com.engine.organization.entity.department.param.QuerySingleDeptListParam;
|
||||||
|
import com.engine.organization.entity.department.po.DepartmentPO;
|
||||||
|
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
|
||||||
|
import com.engine.organization.mapper.department.DepartmentMapper;
|
||||||
|
import com.engine.organization.service.DepartmentService;
|
||||||
|
import com.engine.organization.util.db.MapperProxyFactory;
|
||||||
|
import com.engine.organization.util.page.PageInfo;
|
||||||
|
import com.engine.organization.util.page.PageUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description: TODO
|
||||||
|
* @Date 2022/5/20
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public class DepartmentServiceImpl extends Service implements DepartmentService {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageInfo<SingleDeptTreeVO> getDeptListByPid(QuerySingleDeptListParam param) {
|
||||||
|
|
||||||
|
//1.查询分部下所有部门
|
||||||
|
PageUtil.start(param.getCurrent(),param.getPageSize());
|
||||||
|
List<DepartmentPO> departmentPOS = MapperProxyFactory.getProxy(DepartmentMapper.class).getDeptListByCompId(param.getParentComp());
|
||||||
|
List<SingleDeptTreeVO> singleDeptTreeVOS = DepartmentBO.buildSingleDeptTreeVOS(departmentPOS);
|
||||||
|
PageInfo<SingleDeptTreeVO> pageInfos = new PageInfo<>(singleDeptTreeVOS,SingleDeptTreeVO.class);
|
||||||
|
pageInfos.setTotal(departmentPOS.size());
|
||||||
|
pageInfos.setPageNum(param.getCurrent());
|
||||||
|
pageInfos.setPageSize(param.getPageSize());
|
||||||
|
|
||||||
|
return pageInfos;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package com.engine.organization.web;
|
||||||
|
|
||||||
|
import com.engine.common.util.ServiceUtil;
|
||||||
|
import com.engine.organization.entity.department.param.QuerySingleDeptListParam;
|
||||||
|
import com.engine.organization.util.response.ReturnResult;
|
||||||
|
import com.engine.organization.wrapper.DepartmentWrapper;
|
||||||
|
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||||
|
import weaver.hrm.HrmUserVarify;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.core.Context;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description: TODO
|
||||||
|
* @Date 2022/5/20
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public class DepartmentController {
|
||||||
|
|
||||||
|
private DepartmentWrapper getDepartmentWrapper(User user) {
|
||||||
|
return ServiceUtil.getService(DepartmentWrapper.class,user);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path("/getDeptListByPid")
|
||||||
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
|
public ReturnResult getDeptListByPid(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||||
|
@RequestBody QuerySingleDeptListParam querySingleDeptListParam) {
|
||||||
|
try {
|
||||||
|
User user = HrmUserVarify.getUser(request, response);
|
||||||
|
return getDepartmentWrapper(user).getDeptListByPid(querySingleDeptListParam);
|
||||||
|
}catch (Exception e) {
|
||||||
|
return ReturnResult.exceptionHandle(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package com.engine.organization.wrapper;
|
||||||
|
|
||||||
|
import com.engine.common.util.ServiceUtil;
|
||||||
|
import com.engine.core.impl.Service;
|
||||||
|
import com.engine.organization.entity.department.param.QuerySingleDeptListParam;
|
||||||
|
import com.engine.organization.service.DepartmentService;
|
||||||
|
import com.engine.organization.service.impl.DepartmentServiceImpl;
|
||||||
|
import com.engine.organization.util.page.PageInfo;
|
||||||
|
import com.engine.organization.util.response.ReturnResult;
|
||||||
|
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
|
||||||
|
import weaver.hrm.User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author weaver_cl
|
||||||
|
* @Description: TODO
|
||||||
|
* @Date 2022/5/20
|
||||||
|
* @Version V1.0
|
||||||
|
**/
|
||||||
|
public class DepartmentWrapper extends Service {
|
||||||
|
|
||||||
|
public DepartmentService getDepartmentService(User user) {
|
||||||
|
return ServiceUtil.getService(DepartmentServiceImpl.class,user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReturnResult getDeptListByPid(QuerySingleDeptListParam param) {
|
||||||
|
PageInfo<SingleDeptTreeVO> singleDeptTreeVOS = getDepartmentService(user).getDeptListByPid(param);
|
||||||
|
return ReturnResult.successed(singleDeptTreeVOS);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue