Ejemplo n.º 1
0
        /// <summary>
        /// 获取指定部门下的指定岗位的任职人员
        /// </summary>
        /// <param name="deptId"></param>
        /// <param name="gparams"></param>
        /// <param name="execDescs"></param>
        /// <returns></returns>
        public PersonInfo GetDutyPerson(string deptId, GetDutyPersonParams gparams, ref List <string> execDescs)
        {
            if (execDescs == null)
            {
                execDescs = new List <string>();
            }
            DeptDutyPersonInfo dept = this.GetCacheItem(deptId);

            if (dept == null)
            {
                execDescs.Add("待查找的部门代码为空!");
                return(null);
            }
            else
            {
                return(dept.GetDutyPerson(gparams, ref execDescs));
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据岗位Id查找部门下岗位的任职人员
        /// </summary>
        /// <param name="gparams">查找时的参数</param>
        /// <param name="execDescs">执行中的特殊说明</param>
        /// <returns></returns>
        public PersonInfo GetDutyPerson(GetDutyPersonParams gparams, ref List <string> execDescs)
        {
            if (execDescs == null)
            {
                execDescs = new List <string>();
            }
            if (gparams == null)
            {
                execDescs.Add("查找参数集合为空。");
                return(null);
            }
            string dutyId                    = gparams.DutyId;
            int    dutyLevel                 = gparams.DutyLevel;
            bool   isDutyUp                  = gparams.IsDutyUp;
            bool   isDeptUp                  = gparams.IsDeptUp;
            bool   isNotSelf                 = gparams.IsNotSelf;
            bool   isMustHighLevel           = gparams.IsMustHighLevel;
            string submitPersonId            = gparams.SubmitPersonId;
            int    submitPersonMostHighLevel = gparams.SubmitPersonMostHighLevel;

            if (string.IsNullOrEmpty(dutyId))
            {
                execDescs.Add("待查找的岗位代码为空。");
                return(null);
            }
            PersonInfo    person     = null;
            int           index      = 0;
            DutyPeronInfo dutyPerson = null;

            int dutyLevelUpIndex = int.MinValue;//比需要的职位级别高的职位的索引

            //先查找有没有完全匹配的岗位任职人员
            while (index < this.DutyPersons.Count)
            {
                if (dutyLevelUpIndex == int.MinValue && this.DutyPersons[index].DutyLevel >= dutyLevel)
                {
                    dutyLevelUpIndex = index;
                }
                if (this.DutyPersons[index].DutyId.Equals(dutyId))
                {
                    if (isMustHighLevel == false)
                    {
                        dutyPerson = this.DutyPersons[index];
                        break;
                    }
                    else
                    {
                        //如果审核人职级必须要比提交人职级高,则需要继续判断职级
                        if (this.DutyPersons[index].DutyLevel > submitPersonMostHighLevel)
                        {
                            dutyPerson = this.DutyPersons[index];
                            break;
                        }
                        execDescs.Add(string.Format("设定的岗位:{0}级别没有比提交人的最高职级高。{1}", gparams.DutyName, gparams.ProcStepDesc));
                    }
                }
                index++;
            }
            person = GetPerson(dutyPerson, submitPersonId, isNotSelf, ref execDescs);
            if (person == null)
            {
                if (isDutyUp)
                {
                    execDescs.Add(string.Format("目标岗位:{2}。在部门:{0}中执行了岗位上溯。{1}", this.DeptName, gparams.ProcStepDesc, gparams.DutyName));
                    //先岗位上溯
                    if (dutyLevelUpIndex != int.MinValue) //dutyLevelUpIndex=int.MinValue表示当前部门完全没有岗位人员,或者没有比需要的岗位高的
                    {
                        index = dutyLevelUpIndex;         //从当前部门中比目标岗位级别高的岗位开始查找
                        while (index < this.DutyPersons.Count)
                        {
                            dutyPerson = this.DutyPersons[index];
                            person     = GetPerson(dutyPerson, submitPersonId, isNotSelf, ref execDescs);
                            if (person != null)
                            {
                                return(person);
                            }
                            index++;//继续查找本部门下更高岗位
                        }
                    }
                    //本部门的岗位上溯未找到审核人,则从上级部门查找
                    if (isDeptUp)
                    {
                        execDescs.Add(string.Format("目标岗位:{2}。在部门:{0}中执行了部门上溯。{1}", this.DeptName, gparams.ProcStepDesc, gparams.DutyName));
                        if (string.IsNullOrEmpty(this.ParentDeptId) == false)
                        {
                            DeptDutyPersonInfo parnetDeptInfo = LibDeptDutyPersonCache.Default.GetCacheItem(this.ParentDeptId);
                            if (parnetDeptInfo != null)
                            {
                                return(parnetDeptInfo.GetDutyPerson(gparams, ref execDescs));
                            }
                            else
                            {
                                execDescs.Add(string.Format("部门:{0}的上级部门(代码为:{1})的任职信息为空。{2}", this.DeptName, this.ParentDeptId, gparams.ProcStepDesc));
                                return(null);
                            }
                        }
                        else
                        {
                            execDescs.Add(string.Format("部门:{0}的上级部门为空。{1}", this.DeptName, gparams.ProcStepDesc));
                            return(null);
                        }
                    }
                    else
                    {
                        execDescs.Add(string.Format("此步骤:{0}设置为不允许部门上溯。部门:{1}。", gparams.ProcStepDesc, this.DeptName));
                        return(null);//不允许部门上溯或不存在上级部门,且本部门又未找到
                    }
                }
                else
                {
                    execDescs.Add(string.Format("此步骤:{0}设置为不允许岗位上溯。部门:{1}。", gparams.ProcStepDesc, this.DeptName));
                    return(null);//不允许岗位上溯,而且没找到
                }
            }
            else
            {
                return(person);
            }
        }