示例#1
0
        /// <summary>
        /// 审核处理
        /// </summary>
        /// <param name="returnInfo">返回信息</param>
        /// <param name="findFlowCensorshipIn">查找流程关卡输入</param>
        /// <param name="connectionId">连接ID</param>
        /// <param name="currUser">当前用户</param>
        private void AuditHandle(ReturnInfo <FlowCensorshipOutInfo> returnInfo, FlowCensorshipInInfo findFlowCensorshipIn, string connectionId = null, BasicUserInfo currUser = null)
        {
            if (findFlowCensorshipIn.CurrWorkflowHandle == null)
            {
                returnInfo.SetFailureMsg("当前工作流处理不能为null");
                return;
            }

            if (findFlowCensorshipIn.ActionType == ActionType.SAVE)
            {
                returnInfo.SetFailureMsg("审核阶段不能保存");
                return;
            }

            returnInfo.Data.Workflow = findFlowCensorshipIn.Workflow;

            FlowCensorshipInfo currFlowCens = FindFlowCensorshipByFlowCensorshipId(findFlowCensorshipIn, findFlowCensorshipIn.CurrWorkflowHandle.FlowCensorshipId);

            if (currFlowCens == null)
            {
                returnInfo.SetFailureMsg("找不到当前处理的流程关卡");
                return;
            }

            findFlowCensorshipIn.CurrWorkflowHandle.HandleTime = DateTime.Now;

            returnInfo.Data.CurrConcreteCensorship = new ConcreteCensorshipInfo()
            {
                Id              = findFlowCensorshipIn.CurrWorkflowHandle.ConcreteConcreteId,
                Name            = findFlowCensorshipIn.CurrWorkflowHandle.ConcreteConcrete,
                WorkflowHandles = new WorkflowHandleInfo[] { findFlowCensorshipIn.CurrWorkflowHandle },
                FlowCensorship  = currFlowCens
            };

            string idea = findFlowCensorshipIn.Idea;

            if (findFlowCensorshipIn.ActionType == ActionType.SEND)
            {
                if (string.IsNullOrWhiteSpace(idea))
                {
                    idea = "送件";
                }

                findFlowCensorshipIn.CurrWorkflowHandle.Idea         = idea;
                findFlowCensorshipIn.CurrWorkflowHandle.HandleStatus = HandleStatusEnum.SENDED;

                // 查找是否存在其他并行流程关卡未处理状态,如果有则只更新本次处理为已处理状态,不往下一关卡发送
                int existsOtherUnHandleCount = WorkflowHandlePersistence.CountNotFlowCensorshipIdByWorkflowIdAndHandleStatus(findFlowCensorshipIn.Workflow.Id,
                                                                                                                             HandleStatusEnum.UN_HANDLE, findFlowCensorshipIn.CurrWorkflowHandle.FlowCensorshipId, connectionId);
                if (existsOtherUnHandleCount > 0)
                {
                    return;
                }

                // 查找下一个送件流程关卡
                FlowCensorshipInfo[] nextSendFlowCensorships = FindSendNextFlowCensorships(returnInfo, findFlowCensorshipIn, findFlowCensorshipIn.CurrWorkflowHandle.FlowCensorshipId);
                if (nextSendFlowCensorships.IsNullOrLength0())
                {
                    returnInfo.SetFailureMsg("找不到下一个处理流程关卡");
                    return;
                }

                // 结束的标准关卡
                StandardCensorshipInfo endStand = FindStandardCensorshipByStandardCode(findFlowCensorshipIn, StandardCensorshipDefine.END);
                if (endStand == null)
                {
                    returnInfo.SetFailureMsg("找不到结束的标准关卡");
                    return;
                }

                // 如果下一个关卡为结束,则直接通知申请者
                foreach (var f in nextSendFlowCensorships)
                {
                    if (f.OwnerCensorshipType == CensorshipTypeEnum.STANDARD && f.OwnerCensorshipId == endStand.Id)
                    {
                        // 查找结束流程关卡ID
                        FlowCensorshipInfo     applyFlowCensors  = FindFlowCensorshipByStandardCode(findFlowCensorshipIn, StandardCensorshipDefine.END);
                        StandardCensorshipInfo applyStandCensors = FindStandardCensorshipByStandardCode(findFlowCensorshipIn, StandardCensorshipDefine.END);
                        ConcreteCensorshipInfo applyConsors      = new ConcreteCensorshipInfo()
                        {
                            Id              = applyFlowCensors.Id,
                            Code            = applyStandCensors.Code,
                            Name            = applyStandCensors.Name,
                            WorkflowHandles = new WorkflowHandleInfo[]
                            {
                                new WorkflowHandleInfo()
                                {
                                    ConcreteConcrete   = applyStandCensors.Name,
                                    ConcreteConcreteId = applyStandCensors.Id,
                                    FlowCensorshipId   = applyFlowCensors.Id,
                                    Handler            = findFlowCensorshipIn.Workflow.Creater,
                                    HandlerId          = findFlowCensorshipIn.Workflow.CreaterId,
                                    HandleStatus       = HandleStatusEnum.UN_HANDLE,
                                    HandleType         = HandleTypeEnum.NOTIFY
                                }
                            },
                            FlowCensorship = applyFlowCensors
                        };

                        applyConsors.WorkflowHandles[0].SetCreateInfo(currUser);

                        returnInfo.Data.Workflow.FlowStatus = FlowStatusEnum.AUDIT_PASS;
                        returnInfo.Data.Workflow.SetModifyInfo(currUser);

                        ConcreteCensorshipInfo[] nextConcreteCens = new ConcreteCensorshipInfo[] { applyConsors };
                        UpdateCurrWorkflowHandleInfo(nextConcreteCens, returnInfo.Data.Workflow);

                        returnInfo.Data.NextConcreteCensorshipHandles = nextConcreteCens;

                        return;
                    }
                }

                // 查找具体的送件流程关卡
                ConcreteCensorshipInfo[] concreteCensorships = FindMappingConcreteCensorships(returnInfo, findFlowCensorshipIn, nextSendFlowCensorships, connectionId, currUser);
                if (returnInfo.Failure())
                {
                    return;
                }

                UpdateCurrWorkflowHandleInfo(concreteCensorships, returnInfo.Data.Workflow);

                returnInfo.Data.NextConcreteCensorshipHandles = concreteCensorships;
            }
            else
            {
                if (string.IsNullOrWhiteSpace(idea))
                {
                    idea = "退件";
                }
                findFlowCensorshipIn.CurrWorkflowHandle.Idea = idea;

                // 查找下一个退件流程关卡
                FlowCensorshipInfo[] nextReturnFlowCensorships = FindReturnNextFlowCensorships(returnInfo, findFlowCensorshipIn, findFlowCensorshipIn.CurrWorkflowHandle.FlowCensorshipId);
                if (nextReturnFlowCensorships.IsNullOrLength0())
                {
                    returnInfo.SetFailureMsg("找不到下一个处理流程关卡");
                    return;
                }

                // 申请者的标准关卡
                StandardCensorshipInfo applyStand = FindStandardCensorshipByStandardCode(findFlowCensorshipIn, StandardCensorshipDefine.APPLICANT);
                if (applyStand == null)
                {
                    returnInfo.SetFailureMsg("找不到申请者的标准关卡");
                    return;
                }

                findFlowCensorshipIn.CurrWorkflowHandle.HandleStatus = HandleStatusEnum.RETURNED;

                // 如果下一个关卡为申请者,则直接通知申请者
                foreach (var f in nextReturnFlowCensorships)
                {
                    if (f.OwnerCensorshipType == CensorshipTypeEnum.STANDARD && applyStand.Id == f.OwnerCensorshipId)
                    {
                        // 查找申请者流程关卡ID
                        FlowCensorshipInfo     applyFlowCensors  = FindFlowCensorshipByStandardCode(findFlowCensorshipIn, StandardCensorshipDefine.APPLICANT);
                        StandardCensorshipInfo applyStandCensors = FindStandardCensorshipByStandardCode(findFlowCensorshipIn, StandardCensorshipDefine.APPLICANT);
                        ConcreteCensorshipInfo applyConsors      = new ConcreteCensorshipInfo()
                        {
                            Id              = applyFlowCensors.Id,
                            Code            = applyStandCensors.Code,
                            Name            = applyStandCensors.Name,
                            WorkflowHandles = new WorkflowHandleInfo[]
                            {
                                new WorkflowHandleInfo()
                                {
                                    ConcreteConcrete   = applyStandCensors.Name,
                                    ConcreteConcreteId = applyStandCensors.Id,
                                    FlowCensorshipId   = applyFlowCensors.Id,
                                    Handler            = findFlowCensorshipIn.Workflow.Creater,
                                    HandlerId          = findFlowCensorshipIn.Workflow.CreaterId,
                                    HandleStatus       = HandleStatusEnum.UN_HANDLE,
                                    HandleType         = HandleTypeEnum.NOTIFY
                                }
                            },
                            FlowCensorship = applyFlowCensors
                        };

                        applyConsors.WorkflowHandles[0].SetCreateInfo(currUser);

                        returnInfo.Data.Workflow.FlowStatus = FlowStatusEnum.AUDIT_NOPASS;
                        returnInfo.Data.Workflow.SetModifyInfo(currUser);

                        var nextConcreteCens = new ConcreteCensorshipInfo[] { applyConsors };
                        UpdateCurrWorkflowHandleInfo(nextConcreteCens, returnInfo.Data.Workflow);

                        returnInfo.Data.NextConcreteCensorshipHandles = nextConcreteCens;

                        return;
                    }
                }

                int[] nextFlowCIds = new int[nextReturnFlowCensorships.Length];
                for (var i = 0; i < nextFlowCIds.Length; i++)
                {
                    nextFlowCIds[i] = nextReturnFlowCensorships[i].Id;
                }
                // 退件直接找从已处理列表中的各流程关卡的处理人
                IList <WorkflowHandleInfo> returnWorkflowHandles = WorkflowHandlePersistence.SelectSendedByWorkflowIdAndFlowCensorshipIds(findFlowCensorshipIn.Workflow.Id, nextFlowCIds, connectionId);
                if (returnWorkflowHandles.IsNullOrCount0())
                {
                    returnInfo.SetFailureMsg("找不到可退件的人");
                    return;
                }

                List <ConcreteCensorshipInfo> conList = new List <ConcreteCensorshipInfo>();
                // 具体ID映射工作流处理列表
                IDictionary <int, IList <WorkflowHandleInfo> > dicConIdMapHandles = new Dictionary <int, IList <WorkflowHandleInfo> >();

                // 处理人ID列表
                IList <int> handleIds = new List <int>();

                foreach (var w in returnWorkflowHandles)
                {
                    // 过滤重复的处理人ID
                    if (handleIds.Contains(w.HandlerId))
                    {
                        continue;
                    }
                    handleIds.Add(w.HandlerId);

                    WorkflowHandleInfo newHandle = w.Clone() as WorkflowHandleInfo;
                    newHandle.HandleStatus = HandleStatusEnum.UN_HANDLE;
                    newHandle.HandleTime   = null;
                    newHandle.Idea         = null;
                    newHandle.IsReaded     = false;

                    var c = conList.Find(x => x.Id == w.ConcreteConcreteId);
                    if (c == null)
                    {
                        c = new ConcreteCensorshipInfo()
                        {
                            Id             = w.ConcreteConcreteId,
                            Name           = w.ConcreteConcrete,
                            FlowCensorship = new FlowCensorshipInfo()
                            {
                                Id = w.FlowCensorshipId
                            }
                        };

                        dicConIdMapHandles.Add(c.Id, new List <WorkflowHandleInfo>()
                        {
                            newHandle
                        });

                        conList.Add(c);
                    }
                    else
                    {
                        dicConIdMapHandles[c.Id].Add(newHandle);
                    }
                }

                foreach (var c in conList)
                {
                    foreach (KeyValuePair <int, IList <WorkflowHandleInfo> > item in dicConIdMapHandles)
                    {
                        if (c.Id == item.Key)
                        {
                            c.WorkflowHandles = item.Value.ToArray();

                            break;
                        }
                    }
                }

                ConcreteCensorshipInfo[] cons = conList.ToArray();
                UpdateCurrWorkflowHandleInfo(cons, returnInfo.Data.Workflow);

                returnInfo.Data.NextConcreteCensorshipHandles = cons;
            }
        }
