pull/27/MERGE^2
dxfeng 3 years ago
parent 30ef0c2d84
commit 1ae3dcdec0

@ -0,0 +1,13 @@
package com.api.organization.web;
import javax.ws.rs.Path;
/**
* @description: TODO
* @author:dxfeng
* @createTime: 2022/05/27
* @version: 1.0
*/
@Path("/bs/hrmorganization/job")
public class JobController extends com.engine.organization.web.JobController{
}

@ -1,8 +1,12 @@
package com.engine.organization.entity.comp.bo;
import com.api.hrm.bean.TreeNode;
import com.engine.organization.entity.comp.dto.CompListDTO;
import com.engine.organization.entity.comp.param.CompSearchParam;
import com.engine.organization.entity.comp.po.CompPO;
import com.engine.organization.entity.searchtree.SearchTree;
import com.engine.organization.mapper.comp.CompMapper;
import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections.CollectionUtils;
import weaver.crm.Maint.SectorInfoComInfo;
import weaver.general.StringUtil;
@ -21,23 +25,9 @@ public class CompBO {
public static List<CompListDTO> buildCompDTOList(Collection<CompPO> list) {
// 递归添加父级数据
Map<Long, CompPO> poMaps = list.stream().collect(Collectors.toMap(item -> item.getId(), item -> item));
List<CompListDTO> dtoList = list.stream().map(e -> CompListDTO.builder()
.id(e.getId())
.compNo(e.getCompNo())
.compName(e.getCompName())
.compNameShort(e.getCompNameShort())
.parentCompany(e.getParentCompany())
.parentCompName(null == poMaps.get(e.getParentCompany()) ? "" : poMaps.get(e.getParentCompany()).getCompName())
.orgCode(e.getOrgCode())
.industry(new SectorInfoComInfo().getSectorInfoname(e.getIndustry() + ""))
.compPrincipal(getUserNameById(e.getCompPrincipal() + ""))
.forbiddenTag(e.getForbiddenTag())
.build()
).collect(Collectors.toList());
List<CompListDTO> dtoList = list.stream().map(e -> CompListDTO.builder().id(e.getId()).compNo(e.getCompNo()).compName(e.getCompName()).compNameShort(e.getCompNameShort()).parentCompany(e.getParentCompany()).parentCompName(null == poMaps.get(e.getParentCompany()) ? "" : poMaps.get(e.getParentCompany()).getCompName()).orgCode(e.getOrgCode()).industry(new SectorInfoComInfo().getSectorInfoname(e.getIndustry() + "")).compPrincipal(getUserNameById(e.getCompPrincipal() + "")).forbiddenTag(e.getForbiddenTag()).build()).collect(Collectors.toList());
Map<Long, List<CompListDTO>> collects = dtoList.stream().filter(item -> null != item.getParentCompany() && 0 != item.getParentCompany()).collect(Collectors.groupingBy(CompListDTO::getParentCompany));
return dtoList.stream().map(e -> {
e.setChildren(collects.get(e.getId()));
@ -57,19 +47,7 @@ public class CompBO {
dealParentData(addedList, po, poMaps);
}
List<CompListDTO> dtoList = addedList.stream().map(e -> CompListDTO.builder()
.id(e.getId())
.compNo(e.getCompNo())
.compName(e.getCompName())
.compNameShort(e.getCompNameShort())
.parentCompany(e.getParentCompany())
.parentCompName(null == poMaps.get(e.getParentCompany()) ? "" : poMaps.get(e.getParentCompany()).getCompName())
.orgCode(e.getOrgCode())
.industry(new SectorInfoComInfo().getSectorInfoname(e.getIndustry() + ""))
.compPrincipal(getUserNameById(e.getCompPrincipal() + ""))
.forbiddenTag(e.getForbiddenTag())
.build()
).collect(Collectors.toList());
List<CompListDTO> dtoList = addedList.stream().map(e -> CompListDTO.builder().id(e.getId()).compNo(e.getCompNo()).compName(e.getCompName()).compNameShort(e.getCompNameShort()).parentCompany(e.getParentCompany()).parentCompName(null == poMaps.get(e.getParentCompany()) ? "" : poMaps.get(e.getParentCompany()).getCompName()).orgCode(e.getOrgCode()).industry(new SectorInfoComInfo().getSectorInfoname(e.getIndustry() + "")).compPrincipal(getUserNameById(e.getCompPrincipal() + "")).forbiddenTag(e.getForbiddenTag()).build()).collect(Collectors.toList());
Map<Long, List<CompListDTO>> collects = dtoList.stream().filter(item -> null != item.getParentCompany() && 0 != item.getParentCompany()).collect(Collectors.groupingBy(CompListDTO::getParentCompany));
return dtoList.stream().map(e -> {
e.setChildren(collects.get(e.getId()));
@ -81,23 +59,42 @@ public class CompBO {
if (null == param) {
return null;
}
return CompPO.builder()
.id(param.getId() == null ? 0 : param.getId())
.compNo(param.getCompNo())
.compName(param.getCompName())
.compNameShort(param.getCompNameShort())
.parentCompany(param.getParentCompany())
.orgCode(param.getOrgCode())
.industry(param.getIndustry())
.compPrincipal(param.getCompPrincipal())
.description(param.getDescription())
.forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1)
.deleteType(0)
.createTime(new Date())
.updateTime(new Date())
.creator(employeeId)
.build();
return CompPO.builder().id(param.getId() == null ? 0 : param.getId()).compNo(param.getCompNo()).compName(param.getCompName()).compNameShort(param.getCompNameShort()).parentCompany(param.getParentCompany()).orgCode(param.getOrgCode()).industry(param.getIndustry()).compPrincipal(param.getCompPrincipal()).description(param.getDescription()).forbiddenTag(param.getForbiddenTag() == null ? null : param.getForbiddenTag() ? 0 : 1).deleteType(0).createTime(new Date()).updateTime(new Date()).creator(employeeId).build();
}
public static List<SearchTree> buildListToSearchTree(List<CompPO> comps) {
return comps.stream().map(item -> {
SearchTree tree = new SearchTree();
tree.setCanClick(true);
tree.setCanceled(false);
tree.setIcon("icon-coms-LargeArea");
tree.setId(item.getId().toString());
tree.setIsParent(MapperProxyFactory.getProxy(CompMapper.class).countChildByPID(item.getId()) > 0);
tree.setIsVirtual("0");
tree.setName(item.getCompName());
tree.setPid(null == item.getParentCompany() ? "0" : item.getParentCompany().toString());
tree.setSelected(false);
tree.setType("1");
return tree;
}).collect(Collectors.toList());
}
public static List<TreeNode> buildSetToSearchTree(Set<CompPO> comps) {
return comps.stream().map(item -> {
SearchTree tree = new SearchTree();
tree.setCanClick(true);
tree.setCanceled(false);
tree.setIcon("icon-coms-LargeArea");
tree.setId(item.getId().toString());
tree.setIsParent(false);
tree.setIsVirtual("0");
tree.setName(item.getCompName());
tree.setPid(null == item.getParentCompany() ? "0" : item.getParentCompany().toString());
tree.setSelected(false);
tree.setType("1");
return tree;
}).collect(Collectors.toList());
}
/**

@ -88,7 +88,7 @@ public class CompListDTO {
/**
*
*/
@TableTitle(title = "操作", dataIndex = "operate", key = "operate")
@TableTitle(title = "", dataIndex = "operate", key = "operate")
private String operate;
/**

@ -4,10 +4,12 @@ import com.engine.organization.entity.department.dto.DepartmentListDTO;
import com.engine.organization.entity.department.param.DeptSearchParam;
import com.engine.organization.entity.department.po.DepartmentPO;
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
import com.engine.organization.entity.searchtree.SearchTree;
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 weaver.general.StringUtil;
import java.util.*;
import java.util.stream.Collectors;
@ -20,13 +22,35 @@ import java.util.stream.Collectors;
**/
public class DepartmentBO {
public static List<DepartmentListDTO> buildDeptDTOList(Collection<DepartmentPO> list) {
// 递归添加父级数据
Map<Long, DepartmentPO> poMaps = list.stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item));
List<DepartmentListDTO> dtoList = list.stream().map(e -> DepartmentListDTO.builder()
.id(e.getId())
.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));
return dtoList.stream().peek(e -> e.setChildren(collects.get(e.getId()))).filter(item -> null == item.getParentDept() || 0 == item.getParentDept()).collect(Collectors.toList());
}
public static List<DepartmentListDTO> buildDeptDTOList(Collection<DepartmentPO> list, List<DepartmentPO> filterList) {
// 搜索结果为空,直接返回空
if (CollectionUtils.isEmpty(filterList)) {
return Collections.emptyList();
}
// 递归添加父级数据
Map<Long, DepartmentPO> poMaps = list.stream().collect(Collectors.toMap(item -> item.getId(), item -> item));
Map<Long, DepartmentPO> poMaps = list.stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item));
List<DepartmentPO> addedList = new ArrayList<>();
for (DepartmentPO po : filterList) {
dealParentData(addedList, po, poMaps);
@ -40,16 +64,13 @@ public class DepartmentBO {
.parentComp(e.getParentComp() + "")// 命名
.parentDept(e.getParentDept())
.parentDeptName(null == poMaps.get(e.getParentDept()) ? "" : poMaps.get(e.getParentDept()).getDeptName())
.deptPrincipal(getEmployeeNameById((long) e.getDeptPrincipal()))
.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));
return dtoList.stream().map(e -> {
e.setChildren(collects.get(e.getId()));
return e;
}).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());
}
public static DepartmentPO convertParamsToPO(DeptSearchParam param, Long employeeId) {
@ -66,6 +87,7 @@ public class DepartmentBO {
.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())
@ -78,18 +100,50 @@ public class DepartmentBO {
return Collections.emptyList();
}
List<SingleDeptTreeVO> singleDeptTreeVOS = departmentPOs.stream().map(e -> SingleDeptTreeVO.builder()
return departmentPOs.stream().map(e -> SingleDeptTreeVO.builder()
.id(e.getId())
.deptName(e.getDeptName())
.parentDeptName(getDeptNameById(e.getParentDept().intValue()))
.deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal()))
.parentDeptName(null == e.getParentDept() ? null : getDeptNameById(e.getParentDept().intValue()))
.deptPrincipalName(getEmployeeNameById(e.getDeptPrincipal()))
.children(recursiveData(e.getId()))
.build()
).collect(Collectors.toList());
).filter(item -> StringUtil.isEmpty(item.getParentDeptName())).collect(Collectors.toList());
}
return singleDeptTreeVOS;
public static List<SearchTree> buildListToSearchTree(List<DepartmentPO> departmentPOS) {
return departmentPOS.stream().map(item -> {
SearchTree tree = new SearchTree();
tree.setCanClick(true);
tree.setCanceled(false);
tree.setIcon("icon-coms-Branch");
tree.setId(item.getId().toString());
tree.setIsParent(MapperProxyFactory.getProxy(DepartmentMapper.class).countChildByPID(item.getId()) > 0);
tree.setIsVirtual("0");
tree.setName(item.getDeptName());
tree.setPid(null == item.getParentDept() ? (null == item.getParentComp() ? "0" : item.getParentComp().toString()) : item.getParentDept().toString());
tree.setSelected(false);
tree.setType("2");
return tree;
}).collect(Collectors.toList());
}
public static List<SearchTree> buildSetToSearchTree(Set<DepartmentPO> departmentPOS) {
return departmentPOS.stream().map(item -> {
SearchTree tree = new SearchTree();
tree.setCanClick(true);
tree.setCanceled(false);
tree.setIcon("icon-coms-Branch");
tree.setId(item.getId().toString());
tree.setIsParent(MapperProxyFactory.getProxy(DepartmentMapper.class).countChildByPID(item.getId()) > 0);
tree.setIsVirtual("0");
tree.setName(item.getDeptName());
tree.setPid(null == item.getParentDept() ? "0" : item.getParentDept().toString());
tree.setSelected(false);
tree.setType("2");
tree.setParentComp(null == item.getParentComp() ? "0" : item.getParentComp().toString());
return tree;
}).collect(Collectors.toList());
}
@ -131,16 +185,14 @@ public class DepartmentBO {
return Collections.emptyList();
}
List<SingleDeptTreeVO> singleDeptTreeVOS = departmentPOS.stream().map(e -> SingleDeptTreeVO.builder()
return departmentPOS.stream().map(e -> SingleDeptTreeVO.builder()
.id(e.getId())
.deptName(e.getDeptName())
.parentDeptName(getDeptNameById(e.getParentDept().intValue()))
.deptPrincipalName(getEmployeeNameById((long) e.getDeptPrincipal()))
.deptPrincipalName(getEmployeeNameById(e.getDeptPrincipal()))
.children(recursiveData(e.getId()))
.build()
).collect(Collectors.toList());
return singleDeptTreeVOS;
}

