|
|
@@ -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); |
|
|
|
} |
|
|
|
/// <summary> |
|
|
|
/// 流程加签 |
|
|
|
/// </summary> |
|
|
|
/// <param name="processId">流程进程主键</param> |
|
|
|
/// <param name="taskId">流程任务主键</param> |
|
|
|
/// <param name="userId">加签人员(可多人)</param> |
|
|
|
/// <param name="des">加签说明</param> |
|
|
|
/// <param name="userInfo">当前操作人信息</param> |
|
|
|
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<NWFTaskRelationEntity> taskUserList = (List<NWFTaskRelationEntity>)nWFTaskIBLL.GetTaskUserList(taskId); |
|
|
|
bool isMyTask = false; |
|
|
|
Dictionary<string, string> taskUserMap = new Dictionary<string, string>(); |
|
|
|
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<UserInfo> 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<UserEntity> 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<NWFTaskEntity> taskList = new List<NWFTaskEntity>(); |
|
|
|
|
|
|
|
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<NWFUserInfo>(); |
|
|
|
|
|
|
|
//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<NWFTaskMsgEntity> taskMsgList = _CreateTaskMsg(taskList, nWFEngineParamConfig); |
|
|
|
|
|
|
|
List<NWFTaskMsgEntity> pTaskMsgList = new List<NWFTaskMsgEntity>(); |
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 流程加签审核 |
|
|
|
/// </summary> |
|
|
|