分部、部门、岗位、人员 分权功能开发

pull/32/head
dxfeng 3 years ago
parent 955134dc28
commit 895528617b

@ -698,4 +698,20 @@ BEGIN;
INSERT INTO `JCL_INFO` (`id`, `fname`, `fvalue`) VALUES (1, '董事长人员i', '36');
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;
SET FOREIGN_KEY_CHECKS = 1;
CREATE TABLE `jcl_org_detach` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`manager_type` int(11) NULL DEFAULT NULL,
`ec_manager` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`jcl_manager` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`ec_rolelevel` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`jcl_rolelevel` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`manage_module` text CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`creator` int(11) NULL DEFAULT NULL,
`delete_type` int(11) NULL DEFAULT NULL,
`create_time` date NULL DEFAULT NULL,
`update_time` date NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

@ -1087,4 +1087,29 @@ GO
ALTER TABLE [dbo].[jcl_info] ADD CONSTRAINT [PK_jcl_info] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY]
GO
GO
CREATE TABLE [dbo].[JCL_ORG_DETACH] (
[id] int IDENTITY(1,1) NOT NULL,
[manager_type] int NULL,
[ec_manager] int NOT NULL,
[jcl_manager] int NOT NULL,
[ec_rolelevel] varchar(4000) COLLATE Chinese_PRC_CI_AS NOT NULL,
[jcl_rolelevel] varchar(4000) COLLATE Chinese_PRC_CI_AS NOT NULL,
[manage_module] varchar(4000) COLLATE Chinese_PRC_CI_AS NOT NULL,
[creator] int NULL,
[delete_type] int NULL,
[create_time] date NULL,
[update_time] date NULL
)
GO
ALTER TABLE [dbo].[JCL_ORG_DETACH] SET (LOCK_ESCALATION = TABLE)
GO
ALTER TABLE [dbo].[JCL_ORG_DETACH] ADD CONSTRAINT [JCL_ORG_DETACH_PK] PRIMARY KEY CLUSTERED ([id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY]
GO

@ -524,9 +524,9 @@ create table JCL_ORG_DETACH (
manager_type int null,
ec_manager int not null,
jcl_manager int not null,
ec_rolelevel text not null,
jcl_rolelevel text not null,
manage_module text not null,
ec_rolelevel varchar(4000) not null,
jcl_rolelevel varchar(4000) not null,
manage_module varchar(4000) not null,
creator int null,
delete_type int null,
create_time date null,

@ -68,6 +68,7 @@ public class JobListDTO {
//@TableTitle(title = "上级岗位", dataIndex = "parentJobName", key = "parentJobName")
private String parentJobName;
private Long parentJob;
private Long parentComp;
/**
*
*/

@ -3,6 +3,8 @@ package com.engine.organization.entity.searchtree;
import com.api.hrm.bean.TreeNode;
import lombok.Data;
import java.util.Objects;
/**
* @description:
* @author:dxfeng
@ -19,4 +21,17 @@ public class SearchTree extends TreeNode {
private String requestParams;
private String parentComp;
private Integer orderNum;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SearchTree that = (SearchTree) o;
return isCanceled == that.isCanceled && Objects.equals(this.getId(), that.getId()) &&Objects.equals(companyid, that.companyid) && Objects.equals(isVirtual, that.isVirtual) && Objects.equals(psubcompanyid, that.psubcompanyid) && Objects.equals(displayType, that.displayType) && Objects.equals(requestParams, that.requestParams) && Objects.equals(parentComp, that.parentComp) && Objects.equals(orderNum, that.orderNum);
}
@Override
public int hashCode() {
return Objects.hash(this.getId(),companyid, isVirtual, psubcompanyid, displayType, isCanceled, requestParams, parentComp, orderNum);
}
}

@ -174,4 +174,6 @@ public interface CompMapper {
CompPO getCompanyByNo(@Param("companyNo") String companyNo);
List<Long> getCompanyIdsByUuid(@Param("uuids") List<String> uuids);
}

@ -435,6 +435,13 @@
where forbidden_tag = 0
and delete_type = 0
</select>
<select id="getCompanyIdsByUuid" resultType="java.lang.Long">
select id from jcl_org_comp
where delete_type = 0 and uuid in
<foreach collection="uuids" open="(" item="uuid" separator="," close=")">
#{uuid}
</foreach>
</select>
<update id="updateForbiddenTagById" parameterType="com.engine.organization.entity.sequence.po.SequencePO">
update jcl_org_comp

@ -59,4 +59,6 @@ public interface SystemDataMapper {
Long getHrmResourceMaxId();
List<String> getBatchUuidByIds(@Param("tableName") String tableName,@Param("ecIds") List<String> ecIds);
}

@ -159,5 +159,12 @@
where department_id = #{departmentId}
</select>
<select id="getBatchUuidByIds" resultType="java.lang.String">
select uuid from ${tableName} where id in
<foreach collection="ecIds" open="(" item="ecId" separator="," close=")">
#{ecId}
</foreach>
</select>
</mapper>

@ -55,6 +55,7 @@ import com.engine.organization.util.OrganizationFormItemUtil;
import com.engine.organization.util.coderule.CodeRuleUtil;
import com.engine.organization.util.db.DBType;
import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.detach.DetachUtil;
import com.engine.organization.util.page.PageUtil;
import com.engine.organization.util.tree.SearchTreeUtil;
import org.apache.commons.collections.CollectionUtils;
@ -520,6 +521,13 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
sqlWhere += " AND t.job_title = '" + jobTitle + "'";
}
// 分权查询
List<Long> jclRoleLevels = new DetachUtil(user.getUID()).getJclRoleLevels();
String parentCompanyIds = StringUtils.join(jclRoleLevels, ",");
if (StringUtils.isNotBlank(parentCompanyIds)) {
sqlWhere += " And t.company_id in(" + parentCompanyIds + ")";
}
return sqlWhere;
}
@ -562,7 +570,9 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
*/
private List<SearchTree> buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild, JobPO jobBuild) {
List<JobPO> jobPOS = getJobMapper().listPOsByFilter(jobBuild);
new DetachUtil(user.getUID()).filterJobList(jobPOS);
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "show_order");
new DetachUtil(user.getUID()).filterDepartmentList(filterDeparts);
// 添加父级岗位
Set<JobPO> builderJobs = new HashSet<>();
for (JobPO jobPO : jobPOS) {
@ -592,6 +602,7 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
// 查询分部信息
List<CompPO> filterComps = getCompMapper().listByFilter(compBuild, "show_order");
new DetachUtil(user.getUID()).filterCompanyList(filterComps);
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
buildParentDepts(departmentPO, builderDeparts);
@ -607,9 +618,12 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
filterComps.addAll(compsByIds);
}
}
List<CompPO> allCompanys = getCompMapper().list("show_order");
new DetachUtil(user.getUID()).filterCompanyList(allCompanys);
Map<Long, CompPO> allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1));
Set<CompPO> builderComps = new HashSet<>();
for (CompPO compPO : filterComps) {
buildParentComps(compPO, builderComps);
buildParentComps(compPO, builderComps,allMaps);
}
return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps), searchTrees);
}
@ -684,14 +698,11 @@ public class HrmResourceServiceImpl extends Service implements HrmResourceServic
* @param compPO
* @param builderComps
*/
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps) {
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps,Map<Long, CompPO> allMaps) {
builderComps.add(compPO);
if (SearchTreeUtil.isTop(compPO.getParentCompany())) {
return;
}
CompPO parentComp = getCompMapper().listById(compPO.getParentCompany());
CompPO parentComp = allMaps.get(compPO.getParentCompany());
if (null != parentComp) {
buildParentComps(parentComp, builderComps);
buildParentComps(parentComp, builderComps,allMaps);
}
}