示例#2
0
        /// <summary>
        /// 查找映射对应的具体关卡数组
        /// </summary>
        /// <param name="returnInfo">返回信息</param>
        /// <param name="findFlowCensorshipIn">查找流程关卡输入</param>
        /// <param name="flowCensorships">流程关卡数组</param>
        /// <param name="connectionId">连接ID</param>
        /// <param name="currUser">当前用户</param>
        /// <returns>具体关卡数组</returns>
        private ConcreteCensorshipInfo[] FindMappingConcreteCensorships(ReturnInfo <FlowCensorshipOutInfo> returnInfo, FlowCensorshipInInfo findFlowCensorshipIn, FlowCensorshipInfo[] flowCensorships, string connectionId = null, BasicUserInfo currUser = null)
        {
            IList <ConcreteCensorshipInfo> concreteCensorships = new List <ConcreteCensorshipInfo>();

            var user = UserTool.GetCurrUser(currUser);

            ExecProcConnectionId(connId =>
            {
                foreach (var f in flowCensorships)
                {
                    switch (f.OwnerCensorshipType)
                    {
                    case CensorshipTypeEnum.ROLE:
                        ExecGetToUsers(returnInfo, findFlowCensorshipIn, f, concreteCensorships,
                                       () =>
                        {
                            return(FindHandlerRoleUser.FindById(f.OwnerCensorshipId, user.Id, connId, currUser));
                        }, currUser);
                        if (returnInfo.Failure())
                        {
                            return;
                        }
                        break;

                    case CensorshipTypeEnum.USER:
                        ExecGetToUsers(returnInfo, findFlowCensorshipIn, f, concreteCensorships,
                                       () =>
                        {
                            return(FindHandlerConcreteUser.FindById(f.OwnerCensorshipId, user.Id, connId, currUser));
                        }, currUser);
                        if (returnInfo.Failure())
                        {
                            return;
                        }

                        break;

                    case CensorshipTypeEnum.STANDARD:
                        StandardCensorshipInfo standardCensorship = FindStandardCensorshipByStandardId(findFlowCensorshipIn, f.OwnerCensorshipId);
                        if (standardCensorship != null)
                        {
                            if (standardCensorship.Code == StandardCensorshipDefine.SUPERVISOR)
                            {
                                ExecGetToUsers(returnInfo, findFlowCensorshipIn, f, concreteCensorships,
                                               () =>
                                {
                                    return(FindHandlerSupervisorUser.FindById(f.OwnerCensorshipId, user.Id, connId, currUser));
                                }, currUser);
                                if (returnInfo.Failure())
                                {
                                    return;
                                }
                            }
                        }

                        break;
                    }
                }
            }, connectionId, AccessMode.SLAVE);
            if (returnInfo.Failure())
            {
                return(null);
            }

            if (concreteCensorships.Count == 0)
            {
                returnInfo.SetFailureMsg("找不到下一个处理者");
                return(null);
            }

            return(concreteCensorships.ToArray());
        }
