首页 > 其他 > 详细

flowable获取上级主管

时间:2020-06-28 15:53:19      阅读:177      评论:0      收藏:0      [点我收藏+]
//主管
        Dept managerDept = deptUserUtil.getManagerDept(bean.getCreateDept(),bean.getCreateUser());
        //上级主管
        Dept directorDept = deptUserUtil.getManagerDept(managerDept.getId(),managerDept.getManagerUser());
        //上上级主管
        Dept presidentDept = deptUserUtil.getManagerDept(directorDept.getId(),directorDept.getManagerUser());


public class DeptUserUtil {
/**
     * 根据部门deptId,获取上级部门(包含上级主管managerUser),区分用户userId
     */
    public Dept getManagerDept(Long deptId,Long distinctUserId){
        Dept dept = getDeptById(deptId);
        if(dept==null){
            return null;
        }
        Long managerUserId = dept.getManagerUser();
        if(distinctUserId.equals(managerUserId)){
            dept = getManagerDept(dept.getParentId(),distinctUserId);
        }
        return dept;
    }

    /**
     * 根据部门deptId,获取上级部门(包含上级主管managerUser),区分用户userId,设置上级部门上限
     * 部门等级 level : 1 -> 10  最高级 -> 最低级
     */
    public Dept getManagerDept(Long deptId,Long distinctUserId,Integer level){
        Dept dept = getDeptById(deptId);
        if(dept==null){
            return null;
        }
        Integer managerDeptLevel = dept.getLevel();
        Long managerUserId = dept.getManagerUser();
        if(managerDeptLevel.compareTo(level)<0){
            return null;
        }
        if(distinctUserId.equals(managerUserId)){
            dept = getManagerDept(dept.getParentId(),distinctUserId,level);
        }
        return dept;
    }
}

 

flowable获取上级主管

原文:https://www.cnblogs.com/xianz666/p/13202802.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!