From 1ae3dcdec0ed474b2ef94eabb3b1cbcdcb3b0671 Mon Sep 17 00:00:00 2001 From: dxfeng Date: Fri, 27 May 2022 18:05:15 +0800 Subject: [PATCH] 11 --- .../api/organization/web/JobController.java | 13 + .../organization/entity/comp/bo/CompBO.java | 85 +++-- .../entity/comp/dto/CompListDTO.java | 2 +- .../entity/department/bo/DepartmentBO.java | 84 ++++- .../department/param/DeptSearchParam.java | 4 +- .../entity/department/po/DepartmentPO.java | 2 +- .../entity/searchtree/SearchTree.java | 21 ++ .../entity/searchtree/SearchTreeParams.java | 30 ++ .../organization/mapper/comp/CompMapper.java | 19 +- .../organization/mapper/comp/CompMapper.xml | 14 + .../mapper/department/DepartmentMapper.java | 71 +++- .../mapper/department/DepartmentMapper.xml | 217 +++++++++--- .../service/DepartmentService.java | 50 ++- .../organization/service/JobService.java | 20 ++ .../service/impl/DepartmentServiceImpl.java | 334 +++++++++++++++--- .../service/impl/GroupServiceImpl.java | 1 - .../service/impl/JobServiceImpl.java | 300 ++++++++++++++++ .../organization/web/CompController.java | 2 +- .../web/DepartmentController.java | 145 +++++++- .../organization/web/JobController.java | 42 +++ .../wrapper/DepartmentWrapper.java | 73 +++- .../organization/wrapper/JobWrapper.java | 27 ++ 22 files changed, 1371 insertions(+), 185 deletions(-) create mode 100644 src/com/api/organization/web/JobController.java create mode 100644 src/com/engine/organization/entity/searchtree/SearchTree.java create mode 100644 src/com/engine/organization/entity/searchtree/SearchTreeParams.java create mode 100644 src/com/engine/organization/service/JobService.java create mode 100644 src/com/engine/organization/service/impl/JobServiceImpl.java create mode 100644 src/com/engine/organization/web/JobController.java create mode 100644 src/com/engine/organization/wrapper/JobWrapper.java diff --git a/src/com/api/organization/web/JobController.java b/src/com/api/organization/web/JobController.java new file mode 100644 index 00000000..7ac87cfc --- /dev/null +++ b/src/com/api/organization/web/JobController.java @@ -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{ +} diff --git a/src/com/engine/organization/entity/comp/bo/CompBO.java b/src/com/engine/organization/entity/comp/bo/CompBO.java index 4b70dbf7..e9133ee4 100644 --- a/src/com/engine/organization/entity/comp/bo/CompBO.java +++ b/src/com/engine/organization/entity/comp/bo/CompBO.java @@ -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 buildCompDTOList(Collection list) { - // 递归添加父级数据 Map poMaps = list.stream().collect(Collectors.toMap(item -> item.getId(), item -> item)); - - List 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 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> 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 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 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> 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 buildListToSearchTree(List 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 buildSetToSearchTree(Set 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()); } /** diff --git a/src/com/engine/organization/entity/comp/dto/CompListDTO.java b/src/com/engine/organization/entity/comp/dto/CompListDTO.java index 1c1892b0..963085aa 100644 --- a/src/com/engine/organization/entity/comp/dto/CompListDTO.java +++ b/src/com/engine/organization/entity/comp/dto/CompListDTO.java @@ -88,7 +88,7 @@ public class CompListDTO { /** * 操作列 */ - @TableTitle(title = "操作", dataIndex = "operate", key = "operate") + @TableTitle(title = "", dataIndex = "operate", key = "operate") private String operate; /** diff --git a/src/com/engine/organization/entity/department/bo/DepartmentBO.java b/src/com/engine/organization/entity/department/bo/DepartmentBO.java index d07d15ab..8fdb7ee3 100644 --- a/src/com/engine/organization/entity/department/bo/DepartmentBO.java +++ b/src/com/engine/organization/entity/department/bo/DepartmentBO.java @@ -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 buildDeptDTOList(Collection list) { + + // 递归添加父级数据 + Map poMaps = list.stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item)); + + List 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> 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 buildDeptDTOList(Collection list, List filterList) { // 搜索结果为空,直接返回空 if (CollectionUtils.isEmpty(filterList)) { return Collections.emptyList(); } // 递归添加父级数据 - Map poMaps = list.stream().collect(Collectors.toMap(item -> item.getId(), item -> item)); + Map poMaps = list.stream().collect(Collectors.toMap(DepartmentPO::getId, item -> item)); List 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> 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 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 buildListToSearchTree(List 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 buildSetToSearchTree(Set 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 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; } diff --git a/src/com/engine/organization/entity/department/param/DeptSearchParam.java b/src/com/engine/organization/entity/department/param/DeptSearchParam.java index 75004134..619b9ec1 100644 --- a/src/com/engine/organization/entity/department/param/DeptSearchParam.java +++ b/src/com/engine/organization/entity/department/param/DeptSearchParam.java @@ -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; } diff --git a/src/com/engine/organization/entity/department/po/DepartmentPO.java b/src/com/engine/organization/entity/department/po/DepartmentPO.java index 512b0367..c93a2ae3 100644 --- a/src/com/engine/organization/entity/department/po/DepartmentPO.java +++ b/src/com/engine/organization/entity/department/po/DepartmentPO.java @@ -31,7 +31,7 @@ public class DepartmentPO { private Long parentDept; - private Integer deptPrincipal; //部门负责人 + private Long deptPrincipal; //部门负责人 private Integer showOrder; diff --git a/src/com/engine/organization/entity/searchtree/SearchTree.java b/src/com/engine/organization/entity/searchtree/SearchTree.java new file mode 100644 index 00000000..d15d125c --- /dev/null +++ b/src/com/engine/organization/entity/searchtree/SearchTree.java @@ -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; +} \ No newline at end of file diff --git a/src/com/engine/organization/entity/searchtree/SearchTreeParams.java b/src/com/engine/organization/entity/searchtree/SearchTreeParams.java new file mode 100644 index 00000000..46d9959f --- /dev/null +++ b/src/com/engine/organization/entity/searchtree/SearchTreeParams.java @@ -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 { + /** + * 数据类型 + *

+ * 0:集团 + * 1:分部 + * 2:部门 + * 3:岗位 + */ + private String type; + private String id; + private String isVirtual; + // 树搜索条件 + private String keyword; + private String virtualCompanyid; + private String isLoadSubDepartment; + + +} diff --git a/src/com/engine/organization/mapper/comp/CompMapper.java b/src/com/engine/organization/mapper/comp/CompMapper.java index 8b4cf21f..38dd7109 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.java +++ b/src/com/engine/organization/mapper/comp/CompMapper.java @@ -43,6 +43,23 @@ public interface CompMapper { */ List listChild(@Param("ids") Collection ids); + /** + * 获取当前ID的子元素 + * + * @param pid + * @return + */ + List 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 */ diff --git a/src/com/engine/organization/mapper/comp/CompMapper.xml b/src/com/engine/organization/mapper/comp/CompMapper.xml index f828deb0..ce41d4fd 100644 --- a/src/com/engine/organization/mapper/comp/CompMapper.xml +++ b/src/com/engine/organization/mapper/comp/CompMapper.xml @@ -208,6 +208,20 @@ #{id} + + update jcl_org_comp diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.java b/src/com/engine/organization/mapper/department/DepartmentMapper.java index 0a29efa8..c564d0b1 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.java +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.java @@ -19,26 +19,83 @@ public interface DepartmentMapper { List getDeptListByPId(@Param("PId") Long PId); - List getDeptList(DepartmentPO departmentPO); + int countChildByPID(@Param("pid") Long pid); + + + /** + * 查询所有数据 + * + * @return + */ + List list(); /** - * 获取顶级数据 + * 根据No查询数据 * + * @param deptNo * @return */ - List listParent(); + List listByNo(@Param("deptNo") String deptNo); - List> listDeptsByIds(@Param("ids") Collection ids); + /** + * 根据搜索条件查询数据 + * + * @return + */ + List listByFilter(DepartmentPO departmentPO); /** - * 获取子层级数据 + * 浏览按钮展示数据用 * * @param ids * @return */ - List listChild(@Param("ids") Collection ids); + List> listDeptsByIds(@Param("ids") Collection 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 ids); } diff --git a/src/com/engine/organization/mapper/department/DepartmentMapper.xml b/src/com/engine/organization/mapper/department/DepartmentMapper.xml index c77f78ed..69686a3d 100644 --- a/src/com/engine/organization/mapper/department/DepartmentMapper.xml +++ b/src/com/engine/organization/mapper/department/DepartmentMapper.xml @@ -18,6 +18,22 @@ + + + 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 + + - - - + + + + + + INSERT INTO jcl_org_dept + + + creator, + + + delete_type, + + + create_time, + + + update_time, + + + + dept_no, + + + dept_name, + + + dept_name_short, + + + parent_comp, + + + parent_dept, + + + dept_principal, + + + show_order, + + + description, + + forbidden_tag, + + + + #{creator}, + + + #{deleteType}, + + + #{createTime}, + + + #{updateTime}, + + + #{deptNo}, + + + #{deptName}, + + + #{deptNameShort}, + + + #{parentComp}, + + + #{parentDept}, + + + #{deptPrincipal}, + + + #{showOrder}, + + + #{description}, + + 0, + + + + + update jcl_org_dept + + 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}, + + WHERE id = #{id} AND delete_type = 0 + + + + update jcl_org_dept + + forbidden_tag=#{forbiddenTag}, + + WHERE id = #{id} AND delete_type = 0 + + + + UPDATE jcl_org_dept + SET delete_type = 1 + WHERE delete_type = 0 + AND id IN + + #{id} + + + @@ -142,6 +246,9 @@ and t.dept_name_short like CONCAT('%',#{deptNameShort},'%') + + and t.dept_name_short like CONCAT('%',#{deptNameShort},'%') + diff --git a/src/com/engine/organization/service/DepartmentService.java b/src/com/engine/organization/service/DepartmentService.java index 79ae4d39..bd69c703 100644 --- a/src/com/engine/organization/service/DepartmentService.java +++ b/src/com/engine/organization/service/DepartmentService.java @@ -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 params); + + + /** + * 根据ID批量删除 + * + * @param ids + */ + int deleteByIds(Collection ids); + + /** + * 获取搜索条件 + * + * @param params + * @return + */ + Map getSearchCondition(Map params); + + /** + * 获取列表页面按钮信息 + * + * @return + */ + Map getHasRight(); + + /** + * 获取基本信息表单 + * + * @param params + * @return + */ + Map getDeptBaseForm(Map params); /** @@ -48,5 +95,4 @@ public interface DepartmentService { */ Map getSaveForm(); - } diff --git a/src/com/engine/organization/service/JobService.java b/src/com/engine/organization/service/JobService.java new file mode 100644 index 00000000..7fd0c6d8 --- /dev/null +++ b/src/com/engine/organization/service/JobService.java @@ -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 getSearchTree(SearchTreeParams params); +} diff --git a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java index 68016ffa..15de4c74 100644 --- a/src/com/engine/organization/service/impl/DepartmentServiceImpl.java +++ b/src/com/engine/organization/service/impl/DepartmentServiceImpl.java @@ -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 getDeptListByPid(QuerySingleDeptListParam param) { @@ -56,24 +95,27 @@ public class DepartmentServiceImpl extends Service implements DepartmentService @Override public Map listPage(DeptSearchParam param) { Map datas = new HashMap<>(); - PageUtil.start(param.getCurrent(), param.getPageSize()); - List parentList = getDepartmentMapper().listParent(); - List list = new ArrayList<>(); - list.addAll(parentList); - - if (CollectionUtils.isNotEmpty(parentList)) { - // 递归查询子数据 - getChildPOs(parentList, list); - } DepartmentPO departmentPO = DepartmentBO.convertParamsToPO(param, (long) user.getUID()); - // 搜索条件过滤数据 - List filterList = filterListByParams(list, departmentPO); - - List departmentListDTOS = DepartmentBO.buildDeptDTOList(list, filterList); - PageInfo pageInfo = new PageInfo<>(departmentListDTOS); + boolean filter = isFilter(departmentPO); + PageInfo pageInfos; + List alltList = getDepartmentMapper().list(); + // 通过子级遍历父级元素 + if (filter) { + // 根据条件获取元素 + List filteDeptPOs = getDepartmentMapper().listByFilter(departmentPO); + // 添加父级元素 + List compListDTOS = DepartmentBO.buildDeptDTOList(alltList, filteDeptPOs); + List subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), compListDTOS); + pageInfos = new PageInfo<>(subList, DepartmentListDTO.class); + pageInfos.setTotal(compListDTOS.size()); + } else { + // 组合list + List compListDTOS = DepartmentBO.buildDeptDTOList(alltList); + List subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), compListDTOS); + pageInfos = new PageInfo<>(subList, DepartmentListDTO.class); + pageInfos.setTotal(compListDTOS.size()); + } - PageInfo 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 columns = pageInfos.getColumns(); List 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 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 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 ids) { + OrganizationAssert.notEmpty(ids, "请选择要删除的数据"); + return getDepartmentMapper().deleteByIds(ids); + } + + @Override + public Map getSearchCondition(Map params) { + Map apiDatas = new HashMap<>(); + List addGroups = new ArrayList<>(); + List 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 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 getHasRight() { + Map btnDatas = new HashMap<>(); + ArrayList topMenuList = new ArrayList<>(); + ArrayList 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 getDeptBaseForm(Map 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 buttonsMap = new HashMap<>(); + buttonsMap.put("hasEdit", true); + buttonsMap.put("hasSave", true); + + List 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 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 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 filterListByParams(Collection departmentPOS, DepartmentPO departmentPO) { - // 搜索后的数据 - List filterList = new ArrayList<>(); - // 筛选数据 - for (Iterator 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 getBaseForm(int viewAttr, long id) { + List 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 parentList, List list) { - List ids = parentList.stream().map(DepartmentPO::getId).collect(Collectors.toList()); - List listChild = getDepartmentMapper().listChild(ids); - if (CollectionUtils.isNotEmpty(listChild)) { - list.addAll(listChild); - getChildPOs(listChild, list); - } + private List> creatReplaceDatas(Object id, Object name) { + List> datas = new ArrayList<>(); + Map map = new HashMap<>(); + map.put("id", id); + map.put("name", name); + datas.add(map); + return datas; + } + + } diff --git a/src/com/engine/organization/service/impl/GroupServiceImpl.java b/src/com/engine/organization/service/impl/GroupServiceImpl.java index d2f6d85b..47bb3e61 100644 --- a/src/com/engine/organization/service/impl/GroupServiceImpl.java +++ b/src/com/engine/organization/service/impl/GroupServiceImpl.java @@ -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 row = new HashMap(); diff --git a/src/com/engine/organization/service/impl/JobServiceImpl.java b/src/com/engine/organization/service/impl/JobServiceImpl.java new file mode 100644 index 00000000..e1a2bb04 --- /dev/null +++ b/src/com/engine/organization/service/impl/JobServiceImpl.java @@ -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 getSearchTree(SearchTreeParams params) { + Map dataMap = new HashMap<>(); + SearchTree topGroup = getTopGroup(); + // 集团 + List 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 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 collect = getFilterCompany(id, type, keyword); + + SearchTree rootCompany = getTopGroup(); + rootCompany.setSubs(collect); + rootCompany.setIsParent(CollectionUtils.isNotEmpty(rootCompany.getSubs())); + Map 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 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 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 getCompany(String id, String type) { + List compSearchTree = new ArrayList<>(); + List 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 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 deptListByCompId = getDepartmentMapper().getDeptListByPId(Long.parseLong(id)); + compSearchTree.addAll(DepartmentBO.buildListToSearchTree(deptListByCompId)); + } + } + return compSearchTree; + } + + private List getFilterCompany(String id, String type, String keyword) { + List compSearchTree = new ArrayList<>(); + if (StringUtils.isAllEmpty(id, type)) { + // 查询部门信息 + List filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().deptName(keyword).build()); + Set builderDeparts = new HashSet<>(); + for (DepartmentPO departmentPO : filterDeparts) { + buildParentDepts(departmentPO, builderDeparts); + } + List deptTrees = builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts)); + + // 查询分部信息 + List filterComps = getCompMapper().listByFilter(CompPO.builder().compName(keyword).build()); + Set builderComps = new HashSet<>(); + for (CompPO compPO : filterComps) { + buildParentComps(compPO, builderComps); + } + List compTrees = builderTreeMode(CompBO.buildSetToSearchTree(builderComps), deptTrees); + + // 排序,设置是否为叶子节点 + List 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 filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().deptName(keyword).parentComp(Long.parseLong(id)).build()); + Set builderDeparts = new HashSet<>(); + for (DepartmentPO departmentPO : filterDeparts) { + buildParentDepts(departmentPO, builderDeparts); + } + List deptTrees = builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts)); + + // 查询分部信息 + List filterComps = getCompMapper().listByFilter(CompPO.builder().compName(keyword).parentCompany(Long.parseLong(id)).build()); + Set builderComps = new HashSet<>(); + for (CompPO compPO : filterComps) { + buildParentComps(compPO, builderComps); + } + List compTrees = builderTreeMode(CompBO.buildSetToSearchTree(builderComps), deptTrees); + + // 排序,设置是否为叶子节点 + List 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 filterDeparts = getDepartmentMapper().listByFilter(DepartmentPO.builder().deptName(keyword).parentDept(Long.parseLong(id)).build()); + Set builderDeparts = new HashSet<>(); + for (DepartmentPO departmentPO : filterDeparts) { + buildParentDepts(departmentPO, builderDeparts); + } + List deptTrees = builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts)); + // 排序,设置是否为叶子节点 + List 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 builderTreeMode(List treeList) { + Map> 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 builderTreeMode(List treeList, List deptTrees) { + Map> parentMap = treeList.stream().collect(Collectors.groupingBy(TreeNode::getPid)); + Map> childMap = deptTrees.stream().collect(Collectors.groupingBy(SearchTree::getParentComp)); + boolean isAdd = !childMap.isEmpty(); + return treeList.stream().peek(e -> { + List treeNodes = new ArrayList<>(); + List 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()); + } + +} diff --git a/src/com/engine/organization/web/CompController.java b/src/com/engine/organization/web/CompController.java index a5938a37..7e92cd59 100644 --- a/src/com/engine/organization/web/CompController.java +++ b/src/com/engine/organization/web/CompController.java @@ -93,7 +93,7 @@ public class CompController { } /** - * 更新禁用标记 + * 更新表单 * * @param request * @param response diff --git a/src/com/engine/organization/web/DepartmentController.java b/src/com/engine/organization/web/DepartmentController.java index e191dc0d..3a6a6738 100644 --- a/src/com/engine/organization/web/DepartmentController.java +++ b/src/com/engine/organization/web/DepartmentController.java @@ -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 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 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 map = ParamUtil.request2Map(request); + return ReturnResult.successed(getDepartmentWrapper(user).getDeptBaseForm(map)); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e.getMessage()); + } + } + /** * 新增保存表单 * diff --git a/src/com/engine/organization/web/JobController.java b/src/com/engine/organization/web/JobController.java new file mode 100644 index 00000000..ef405ec4 --- /dev/null +++ b/src/com/engine/organization/web/JobController.java @@ -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 getSearchTree(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map map = ParamUtil.request2Map(request); + SearchTreeParams params = JSONObject.toJavaObject((JSON) JSONObject.toJSON(map), SearchTreeParams.class); + return getJobWrapper(user).getSearchTree(params); + + } +} diff --git a/src/com/engine/organization/wrapper/DepartmentWrapper.java b/src/com/engine/organization/wrapper/DepartmentWrapper.java index 8e90b9fc..363ae0f4 100644 --- a/src/com/engine/organization/wrapper/DepartmentWrapper.java +++ b/src/com/engine/organization/wrapper/DepartmentWrapper.java @@ -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 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 params) { + return getDepartmentService(user).updateForm(params); + } + + /** + * 根据ID批量删除 + * + * @param ids + */ + public int deleteByIds(Collection ids) { + return getDepartmentService(user).deleteByIds(ids); + } + + /** + * 获取搜索条件 + * + * @param params + * @return + */ + public Map getSearchCondition(Map params) { + return getDepartmentService(user).getSearchCondition(params); + } + + /** + * 获取列表页面按钮信息 + * + * @return + */ + public Map getHasRight() { + return getDepartmentService(user).getHasRight(); + } + + /** + * 获取基本信息表单 + * + * @param params + * @return + */ + public Map getDeptBaseForm(Map params) { + return getDepartmentService(user).getDeptBaseForm(params); + } + + } diff --git a/src/com/engine/organization/wrapper/JobWrapper.java b/src/com/engine/organization/wrapper/JobWrapper.java new file mode 100644 index 00000000..a833d728 --- /dev/null +++ b/src/com/engine/organization/wrapper/JobWrapper.java @@ -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 getSearchTree(SearchTreeParams params) { + return getJobService(user).getSearchTree(params); + } + +}