示例#3
0
        /// <summary>
        /// 申请者处理
        /// </summary>
        /// <param name="returnInfo">返回信息</param>
        /// <param name="findFlowCensorshipIn">查找流程关卡输入</param>
        /// <param name="connectionId">连接ID</param>
        /// <param name="currUser">当前用户</param>
        private void ApplyHandle(ReturnInfo <FlowCensorshipOutInfo> returnInfo, FlowCensorshipInInfo findFlowCensorshipIn, string connectionId = null, BasicUserInfo currUser = null)
        {
            if (findFlowCensorshipIn.ActionType == ActionType.RETURN)
            {
                returnInfo.SetFailureMsg("申请阶段必须不能退件");
                return;
            }

            // 查找申请者流程关卡ID
            StandardCensorshipInfo applyStand = FindStandardCensorshipByStandardCode(findFlowCensorshipIn, StandardCensorshipDefine.APPLICANT);

            if (applyStand == null)
            {
                returnInfo.SetFailureMsg("找不到申请者的标准关卡");
                return;
            }

            var user = UserTool.GetCurrUser(currUser);

            if (returnInfo.Data.Workflow == null)
            {
                if (findFlowCensorshipIn.Workflow == null)
                {
                    returnInfo.Data.Workflow = new WorkflowInfo()
                    {
                        ApplyNo          = findFlowCensorshipIn.ApplyNo,
                        Title            = findFlowCensorshipIn.Title,
                        WorkflowDefineId = findFlowCensorshipIn.WorkflowDefine.Id
                    };
                    returnInfo.Data.Workflow.SetCreateInfo(currUser);
                }
                else
                {
                    returnInfo.Data.Workflow = findFlowCensorshipIn.Workflow;
                    returnInfo.Data.Workflow.SetModifyInfo(currUser);
                }
            }
            else
            {
                returnInfo.Data.Workflow.SetModifyInfo(currUser);
            }
            returnInfo.Data.Workflow.FlowStatus = findFlowCensorshipIn.ActionType == ActionType.SEND ? FlowStatusEnum.AUDITING : FlowStatusEnum.DRAFT;
            string idea = findFlowCensorshipIn.Idea;

            returnInfo.Data.Workflow.Title = findFlowCensorshipIn.Title;

            // 申请者需要构造一条申请处理的记录
            FlowCensorshipInfo applyFlowCensors = FindFlowCensorshipByStandardCode(findFlowCensorshipIn, StandardCensorshipDefine.APPLICANT);

            // 送件才需要找下一个处理
            if (findFlowCensorshipIn.ActionType == ActionType.SEND)
            {
                FlowCensorshipInfo[] nextSendFlowCensorships = FindSendNextFlowCensorships(returnInfo, findFlowCensorshipIn, applyFlowCensors.Id);
                if (nextSendFlowCensorships.IsNullOrLength0())
                {
                    returnInfo.SetFailureMsg("找不到申请者的下一个处理流程关卡");
                    return;
                }

                ConcreteCensorshipInfo[] concreteCensorships = FindMappingConcreteCensorships(returnInfo, findFlowCensorshipIn, nextSendFlowCensorships, connectionId, currUser);
                if (returnInfo.Failure())
                {
                    return;
                }

                UpdateCurrWorkflowHandleInfo(concreteCensorships, returnInfo.Data.Workflow);

                returnInfo.Data.NextConcreteCensorshipHandles = concreteCensorships;

                if (string.IsNullOrWhiteSpace(idea))
                {
                    idea = "提交申请";
                }
            }
            else
            {
                returnInfo.Data.Workflow.CurrConcreteCensorshipIds = applyStand.Id.ToString();
                returnInfo.Data.Workflow.CurrConcreteCensorships   = applyStand.Name;
                returnInfo.Data.Workflow.CurrFlowCensorshipIds     = applyFlowCensors.Id.ToString();
                returnInfo.Data.Workflow.CurrHandlerIds            = user.Id.ToString();
                returnInfo.Data.Workflow.CurrHandlers = user.Name;

                if (string.IsNullOrWhiteSpace(idea))
                {
                    idea = "保存草稿";
                }
            }

            StandardCensorshipInfo applyStandCensors = FindStandardCensorshipByStandardCode(findFlowCensorshipIn, StandardCensorshipDefine.APPLICANT);
            ConcreteCensorshipInfo applyConsors      = new ConcreteCensorshipInfo()
            {
                Id              = applyFlowCensors.Id,
                Code            = applyStandCensors.Code,
                Name            = applyStandCensors.Name,
                WorkflowHandles = new WorkflowHandleInfo[]
                {
                    new WorkflowHandleInfo()
                    {
                        ConcreteConcrete   = applyStandCensors.Name,
                        ConcreteConcreteId = applyStandCensors.Id,
                        FlowCensorshipId   = applyFlowCensors.Id,
                        Handler            = user.Name,
                        HandlerId          = user.Id,
                        HandleStatus       = findFlowCensorshipIn.ActionType == ActionType.SEND ? HandleStatusEnum.SENDED : HandleStatusEnum.UN_HANDLE,
                        Idea       = idea,
                        IsReaded   = true,
                        HandleType = HandleTypeEnum.APPLY,
                        HandleTime = DateTime.Now
                    }
                },
                FlowCensorship = applyFlowCensors
            };

            if (findFlowCensorshipIn.ActionType == ActionType.SEND)
            {
                applyConsors.WorkflowHandles[0].HandleTime = DateTime.Now;
            }

            applyConsors.WorkflowHandles[0].SetCreateInfo(currUser);
            returnInfo.Data.CurrConcreteCensorship = applyConsors;
        }