@ -29,9 +29,11 @@ public class DeptSearchParam extends BaseQueryParam {
private Long parentDept;
private Integer deptPrincipal;
private Long deptPrincipal;
private Integer showOrder;
private String description;
private Boolean forbiddenTag;
}

@ -31,7 +31,7 @@ public class DepartmentPO {
private Long parentDept;
private Integer deptPrincipal; //部门负责人
private Long deptPrincipal; //部门负责人
private Integer showOrder;

@ -0,0 +1,21 @@
package com.engine.organization.entity.searchtree;
import com.api.hrm.bean.TreeNode;
import lombok.Data;
/**
* @description: TODO
* @author:dxfeng
* @createTime: 2022/05/26
* @version: 1.0
*/
@Data
public class SearchTree extends TreeNode {
private String companyid;
private String isVirtual;
private String psubcompanyid;
private String displayType;
private boolean isCanceled;
private String requestParams;
private String parentComp;
}

@ -0,0 +1,30 @@
package com.engine.organization.entity.searchtree;
import lombok.Data;
/**
* @description: TODO
* @author:dxfeng
* @createTime: 2022/05/26
* @version: 1.0
*/
@Data
public class SearchTreeParams {
/**
*
* <p>
* 0
* 1
* 2
* 3
*/
private String type;
private String id;
private String isVirtual;
// 树搜索条件
private String keyword;
private String virtualCompanyid;
private String isLoadSubDepartment;
}

@ -43,6 +43,23 @@ public interface CompMapper {
*/
List<CompPO> listChild(@Param("ids") Collection ids);
/**
* ID
*
* @param pid
* @return
*/
List<CompPO> listChildByPID(@Param("pid") String pid);
/**
* ID
*
* @param pid
* @return
*/
int countChildByPID(@Param("pid") long pid);
/**
* ID
*
@ -96,7 +113,7 @@ public interface CompMapper {
int updateForbiddenTagById(CompPO compPO);
/**
*
*
*
* @param ids
*/

@ -208,6 +208,20 @@
#{id}
</foreach>
</select>
<select id="listChildByPID" resultMap="BaseResultMap">
SELECT
<include refid="baseColumns"/>
FROM
jcl_org_comp t
WHERE t.delete_type = 0
and parent_company = #{pid}
</select>
<select id="countChildByPID" resultType="java.lang.Integer">
SELECT count(1)
FROM jcl_org_comp t
WHERE t.delete_type = 0
and parent_company = #{pid}
</select>
<update id="updateForbiddenTagById" parameterType="com.engine.organization.entity.sequence.po.SequencePO">
update jcl_org_comp

@ -19,26 +19,83 @@ public interface DepartmentMapper {
List<DepartmentPO> getDeptListByPId(@Param("PId") Long PId);
List<DepartmentPO> getDeptList(DepartmentPO departmentPO);
int countChildByPID(@Param("pid") Long pid);
/**
*
*
* @return
*/
List<DepartmentPO> list();
/**
*
* No
*
* @param deptNo
* @return
*/
List<DepartmentPO> listParent();
List<DepartmentPO> listByNo(@Param("deptNo") String deptNo);
List<Map<String,Object>> listDeptsByIds(@Param("ids") Collection<Long> ids);
/**
*
*
* @return
*/
List<DepartmentPO> listByFilter(DepartmentPO departmentPO);
/**
*
*
*
* @param ids
* @return
*/
List<DepartmentPO> listChild(@Param("ids") Collection ids);
List<Map<String, Object>> listDeptsByIds(@Param("ids") Collection<Long> ids);
DepartmentPO getDeptById(@Param("id") int id);
/**
* ID
*
* @param id
* @return
*/
DepartmentPO getDeptById(@Param("id") long id);
/**
* ID
*
* @param id
* @return
*/
String getDeptNameById(@Param("id") int id);
/**
*
*
* @param departmentPO
* @return
*/
int insertIgnoreNull(DepartmentPO departmentPO);
/**
*
*
* @param departmentPO
* @return
*/
int updateBaseDept(DepartmentPO departmentPO);
/**
*
*
* @param departmentPO
* @return
*/
int updateForbiddenTagById(DepartmentPO departmentPO);
/**
*
*
* @param ids
*/
int deleteByIds(@Param("ids") Collection<Long> ids);
}

@ -18,6 +18,22 @@
<result column="update_time" property="updateTime"/>
</resultMap>
<!-- 表字段 -->
<sql id="baseColumns">
t
.
id
,
t.dept_no,
t.dept_name,
t.dept_name_short,
t.parent_comp,
t.parent_dept,
t.dept_principal,
t.show_order,
t.forbidden_tag
</sql>
<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
@ -38,17 +54,10 @@
where id = #{id}
</select>
<select id="getDeptList" parameterType="com.engine.organization.entity.department.po.DepartmentPO"
<select id="listByFilter" parameterType="com.engine.organization.entity.department.po.DepartmentPO"
resultMap="BaseResultMap">
select t.id,
t.dept_no,
t.dept_name,
t.dept_name_short,
t.parent_comp,
t.parent_dept,
t.dept_principal,
t.show_order,
t.forbidden_tag
select
<include refid="baseColumns"/>
from jcl_org_dept t
where delete_type = 0
<include refid="likeSQL"/>
@ -70,55 +79,13 @@
</select>
<select id="getDeptById" resultType="com.engine.organization.entity.department.po.DepartmentPO">
select t.id,
t.dept_no,
t.dept_name,
t.dept_name_short,
t.parent_comp,
t.parent_dept,
t.dept_principal,
t.show_order,
t.forbidden_tag
select
<include refid="baseColumns"/>
from jcl_org_dept t
where delete_type = 0
and id = #{id}
</select>
<select id="listParent" resultMap="BaseResultMap">
SELECT
t.id,
t.dept_no,
t.dept_name,
t.dept_name_short,
t.parent_comp,
t.parent_dept,
t.dept_principal,
t.show_order,
t.forbidden_tag
FROM
jcl_org_dept t
WHERE t.delete_type = 0
<include refid="nullSql"/>
and id = #{id}
</select>
<select id="listChild" resultMap="BaseResultMap">
SELECT
t.id,
t.dept_no,
t.dept_name,
t.dept_name_short,
t.parent_comp,
t.parent_dept,
t.dept_principal,
t.show_order,
t.forbidden_tag
FROM
jcl_org_dept t
WHERE t.delete_type = 0
AND parent_dept IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</select>
<select id="listDeptsByIds" resultType="java.util.Map">
select
id,
@ -131,6 +98,143 @@
</foreach>
</select>
<select id="list" resultType="com.engine.organization.entity.department.po.DepartmentPO">
SELECT
<include refid="baseColumns"/>
FROM jcl_org_dept t
WHERE t.delete_type = 0
</select>
<select id="listByNo" resultType="com.engine.organization.entity.department.po.DepartmentPO">
select
<include refid="baseColumns"/>
from jcl_org_dept t where dept_no = #{deptNo} AND delete_type = 0
</select>
<select id="countChildByPID" resultType="java.lang.Integer">
select count(1)
from jcl_org_dept t
where delete_type = 0
and parent_dept = #{pid}
</select>
<insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.department.po.DepartmentPO"
keyProperty="id"
keyColumn="id" useGeneratedKeys="true">
INSERT INTO jcl_org_dept
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="creator != null">
creator,
</if>
<if test="deleteType != null">
delete_type,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="deptNo != null ">
dept_no,
</if>
<if test="deptName != null ">
dept_name,
</if>
<if test="deptNameShort != null ">
dept_name_short,
</if>
<if test="parentComp != null ">
parent_comp,
</if>
<if test="parentDept != null ">
parent_dept,
</if>
<if test="deptPrincipal != null ">
dept_principal,
</if>
<if test="showOrder != null ">
show_order,
</if>
<if test="description != null ">
description,
</if>
forbidden_tag,
</trim>
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="creator != null">
#{creator},
</if>
<if test="deleteType != null">
#{deleteType},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="deptNo != null ">
#{deptNo},
</if>
<if test="deptName != null ">
#{deptName},
</if>
<if test="deptNameShort != null ">
#{deptNameShort},
</if>
<if test="parentComp != null ">
#{parentComp},
</if>
<if test="parentDept != null ">
#{parentDept},
</if>
<if test="deptPrincipal != null ">
#{deptPrincipal},
</if>
<if test="showOrder != null ">
#{showOrder},
</if>
<if test="description != null ">
#{description},
</if>
0,
</trim>
</insert>
<update id="updateBaseDept" parameterType="com.engine.organization.entity.department.po.DepartmentPO">
update jcl_org_dept
<set>
creator=#{creator},
update_time=#{updateTime},
dept_name=#{deptName},
dept_name_short=#{deptNameShort},
parent_comp=#{parentComp},
parent_dept=#{parentDept},
dept_principal=#{deptPrincipal},
show_order=#{showOrder},
description=#{description},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<update id="updateForbiddenTagById" parameterType="com.engine.organization.entity.department.po.DepartmentPO">
update jcl_org_dept
<set>
forbidden_tag=#{forbiddenTag},
</set>
WHERE id = #{id} AND delete_type = 0
</update>
<update id="deleteByIds">
UPDATE jcl_org_dept
SET delete_type = 1
WHERE delete_type = 0
AND id IN
<foreach collection="ids" open="(" item="id" separator="," close=")">
#{id}
</foreach>
</update>
<sql id="likeSQL">
<if test=" deptNo != null and deptNo != '' ">
@ -142,6 +246,9 @@
<if test=" deptNameShort != null and deptNameShort != '' ">
and t.dept_name_short like CONCAT('%',#{deptNameShort},'%')
</if>
<if test=" deptNameShort != null and deptNameShort != '' ">
and t.dept_name_short like CONCAT('%',#{deptNameShort},'%')
</if>
</sql>
<sql id="likeSQL" databaseId="oracle">

@ -5,6 +5,7 @@ import com.engine.organization.entity.department.param.QuerySingleDeptListParam;
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
import com.engine.organization.util.page.PageInfo;
import java.util.Collection;
import java.util.Map;
/**
@ -38,7 +39,53 @@ public interface DepartmentService {
* @param params
* @return
*/
int saveBaseComp(DeptSearchParam params);
int saveBaseForm(DeptSearchParam params);
/**
*
*
* @param params
*/
int updateForbiddenTagById(DeptSearchParam params);
/**
*
*
* @param params
* @return
*/
int updateForm(Map<String, Object> params);
/**
* ID
*
* @param ids
*/
int deleteByIds(Collection<Long> ids);
/**
*
*
* @param params
* @return
*/
Map<String, Object> getSearchCondition(Map<String, Object> params);
/**
*
*
* @return
*/
Map<String, Object> getHasRight();
/**
*
*
* @param params
* @return
*/
Map<String, Object> getDeptBaseForm(Map<String, Object> params);
/**
@ -48,5 +95,4 @@ public interface DepartmentService {
*/
Map<String, Object> getSaveForm();
}

@ -0,0 +1,20 @@
package com.engine.organization.service;
import com.engine.organization.entity.searchtree.SearchTreeParams;
import java.util.Map;
/**
* @description: TODO
* @author:dxfeng
* @createTime: 2022/05/26
* @version: 1.0
*/
public interface JobService {
/**
*
*
* @return
*/
Map<String, Object> getSearchTree(SearchTreeParams params);
}

@ -1,9 +1,13 @@
package com.engine.organization.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.api.browser.bean.BrowserBean;
import com.api.browser.bean.SearchConditionGroup;
import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.organization.component.OrganizationWeaTable;
import com.engine.organization.entity.department.bo.DepartmentBO;
@ -12,15 +16,21 @@ import com.engine.organization.entity.department.param.DeptSearchParam;
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.comp.CompMapper;
import com.engine.organization.mapper.department.DepartmentMapper;
import com.engine.organization.mapper.extend.ExtendGroupMapper;
import com.engine.organization.service.DepartmentService;
import com.engine.organization.service.ExtService;
import com.engine.organization.util.MenuBtn;
import com.engine.organization.util.OrganizationAssert;
import com.engine.organization.util.OrganizationFormItemUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.page.Column;
import com.engine.organization.util.page.PageInfo;
import com.engine.organization.util.page.PageUtil;
import org.apache.commons.collections4.CollectionUtils;
import weaver.general.StringUtil;
import weaver.general.Util;
import weaver.hrm.User;
import java.util.*;
import java.util.stream.Collectors;
@ -33,10 +43,39 @@ import java.util.stream.Collectors;
**/
public class DepartmentServiceImpl extends Service implements DepartmentService {
/**
*
* 1
* 2
* 3
*/
private static final String EXTEND_TYPE = "w";
/**
*
*/
private static final String JCL_ORG_DEPTEXT = "JCL_ORG_DEPTEXT";
/**
*
*/
private static final String JCL_ORG_DEPTEXT_DT1 = "JCL_ORG_DEPTEXT_DT1";
private DepartmentMapper getDepartmentMapper() {
return MapperProxyFactory.getProxy(DepartmentMapper.class);
}
private CompMapper getCompMapper() {
return MapperProxyFactory.getProxy(CompMapper.class);
}
private ExtendGroupMapper getExtendGroupMapper() {
return MapperProxyFactory.getProxy(ExtendGroupMapper.class);
}
private ExtService getExtService(User user) {
return ServiceUtil.getService(ExtServiceImpl.class, user);
}
@Override
public PageInfo<SingleDeptTreeVO> getDeptListByPid(QuerySingleDeptListParam param) {
@ -56,24 +95,27 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
@Override
public Map<String, Object> listPage(DeptSearchParam param) {
Map<String, Object> datas = new HashMap<>();
PageUtil.start(param.getCurrent(), param.getPageSize());
List<DepartmentPO> parentList = getDepartmentMapper().listParent();
List<DepartmentPO> list = new ArrayList<>();
list.addAll(parentList);
if (CollectionUtils.isNotEmpty(parentList)) {
// 递归查询子数据
getChildPOs(parentList, list);
}
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(param, (long) user.getUID());
// 搜索条件过滤数据
List<DepartmentPO> filterList = filterListByParams(list, departmentPO);
List<DepartmentListDTO> departmentListDTOS = DepartmentBO.buildDeptDTOList(list, filterList);
PageInfo<DepartmentListDTO> pageInfo = new PageInfo<>(departmentListDTOS);
boolean filter = isFilter(departmentPO);
PageInfo<DepartmentListDTO> pageInfos;
List<DepartmentPO> alltList = getDepartmentMapper().list();
// 通过子级遍历父级元素
if (filter) {
// 根据条件获取元素
List<DepartmentPO> filteDeptPOs = getDepartmentMapper().listByFilter(departmentPO);
// 添加父级元素
List<DepartmentListDTO> compListDTOS = DepartmentBO.buildDeptDTOList(alltList, filteDeptPOs);
List<DepartmentListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), compListDTOS);
pageInfos = new PageInfo<>(subList, DepartmentListDTO.class);
pageInfos.setTotal(compListDTOS.size());
} else {
// 组合list
List<DepartmentListDTO> compListDTOS = DepartmentBO.buildDeptDTOList(alltList);
List<DepartmentListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), compListDTOS);
pageInfos = new PageInfo<>(subList, DepartmentListDTO.class);
pageInfos.setTotal(compListDTOS.size());
}
PageInfo<DepartmentListDTO> pageInfos = new PageInfo<>(departmentListDTOS, DepartmentListDTO.class);
pageInfos.setTotal(pageInfo.getTotal());
pageInfos.setPageNum(param.getCurrent());
pageInfos.setPageSize(param.getPageSize());
@ -81,22 +123,146 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
List<Column> columns = pageInfos.getColumns();
List<WeaTableColumn> weaTableColumn = columns.stream().map(v -> new WeaTableColumn("100", v.getTitle(), v.getKey())).collect(Collectors.toList());
table.setColumns(weaTableColumn);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
datas.put("pageInfo", pageInfos);
datas.put("dataKey", result.getResultMap());
return datas;
}
@Override
public int saveBaseComp(DeptSearchParam params) {
return 0;
public int saveBaseForm(DeptSearchParam params) {
List<DepartmentPO> list = getDepartmentMapper().listByNo(Util.null2String(params.getDeptNo()));
OrganizationAssert.isEmpty(list, "编号不允许重复");
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(params, (long) user.getUID());
return getDepartmentMapper().insertIgnoreNull(departmentPO);
}
@Override
public int updateForbiddenTagById(DeptSearchParam params) {
DepartmentPO departmentPO = DepartmentPO.builder().id(params.getId()).forbiddenTag(params.getForbiddenTag() ? 0 : 1).build();
return getDepartmentMapper().updateForbiddenTagById(departmentPO);
}
@Override
public int updateForm(Map<String, Object> params) {
DeptSearchParam searchParam = JSONObject.parseObject(JSONObject.toJSONString(params), DeptSearchParam.class);
String groupId = (String) params.get("viewCondition");
DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(searchParam, (long) user.getUID());
int updateCount = 0;
// 更新主表数据
updateCount += getDepartmentMapper().updateBaseDept(departmentPO);
// 更新主表拓展表
updateCount += getExtService(user).updateExtForm(user, EXTEND_TYPE, JCL_ORG_DEPTEXT, params, groupId, departmentPO.getId());
//更新明细表
getExtService(user).updateExtDT(user, EXTEND_TYPE, JCL_ORG_DEPTEXT_DT1, params, departmentPO.getId());
return updateCount;
}
@Override
public int deleteByIds(Collection<Long> ids) {
OrganizationAssert.notEmpty(ids, "请选择要删除的数据");
return getDepartmentMapper().deleteByIds(ids);
}
@Override
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
Map<String, Object> apiDatas = new HashMap<>();
List<SearchConditionGroup> addGroups = new ArrayList<>();
List<SearchConditionItem> conditionItems = new ArrayList<>();
// 编号
SearchConditionItem deptNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "编号", "deptNo");
// 名称
SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "名称", "deptName");
// 简称
SearchConditionItem deptNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 2, 50, "简称", "deptNameShort");
// TODO
// 所属分部
SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "161", "parentComp", "compBrowser");
// 上级部门
SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级部门", "161", "parentDept", "deptBrowser");
// 部门负责人
SearchConditionItem deptPrincipalBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "部门负责人", "1", "deptPrincipal", "");
// 显示顺序
SearchConditionItem showOrderItem = OrganizationFormItemUtil.inputNumberItem(user, 2, 16, 2, "显示顺序", "showOrder");
// 禁用标记
List<SearchConditionOption> selectOptions = new ArrayList<>();
SearchConditionOption enableOption = new SearchConditionOption("true", "启用");
SearchConditionOption disableOption = new SearchConditionOption("false", "禁用");
selectOptions.add(enableOption);
selectOptions.add(disableOption);
SearchConditionItem forbiddenTagItem = OrganizationFormItemUtil.selectItem(user, selectOptions, 2, 16, 6, false, "禁用标记", "forbiddenTag");
conditionItems.add(deptNoItem);
conditionItems.add(deptNameItem);
conditionItems.add(deptNameShortItem);
conditionItems.add(parentCompBrowserItem);
conditionItems.add(parentDeptBrowserItem);
conditionItems.add(deptPrincipalBrowserItem);
conditionItems.add(showOrderItem);
conditionItems.add(forbiddenTagItem);
addGroups.add(new SearchConditionGroup("高级搜索条件", true, conditionItems));
apiDatas.put("conditions", addGroups);
return apiDatas;
}
@Override
public Map<String, Object> getHasRight() {
Map<String, Object> btnDatas = new HashMap<>();
ArrayList<MenuBtn> topMenuList = new ArrayList<>();
ArrayList<MenuBtn> rightMenuList = new ArrayList<>();
// 新增
topMenuList.add(MenuBtn.topMenu_addNew());
// 批量删除
topMenuList.add(MenuBtn.topMenu_batchDelete());
btnDatas.put("topMenu", topMenuList);
// 新增
rightMenuList.add(MenuBtn.rightMenu_addNew());
// 日志
rightMenuList.add(MenuBtn.rightMenu_btnLog());
btnDatas.put("rightMenu", rightMenuList);
return btnDatas;
}
@Override
public Map<String, Object> getDeptBaseForm(Map<String, Object> params) {
OrganizationAssert.notNull(params.get("viewAttr"), "请标识操作类型");
// 2编辑 1查看
int viewAttr = Integer.parseInt((String) params.get("viewAttr"));
long id = Long.parseLong((String) params.get("id"));
String groupId = (String) params.get("viewCondition");
HashMap<String, Object> buttonsMap = new HashMap<>();
buttonsMap.put("hasEdit", true);
buttonsMap.put("hasSave", true);
List<SearchConditionGroup> addGroups = new ArrayList<>();
if (StringUtil.isEmpty(groupId) || "0".equals(groupId)) {
addGroups.add(new SearchConditionGroup("基本信息", true, getBaseForm(viewAttr, id)));
} else {
addGroups.add(new SearchConditionGroup(getExtendGroupMapper().getGroupNameById(groupId), true, getExtService(user).getExtForm(user, EXTEND_TYPE, JCL_ORG_DEPTEXT, viewAttr, id, groupId)));
}
HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("buttons", buttonsMap);
resultMap.put("conditions", addGroups);
resultMap.put("id", id);
// 拓展页面分组
resultMap.put("tabInfo", getExtService(user).getTabInfo(EXTEND_TYPE, JCL_ORG_DEPTEXT));
// 处理明细表
resultMap.put("tables", getExtService(user).getExtendTables(user, EXTEND_TYPE, JCL_ORG_DEPTEXT_DT1, id, viewAttr, false));
Map<String, Object> apiDatas = new HashMap<>();
apiDatas.put("result", resultMap);
return apiDatas;
}
@Override
@ -113,7 +279,6 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
// 简称
SearchConditionItem deptNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "简称", "deptNameShort");
deptNameShortItem.setRules("required|string");
// TODO 自定义按钮
// 所属分部
SearchConditionItem compBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "161", "parentComp", "compBrowser");
//上级部门
@ -142,47 +307,110 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
}
/**
* list
*
*
* @param departmentPOS
* @param departmentPO
* @return
*/
private List<DepartmentPO> filterListByParams(Collection<DepartmentPO> departmentPOS, DepartmentPO departmentPO) {
// 搜索后的数据
List<DepartmentPO> filterList = new ArrayList<>();
// 筛选数据
for (Iterator<DepartmentPO> iterator = departmentPOS.iterator(); iterator.hasNext(); ) {
DepartmentPO next = iterator.next();
boolean isAdd = (StringUtil.isEmpty(departmentPO.getDeptName()) || next.getDeptName().contains(departmentPO.getDeptName())) // 名称
&& (StringUtil.isEmpty(departmentPO.getDeptNo()) || next.getDeptNo().contains(departmentPO.getDeptNo()))//编号
&& (StringUtil.isEmpty(departmentPO.getDeptNameShort()) || next.getDeptNameShort().contains(departmentPO.getDeptNameShort()))//简称
&& (null == departmentPO.getParentComp() || next.getParentComp().equals(departmentPO.getParentComp()))//所属分部
&& (null == departmentPO.getParentDept() || next.getParentDept().equals(departmentPO.getParentDept()))//上级部门
&& (null == departmentPO.getDeptPrincipal() || next.getDeptPrincipal().equals(departmentPO.getDeptPrincipal()))//部门负责人
&& (null == departmentPO.getShowOrder() || next.getShowOrder().equals(departmentPO.getShowOrder()))//显示顺序
&& (null == departmentPO.getForbiddenTag() || next.getForbiddenTag().equals(departmentPO.getForbiddenTag()));//禁用标记
if (isAdd) {
filterList.add(next);
}
private boolean isFilter(DepartmentPO departmentPO) {
return !(StringUtil.isEmpty(departmentPO.getDeptNo()) && StringUtil.isEmpty(departmentPO.getDeptName()) && StringUtil.isEmpty(departmentPO.getDeptNameShort()) && null == departmentPO.getParentComp() && null == departmentPO.getParentDept() && null == departmentPO.getDeptPrincipal() && null == departmentPO.getShowOrder() && null == departmentPO.getForbiddenTag());
}
/**
*
*
* @param viewAttr
* @param id
* @return
*/
private List<SearchConditionItem> getBaseForm(int viewAttr, long id) {
List<SearchConditionItem> conditionItems = new ArrayList<>();
// 编号
SearchConditionItem deptNoItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "编号", "deptNo");
deptNoItem.setRules("required|string");
// 名称
SearchConditionItem deptNameItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "名称", "deptName");
deptNameItem.setRules("required|string");
// 简称
SearchConditionItem deptNameShortItem = OrganizationFormItemUtil.inputItem(user, 2, 16, 3, 50, "简称", "deptNameShort");
deptNameShortItem.setRules("required|string");
// 所属分部
SearchConditionItem parentCompBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "所属分部", "161", "parentComp", "compBrowser");
// 上级部门
SearchConditionItem parentDeptBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "上级部门", "161", "parentDept", "deptBrowser");
// 部门负责人
SearchConditionItem deptPrincipalBrowserItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "部门负责人", "1", "deptPrincipal", "");
// 显示顺序
SearchConditionItem showOrderItem = OrganizationFormItemUtil.inputNumberItem(user, 2, 16, 2, "显示顺序", "showOrder");
// 说明
SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 2, 60, "说明", "description");
conditionItems.add(deptNoItem);
conditionItems.add(deptNameItem);
conditionItems.add(deptNameShortItem);
conditionItems.add(parentCompBrowserItem);
conditionItems.add(parentDeptBrowserItem);
conditionItems.add(deptPrincipalBrowserItem);
conditionItems.add(showOrderItem);
conditionItems.add(descriptionItem);
// 编辑、查看状态赋值,设置只读状态
// 赋值
DepartmentPO departmentPO = getDepartmentMapper().getDeptById(id);
OrganizationAssert.notNull(departmentPO, "数据不存在或数据已删除");
deptNoItem.setValue(departmentPO.getDeptNo());
deptNameItem.setValue(departmentPO.getDeptName());
deptNameShortItem.setValue(departmentPO.getDeptNameShort());
// parentCompBrowserItem
if (null != departmentPO.getParentComp()) {
BrowserBean browserBean = parentCompBrowserItem.getBrowserConditionParam();
browserBean.setReplaceDatas(creatReplaceDatas(departmentPO.getParentComp(), getCompMapper().listById(departmentPO.getParentComp()).getCompName()));
parentCompBrowserItem.setBrowserConditionParam(browserBean);
}
// parentDeptBrowserItem
if (null != departmentPO.getParentDept()) {
BrowserBean browserBean = parentDeptBrowserItem.getBrowserConditionParam();
browserBean.setReplaceDatas(creatReplaceDatas(departmentPO.getParentDept(), getDepartmentMapper().getDeptById(departmentPO.getParentDept()).getDeptName()));
parentDeptBrowserItem.setBrowserConditionParam(browserBean);
}
// deptPrincipalBrowserItem
if (null != departmentPO.getDeptPrincipal()) {
BrowserBean browserBean = deptPrincipalBrowserItem.getBrowserConditionParam();
browserBean.setReplaceDatas(creatReplaceDatas(departmentPO.getDeptPrincipal(), DepartmentBO.getEmployeeNameById(departmentPO.getDeptPrincipal())));
deptPrincipalBrowserItem.setBrowserConditionParam(browserBean);
}
showOrderItem.setValue(departmentPO.getShowOrder());
descriptionItem.setValue(departmentPO.getDescription());
// 查看,全部置位只读
if (1 == viewAttr) {
for (SearchConditionItem item : conditionItems) {
item.setViewAttr(viewAttr);
}
}
return filterList;
return conditionItems;
}
/**
*
*
*
* @param parentList
* @param list
* @param id
* @param name
* @return
*/
private void getChildPOs(List<DepartmentPO> parentList, List<DepartmentPO> list) {
List<Long> ids = parentList.stream().map(DepartmentPO::getId).collect(Collectors.toList());
List<DepartmentPO> listChild = getDepartmentMapper().listChild(ids);
if (CollectionUtils.isNotEmpty(listChild)) {
list.addAll(listChild);
getChildPOs(listChild, list);
}
private List<Map<String, Object>> creatReplaceDatas(Object id, Object name) {
List<Map<String, Object>> datas = new ArrayList<>();
Map<String, Object> map = new HashMap<>();
map.put("id", id);
map.put("name", name);
datas.add(map);
return datas;
}
}

