flowable获取上级主管
//主管 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; } }