瀏覽代碼

【修改】增加流程退回方法,暂定使用;

master
dyy 3 年之前
父節點
當前提交
fc4a1e51af
共有 5 個檔案被更改,包括 491 行新增1 行删除
  1. +10
    -1
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_NewWorkFlow/Controllers/NWFProcessController.cs
  2. +346
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Process/NWFProcessBLL.cs
  3. +13
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Process/NWFProcessIBLL.cs
  4. +111
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Workflow/Learun.Workflow.Engine/NWFEngine.cs
  5. +11
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Workflow/Learun.Workflow.Engine/NWFIEngine.cs

+ 10
- 1
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
/// <summary>
/// 审批流程
/// </summary>
/// <param name="operationCode">流程审批操作码agree 同意 disagree 不同意 lrtimeout 超时</param>
/// <param name="operationCode">流程审批操作码agree 同意 disagree 不同意 lrtimeout 超时 back 退回至上一个审核节点</param>
/// <param name="operationName">流程审批操名称</param>
/// <param name="processId">流程进程主键</param>
/// <param name="taskId">流程任务主键</param>
@@ -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("流程审批成功");
}


+ 346
- 0
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);

}

/// <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>


+ 13
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.WorkFlow/Process/NWFProcessIBLL.cs 查看文件

@@ -192,6 +192,19 @@ namespace Learun.Application.WorkFlow
/// <param name="auditors">下一节点指定审核人</param>
/// <param name="userInfo">当前操作人信息</param>
void AuditFlow(string operationCode, string operationName, string processId, string taskId, string des, string auditors, string stamp, string signUrl, UserInfo 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>
void AuditFlow2(string operationCode, string operationName, string processId, string taskId, string des, string auditors, string stamp, string signUrl, UserInfo userInfo);

/// <summary>
/// 批量审核(只有同意和不同意)
/// </summary>


+ 111
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Workflow/Learun.Workflow.Engine/NWFEngine.cs 查看文件

@@ -544,6 +544,117 @@ namespace Learun.Workflow.Engine

return list;
}

/// <summary>
/// 获取上一步的任务节点信息(只有审批操作码为back(退回至上一个审核节点)情况下执行)【暂定】
/// </summary>
/// <param name="beginNode">起始节点</param>
/// <param name="code">节点操作码 agree 同意 disagree 不同意 lrtimeout 超时 back 退回至上一个审核节点</param>
/// <param name="isGetAuditors">是否获取下一节点审核人</param>
/// <param name="lineList">经过的线段需要执行操作的</param>
/// <returns></returns>
public List<NWFNodeInfo> GetPrevTaskNode(NWFNodeInfo beginNode, string code, bool isGetAuditors, List<NWFLineInfo> lineList, bool overWF = false)
{
List<NWFNodeInfo> list = new List<NWFNodeInfo>();
List<NWFNodeInfo> nextNodeList = new List<NWFNodeInfo>();

//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<string, string> auditers = null;
if (!string.IsNullOrEmpty(config.ParamConfig.Auditers))
{
auditers = config.ParamConfig.Auditers.ToObject<Dictionary<string, string>>();
}


foreach (var node in nextNodeList)
{
if (auditers != null && auditers.ContainsKey(node.id))
{
node.auditors = new List<NWFAuditor>();
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

}


+ 11
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Workflow/Learun.Workflow.Engine/NWFIEngine.cs 查看文件

@@ -70,6 +70,17 @@ namespace Learun.Workflow.Engine
/// <param name="lineList">经过的线段需要执行操作的</param>
/// <returns></returns>
List<NWFNodeInfo> GetNextTaskNode(NWFNodeInfo beginNode, string code, bool isGetAuditors, List<NWFLineInfo> lineList, bool overWF = false);

/// <summary>
/// 获取上一步的任务节点信息(只有审批操作码为back(退回至上一个审核节点)情况下执行)【暂定】
/// </summary>
/// <param name="beginNode">起始节点</param>
/// <param name="code">节点操作码 agree 同意 disagree 不同意 lrtimeout 超时 back 退回至上一个审核节点</param>
/// <param name="isGetAuditors">是否获取下一节点审核人</param>
/// <param name="lineList">经过的线段需要执行操作的</param>
/// <returns></returns>
List<NWFNodeInfo> GetPrevTaskNode(NWFNodeInfo beginNode, string code, bool isGetAuditors, List<NWFLineInfo> lineList, bool overWF = false);

#endregion
}
}

Loading…
取消
儲存