@ -40,7 +40,6 @@ public class GroupServiceImpl extends Service implements GroupService {
RecordSet rs = new RecordSet();
String sql = "select * from HrmCompany where id in(" + id + ")";
rs.executeQuery(sql);
rs.executeQuery(sql);
int colcount = rs.getColCounts();
while (rs.next()) {
Map<String, Object> row = new HashMap<String, Object>();

@ -0,0 +1,300 @@
package com.engine.organization.service.impl;
import com.api.hrm.bean.TreeNode;
import com.engine.core.impl.Service;
import com.engine.organization.entity.comp.bo.CompBO;
import com.engine.organization.entity.comp.po.CompPO;
import com.engine.organization.entity.department.bo.DepartmentBO;
import com.engine.organization.entity.department.po.DepartmentPO;
import com.engine.organization.entity.searchtree.SearchTree;
import com.engine.organization.entity.searchtree.SearchTreeParams;
import com.engine.organization.mapper.comp.CompMapper;
import com.engine.organization.mapper.department.DepartmentMapper;
import com.engine.organization.service.JobService;
import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.StringUtil;
import weaver.general.Util;
import java.util.*;
import java.util.stream.Collectors;
/**
* @description: TODO
* @author:dxfeng
* @createTime: 2022/05/26
* @version: 1.0
*/
public class JobServiceImpl extends Service implements JobService {
private static final String TYPE_GROUP = "0";
private static final String TYPE_COMP = "1";
private static final String TYPE_DEPT = "2";
private CompMapper getCompMapper() {
return MapperProxyFactory.getProxy(CompMapper.class);
}
private DepartmentMapper getDepartmentMapper() {
return MapperProxyFactory.getProxy(DepartmentMapper.class);
}
@Override
public Map<String, Object> getSearchTree(SearchTreeParams params) {
Map<String, Object> dataMap = new HashMap<>();
SearchTree topGroup = getTopGroup();
// 集团
List<SearchTree> companyList = new ArrayList<>();
companyList.add(topGroup);
String keyword = params.getKeyword();
String type = Util.null2String(params.getType());
String id = params.getId();
// 没有搜索条件查询
if (StringUtil.isEmpty(keyword)) {
// 无条件,初始化树结构
if (StringUtil.isEmpty(type)) {
dataMap.put("companys", companyList);
SearchTree rootCompany = getTopGroup();
rootCompany.setSubs(getCompany("", ""));
rootCompany.setIsParent(CollectionUtils.isNotEmpty(rootCompany.getSubs()));
Map<String, Object> rootCompanyMap = new HashMap<>();
rootCompanyMap.put("rootCompany", rootCompany);
dataMap.put("datas", rootCompanyMap);
} else {
// 根据ID查询
dataMap.put("datas", getCompany(id, type));
}
} else {
if (StringUtil.isEmpty(type)) {
List<TreeNode> collect = getFilterCompany(id, type, keyword);
SearchTree rootCompany = getTopGroup();
rootCompany.setSubs(collect);
rootCompany.setIsParent(CollectionUtils.isNotEmpty(rootCompany.getSubs()));
Map<String, Object> rootCompanyMap = new HashMap<>();
rootCompanyMap.put("rootCompany", rootCompany);
dataMap.put("datas", rootCompanyMap);
dataMap.put("companys", companyList);
} else {
dataMap.put("datas", getFilterCompany(id, type, keyword));
}
}
return dataMap;
}
/**
*
*
* @param departmentPO
* @param builderDeparts
*/
private void buildParentDepts(DepartmentPO departmentPO, Set<DepartmentPO> builderDeparts) {
builderDeparts.add(departmentPO);
if (isTop(departmentPO.getParentDept())) {
return;
}
DepartmentPO parentDept = getDepartmentMapper().getDeptById(departmentPO.getParentDept());
if (null != parentDept) {
buildParentDepts(parentDept, builderDeparts);
}
}
/**
*
*
* @param compPO
* @param builderComps
*/
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps) {
builderComps.add(compPO);
if (isTop(compPO.getParentCompany())) {
return;
}
CompPO parentComp = getCompMapper().listById(compPO.getParentCompany());
if (null != parentComp) {
buildParentComps(parentComp, builderComps);
}
}
/**
*
*
* @return
*/
private SearchTree getTopGroup() {
RecordSet rs = new RecordSet();
String sql = "select * from HrmCompany ";
rs.executeQuery(sql);
SearchTree groupTree = new SearchTree();
groupTree.setCanClick(false);
groupTree.setCanceled(false);
groupTree.setCompanyid("1");
groupTree.setIcon("icon-coms-LargeArea");
groupTree.setId("0");
groupTree.setIsVirtual("0");
while (rs.next()) {
groupTree.setName(rs.getString("COMPANYNAME"));
}
groupTree.setSelected(false);
groupTree.setType(TYPE_GROUP);
return groupTree;
}
/**
*
*
* @param id
* @return
*/
private List<TreeNode> getCompany(String id, String type) {
List<TreeNode> compSearchTree = new ArrayList<>();
List<CompPO> compPOS;
if (StringUtils.isAllEmpty(id, type)) {
compPOS = getCompMapper().listParent();
compSearchTree.addAll(CompBO.buildListToSearchTree(compPOS));
} else {
if (TYPE_COMP.equals(type)) {
compPOS = getCompMapper().listChildByPID(id);
// 获取该分部下的部门
List<DepartmentPO> deptListByCompId = getDepartmentMapper().getDeptListByCompId(Integer.parseInt(id)).stream().filter(item -> null == item.getParentDept()).collect(Collectors.toList());
compSearchTree.addAll(CompBO.buildListToSearchTree(compPOS));
compSearchTree.addAll(DepartmentBO.buildListToSearchTree(deptListByCompId));
} else if (TYPE_DEPT.equals(type)) {
List<DepartmentPO> deptListByCompId = getDepartmentMapper().getDeptListByPId(Long.parseLong(id));
compSearchTree.addAll(DepartmentBO.buildListToSearchTree(deptListByCompId));
}
}
return compSearchTree;
}
private List<TreeNode> getFilterCompany(String id, String type, String keyword) {
List<TreeNode> compSearchTree = new ArrayList<>();
if (StringUtils.isAllEmpty(id, type)) {
// 查询部门信息
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().deptName(keyword).build());
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
buildParentDepts(departmentPO, builderDeparts);
}
List<SearchTree> deptTrees = builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
// 查询分部信息
List<CompPO> filterComps = getCompMapper().listByFilter(CompPO.builder().compName(keyword).build());
Set<CompPO> builderComps = new HashSet<>();
for (CompPO compPO : filterComps) {
buildParentComps(compPO, builderComps);
}
List<TreeNode> compTrees = builderTreeMode(CompBO.buildSetToSearchTree(builderComps), deptTrees);
// 排序,设置是否为叶子节点
List<TreeNode> collect = compTrees.stream().peek(item ->
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
compSearchTree.addAll(collect);
}
} else {
if (TYPE_COMP.equals(type)) { // 查询部门信息
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().deptName(keyword).parentComp(Long.parseLong(id)).build());
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
buildParentDepts(departmentPO, builderDeparts);
}
List<SearchTree> deptTrees = builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
// 查询分部信息
List<CompPO> filterComps = getCompMapper().listByFilter(CompPO.builder().compName(keyword).parentCompany(Long.parseLong(id)).build());
Set<CompPO> builderComps = new HashSet<>();
for (CompPO compPO : filterComps) {
buildParentComps(compPO, builderComps);
}
List<TreeNode> compTrees = builderTreeMode(CompBO.buildSetToSearchTree(builderComps), deptTrees);
// 排序,设置是否为叶子节点
List<TreeNode> collect = compTrees.stream().peek(item ->
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
compSearchTree.addAll(collect);
}
} else if (TYPE_DEPT.equals(type)) {
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().deptName(keyword).parentDept(Long.parseLong(id)).build());
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
buildParentDepts(departmentPO, builderDeparts);
}
List<SearchTree> deptTrees = builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts));
// 排序,设置是否为叶子节点
List<TreeNode> collect = deptTrees.stream().peek(item ->
item.setIsParent(CollectionUtils.isNotEmpty(item.getSubs()))
).sorted(Comparator.comparing(item -> Integer.parseInt(item.getId()))).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
compSearchTree.addAll(collect);
}
}
}
return compSearchTree;
}
/**
*
*
* @param pid
* @return
*/
private boolean isTop(Long pid) {
return null == pid;
}
/**
*
*
* @param pid
* @return
*/
private boolean isTop(String pid) {
return StringUtil.isEmpty(pid) || "0".equals(pid);
}
/**
*
*
* @param treeList
* @return
*/
private List<SearchTree> builderTreeMode(List<SearchTree> treeList) {
Map<String, List<TreeNode>> collects = treeList.stream().collect(Collectors.groupingBy(TreeNode::getPid));
return treeList.stream().peek(e -> e.setSubs(collects.get(e.getId()))).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
}
/**
*
*
* @param treeList
* @param deptTrees
* @return
*/
private List<TreeNode> builderTreeMode(List<TreeNode> treeList, List<SearchTree> deptTrees) {
Map<String, List<TreeNode>> parentMap = treeList.stream().collect(Collectors.groupingBy(TreeNode::getPid));
Map<String, List<SearchTree>> childMap = deptTrees.stream().collect(Collectors.groupingBy(SearchTree::getParentComp));
boolean isAdd = !childMap.isEmpty();
return treeList.stream().peek(e -> {
List<TreeNode> treeNodes = new ArrayList<>();
List<TreeNode> nodes = parentMap.get(e.getId());
if (CollectionUtils.isNotEmpty(nodes)) {
treeNodes.addAll(nodes);
}
if (isAdd && CollectionUtils.isNotEmpty(childMap.get(e.getId()))) {
treeNodes.addAll(childMap.get(e.getId()));
}
e.setSubs(treeNodes);
}).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
}
}

