From aa8125a38121b2770d54f7dbda522ee47b87a796 Mon Sep 17 00:00:00 2001 From: dyy <18335927079@163.com> Date: Thu, 15 Apr 2021 18:12:07 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E5=8A=A0?= =?UTF-8?q?=E7=AD=BE=E9=A1=B5=E9=9D=A2=EF=BC=9A=E9=83=A8=E9=97=A8=E8=B7=9F?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E8=B0=83=E6=95=B4=E4=B8=BA=E5=8F=AF=E5=A4=9A?= =?UTF-8?q?=E9=80=89=EF=BC=9B=E5=AE=A1=E6=A0=B8=E9=A1=B5=E9=9D=A2=EF=BC=9A?= =?UTF-8?q?=E5=8A=A0=E7=AD=BE=E6=8C=89=E9=92=AE=E8=B0=83=E6=95=B4=E4=B8=BA?= =?UTF-8?q?=E8=BD=AC=E5=AE=A1=E6=8C=89=E9=92=AE=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../User/UserService.cs | 15 +- .../Controllers/NWFProcessController.cs | 16 ++ .../Views/NWFProcess/NWFContainerForm.cshtml | 2 +- .../Views/NWFProcess/NWFContainerForm.js | 4 +- .../Views/NWFProcess/SignFlowForm.js | 11 +- .../Process/NWFProcessBLL.cs | 197 ++++++++++++++++++ .../Process/NWFProcessIBLL.cs | 10 + 7 files changed, 246 insertions(+), 9 deletions(-) diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserService.cs b/Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserService.cs index c3bd4ab11..2ea747f65 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Organization/User/UserService.cs @@ -599,8 +599,19 @@ namespace Learun.Application.Organization { try { - var ids = departmentId.Split(','); - return this.BaseRepository().FindList(a => ids.Contains(a.F_DepartmentId)).ToList(); + if (string.IsNullOrEmpty(departmentId)) + { + return new List(); + } + if (departmentId.IndexOf(',') == -1) + { + return this.BaseRepository().FindList(a => a.F_DepartmentId == departmentId && a.F_DeleteMark == 0).ToList(); + } + else + { + var ids = departmentId.Split(','); + return this.BaseRepository().FindList(a => ids.Contains(a.F_DepartmentId) && a.F_DeleteMark == 0).ToList(); + } } catch (Exception ex) { 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 d6d2ba915..49960a48f 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 @@ -705,6 +705,22 @@ namespace Learun.Application.Web.Areas.LR_NewWorkFlow.Controllers return Success("流程加签成功"); } /// + /// 流程加签 + /// + /// 流程进程主键 + /// 流程任务主键 + /// 加签人员(可多人) + /// 加签说明 + /// + [HttpPost] + [AjaxOnly] + public ActionResult SignFlowTwo(string processId, string taskId, string userId, string des) + { + UserInfo userInfo = LoginUserInfo.Get(); + nWFProcessIBLL.SignFlowTwo(processId, taskId, userId, des, userInfo); + return Success("流程加签成功"); + } + /// /// 流程加签审核 /// /// 审核操作码 diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/NWFContainerForm.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/NWFContainerForm.cshtml index b4498a4ff..fba3e170c 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/NWFContainerForm.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/NWFContainerForm.cshtml @@ -80,7 +80,7 @@
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/NWFContainerForm.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/NWFContainerForm.js index 9186befeb..cd93fef49 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/NWFContainerForm.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/NWFContainerForm.js @@ -785,7 +785,7 @@ var bootstrap = function ($, learun) { processId: nwflow.processId, taskId: nwflow.taskId }; - learun.httpAsync('Post', top.$.rootUrl + '/LR_NewWorkFlow/NWFProcess/SignFlow', postData, function (data) { + learun.httpAsync('Post', top.$.rootUrl + '/LR_NewWorkFlow/NWFProcess/SignFlowTwo', postData, function (data) { learun.loading(false); if (data) { //learun.frameTab.parentIframe().refreshGirdData(); @@ -936,7 +936,7 @@ var bootstrap = function ($, learun) { processId: nwflow.processId, taskId: nwflow.taskId }; - learun.httpAsync('Post', top.$.rootUrl + '/LR_NewWorkFlow/NWFProcess/SignFlow', postData, function (data) { + learun.httpAsync('Post', top.$.rootUrl + '/LR_NewWorkFlow/NWFProcess/SignFlowTwo', postData, function (data) { learun.loading(false); if (data) { //learun.frameTab.parentIframe().refreshGirdData(); diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/SignFlowForm.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/SignFlowForm.js index 6256dd3bf..5eca21ccc 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/SignFlowForm.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Views/NWFProcess/SignFlowForm.js @@ -19,18 +19,21 @@ var bootstrap = function ($, learun) { maxHeight: 190, // 是否允许搜索 allowSearch: true, + type: 'multiple', select: function (item) { - if (item) { - auditorName = item.F_RealName; - } + //if (item) { + // auditorName = item.F_RealName; + //} } }); $('#department').lrDepartmentSelect({ + type: 'treemultiple', maxHeight: 220 }).on('change', function () { var value = $(this).lrselectGet(); + //人员列表根据多部门列表查找 $('#auditorId').lrselectRefresh({ - url: top.$.rootUrl + '/LR_OrganizationModule/User/GetList', + url: top.$.rootUrl + '/LR_OrganizationModule/User/GetListByDepartmentIds', param: { departmentId: value } }); }); 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 6c315f60b..a30cccfe6 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 @@ -11,6 +11,7 @@ using System.Data; using Learun.Application.TwoDevelopment.LogisticsManagement; using Learun.Application.TwoDevelopment.LR_LGManager; using Newtonsoft.Json; +using System.Linq; namespace Learun.Application.WorkFlow { @@ -2547,6 +2548,202 @@ namespace Learun.Application.WorkFlow _SendMsg(pTaskMsgList, pNWFIEngine); _SendMsg(taskMsgList, nWFIEngine); } + /// + /// 流程加签 + /// + /// 流程进程主键 + /// 流程任务主键 + /// 加签人员(可多人) + /// 加签说明 + /// 当前操作人信息 + public void SignFlowTwo(string processId, string taskId, string userId, string des, UserInfo userInfo) + { + // 初始化流程引擎 + NWFIEngine nWFIEngine = _Bootstraper("", processId, taskId, userInfo); + NWFEngineParamConfig nWFEngineParamConfig = nWFIEngine.GetConfig(); + // 获取任务实体 + 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; + 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; + } + } + } + + //UserEntity userEntity = userIBLL.GetEntityByUserId(userId); + //todo: + List userEntities = userIBLL.GetListByUserIds(userId); + // 创建任务日志信息 + NWFTaskLogEntity nWFTaskLogEntity = new NWFTaskLogEntity() + { + F_ProcessId = processId, + F_OperationCode = "sign", + //F_OperationName = "请求【" + userEntity.F_RealName + "】加签", + //todo: + F_OperationName = "请求【" + string.Join(",", userEntities.Select(x => x.F_RealName).ToArray()) + "】加签", + F_NodeId = taskEntiy.F_NodeId, + F_NodeName = taskEntiy.F_NodeName, + F_PrevNodeId = taskEntiy.F_PrevNodeId, + F_PrevNodeName = taskEntiy.F_PrevNodeName, + F_Des = des, + F_TaskId = taskId, + F_TaskType = 8, + F_CreateUserId = userInfo.userId, + F_CreateUserName = userInfo.realName, + F_TaskUserId = userInfo.userId, + F_TaskUserName = userInfo.realName + }; + 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 + "加签", + 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; + nWFTaskRelationEntity.F_Result = 4; + + // 创建任务 + List taskList = new List(); + + NWFNodeInfo nodeInfo = nWFIEngine.GetNode(taskEntiy.F_NodeId); + NWFTaskEntity nWFTaskEntity = new NWFTaskEntity(); + nWFTaskEntity.Create(); + nWFTaskEntity.F_ProcessId = nWFEngineParamConfig.ProcessId; + nWFTaskEntity.F_NodeId = taskEntiy.F_NodeId; + nWFTaskEntity.F_NodeName = taskEntiy.F_NodeName; + nWFTaskEntity.F_PrevNodeId = taskEntiy.F_NodeId; + nWFTaskEntity.F_PrevNodeName = taskEntiy.F_NodeName; + + nWFTaskEntity.F_CreateUserId = userInfo.userId; + nWFTaskEntity.F_CreateUserName = userInfo.realName; + nWFTaskEntity.F_TimeoutAction = taskEntiy.F_TimeoutAction; + nWFTaskEntity.F_TimeoutInterval = taskEntiy.F_TimeoutInterval; + nWFTaskEntity.F_TimeoutNotice = taskEntiy.F_TimeoutNotice; + nWFTaskEntity.F_TimeoutStrategy = taskEntiy.F_TimeoutStrategy; + nWFTaskEntity.nWFUserInfoList = new List(); + + //nWFTaskEntity.nWFUserInfoList.Add(new NWFUserInfo() + //{ + // Id = userId, + // Account = userEntity.F_Account, + // Name = userEntity.F_RealName + //}); + //todo: + foreach (var userItem in userEntities) + { + nWFTaskEntity.nWFUserInfoList.Add(new NWFUserInfo() + { + Id = userItem.F_UserId, + Account = userItem.F_Account, + Name = userItem.F_RealName + }); + } + + nWFTaskEntity.F_Type = 3; + + if (string.IsNullOrEmpty(taskEntiy.F_FirstUserId)) + { + nWFTaskEntity.F_FirstUserId = taskUserId; + } + else + { + nWFTaskEntity.F_FirstUserId = taskEntiy.F_FirstUserId; + } + + taskList.Add(nWFTaskEntity); + // 创建任务消息 + List taskMsgList = _CreateTaskMsg(taskList, nWFEngineParamConfig); + + List pTaskMsgList = new List(); + NWFEngineParamConfig pNWFEngineParamConfig = null; + NWFIEngine pNWFIEngine = 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 + "加签"; + nWFTaskMsgEntity.NodeId = pNWFIEngine.GetStartNode().id; + nWFTaskMsgEntity.F_NodeName = pNWFIEngine.GetStartNode().name; + + pTaskMsgList.Add(nWFTaskMsgEntity); + } + else + { + taskMsgList.Add(nWFTaskMsgEntity); + } + // 保存流程进程信息 + NWFProcessEntity nWFProcessEntity = new NWFProcessEntity() + { + F_Id = nWFEngineParamConfig.ProcessId, + F_IsStart = 1 + }; + nWFProcessSerive.Save(nWFTaskLogEntity, nWFTaskRelationEntity, taskEntiy, nWFProcessEntity, null, null, taskList, taskMsgList); + + // 触发消息 + _SendMsg(pTaskMsgList, pNWFIEngine); + _SendMsg(taskMsgList, nWFIEngine); + } + /// /// 流程加签审核 /// 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 70b02c621..c9126951c 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 @@ -209,6 +209,16 @@ namespace Learun.Application.WorkFlow /// 加签说明 /// 当前操作人信息 void SignFlow(string processId, string taskId, string userId, string des, UserInfo userInfo); + /// + /// 流程加签 + /// + /// 流程进程主键 + /// 流程任务主键 + /// 加签人员(可多人) + /// 加签说明 + /// 当前操作人信息 + void SignFlowTwo(string processId, string taskId, string userId, string des, UserInfo userInfo); + /// /// 流程加签审核 ///