From 586330f99ebe5b880144862857c883c4f1b2005f Mon Sep 17 00:00:00 2001 From: dxfeng Date: Wed, 4 Jan 2023 16:50:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=91=98=E7=AD=9B=E9=80=89=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=BC=80=E5=8F=91=E3=80=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/searchtree/SearchTreeParams.java | 39 +++++++ .../mapper/resource/HrmResourceMapper.java | 1 + .../mapper/resource/HrmResourceMapper.xml | 30 ++++++ .../service/PersonnelResumeService.java | 4 + .../impl/PersonnelResumeServiceImpl.java | 102 +++++++++++++++--- .../util/OrganizationFormItemUtil.java | 10 ++ .../organization/util/detach/DetachUtil.java | 7 ++ .../web/PersonnelResumeController.java | 21 ++++ .../wrapper/PersonnelResumeWrapper.java | 6 ++ 9 files changed, 207 insertions(+), 13 deletions(-) diff --git a/src/com/engine/organization/entity/searchtree/SearchTreeParams.java b/src/com/engine/organization/entity/searchtree/SearchTreeParams.java index bc1b08f2..34018fbe 100644 --- a/src/com/engine/organization/entity/searchtree/SearchTreeParams.java +++ b/src/com/engine/organization/entity/searchtree/SearchTreeParams.java @@ -1,6 +1,12 @@ package com.engine.organization.entity.searchtree; import lombok.Data; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; /** * @description: @@ -26,5 +32,38 @@ public class SearchTreeParams { private String virtualCompanyid; private String isLoadSubDepartment; + // 人员筛选,添加分部、部门、岗位、人员搜索条件 + private String subcompanyid1; + private String departmentid; + private String jobId; + private String resourceId; + private boolean personnelScreening; + + public List getSubcompanyid1() { + if (StringUtils.isBlank(subcompanyid1)) { + return new ArrayList<>(); + } + return Arrays.stream(subcompanyid1.split(",")).map(Integer::parseInt).collect(Collectors.toList()); + } + + public List getDepartmentid() { + if (StringUtils.isBlank(departmentid)) { + return new ArrayList<>(); + } + return Arrays.stream(departmentid.split(",")).map(Integer::parseInt).collect(Collectors.toList()); + } + + public List getJobId() { + if (StringUtils.isBlank(jobId)) { + return new ArrayList<>(); + } + return Arrays.stream(jobId.split(",")).map(Long::parseLong).collect(Collectors.toList()); + } + public List getResourceId() { + if (StringUtils.isBlank(resourceId)) { + return new ArrayList<>(); + } + return Arrays.stream(resourceId.split(",")).map(Long::parseLong).collect(Collectors.toList()); + } } diff --git a/src/com/engine/organization/mapper/resource/HrmResourceMapper.java b/src/com/engine/organization/mapper/resource/HrmResourceMapper.java index e303bd30..43a1dca0 100644 --- a/src/com/engine/organization/mapper/resource/HrmResourceMapper.java +++ b/src/com/engine/organization/mapper/resource/HrmResourceMapper.java @@ -23,4 +23,5 @@ public interface HrmResourceMapper { List getHrmFamilyInfoByUser(@Param("resourceId") Integer resourceId); + List getPersonnelScreening(@Param("subCompanyIds") List subcompanyid1, @Param("departmentIds") List departmentid, @Param("jobIds") List jobId, @Param("resourceIds") List resourceId); } diff --git a/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml b/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml index 8dae95f3..f67c7f09 100644 --- a/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml +++ b/src/com/engine/organization/mapper/resource/HrmResourceMapper.xml @@ -56,6 +56,36 @@ from HrmFamilyInfo where resourceid = #{resourceId} + diff --git a/src/com/engine/organization/service/PersonnelResumeService.java b/src/com/engine/organization/service/PersonnelResumeService.java index 28b83ab2..cebc220e 100644 --- a/src/com/engine/organization/service/PersonnelResumeService.java +++ b/src/com/engine/organization/service/PersonnelResumeService.java @@ -1,7 +1,9 @@ package com.engine.organization.service; +import com.api.browser.bean.SearchConditionItem; import com.engine.organization.entity.searchtree.SearchTreeParams; +import java.util.List; import java.util.Map; /** @@ -32,4 +34,6 @@ public interface PersonnelResumeService { * @return */ Map hasRight(); + + List personnelScreening(); } diff --git a/src/com/engine/organization/service/impl/PersonnelResumeServiceImpl.java b/src/com/engine/organization/service/impl/PersonnelResumeServiceImpl.java index 50e55f5a..c62e4d42 100644 --- a/src/com/engine/organization/service/impl/PersonnelResumeServiceImpl.java +++ b/src/com/engine/organization/service/impl/PersonnelResumeServiceImpl.java @@ -1,5 +1,6 @@ package com.engine.organization.service.impl; +import com.api.browser.bean.SearchConditionItem; import com.engine.core.impl.Service; import com.engine.organization.entity.DeleteParam; import com.engine.organization.entity.company.bo.CompBO; @@ -24,6 +25,7 @@ import com.engine.organization.mapper.resource.HrmResourceMapper; import com.engine.organization.service.PersonnelResumeService; 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.detach.DetachUtil; import com.engine.organization.util.page.PageUtil; @@ -61,11 +63,16 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu @Override public Map getSearchTree(SearchTreeParams params) { - String keyword = params.getKeyword(); - String id = params.getId(); - String type = Util.null2String(params.getType()); - List treeList = getFilterDatas(id, type, keyword); - return SearchTreeUtil.getSearchTree(type, treeList); + // 查询所有满足条件的人员ID、根据人员向上查找对应的组织架构 + List resourcePOList = null; + if (CollectionUtils.isNotEmpty(params.getSubcompanyid1()) || CollectionUtils.isNotEmpty(params.getDepartmentid()) || CollectionUtils.isNotEmpty(params.getJobId()) || CollectionUtils.isNotEmpty(params.getResourceId())) { + params.setPersonnelScreening(true); + // 人员筛选 + resourcePOList = getHrmResourceMapper().getPersonnelScreening(params.getSubcompanyid1(), params.getDepartmentid(), params.getJobId(), params.getResourceId()); + resourcePOList.removeIf(item->!item.getLastName().contains(params.getKeyword())); + } + List treeList = getFilterDatas(params, resourcePOList); + return SearchTreeUtil.getSearchTree(Util.null2String(params.getType()), treeList); } @Override @@ -165,29 +172,66 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu return resultMap; } - public List getFilterDatas(String id, String type, String keyword) { + @Override + public List personnelScreening() { + List items = new ArrayList<>(); + // 所属分部 + SearchConditionItem companyItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "分部", "194", "subcompanyid1", ""); + // 所属部门 + SearchConditionItem departmentItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "部门", "57", "departmentid", ""); + + SearchConditionItem jobItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "岗位", "666", "jobId", ""); + + SearchConditionItem resourceItem = OrganizationFormItemUtil.browserItem(user, 2, 16, 2, false, "人员", "17", "resourceId", ""); + items.add(companyItem); + items.add(departmentItem); + items.add(jobItem); + items.add(resourceItem); + return items; + } + + public List getFilterDatas(SearchTreeParams params, List resourcePOList) { + String keyword = params.getKeyword(); + String id = params.getId(); + String type = Util.null2String(params.getType()); + List searchTree = new ArrayList<>(); // 通过分部、公司 组装数据 if (StringUtil.isEmpty(id) || ModuleTypeEnum.subcompanyfielddefined.getValue().toString().equals(type)) { Integer subCompanyId1 = StringUtil.isEmpty(id) ? null : Integer.parseInt(id); + if (params.isPersonnelScreening()) { + new DetachUtil(user).filterResourceList(resourcePOList); + if (null != subCompanyId1) { + resourcePOList.removeIf(item -> !subCompanyId1.equals(item.getSubcompanyid1())); + } + } DepartmentPO departmentBuild = DepartmentPO.builder().departmentName(keyword).subCompanyId1(subCompanyId1).canceled(0).build(); CompPO compBuild = CompPO.builder().subCompanyName(keyword).supSubComId(subCompanyId1).canceled(0).build(); // 所属分部下的岗位 JobPO jobBuild = JobPO.builder().jobTitleName(keyword).ecCompany(subCompanyId1).forbiddenTag(0).build(); ResourcePO resourcePO = ResourcePO.builder().lastName(keyword).subcompanyid1(subCompanyId1).build(); - searchTree = buildTreeByCompAndDept(departmentBuild, compBuild, jobBuild, resourcePO); + searchTree = buildTreeByCompAndDept(params, resourcePOList, departmentBuild, compBuild, jobBuild, resourcePO); } else if (ModuleTypeEnum.departmentfielddefined.getValue().toString().equals(type)) { Integer departmentId = Integer.parseInt(id); + if (null != resourcePOList) { + new DetachUtil(user).filterResourceList(resourcePOList); + resourcePOList.removeIf(item -> !departmentId.equals(item.getDepartmentid())); + } DepartmentPO departmentBuild = DepartmentPO.builder().departmentName(keyword).supDepId(departmentId).canceled(0).build(); // 所属分部下的岗位 JobPO jobBuild = JobPO.builder().jobTitleName(keyword).ecDepartment(departmentId).forbiddenTag(0).build(); ResourcePO resourcePO = ResourcePO.builder().lastName(keyword).departmentid(departmentId).build(); - searchTree = buildTreeByDeptAndJob(departmentBuild, jobBuild, resourcePO); + searchTree = buildTreeByDeptAndJob(params, resourcePOList, departmentBuild, jobBuild, resourcePO); } else if (ModuleTypeEnum.jobfielddefined.getValue().toString().equals(type)) { Long jobId = Long.parseLong(id); JobPO jobById = getJobMapper().getJobById(jobId); + if (null != resourcePOList) { + new DetachUtil(user).filterResourceList(resourcePOList); + resourcePOList.removeIf(item -> !(jobById.getEcCompany().equals(item.getSubcompanyid1()) && jobById.getEcDepartment().equals(item.getDepartmentid())) && jobById.getEcJobTitle().equals(item.getJobtitle())); + return SearchTreeUtil.builderTreeMode(ResourceBO.buildSetToSearchTree(resourcePOList)); + } ResourcePO resourcePO = ResourcePO.builder().lastName(keyword).subcompanyid1(jobById.getEcCompany()).departmentid(jobById.getEcDepartment()).jobtitle(jobById.getEcJobTitle()).build(); List resourcePOS = getHrmResourceMapper().listByFilter(resourcePO); searchTree = SearchTreeUtil.builderTreeMode(ResourceBO.buildSetToSearchTree(resourcePOS)); @@ -203,9 +247,14 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu * @param jobBuild * @return */ - private List buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild, JobPO jobBuild, ResourcePO resourcePO) { + private List buildTreeByCompAndDept(SearchTreeParams params, List resourcePOList, DepartmentPO departmentBuild, CompPO compBuild, JobPO jobBuild, ResourcePO resourcePO) { // 查询人员数据 - List resourcePOS = getHrmResourceMapper().listByFilter(resourcePO); + List resourcePOS; + if (params.isPersonnelScreening()) { + resourcePOS = resourcePOList; + } else { + resourcePOS = getHrmResourceMapper().listByFilter(resourcePO); + } Set builderJobs = new HashSet<>(); // 补充人员所有岗位,关联人员及聚才林岗位 @@ -220,8 +269,15 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu List jobPOS = getJobMapper().listPOsByFilter(jobBuild); + if (params.isPersonnelScreening()) { + jobPOS.removeIf(item -> !params.getJobId().contains(item.getId())); + } + new DetachUtil(user).filterJobList(jobPOS); List filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder"); + if (params.isPersonnelScreening()) { + filterDeparts.removeIf(item -> !params.getDepartmentid().contains(item.getId())); + } new DetachUtil(user).filterDepartmentList(filterDeparts); // 添加父级岗位 builderJobs.addAll(jobPOS); @@ -242,12 +298,17 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu } if (CollectionUtils.isNotEmpty(departmentsByIds)) { + departmentsByIds.removeIf(item -> item.getCanceled() != null && item.getCanceled() != 0); filterDeparts.addAll(departmentsByIds); } } // 查询分部信息 List filterComps = getCompMapper().listByFilter(compBuild, "showorder"); + if (params.isPersonnelScreening()) { + filterComps.removeIf(item -> !params.getSubcompanyid1().contains(item.getId())); + } + new DetachUtil(user).filterCompanyList(filterComps); Set builderDeparts = new HashSet<>(); for (DepartmentPO departmentPO : filterDeparts) { @@ -274,9 +335,14 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps), searchTrees); } - private List buildTreeByDeptAndJob(DepartmentPO departmentBuild, JobPO jobBuild, ResourcePO resourcePO) { + private List buildTreeByDeptAndJob(SearchTreeParams params, List resourcePOList, DepartmentPO departmentBuild, JobPO jobBuild, ResourcePO resourcePO) { // 查询人员数据 - List resourcePOS = getHrmResourceMapper().listByFilter(resourcePO); + List resourcePOS; + if (params.isPersonnelScreening()) { + resourcePOS = resourcePOList; + } else { + resourcePOS = getHrmResourceMapper().listByFilter(resourcePO); + } Set builderJobs = new HashSet<>(); // 补充人员所有岗位,关联人员及聚才林岗位 @@ -290,7 +356,14 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu List resourceTrees = SearchTreeUtil.builderTreeMode(ResourceBO.buildSetToSearchTree(resourcePOS)); List jobPOS = getJobMapper().listPOsByFilter(jobBuild); + if (params.isPersonnelScreening()) { + jobPOS.removeIf(item -> !params.getJobId().contains(item.getId())); + } + List filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "showorder"); + if (params.isPersonnelScreening()) { + filterDeparts.removeIf(item -> !params.getDepartmentid().contains(item.getId())); + } // 添加父级岗位 builderJobs.addAll(jobPOS); // 添加岗位的上级部门或分部 @@ -309,6 +382,7 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu } if (CollectionUtils.isNotEmpty(departmentsByIds)) { + departmentsByIds.removeIf(item -> item.getCanceled() != null && item.getCanceled() != 0); filterDeparts.addAll(departmentsByIds); } } @@ -321,7 +395,6 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu return SearchTreeUtil.builderTreeMode(DepartmentBO.buildSetToSearchTree(builderDeparts), jobTrees); } - /** * 添加查询元素的父级元素 * @@ -346,6 +419,9 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu * @param builderComps */ private void buildParentComps(CompPO compPO, Set builderComps, Map allMaps) { + if (null != compPO.getCanceled() && 0 != compPO.getCanceled()) { + return; + } builderComps.add(compPO); CompPO parentComp = allMaps.get(compPO.getSupSubComId()); if (null != parentComp) { diff --git a/src/com/engine/organization/util/OrganizationFormItemUtil.java b/src/com/engine/organization/util/OrganizationFormItemUtil.java index 7f7daa2a..91697ee1 100644 --- a/src/com/engine/organization/util/OrganizationFormItemUtil.java +++ b/src/com/engine/organization/util/OrganizationFormItemUtil.java @@ -1,10 +1,12 @@ package com.engine.organization.util; +import com.alibaba.fastjson.JSONObject; import com.api.browser.bean.BrowserBean; import com.api.browser.bean.SearchConditionItem; import com.api.browser.bean.SearchConditionOption; import com.api.browser.util.ConditionFactory; import com.api.browser.util.ConditionType; +import com.engine.organization.entity.browser.po.CustomBrowserBean; import weaver.hrm.User; import java.util.ArrayList; @@ -182,6 +184,14 @@ public class OrganizationFormItemUtil { browser.setOtherParams(otherMap); } } + if ("666".equals(type)) { + BrowserBean browserBean = browser.getBrowserConditionParam(); + String s = JSONObject.toJSONString(browserBean); + CustomBrowserBean customBrowserBean = JSONObject.parseObject(s, CustomBrowserBean.class); + customBrowserBean.setHasLeftTree(true); + customBrowserBean.setLeftToSearchKey("treeKey"); + browser.setBrowserConditionParam(customBrowserBean); + } return browser; } diff --git a/src/com/engine/organization/util/detach/DetachUtil.java b/src/com/engine/organization/util/detach/DetachUtil.java index d27ca2bb..12f269ef 100644 --- a/src/com/engine/organization/util/detach/DetachUtil.java +++ b/src/com/engine/organization/util/detach/DetachUtil.java @@ -2,6 +2,7 @@ package com.engine.organization.util.detach; import com.engine.organization.entity.company.po.CompPO; import com.engine.organization.entity.department.po.DepartmentPO; +import com.engine.organization.entity.hrmresource.po.ResourcePO; import com.engine.organization.entity.job.dto.JobListDTO; import com.engine.organization.entity.job.po.JobPO; import com.engine.organization.service.impl.ManagerDetachServiceImpl; @@ -70,6 +71,12 @@ public class DetachUtil { } } + public void filterResourceList(List resourcePOS) { + if (DETACH && CollectionUtils.isNotEmpty(resourcePOS)) { + resourcePOS.removeIf(item -> !jclRoleLevels.contains(item.getSubcompanyid1())); + } + } + public String getJclRoleLevels() { return StringUtils.join(jclRoleLevels, ","); } diff --git a/src/com/engine/organization/web/PersonnelResumeController.java b/src/com/engine/organization/web/PersonnelResumeController.java index f09053b3..89700da1 100644 --- a/src/com/engine/organization/web/PersonnelResumeController.java +++ b/src/com/engine/organization/web/PersonnelResumeController.java @@ -2,6 +2,7 @@ package com.engine.organization.web; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.api.browser.bean.SearchConditionGroup; import com.engine.common.util.ParamUtil; import com.engine.common.util.ServiceUtil; import com.engine.organization.entity.searchtree.SearchTreeParams; @@ -18,6 +19,9 @@ 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.ArrayList; +import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -75,4 +79,21 @@ public class PersonnelResumeController { } + @GET + @Path("/personnelScreening") + @Produces(MediaType.APPLICATION_JSON) + public ReturnResult personnelScreening(@Context HttpServletRequest request, @Context HttpServletResponse response) { + try { + User user = HrmUserVarify.getUser(request, response); + Map returnMap = new HashMap<>(); + List addGroups = new ArrayList<>(); + addGroups.add(new SearchConditionGroup("高级搜索条件", true, getPersonnelResumeWrapper(user).personnelScreening())); + returnMap.put("conditions",addGroups); + return ReturnResult.successed(returnMap); + } catch (Exception e) { + return ReturnResult.exceptionHandle(e); + } + + } + } diff --git a/src/com/engine/organization/wrapper/PersonnelResumeWrapper.java b/src/com/engine/organization/wrapper/PersonnelResumeWrapper.java index 460b3fc2..64c0f2fb 100644 --- a/src/com/engine/organization/wrapper/PersonnelResumeWrapper.java +++ b/src/com/engine/organization/wrapper/PersonnelResumeWrapper.java @@ -1,5 +1,6 @@ package com.engine.organization.wrapper; +import com.api.browser.bean.SearchConditionItem; import com.engine.common.util.ServiceUtil; import com.engine.organization.entity.searchtree.SearchTreeParams; import com.engine.organization.service.PersonnelResumeService; @@ -7,6 +8,7 @@ import com.engine.organization.service.impl.PersonnelResumeServiceImpl; import com.engine.organization.util.OrganizationWrapper; import weaver.hrm.User; +import java.util.List; import java.util.Map; /** @@ -30,4 +32,8 @@ public class PersonnelResumeWrapper extends OrganizationWrapper { public Map getResumeList(Integer uId) { return getPersonnelResumeService(user).getResumeList(uId); } + + public List personnelScreening() { + return getPersonnelResumeService(user).personnelScreening(); + } }