@ -93,7 +93,7 @@ public class CompController {
}
/**
*
*
*
* @param request
* @param response

@ -1,6 +1,8 @@
package com.engine.organization.web;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.organization.entity.QueryParam;
import com.engine.organization.entity.department.param.DeptSearchParam;
import com.engine.organization.entity.department.param.QuerySingleDeptListParam;
import com.engine.organization.util.response.ReturnResult;
@ -17,6 +19,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Map;
/**
* @Author weaver_cl
@ -52,7 +55,7 @@ public class DepartmentController {
* @return
*/
@POST
@Path("/listDept")
@Path("/listPage")
@Produces(MediaType.APPLICATION_JSON)
public ReturnResult listDept(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DeptSearchParam params) {
try {
@ -63,6 +66,146 @@ public class DepartmentController {
}
}
/**
* /
*
* @param request
* @param response
* @param params
* @return
*/
@POST
@Path("/saveBaseForm")
@Produces(MediaType.APPLICATION_JSON)
public ReturnResult saveBaseComp(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DeptSearchParam params) {
try {
User user = HrmUserVarify.getUser(request, response);
return ReturnResult.successed(getDepartmentWrapper(user).saveBaseForm(params));
} catch (Exception e) {
return ReturnResult.exceptionHandle(e.getMessage());
}
}
/**
*
*
* @param request
* @param response
* @param param
* @return
*/
@POST
@Path("/updateForbiddenTagById")
@Produces(MediaType.APPLICATION_JSON)
public ReturnResult updateForbiddenTagById(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DeptSearchParam param) {
try {
User user = HrmUserVarify.getUser(request, response);
return ReturnResult.successed(getDepartmentWrapper(user).updateForbiddenTagById(param));
} catch (Exception e) {
return ReturnResult.exceptionHandle(e.getMessage());
}
}
/**
*
*
* @param request
* @param response
* @return
*/
@POST
@Path("/updateForm")
@Produces(MediaType.APPLICATION_JSON)
public ReturnResult updateForm(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
return ReturnResult.successed(getDepartmentWrapper(user).updateForm(map));
} catch (Exception e) {
return ReturnResult.exceptionHandle(e.getMessage());
}
}
/**
* ID
*
* @param request
* @param response
* @param param
* @return
*/
@POST
@Path("/deleteByIds")
@Produces(MediaType.APPLICATION_JSON)
public ReturnResult deleteByIds(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody QueryParam param) {
try {
User user = HrmUserVarify.getUser(request, response);
return ReturnResult.successed(getDepartmentWrapper(user).deleteByIds(param.getIds()));
} catch (Exception e) {
return ReturnResult.exceptionHandle(e.getMessage());
}
}
/**
*
*
* @param request
* @param response
* @return
*/
@GET
@Path("/getSearchCondition")
@Produces(MediaType.APPLICATION_JSON)
public ReturnResult getSearchCondition(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
return ReturnResult.successed(getDepartmentWrapper(user).getSearchCondition(map));
} catch (Exception e) {
return ReturnResult.exceptionHandle(e.getMessage());
}
}
/**
*
*
* @param request
* @param response
* @return
*/
@GET
@Path("/getHasRight")
@Produces(MediaType.APPLICATION_JSON)
public ReturnResult getHasRight(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
User user = HrmUserVarify.getUser(request, response);
return ReturnResult.successed(getDepartmentWrapper(user).getHasRight());
} catch (Exception e) {
return ReturnResult.exceptionHandle(e.getMessage());
}
}
/**
*
*
* @param request
* @param response
* @return
*/
@GET
@Path("/getDeptBaseForm")
@Produces(MediaType.APPLICATION_JSON)
public ReturnResult getCompBaseForm(@Context HttpServletRequest request, @Context HttpServletResponse response) {
try {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
return ReturnResult.successed(getDepartmentWrapper(user).getDeptBaseForm(map));
} catch (Exception e) {
return ReturnResult.exceptionHandle(e.getMessage());
}
}
/**
*
*

@ -0,0 +1,42 @@
package com.engine.organization.web;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.organization.entity.searchtree.SearchTreeParams;
import com.engine.organization.wrapper.JobWrapper;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Map;
/**
* @description: TODO
* @author:dxfeng
* @createTime: 2022/05/27
* @version: 1.0
*/
public class JobController {
public JobWrapper getJobWrapper(User user) {
return ServiceUtil.getService(JobWrapper.class, user);
}
@GET
@Path("/getSearchTree")
@Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> getSearchTree(@Context HttpServletRequest request, @Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> map = ParamUtil.request2Map(request);
SearchTreeParams params = JSONObject.toJavaObject((JSON) JSONObject.toJSON(map), SearchTreeParams.class);
return getJobWrapper(user).getSearchTree(params);
}
}

