/// <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; } }
/// <summary> /// 执行获取到用户数组 /// 且构造处理者 /// </summary> /// <param name="returnInfo">返回信息</param> /// <param name="findFlowCensorshipIn">查找流程关卡输入</param> /// <param name="flowCensorship">流程关卡</param> /// <param name="concreteCensorships">具体关卡列表</param> /// <param name="funcToUsers">回调获取到用户数组</param> /// <param name="currUser">当前用户</param> private void ExecGetToUsers(ReturnInfo <FlowCensorshipOutInfo> returnInfo, FlowCensorshipInInfo findFlowCensorshipIn, FlowCensorshipInfo flowCensorship, IList <ConcreteCensorshipInfo> concreteCensorships, Func <ReturnInfo <FindHandlerUserOutInfo> > funcToUsers, BasicUserInfo currUser = null) { ReturnInfo <FindHandlerUserOutInfo> reUsers = funcToUsers(); if (reUsers.Failure()) { returnInfo.FromBasic(reUsers); return; } if (reUsers.Data == null || reUsers.Data.Users.IsNullOrLength0()) { return; } IList <WorkflowHandleInfo> workflowHandles = new List <WorkflowHandleInfo>(reUsers.Data.Users.Length); foreach (var u in reUsers.Data.Users) { bool isExists = false; // 查找是否已经存在处理者 foreach (var fc in concreteCensorships) { if (fc.WorkflowHandles.IsNullOrLength0()) { continue; } foreach (var h in fc.WorkflowHandles) { if (h.HandlerId == u.Id) { isExists = true; break; } } if (isExists) { break; } } if (isExists) { continue; } // 构造处理者数组 WorkflowHandleInfo wh = new WorkflowHandleInfo() { ConcreteConcrete = reUsers.Data.ConcreteCensorship.Name, ConcreteConcreteId = reUsers.Data.ConcreteCensorship.Id, FlowCensorshipId = flowCensorship.Id, Handler = u.Name, HandlerId = u.Id, HandleType = HandleTypeEnum.AUDIT, HandleStatus = HandleStatusEnum.UN_HANDLE, }; if (findFlowCensorshipIn.Workflow != null) { wh.WorkflowId = findFlowCensorshipIn.Workflow.Id; } wh.SetCreateInfo(currUser); workflowHandles.Add(wh); } if (workflowHandles.Count == 0) { return; } concreteCensorships.Add(new ConcreteCensorshipInfo() { Id = reUsers.Data.ConcreteCensorship.Id, Code = reUsers.Data.ConcreteCensorship.Code, Name = reUsers.Data.ConcreteCensorship.Name, WorkflowHandles = workflowHandles.ToArray(), FlowCensorship = flowCensorship }); }
/// <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; }