|
|
@@ -2344,6 +2344,352 @@ namespace Learun.Application.WorkFlow |
|
|
|
_AutoAuditFlow(pTaskList, pNWFIEngine, userInfo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 审批流程(只有审批操作码为back(退回至上一个审核节点)情况下执行)【暂定】 |
|
|
|
/// </summary> |
|
|
|
/// <param name="operationCode">流程审批操作码agree 同意 disagree 不同意 lrtimeout 超时 back 退回至上一个审核节点</param> |
|
|
|
/// <param name="operationName">流程审批操名称</param> |
|
|
|
/// <param name="processId">流程进程主键</param> |
|
|
|
/// <param name="taskId">流程任务主键</param> |
|
|
|
/// <param name="des">审批意见</param> |
|
|
|
/// <param name="auditors">下一节点指定审核人</param> |
|
|
|
/// <param name="userInfo">当前操作人信息</param> |
|
|
|
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<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; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 创建任务日志信息 |
|
|
|
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<NWFTaskRelationEntity> taskUserUpdateList = new List<NWFTaskRelationEntity>(); |
|
|
|
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<NWFTaskRelationEntity> taskUserUpdateList = new List<NWFTaskRelationEntity>(); |
|
|
|
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<NWFLineInfo> lineList = new List<NWFLineInfo>(); |
|
|
|
//List<NWFNodeInfo> list = nWFIEngine.GetNextTaskNode(nodeInfo, operationCode, false, lineList, overFW); |
|
|
|
List<NWFNodeInfo> list = nWFIEngine.GetPrevTaskNode(nodeInfo, operationCode, false, lineList, overFW); |
|
|
|
|
|
|
|
// 会签处理 |
|
|
|
int state = 0; |
|
|
|
if (operationCode == "agree") |
|
|
|
{ |
|
|
|
state = 1; |
|
|
|
} |
|
|
|
List<NWFTaskEntity> closeTaskList = new List<NWFTaskEntity>(); |
|
|
|
List<NWFConfluenceEntity> confluenceList = _ClearConfluence(list, closeTaskList, nodeInfo.id, nWFEngineParamConfig.ProcessId, state, nWFIEngine); |
|
|
|
|
|
|
|
// 创建任务 |
|
|
|
List<NWFTaskEntity> taskList = _CreateTask(list, nodeInfo, nWFEngineParamConfig); |
|
|
|
// 创建任务消息 |
|
|
|
List<NWFTaskMsgEntity> 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<NWFLineInfo> pLineList = new List<NWFLineInfo>(); |
|
|
|
List<NWFTaskEntity> pTaskList = new List<NWFTaskEntity>(); |
|
|
|
List<NWFTaskMsgEntity> pTaskMsgList = new List<NWFTaskMsgEntity>(); |
|
|
|
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<NWFNodeInfo> 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<NWFTaskEntity> nTaskList = new List<NWFTaskEntity>(); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 批量审核(只有同意和不同意) |
|
|
|
/// </summary> |
|
|
|