@ -4,13 +4,14 @@ import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.organization.entity.department.param.DeptSearchParam;
import com.engine.organization.entity.department.param.QuerySingleDeptListParam;
import com.engine.organization.entity.department.vo.SingleDeptTreeVO;
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;
import java.util.Collection;
import java.util.Map;
/**
@ -48,4 +49,74 @@ public class DepartmentWrapper extends Service {
public Map<String, Object> getSaveForm() {
return getDepartmentService(user).getSaveForm();
}
/**
*
*
* @param params
* @return
*/
public int saveBaseForm(DeptSearchParam params) {
return getDepartmentService(user).saveBaseForm(params);
}
/**
*
*
* @param params
*/
public int updateForbiddenTagById(DeptSearchParam params) {
return getDepartmentService(user).updateForbiddenTagById(params);
}
/**
*
*
* @param params
* @return
*/
public int updateForm(Map<String, Object> params) {
return getDepartmentService(user).updateForm(params);
}
/**
* ID
*
* @param ids
*/
public int deleteByIds(Collection<Long> ids) {
return getDepartmentService(user).deleteByIds(ids);
}
/**
*
*
* @param params
* @return
*/
public Map<String, Object> getSearchCondition(Map<String, Object> params) {
return getDepartmentService(user).getSearchCondition(params);
}
/**
*
*
* @return
*/
public Map<String, Object> getHasRight() {
return getDepartmentService(user).getHasRight();
}
/**
*
*
* @param params
* @return
*/
public Map<String, Object> getDeptBaseForm(Map<String, Object> params) {
return getDepartmentService(user).getDeptBaseForm(params);
}
}

@ -0,0 +1,27 @@
package com.engine.organization.wrapper;
import com.engine.common.util.ServiceUtil;
import com.engine.core.impl.Service;
import com.engine.organization.entity.searchtree.SearchTreeParams;
import com.engine.organization.service.JobService;
import com.engine.organization.service.impl.JobServiceImpl;
import weaver.hrm.User;
import java.util.Map;
/**
* @description: TODO
* @author:dxfeng
* @createTime: 2022/05/27
* @version: 1.0
*/
public class JobWrapper extends Service {
private JobService getJobService(User user) {
return ServiceUtil.getService(JobServiceImpl.class, user);
}
public Map<String, Object> getSearchTree(SearchTreeParams params) {
return getJobService(user).getSearchTree(params);
}
}
Loading…
Cancel
Save