From fc4a1e51afcbf3e56d3c9e2f41c6b6e995e70163 Mon Sep 17 00:00:00 2001 From: dyy <18335927079@163.com> Date: Fri, 30 Apr 2021 10:38:02 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=B5=81=E7=A8=8B=E9=80=80=E5=9B=9E=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E6=9A=82=E5=AE=9A=E4=BD=BF=E7=94=A8=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/NWFProcessController.cs | 11 +- .../Process/NWFProcessBLL.cs | 346 ++++++++++++++++++ .../Process/NWFProcessIBLL.cs | 13 + .../Learun.Workflow.Engine/NWFEngine.cs | 111 ++++++ .../Learun.Workflow.Engine/NWFIEngine.cs | 11 + 5 files changed, 491 insertions(+), 1 deletion(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Controllers/NWFProcessController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Controllers/NWFProcessController.cs index 52935e0b5..18f764fb3 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Controllers/NWFProcessController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Controllers/NWFProcessController.cs @@ -671,7 +671,7 @@ namespace Learun.Application.Web.Areas.LR_NewWorkFlow.Controllers /// /// 审批流程 /// - /// 流程审批操作码agree 同意 disagree 不同意 lrtimeout 超时 + /// 流程审批操作码agree 同意 disagree 不同意 lrtimeout 超时 back 退回至上一个审核节点 /// 流程审批操名称 /// 流程进程主键 /// 流程任务主键 @@ -686,6 +686,15 @@ namespace Learun.Application.Web.Areas.LR_NewWorkFlow.Controllers try { + //if (operationCode == "back")//退回至上一个审核节点【暂定】 + //{ + // nWFProcessIBLL.AuditFlow2(operationCode, operationName, processId, taskId, des, auditors, stamp, signUrl, userInfo); + //} + //else + //{ + // nWFProcessIBLL.AuditFlow(operationCode, operationName, processId, taskId, des, auditors, stamp, signUrl, userInfo); + //} + nWFProcessIBLL.AuditFlow(operationCode, operationName, processId, taskId, des, auditors, stamp, signUrl, userInfo); return Success("流程审批成功"); } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Process/NWFProcessBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Process/NWFProcessBLL.cs index 503b5dd51..6001039cf 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Process/NWFProcessBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Process/NWFProcessBLL.cs @@ -2344,6 +2344,352 @@ namespace Learun.Application.WorkFlow _AutoAuditFlow(pTaskList, pNWFIEngine, userInfo); } + + /// + /// 审批流程(只有审批操作码为back(退回至上一个审核节点)情况下执行)【暂定】 + /// + /// 流程审批操作码agree 同意 disagree 不同意 lrtimeout 超时 back 退回至上一个审核节点 + /// 流程审批操名称 + /// 流程进程主键 + /// 流程任务主键 + /// 审批意见 + /// 下一节点指定审核人 + /// 当前操作人信息 + public void AuditFlow2(string operationCode, string operationName, string processId, string taskId, string des, string auditors, string stamp, string signUrl, UserInfo userInfo) + { + // 初始化流程引擎 + NWFIEngine nWFIEngine = _Bootstraper("", processId, taskId, userInfo); + NWFEngineParamConfig nWFEngineParamConfig = nWFIEngine.GetConfig(); + nWFEngineParamConfig.Auditers = auditors; + + //overFW 任一审核者不同意 即流程任务结束 + bool overFW = false; + + // 获取任务实体 + var taskEntiy = nWFTaskIBLL.GetEntity(taskId); + if (taskEntiy == null) + { + throw (new Exception("找不到对应流程任务!")); + } + if (taskEntiy.F_IsFinished != 0) + { + throw (new Exception("该任务已经结束!")); + } + + taskEntiy.F_ModifyDate = DateTime.Now; + taskEntiy.F_ModifyUserId = userInfo.userId; + taskEntiy.F_ModifyUserName = userInfo.realName; + taskEntiy.F_IsFinished = 1; + NWFNodeInfo nodeInfo = nWFIEngine.GetNode(taskEntiy.F_NodeId); + string taskUserId = userInfo.userId; + + // 获取当前任务的执行人列表 + List taskUserList = (List)nWFTaskIBLL.GetTaskUserList(taskId); + bool isMyTask = false; + Dictionary taskUserMap = new Dictionary(); + foreach (var item in taskUserList) + { + if (item.F_UserId == userInfo.userId) + { + isMyTask = true; + } + if (!taskUserMap.ContainsKey(userInfo.userId)) + { + taskUserMap.Add(userInfo.userId, "1"); + } + } + if (!isMyTask) + { + // 如果是委托任务 + List delegateList = nWFProcessSerive.GetDelegateProcess(userInfo.userId); + foreach (var item in delegateList) + { + //如果当前用户是处理委托任务时,找到原本任务处理人 + if (!taskUserMap.ContainsKey(item.userId)) + { + taskUserId = item.userId; + } + } + } + // 创建任务日志信息 + NWFTaskLogEntity nWFTaskLogEntity = new NWFTaskLogEntity() + { + F_ProcessId = processId, + F_OperationCode = operationCode, + F_OperationName = operationName, + F_NodeId = nodeInfo.id, + F_NodeName = nodeInfo.name, + F_PrevNodeId = taskEntiy.F_PrevNodeId, + F_PrevNodeName = taskEntiy.F_PrevNodeName, + F_Des = des, + F_TaskId = taskId, + F_TaskType = 1, + F_CreateUserId = userInfo.userId, + F_CreateUserName = userInfo.realName, + F_TaskUserId = userInfo.userId, + F_TaskUserName = userInfo.realName, + F_StampImg = stamp + }; + + // 保存签字图片 + if (!string.IsNullOrEmpty(signUrl)) + { + ImgEntity imgEntity = new ImgEntity(); + imgEntity.F_Name = "sign"; + imgEntity.F_ExName = ".png"; + imgEntity.F_Content = signUrl; + imgIBLL.SaveEntity("", imgEntity); + nWFTaskLogEntity.F_SignImg = imgEntity.F_Id; + + } + + + + if (userInfo.userId != taskUserId) + { + // 说明是委托任务 + nWFTaskLogEntity.F_TaskUserId = taskUserId; + nWFTaskLogEntity.F_TaskUserName = userIBLL.GetEntityByUserId(taskUserId).F_RealName; + } + nWFTaskLogEntity.Create(); + // 给流程发起者一条通知信息 + NWFTaskMsgEntity nWFTaskMsgEntity = new NWFTaskMsgEntity() + { + F_ProcessId = nWFEngineParamConfig.ProcessId, + F_FromUserId = nWFEngineParamConfig.CurrentUser.Id, + F_FromUserAccount = nWFEngineParamConfig.CurrentUser.Account, + F_FromUserName = nWFEngineParamConfig.CurrentUser.Name, + F_ToUserId = nWFEngineParamConfig.CreateUser.Id, + F_ToAccount = nWFEngineParamConfig.CreateUser.Account, + F_ToName = nWFEngineParamConfig.CreateUser.Name, + F_Title = nWFEngineParamConfig.SchemeName, + F_Content = "你的流程有状态的更新:" + nWFEngineParamConfig.CurrentUser.Name + operationName, + NodeId = nWFIEngine.GetStartNode().id, + F_NodeName = nWFIEngine.GetStartNode().name + }; + nWFTaskMsgEntity.Create(); + + NWFTaskRelationEntity nWFTaskRelationEntity = taskUserList.Find(t => t.F_UserId == taskUserId); + nWFTaskRelationEntity.F_Time = DateTime.Now; + // 如果是一般审核节点 + if (nodeInfo.isAllAuditor == "2") + { + // 需要所有人都审核,有一人不同意或者所有人都同意 + if (operationCode == "agree") + { + nWFTaskRelationEntity.F_Result = 1; + if (taskUserList.FindAll(t => t.F_Result == 0).Count > 0) + { + List taskUserUpdateList = new List(); + taskUserUpdateList.Add(nWFTaskRelationEntity); + if (nodeInfo.auditorType == "2") + { + // 串行 + NWFTaskRelationEntity nWFTaskRelationEntity2 = taskUserList[(int)nWFTaskRelationEntity.F_Sort]; + nWFTaskRelationEntity2.F_Mark = 0; + taskUserUpdateList.Add(nWFTaskRelationEntity2); + } + nWFProcessSerive.Save(nWFTaskLogEntity, taskUserUpdateList, nWFTaskMsgEntity); + return; + } + } + else if (nodeInfo.auditExecutType == "2") + {// 需要所有人执行完才往下走 + if (operationCode == "disagree") + { + nWFTaskRelationEntity.F_Result = 2; + } + else + { + nWFTaskRelationEntity.F_Result = 4; + } + if (taskUserList.FindAll(t => t.F_Result == 0).Count > 0) + { + List taskUserUpdateList = new List(); + taskUserUpdateList.Add(nWFTaskRelationEntity); + if (nodeInfo.auditorType == "2") + { + // 串行 + NWFTaskRelationEntity nWFTaskRelationEntity2 = taskUserList[(int)nWFTaskRelationEntity.F_Sort]; + nWFTaskRelationEntity2.F_Mark = 0; + taskUserUpdateList.Add(nWFTaskRelationEntity2); + } + nWFProcessSerive.Save(nWFTaskLogEntity, taskUserUpdateList, nWFTaskMsgEntity); + return; + } + } + else + { + operationCode = "disagree"; + nWFTaskRelationEntity.F_Result = 2; + } + } + else + { + if (operationCode == "agree") + { + nWFTaskRelationEntity.F_Result = 1; + } + else if (operationCode == "disagree") + { + nWFTaskRelationEntity.F_Result = 2; + overFW = true; + } + else + { + nWFTaskRelationEntity.F_Result = 4; + } + } + + // 获取上一节点信息 + List lineList = new List(); + //List list = nWFIEngine.GetNextTaskNode(nodeInfo, operationCode, false, lineList, overFW); + List list = nWFIEngine.GetPrevTaskNode(nodeInfo, operationCode, false, lineList, overFW); + + // 会签处理 + int state = 0; + if (operationCode == "agree") + { + state = 1; + } + List closeTaskList = new List(); + List confluenceList = _ClearConfluence(list, closeTaskList, nodeInfo.id, nWFEngineParamConfig.ProcessId, state, nWFIEngine); + + // 创建任务 + List taskList = _CreateTask(list, nodeInfo, nWFEngineParamConfig); + // 创建任务消息 + List taskMsgList = _CreateTaskMsg(taskList, nWFEngineParamConfig); + + // 保存流程进程信息 + NWFProcessEntity nWFProcessEntity = new NWFProcessEntity() + { + F_Id = nWFEngineParamConfig.ProcessId, + F_IsStart = 1 + }; + if (nWFEngineParamConfig.State == 1) + { + nWFProcessEntity.F_IsAgain = 1; + } + else if (nWFEngineParamConfig.State == 2) + { + nWFProcessEntity.F_IsFinished = 1; + } + + // 如果任一审核者不同意,即流程结束(终止) + if (overFW) + { + nWFProcessEntity.F_EnabledMark = 4;//终止 + } + + List pLineList = new List(); + List pTaskList = new List(); + List pTaskMsgList = new List(); + NWFEngineParamConfig pNWFEngineParamConfig = null; + NWFNodeInfo pNodeInfo = null; + NWFIEngine pNWFIEngine = null; + + NWFProcessEntity pNWFProcessEntity = null; + if (nWFEngineParamConfig.IsChild == 1) + { + pNWFIEngine = _Bootstraper("", nWFEngineParamConfig.ParentProcessId, nWFEngineParamConfig.ParentTaskId, userInfo); + pNWFEngineParamConfig = pNWFIEngine.GetConfig(); + // 获取父级流程 + nWFTaskMsgEntity.F_ToUserId = pNWFEngineParamConfig.CreateUser.Id; + nWFTaskMsgEntity.F_ToName = pNWFEngineParamConfig.CreateUser.Name; + nWFTaskMsgEntity.F_ToAccount = pNWFEngineParamConfig.CreateUser.Account; + nWFTaskMsgEntity.F_Title = pNWFEngineParamConfig.SchemeName; + nWFTaskMsgEntity.F_Content = "你的流程【子流程:" + nWFEngineParamConfig.SchemeName + "】有状态的更新:" + nWFEngineParamConfig.CurrentUser.Name + operationName; + nWFTaskMsgEntity.NodeId = pNWFIEngine.GetStartNode().id; + nWFTaskMsgEntity.F_NodeName = pNWFIEngine.GetStartNode().name; + + // 获取子流程 + NWFProcessEntity cNWFProcessEntity = nWFProcessSerive.GetEntity(nWFEngineParamConfig.ProcessId); + if (cNWFProcessEntity.F_IsAsyn == 0) + { + if (nWFEngineParamConfig.State == 2) + { + // 父节点信息 + NWFTaskEntity pTaskEntity = nWFTaskIBLL.GetEntity(nWFEngineParamConfig.ParentTaskId); + pNodeInfo = pNWFIEngine.GetNode(pTaskEntity.F_NodeId); + + // 获取上一节点信息 + List pList = pNWFIEngine.GetPrevTaskNode(pNodeInfo, "agree", false, pLineList); + // 创建任务 + pTaskList = _CreateTask(pList, pNodeInfo, pNWFEngineParamConfig); + // 创建任务消息 + pTaskMsgList = _CreateTaskMsg(pTaskList, pNWFEngineParamConfig); + + if (pNWFEngineParamConfig.State == 1) + { + pNWFProcessEntity = new NWFProcessEntity(); + pNWFProcessEntity.F_Id = pNWFEngineParamConfig.ProcessId; + pNWFProcessEntity.F_IsAgain = 1; + } + else if (pNWFEngineParamConfig.State == 2) + { + pNWFProcessEntity = new NWFProcessEntity(); + pNWFProcessEntity.F_Id = pNWFEngineParamConfig.ProcessId; + pNWFProcessEntity.F_IsFinished = 1; + } + } + } + pTaskMsgList.Add(nWFTaskMsgEntity); + } + else + { + taskMsgList.Add(nWFTaskMsgEntity); + } + + // 触发消息 + _SendMsg(pTaskMsgList, pNWFIEngine); + // 触发消息 + _SendMsg(taskMsgList, nWFIEngine); + + List nTaskList = new List(); + nTaskList.AddRange(taskList); + + taskList.AddRange(pTaskList); + taskMsgList.AddRange(pTaskMsgList); + // 保存信息 任务日志 任务执行人状态更新 任务状态更新 流程进程状态更新 会签信息更新 新的任务列表 新的任务消息列表 + nWFProcessSerive.Save(nWFTaskLogEntity, nWFTaskRelationEntity, taskEntiy, nWFProcessEntity, confluenceList, closeTaskList, taskList, taskMsgList, pNWFProcessEntity); + + // 触发流程绑定方法(父级点事件) + foreach (var line in pLineList) + { + _TriggerMethod(line, "", pNodeInfo.name, "create", pNWFEngineParamConfig); + } + + // 触发流程绑定方法 + foreach (var line in lineList) + { + _TriggerMethod(line, taskId, nodeInfo.name, operationCode, nWFEngineParamConfig); + } + + // 触发子流程节点方法 + foreach (var taskItem in taskList) + { + if (taskItem.F_Type == 4) + { + NWFNodeInfo cNodeInfo = nWFIEngine.GetNode(taskItem.F_NodeId); + if (cNodeInfo == null) + { + cNodeInfo = pNWFIEngine.GetNode(taskItem.F_NodeId); + _TriggerMethod(cNodeInfo, taskItem.F_Id, cNodeInfo.name, taskItem.F_ChildProcessId, pNWFEngineParamConfig); + + } + else + { + _TriggerMethod(cNodeInfo, taskItem.F_Id, cNodeInfo.name, taskItem.F_ChildProcessId, nWFEngineParamConfig); + } + } + } + + // 触发自动跳过规则 + _AutoAuditFlow(nTaskList, nWFIEngine, userInfo); + _AutoAuditFlow(pTaskList, pNWFIEngine, userInfo); + + } + /// /// 批量审核(只有同意和不同意) /// diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Process/NWFProcessIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Process/NWFProcessIBLL.cs index 336326ba9..b418c6504 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Process/NWFProcessIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Process/NWFProcessIBLL.cs @@ -192,6 +192,19 @@ namespace Learun.Application.WorkFlow /// 下一节点指定审核人 /// 当前操作人信息 void AuditFlow(string operationCode, string operationName, string processId, string taskId, string des, string auditors, string stamp, string signUrl, UserInfo userInfo); + + /// + /// 审批流程(只有审批操作码为back(退回至上一个审核节点)情况下执行)【暂定】 + /// + /// 流程审批操作码agree 同意 disagree 不同意 lrtimeout 超时 back 退回至上一个审核节点 + /// 流程审批操名称 + /// 流程进程主键 + /// 流程任务主键 + /// 审批意见 + /// 下一节点指定审核人 + /// 当前操作人信息 + void AuditFlow2(string operationCode, string operationName, string processId, string taskId, string des, string auditors, string stamp, string signUrl, UserInfo userInfo); + /// /// 批量审核(只有同意和不同意) /// diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Workflow/Learun.Workflow.Engine/NWFEngine.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Workflow/Learun.Workflow.Engine/NWFEngine.cs index 612e38dee..69a05d15d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Workflow/Learun.Workflow.Engine/NWFEngine.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Workflow/Learun.Workflow.Engine/NWFEngine.cs @@ -544,6 +544,117 @@ namespace Learun.Workflow.Engine return list; } + + /// + /// 获取上一步的任务节点信息(只有审批操作码为back(退回至上一个审核节点)情况下执行)【暂定】 + /// + /// 起始节点 + /// 节点操作码 agree 同意 disagree 不同意 lrtimeout 超时 back 退回至上一个审核节点 + /// 是否获取下一节点审核人 + /// 经过的线段需要执行操作的 + /// + public List GetPrevTaskNode(NWFNodeInfo beginNode, string code, bool isGetAuditors, List lineList, bool overWF = false) + { + List list = new List(); + List nextNodeList = new List(); + + //nextNodeList = GetNextNodes(beginNode.id, code, lineList, overWF); + var prevNodes = GetPreNodes(beginNode.id); + foreach (var item in prevNodes) + { + var prevNode = GetNode(item); + nextNodeList.Add(prevNode); + } + + Dictionary auditers = null; + if (!string.IsNullOrEmpty(config.ParamConfig.Auditers)) + { + auditers = config.ParamConfig.Auditers.ToObject>(); + } + + + foreach (var node in nextNodeList) + { + if (auditers != null && auditers.ContainsKey(node.id)) + { + node.auditors = new List(); + node.auditors.Add(new NWFAuditor() + { + type = 3, + auditorId = auditers[node.id] + }); + } + + switch (node.type) + { + case "conditionnode": // 条件节点 + if (!isGetAuditors) + { + if (CalcCondition(node)) + { + list.AddRange(GetPrevTaskNode(node, "agree", isGetAuditors, lineList)); + } + else + { + list.AddRange(GetPrevTaskNode(node, "disagree", isGetAuditors, lineList)); + } + } + else + { + list.AddRange(GetPrevTaskNode(node, "agree", isGetAuditors, lineList)); + list.AddRange(GetPrevTaskNode(node, "disagree", isGetAuditors, lineList)); + } + break; + case "confluencenode":// 会签节点 + if (!isGetAuditors) + { + int confluenceRes; + if (code == "agree") + { + confluenceRes = CalcConfluence(node, beginNode.id, true); + } + else + { + confluenceRes = CalcConfluence(node, beginNode.id, false); + } + if (confluenceRes == 1)// 会签审核通过 + { + list.AddRange(GetPrevTaskNode(node, "agree", false, lineList)); + } + else if (confluenceRes == -1)// 会签审核不通过 + { + list.AddRange(GetPrevTaskNode(node, "disagree", false, lineList)); + } + node.confluenceRes = confluenceRes; + list.Add(node); + } + break; + case "auditornode":// 传阅节点 + list.Add(node); + break; + case "childwfnode":// 子流程节点 + list.Add(node); + if (node.childType == "2") + { // 异步的情况下直接往下走 + list.AddRange(GetPrevTaskNode(node, "agree", isGetAuditors, lineList)); + } + break; + case "startround":// 开始节点 需要重新审核 + list.Add(node); + config.ParamConfig.State = 1; + break; + case "endround":// 结束节点 + config.ParamConfig.State = 2; + break; + default: // 默认一般审核界定啊 + list.Add(node); + break; + } + } + + return list; + } + #endregion } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Workflow/Learun.Workflow.Engine/NWFIEngine.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Workflow/Learun.Workflow.Engine/NWFIEngine.cs index c66897e59..4a3112c8a 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Workflow/Learun.Workflow.Engine/NWFIEngine.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Workflow/Learun.Workflow.Engine/NWFIEngine.cs @@ -70,6 +70,17 @@ namespace Learun.Workflow.Engine /// 经过的线段需要执行操作的 /// List GetNextTaskNode(NWFNodeInfo beginNode, string code, bool isGetAuditors, List lineList, bool overWF = false); + + /// + /// 获取上一步的任务节点信息(只有审批操作码为back(退回至上一个审核节点)情况下执行)【暂定】 + /// + /// 起始节点 + /// 节点操作码 agree 同意 disagree 不同意 lrtimeout 超时 back 退回至上一个审核节点 + /// 是否获取下一节点审核人 + /// 经过的线段需要执行操作的 + /// + List GetPrevTaskNode(NWFNodeInfo beginNode, string code, bool isGetAuditors, List lineList, bool overWF = false); + #endregion } }