@ -50,6 +50,7 @@ import com.engine.organization.thread.OrganizationSyncEc;
import com.engine.organization.util.*;
import com.engine.organization.util.coderule.CodeRuleUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.detach.DetachUtil;
import com.engine.organization.util.page.Column;
import com.engine.organization.util.page.PageInfo;
import com.engine.organization.util.page.PageUtil;
@ -164,10 +165,12 @@ public class JobServiceImpl extends Service implements JobService {
PageInfo<JobListDTO> pageInfos;
String orderSql = PageInfoSortUtil.getSortSql(param.getSortParams());
List<JobListDTO> allList = getJobMapper().listNoFilter(orderSql);
new DetachUtil(user.getUID()).filterJobDTOList(allList);
// 通过子级遍历父级元素
if (filter) {
// 根据条件获取元素
List<JobListDTO> filterJobPOs = getJobMapper().listByFilter(jobPO, orderSql);
new DetachUtil(user.getUID()).filterJobDTOList(allList);
// 添加父级元素
List<JobListDTO> jobListDTOS = JobBO.buildJobDTOList(allList, filterJobPOs);
List<JobListDTO> subList = PageUtil.subList(param.getCurrent(), param.getPageSize(), jobListDTOS);
@ -639,14 +642,11 @@ public class JobServiceImpl extends Service implements JobService {
* @param compPO
* @param builderComps
*/
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps) {
private void buildParentComps(CompPO compPO, Set<CompPO> builderComps,Map<Long, CompPO> allMaps) {
builderComps.add(compPO);
if (SearchTreeUtil.isTop(compPO.getParentCompany())) {
return;
}
CompPO parentComp = getCompMapper().listById(compPO.getParentCompany());
CompPO parentComp = allMaps.get(compPO.getParentCompany());
if (null != parentComp && 0 == parentComp.getForbiddenTag()) {
buildParentComps(parentComp, builderComps);
buildParentComps(parentComp, builderComps,allMaps);
}
}
@ -689,8 +689,10 @@ public class JobServiceImpl extends Service implements JobService {
*/
private List<SearchTree> buildTreeByCompAndDept(DepartmentPO departmentBuild, CompPO compBuild) {
List<DepartmentPO> filterDeparts = getDepartmentMapper().listByFilter(departmentBuild, "show_order");
new DetachUtil(user.getUID()).filterDepartmentList(filterDeparts);
// 查询分部信息
List<CompPO> filterComps = getCompMapper().listByFilter(compBuild, "show_order");
new DetachUtil(user.getUID()).filterCompanyList(filterComps);
Set<DepartmentPO> builderDeparts = new HashSet<>();
for (DepartmentPO departmentPO : filterDeparts) {
buildParentDepts(departmentPO, builderDeparts);
@ -704,9 +706,12 @@ public class JobServiceImpl extends Service implements JobService {
filterComps.addAll(compsByIds);
}
}
List<CompPO> allCompanys = getCompMapper().list("show_order");
new DetachUtil(user.getUID()).filterCompanyList(allCompanys);
Map<Long, CompPO> allMaps = allCompanys.stream().collect(Collectors.toMap(CompPO::getId, item -> item, (k1, k2) -> k1));
Set<CompPO> builderComps = new HashSet<>();
for (CompPO compPO : filterComps) {
buildParentComps(compPO, builderComps);
buildParentComps(compPO, builderComps,allMaps);
}
return SearchTreeUtil.builderTreeMode(CompBO.buildSetToSearchTree(builderComps), deptTrees);
}

@ -125,8 +125,7 @@ public class ManagerDetachServiceImpl extends Service implements ManagerDetachSe
.ecManager(param.getEcManager())
.jclManager(getHrmResourceMapper().getJclResourceId(String.valueOf(param.getEcManager())).intValue())
.ecRolelevel(param.getEcRolelevel())
// TODO 遍历存储
.jclRolelevel(EcHrmRelationUtil.getJclCompanyId(param.getEcRolelevel()) != null ? String.valueOf(EcHrmRelationUtil.getJclCompanyId(param.getEcRolelevel()).getId()) : null)
.jclRolelevel(EcHrmRelationUtil.getJclCompanyId(param.getEcRolelevel()) != null ? String.valueOf(EcHrmRelationUtil.getBatchJclCompanyId(param.getEcRolelevel())) : null)
.manageModule("组织管理")
.creator((long)user.getUID())
.deleteType(0)
@ -144,7 +143,7 @@ public class ManagerDetachServiceImpl extends Service implements ManagerDetachSe
.ecManager(param.getEcManager())
.jclManager(getHrmResourceMapper().getJclResourceId(String.valueOf(param.getEcManager())).intValue())
.ecRolelevel(param.getEcRolelevel())
.jclRolelevel(EcHrmRelationUtil.getJclCompanyId(param.getEcRolelevel()) != null ? String.valueOf(EcHrmRelationUtil.getJclCompanyId(param.getEcRolelevel()).getId()) : null)
.jclRolelevel(EcHrmRelationUtil.getJclCompanyId(param.getEcRolelevel()) != null ? String.valueOf(EcHrmRelationUtil.getBatchJclCompanyId(param.getEcRolelevel())) : null)
.build();
return getMangeDetachMapper().updateDetach(managerDetachPO);
}

@ -2,10 +2,13 @@ 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.job.dto.JobListDTO;
import com.engine.organization.entity.job.po.JobPO;
import com.engine.organization.service.impl.ManagerDetachServiceImpl;
import com.weaver.general.BaseBean;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
/**
@ -14,13 +17,19 @@ import java.util.List;
* @version: 1.0
*/
public class DetachUtil {
// private static final boolean IS_DETACH = "true".equals(new BaseBean().getPropValue("", ""));
private boolean IS_DETACH = true;
private boolean IS_DETACH = "true".equals(new BaseBean().getPropValue("hrmOrganization", "detach"));
private static List<Long> ecRoleLevels = null;
private final List<Long> jclRoleLevels;
public DetachUtil(Integer uId) {
ecRoleLevels = ManagerDetachServiceImpl.getJclRoleLevels(uId);
if (1 == uId) {
IS_DETACH = false;
}
if (IS_DETACH) {
jclRoleLevels = ManagerDetachServiceImpl.getJclRoleLevels(uId);
} else {
jclRoleLevels = new ArrayList<>();
}
}
/**
@ -28,7 +37,7 @@ public class DetachUtil {
*/
public void filterCompanyList(List<CompPO> companyList) {
if (IS_DETACH && CollectionUtils.isNotEmpty(companyList)) {
companyList.removeIf(item -> !ecRoleLevels.contains(item.getId()));
companyList.removeIf(item -> !jclRoleLevels.contains(item.getId()));
}
}
@ -37,7 +46,16 @@ public class DetachUtil {
*/
public void filterDepartmentList(List<DepartmentPO> departmentList) {
if (IS_DETACH && CollectionUtils.isNotEmpty(departmentList)) {
departmentList.removeIf(item -> !ecRoleLevels.contains(item.getParentComp()));
departmentList.removeIf(item -> !jclRoleLevels.contains(item.getParentComp()));
}
}
/**
*
*/
public void filterJobDTOList(List<JobListDTO> jobList) {
if (IS_DETACH && CollectionUtils.isNotEmpty(jobList)) {
jobList.removeIf(item -> !jclRoleLevels.contains(item.getParentComp()));
}
}
@ -46,7 +64,11 @@ public class DetachUtil {
*/
public void filterJobList(List<JobPO> jobList) {
if (IS_DETACH && CollectionUtils.isNotEmpty(jobList)) {
jobList.removeIf(item -> !ecRoleLevels.contains(item.getParentComp()));
jobList.removeIf(item -> !jclRoleLevels.contains(item.getParentComp()));
}
}
public List<Long> getJclRoleLevels() {
return jclRoleLevels;
}
}

@ -12,6 +12,7 @@ import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import java.util.Arrays;
import java.util.List;
/**
@ -80,6 +81,19 @@ public class EcHrmRelationUtil {
return getCompMapper().getCompanyByUUID(uuid);
}
public static String getBatchJclCompanyId(String ecBatchCompanyId) {
if (StringUtils.isBlank(ecBatchCompanyId)) {
return null;
}
List<String> strings = Arrays.asList(ecBatchCompanyId.split(","));
List<String> uuids = getSystemDataMapper().getBatchUuidByIds(HRM_COMPANY, strings);
List<Long> companyIdsByUuid = getCompMapper().getCompanyIdsByUuid(uuids);
if (CollectionUtils.isNotEmpty(companyIdsByUuid)) {
return StringUtils.join(companyIdsByUuid, ",");
}
return "";
}
public static DepartmentPO getJclDepartmentId(String ecDepartmentId) {
if (StringUtils.isBlank(ecDepartmentId)) {

@ -111,7 +111,8 @@ public class SearchTreeUtil {
Map<String, List<TreeNode>> parentMap = treeList.stream().collect(Collectors.groupingBy(TreeNode::getPid));
Map<String, List<SearchTree>> childMap = deptTrees.stream().collect(Collectors.groupingBy(SearchTree::getParentComp));
boolean isAdd = !childMap.isEmpty();
return treeList.stream().peek(e -> {
Set<String> leafIds = new HashSet<>();
List<SearchTree> collect = treeList.stream().peek(e -> {
Set<TreeNode> treeNodes = new HashSet<>();
List<TreeNode> nodes = parentMap.get(e.getId());
if (CollectionUtils.isNotEmpty(nodes)) {
@ -124,11 +125,13 @@ public class SearchTreeUtil {
treeNodes.addAll(e.getSubs());
}
e.setSubs(new ArrayList<>(treeNodes));
}).peek(item -> {
leafIds.add(e.getId());
}).collect(Collectors.toList());
return collect.stream().peek(item -> {
if (CollectionUtils.isNotEmpty(item.getSubs())) {
item.setIsParent(true);
}
}).filter(item -> isTop(item.getPid())).collect(Collectors.toList());
}).filter(item -> !leafIds.contains(item.getPid())).collect(Collectors.toList());
}
/**

Loading…
Cancel
Save