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 deddbf74..291e464c 100644 --- a/src/com/engine/organization/service/PersonnelResumeService.java +++ b/src/com/engine/organization/service/PersonnelResumeService.java @@ -1,8 +1,10 @@ package com.engine.organization.service; +import com.api.browser.bean.SearchConditionItem; import com.engine.organization.entity.searchtree.SearchTreeParams; import javax.servlet.http.HttpServletResponse; +import java.util.List; import java.util.Map; /** @@ -43,4 +45,6 @@ public interface PersonnelResumeService { */ String downloadPerResume(Integer type, HttpServletResponse response) throws Exception; + + List personnelScreening(); } diff --git a/src/com/engine/organization/service/impl/PersonnelResumeServiceImpl.java b/src/com/engine/organization/service/impl/PersonnelResumeServiceImpl.java index d62ca475..a8e844d6 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; @@ -73,11 +75,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 @@ -410,28 +417,66 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu return flag; } 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)); @@ -447,9 +492,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<>(); // 补充人员所有岗位,关联人员及聚才林岗位 @@ -464,8 +514,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); @@ -492,6 +549,10 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu // 查询分部信息 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) { @@ -518,9 +579,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<>(); // 补充人员所有岗位,关联人员及聚才林岗位 @@ -534,7 +600,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); // 添加岗位的上级部门或分部 @@ -553,6 +626,7 @@ public class PersonnelResumeServiceImpl extends Service implements PersonnelResu } if (CollectionUtils.isNotEmpty(departmentsByIds)) { + departmentsByIds.removeIf(item -> item.getCanceled() != null && item.getCanceled() != 0); filterDeparts.addAll(departmentsByIds); } } @@ -590,6 +664,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 55618633..d8ac6c72 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; @@ -19,6 +20,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 javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; import java.io.*; @@ -81,6 +85,23 @@ 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 4ce1df04..8ec38cea 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; @@ -8,6 +9,7 @@ import com.engine.organization.util.OrganizationWrapper; import tebie.applib.api.O; import weaver.hrm.User; +import java.util.List; import javax.servlet.http.HttpServletResponse; import java.util.Map; @@ -36,4 +38,8 @@ public class PersonnelResumeWrapper extends OrganizationWrapper { public String downloadPerResume(Integer type, HttpServletResponse response) throws Exception { return getPersonnelResumeService(user).downloadPerResume(type, response); } + + public List personnelScreening() { + return getPersonnelResumeService(user).personnelScreening(); + } }