/// <summary> /// 获取员工的层级部门信息 /// </summary> /// <returns></returns> public ActionResult GetEmpLevelDepthDept() { if (_Request == null) { _Request = Request; } SetRequest(_Request); int levelDepth = _Request["levelDepth"].ObjToInt(); //层级 Guid empId = _Request["empId"].ObjToGuid(); //员工ID Guid?companyId = _Request["companyId"].ObjToGuidNull(); //所属公司,集团模式下用到 Guid?deptId = _Request["deptId"].ObjToGuidNull(); //兼职部门,以兼职部门找 if (empId == Guid.Empty || levelDepth < 0) { return(Json(null)); } //层级部门 OrgM_Dept depthDept = OrgMOperate.GetEmpLevelDepthDept(levelDepth, empId, companyId, deptId); //当前部门 OrgM_Dept currDept = deptId.HasValue && deptId.Value != Guid.Empty ? OrgMOperate.GetDeptById(deptId.Value) : OrgMOperate.GetEmpMainDept(empId, companyId); return(Json(new { CurrDept = currDept, DepthDept = depthDept })); }
/// <summary> /// 获取用户扩展信息 /// </summary> /// <param name="userInfo">用户信息</param> /// <returns></returns> public static UserExtendBase GetUserExtend(UserInfo userInfo) { if (userInfo == null) { return(null); } if (userInfo.ExtendUserObject != null) { return(userInfo.ExtendUserObject); } if (userInfo.EmpId.HasValue) { List <EmpExtendInfo> empExtends = new List <EmpExtendInfo>(); List <Guid> companyIds = OrgMOperate.GetEmpCompanys(userInfo.EmpId.Value).Select(x => x.Id).ToList(); if (companyIds.Count > 0) { foreach (Guid companyId in companyIds) { OrgM_Dept mainDept = OrgMOperate.GetEmpMainDept(userInfo.EmpId.Value, companyId); OrgM_Duty mainDuty = OrgMOperate.GetEmpMainDuty(userInfo.EmpId.Value, companyId); List <OrgM_Dept> partimeDepts = OrgMOperate.GetEmpPartTimeDepts(userInfo.EmpId.Value, companyId); List <OrgM_DeptDuty> partimePositions = OrgMOperate.GetPartTimePositions(userInfo.EmpId.Value, companyId); empExtends.Add(new EmpExtendInfo() { CompanyId = companyId, DeptId = mainDept != null ? mainDept.Id : (Guid?)null, DeptName = mainDept != null ? (string.IsNullOrEmpty(mainDept.Alias) ? mainDept.Name : mainDept.Alias) : string.Empty, DutyId = mainDuty != null ? mainDuty.Id : (Guid?)null, DutyName = mainDuty != null ? mainDuty.Name : string.Empty, PartimeDeptIds = partimeDepts != null && partimeDepts.Count > 0 ? partimeDepts.Select(x => x.Id).ToList() : null, PartimeDeptNames = partimeDepts != null && partimeDepts.Count > 0 ? partimeDepts.Select(x => x.Name).ToList() : null, PartimePositionIds = partimePositions != null && partimePositions.Count > 0 ? partimePositions.Select(x => x.Id).ToList() : null, PartimePositionNames = partimePositions != null && partimePositions.Count > 0 ? partimePositions.Select(x => x.Name).ToList() : null }); } } else { OrgM_Dept mainDept = OrgMOperate.GetEmpMainDept(userInfo.EmpId.Value); OrgM_Duty mainDuty = OrgMOperate.GetEmpMainDuty(userInfo.EmpId.Value); List <OrgM_Dept> partimeDepts = OrgMOperate.GetEmpPartTimeDepts(userInfo.EmpId.Value); List <OrgM_DeptDuty> partimePositions = OrgMOperate.GetPartTimePositions(userInfo.EmpId.Value); empExtends.Add(new EmpExtendInfo() { CompanyId = null, DeptId = mainDept != null ? mainDept.Id : (Guid?)null, DeptName = mainDept != null ? (string.IsNullOrEmpty(mainDept.Alias) ? mainDept.Name : mainDept.Alias) : string.Empty, DutyId = mainDuty != null ? mainDuty.Id : (Guid?)null, DutyName = mainDuty != null ? mainDuty.Name : string.Empty, PartimeDeptIds = partimeDepts != null && partimeDepts.Count > 0 ? partimeDepts.Select(x => x.Id).ToList() : null, PartimeDeptNames = partimeDepts != null && partimeDepts.Count > 0 ? partimeDepts.Select(x => x.Name).ToList() : null, PartimePositionIds = partimePositions != null && partimePositions.Count > 0 ? partimePositions.Select(x => x.Id).ToList() : null, PartimePositionNames = partimePositions != null && partimePositions.Count > 0 ? partimePositions.Select(x => x.Name).ToList() : null }); } UserExtendInfo userExtendInfo = new UserExtendInfo() { EmpExtend = empExtends }; List <Sys_UserRole> userRoles = PermissionOperate.GetAllUserRoles(x => x.Sys_RoleId != null && x.Sys_UserId == userInfo.UserId); if (userRoles.Count > 0) { userExtendInfo.RoleIds = userRoles.Select(x => x.Sys_RoleId).ToList(); userExtendInfo.RoleNames = userRoles.Select(x => x.Sys_RoleName).ToList(); } return(userExtendInfo); } else { UserExtendInfo userExtendInfo = new UserExtendInfo(); List <Sys_UserRole> userRoles = PermissionOperate.GetAllUserRoles(x => x.Sys_RoleId != null && x.Sys_UserId == userInfo.UserId); if (userRoles.Count > 0) { userExtendInfo.RoleIds = userRoles.Select(x => x.Sys_RoleId).ToList(); userExtendInfo.RoleNames = userRoles.Select(x => x.Sys_RoleName).ToList(); } return(userExtendInfo); } }
/// <summary> /// 获取员工的层级部门信息 /// </summary> /// <returns></returns> public JsonResult GetEmpLevelDepthDept() { if (_Request == null) { _Request = Request; } SetRequest(_Request); string levelDepthStr = _Request.QueryEx("levelDepth").ObjToStr(); int levelDepth = levelDepthStr.ObjToInt(); //层级 string empIdStr = _Request.QueryEx("empId").ObjToStr(); Guid empId = empIdStr.ObjToGuid(); //员工ID string companyIdStr = _Request.QueryEx("companyId").ObjToStr(); Guid? companyId = companyIdStr.ObjToGuidNull(); //所属公司,集团模式下用到 string deptIdStr = _Request.QueryEx("deptId").ObjToStr(); Guid? deptId = deptIdStr.ObjToGuidNull(); //兼职部门,以兼职部门找 if (empId == Guid.Empty || levelDepth < 0) { return(Json(null)); } //层级部门 OrgM_Dept depthDept = OrgMOperate.GetEmpLevelDepthDept(levelDepth, empId, companyId, deptId); //当前部门 OrgM_Dept currDept = deptId.HasValue && deptId.Value != Guid.Empty ? OrgMOperate.GetDeptById(deptId.Value) : OrgMOperate.GetEmpMainDept(empId, companyId); return(Json(new { CurrDept = currDept, DepthDept = depthDept })); }