mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-11-09 19:04:44 +08:00
fix #IAYJL2
This commit is contained in:
@@ -33,7 +33,7 @@ namespace OpenAuth.App.Flow
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public FlowRuntime(FlowInstance instance)
|
public FlowRuntime(FlowInstance instance)
|
||||||
{
|
{
|
||||||
dynamic schemeContentJson = instance.SchemeContent.ToJson();//获取工作流模板内容的json对象;
|
dynamic schemeContentJson = instance.SchemeContent.ToJson(); //获取工作流模板内容的json对象;
|
||||||
|
|
||||||
InitLines(schemeContentJson);
|
InitLines(schemeContentJson);
|
||||||
InitNodes(schemeContentJson);
|
InitNodes(schemeContentJson);
|
||||||
@@ -42,7 +42,7 @@ namespace OpenAuth.App.Flow
|
|||||||
currentNodeType = GetNodeType(currentNodeId);
|
currentNodeType = GetNodeType(currentNodeId);
|
||||||
FrmData = instance.FrmData;
|
FrmData = instance.FrmData;
|
||||||
title = schemeContentJson.title;
|
title = schemeContentJson.title;
|
||||||
initNum = schemeContentJson.initNum?? 0;
|
initNum = schemeContentJson.initNum ?? 0;
|
||||||
previousId = instance.PreviousId;
|
previousId = instance.PreviousId;
|
||||||
flowInstanceId = instance.Id;
|
flowInstanceId = instance.Id;
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ namespace OpenAuth.App.Flow
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nextNodeId = GetNextNodeId();//下一个节点
|
nextNodeId = GetNextNodeId(); //下一个节点
|
||||||
nextNodeType = GetNodeType(nextNodeId);
|
nextNodeType = GetNodeType(nextNodeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,6 +76,7 @@ namespace OpenAuth.App.Flow
|
|||||||
{
|
{
|
||||||
Nodes.Add(node.id, node);
|
Nodes.Add(node.id, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.type == FlowNode.START)
|
if (node.type == FlowNode.START)
|
||||||
{
|
{
|
||||||
this.startNodeId = node.id;
|
this.startNodeId = node.id;
|
||||||
@@ -128,12 +129,12 @@ namespace OpenAuth.App.Flow
|
|||||||
|
|
||||||
if (FrmData == "" || FrmData == "{}") return lines[0].to;
|
if (FrmData == "" || FrmData == "{}") return lines[0].to;
|
||||||
|
|
||||||
FrmData = FrmData.ToLower();//统一转小写
|
FrmData = FrmData.ToLower(); //统一转小写
|
||||||
var frmDataJson = FrmData.ToJObject();//获取数据内容
|
var frmDataJson = FrmData.ToJObject(); //获取数据内容
|
||||||
|
|
||||||
foreach (var l in lines)
|
foreach (var l in lines)
|
||||||
{
|
{
|
||||||
if (!(l.Compares.IsNullOrEmpty()) &&l.Compare(frmDataJson))
|
if (!(l.Compares.IsNullOrEmpty()) && l.Compare(frmDataJson))
|
||||||
{
|
{
|
||||||
return l.to;
|
return l.to;
|
||||||
}
|
}
|
||||||
@@ -162,6 +163,7 @@ namespace OpenAuth.App.Flow
|
|||||||
{
|
{
|
||||||
return GetNodeType(nextNodeId);
|
return GetNodeType(nextNodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,23 +200,23 @@ namespace OpenAuth.App.Flow
|
|||||||
/// <param name="nodeId">会签时,currentNodeId是会签开始节点。这个表示当前正在处理的节点</param>
|
/// <param name="nodeId">会签时,currentNodeId是会签开始节点。这个表示当前正在处理的节点</param>
|
||||||
/// <param name="tag"></param>
|
/// <param name="tag"></param>
|
||||||
/// <returns>-1不通过,1等待,其它通过</returns>
|
/// <returns>-1不通过,1等待,其它通过</returns>
|
||||||
public string NodeConfluence(string nodeId, Tag tag)
|
public string NodeConfluence(HttpClient httpClient, string nodeId, Tag tag)
|
||||||
{
|
{
|
||||||
var forkNode = Nodes[currentNodeId]; //会签开始节点
|
var forkNode = Nodes[currentNodeId]; //会签开始节点
|
||||||
FlowNode nextNode = GetNextNode(nodeId); //获取当前处理的下一个节点
|
FlowNode nextNode = GetNextNode(nodeId); //获取当前处理的下一个节点
|
||||||
|
|
||||||
int forkNumber = FromNodeLines[currentNodeId].Count; //直接与会签节点连接的点,即会签分支数目
|
int forkNumber = FromNodeLines[currentNodeId].Count; //直接与会签节点连接的点,即会签分支数目
|
||||||
string res =string.Empty; //记录会签的结果,默认正在会签
|
string res = string.Empty; //记录会签的结果,默认正在会签
|
||||||
if (forkNode.setInfo.NodeConfluenceType == "one") //有一个步骤通过即可
|
if (forkNode.setInfo.NodeConfluenceType == "one") //有一个步骤通过即可
|
||||||
{
|
{
|
||||||
if (tag.Taged == (int) TagState.Ok)
|
if (tag.Taged == (int)TagState.Ok)
|
||||||
{
|
{
|
||||||
if (nextNode.type == FlowNode.JOIN) //下一个节点是会签结束,则该线路结束
|
if (nextNode.type == FlowNode.JOIN) //下一个节点是会签结束,则该线路结束
|
||||||
{
|
{
|
||||||
res = GetNextNodeId(nextNode.id);
|
res = GetNextNodeId(nextNode.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(tag.Taged ==(int) TagState.No)
|
else if (tag.Taged == (int)TagState.No)
|
||||||
{
|
{
|
||||||
if (forkNode.setInfo.ConfluenceNo == null)
|
if (forkNode.setInfo.ConfluenceNo == null)
|
||||||
{
|
{
|
||||||
@@ -230,7 +232,7 @@ namespace OpenAuth.App.Flow
|
|||||||
var preNode = GetPreNode(nodeId);
|
var preNode = GetPreNode(nodeId);
|
||||||
while (preNode.id != forkNode.id) //反向一直到会签开始节点
|
while (preNode.id != forkNode.id) //反向一直到会签开始节点
|
||||||
{
|
{
|
||||||
if (preNode.setInfo != null && preNode.setInfo.Taged == (int) TagState.No)
|
if (preNode.setInfo != null && preNode.setInfo.Taged == (int)TagState.No)
|
||||||
{
|
{
|
||||||
isFirst = false;
|
isFirst = false;
|
||||||
break;
|
break;
|
||||||
@@ -246,11 +248,11 @@ namespace OpenAuth.App.Flow
|
|||||||
}
|
}
|
||||||
else //默认所有步骤通过
|
else //默认所有步骤通过
|
||||||
{
|
{
|
||||||
if (tag.Taged == (int) TagState.No) //只要有一个不同意,那么流程就结束
|
if (tag.Taged == (int)TagState.No) //只要有一个不同意,那么流程就结束
|
||||||
{
|
{
|
||||||
res = TagState.No.ToString("D");
|
res = TagState.No.ToString("D");
|
||||||
}
|
}
|
||||||
else if(tag.Taged == (int)TagState.Ok)
|
else if (tag.Taged == (int)TagState.Ok)
|
||||||
{
|
{
|
||||||
if (nextNode.type == FlowNode.JOIN) //这种模式下只有坚持到【会签结束】节点之前才有意义,是否需要判定这条线所有的节点都通过,不然直接执行这个节点??
|
if (nextNode.type == FlowNode.JOIN) //这种模式下只有坚持到【会签结束】节点之前才有意义,是否需要判定这条线所有的节点都通过,不然直接执行这个节点??
|
||||||
{
|
{
|
||||||
@@ -272,12 +274,12 @@ namespace OpenAuth.App.Flow
|
|||||||
|
|
||||||
if (res == TagState.No.ToString("D"))
|
if (res == TagState.No.ToString("D"))
|
||||||
{
|
{
|
||||||
tag.Taged = (int) TagState.No;
|
tag.Taged = (int)TagState.No;
|
||||||
MakeTagNode(nextNode.id, tag);
|
MakeTagNode(nextNode.id, tag);
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrEmpty(res)) //会签结束,标记合流节点
|
else if (!string.IsNullOrEmpty(res)) //会签结束,标记合流节点
|
||||||
{
|
{
|
||||||
tag.Taged = (int) TagState.Ok;
|
tag.Taged = (int)TagState.Ok;
|
||||||
MakeTagNode(nextNode.id, tag);
|
MakeTagNode(nextNode.id, tag);
|
||||||
nextNodeId = res;
|
nextNodeId = res;
|
||||||
nextNodeType = GetNodeType(res);
|
nextNodeType = GetNodeType(res);
|
||||||
@@ -287,6 +289,12 @@ namespace OpenAuth.App.Flow
|
|||||||
nextNodeId = nextNode.id;
|
nextNodeId = nextNode.id;
|
||||||
nextNodeType = GetNodeType(nextNode.id);
|
nextNodeType = GetNodeType(nextNode.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(res)) //会签结束节点配置了回调,则发起通知
|
||||||
|
{
|
||||||
|
NotifyThirdParty(httpClient, nextNode, tag);
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,6 +306,7 @@ namespace OpenAuth.App.Flow
|
|||||||
{
|
{
|
||||||
throw new Exception("无法找到上一个点");
|
throw new Exception("无法找到上一个点");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Nodes[lines[0].from];
|
return Nodes[lines[0].from];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,10 +327,12 @@ namespace OpenAuth.App.Flow
|
|||||||
{
|
{
|
||||||
return previousId;
|
return previousId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rejectType == "1")
|
if (rejectType == "1")
|
||||||
{
|
{
|
||||||
return GetNextNodeId(startNodeId);
|
return GetNextNodeId(startNodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return previousId;
|
return previousId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,6 +361,7 @@ namespace OpenAuth.App.Flow
|
|||||||
{
|
{
|
||||||
item.Value.setInfo = new Setinfo();
|
item.Value.setInfo = new Setinfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
item.Value.setInfo.Taged = tag.Taged;
|
item.Value.setInfo.Taged = tag.Taged;
|
||||||
item.Value.setInfo.UserId = tag.UserId;
|
item.Value.setInfo.UserId = tag.UserId;
|
||||||
item.Value.setInfo.UserName = tag.UserName;
|
item.Value.setInfo.UserName = tag.UserName;
|
||||||
@@ -375,9 +387,9 @@ namespace OpenAuth.App.Flow
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通知三方系统,节点执行情况
|
/// 通知三方系统,节点执行情况
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void NotifyThirdParty(HttpClient client, Tag tag)
|
public void NotifyThirdParty(HttpClient client, FlowNode node, Tag tag)
|
||||||
{
|
{
|
||||||
if (currentNode.setInfo == null || string.IsNullOrEmpty(currentNode.setInfo.ThirdPartyUrl))
|
if (node.setInfo == null || string.IsNullOrEmpty(node.setInfo.ThirdPartyUrl))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -385,20 +397,20 @@ namespace OpenAuth.App.Flow
|
|||||||
var postData = new
|
var postData = new
|
||||||
{
|
{
|
||||||
flowInstanceId,
|
flowInstanceId,
|
||||||
nodeName=currentNode.name,
|
nodeName = node.name,
|
||||||
nodeId = currentNodeId,
|
nodeId = node.id,
|
||||||
userId = tag.UserId,
|
userId = tag.UserId,
|
||||||
userName = tag.UserName,
|
userName = tag.UserName,
|
||||||
result=tag.Taged, //1:通过;2:不通过;3驳回
|
result = tag.Taged, //1:通过;2:不通过;3驳回
|
||||||
description = tag.Description,
|
description = tag.Description,
|
||||||
execTime = tag.TagedTime,
|
execTime = tag.TagedTime,
|
||||||
isFinish = currentNodeType == 4
|
isFinish = node.type == FlowNode.END
|
||||||
};
|
};
|
||||||
|
|
||||||
using (HttpContent httpContent = new StringContent(JsonHelper.Instance.Serialize(postData), Encoding.UTF8))
|
using (HttpContent httpContent = new StringContent(JsonHelper.Instance.Serialize(postData), Encoding.UTF8))
|
||||||
{
|
{
|
||||||
httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
|
httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
|
||||||
client.PostAsync(currentNode.setInfo.ThirdPartyUrl, httpContent);
|
client.PostAsync(node.setInfo.ThirdPartyUrl, httpContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +461,7 @@ namespace OpenAuth.App.Flow
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下一个节点对象
|
/// 下一个节点对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FlowNode nextNode => nextNodeId != "-1"? Nodes[nextNodeId] : null;
|
public FlowNode nextNode => nextNodeId != "-1" ? Nodes[nextNodeId] : null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上一个节点
|
/// 上一个节点
|
||||||
|
|||||||
@@ -318,10 +318,38 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
|
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
|
||||||
|
|
||||||
#region 会签
|
|
||||||
|
|
||||||
if (flowInstance.ActivityType == 0) //当前节点是会签节点
|
if (flowInstance.ActivityType == 0) //当前节点是会签节点
|
||||||
{
|
{
|
||||||
|
CounterSign(wfruntime, tag, flowInstance);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VerifyNode(request, tag, flowInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
//自定义开发表单,需要更新对应的数据库
|
||||||
|
if (!string.IsNullOrEmpty(request.FrmData) && flowInstance.FrmType == 1)
|
||||||
|
{
|
||||||
|
var t = Type.GetType("OpenAuth.App." + flowInstance.DbName + "App");
|
||||||
|
ICustomerForm icf = (ICustomerForm)_serviceProvider.GetService(t);
|
||||||
|
icf.Update(flowInstance.Id, flowInstance.FrmData);
|
||||||
|
}
|
||||||
|
|
||||||
|
//给流程创建人发送通知信息
|
||||||
|
_messageApp.SendMsgTo(flowInstance.CreateUserId,
|
||||||
|
$"你的流程[{flowInstance.CustomName}]已被{user.Name}处理。");
|
||||||
|
|
||||||
|
wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), wfruntime.currentNode, tag);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 会签
|
||||||
|
/// </summary>
|
||||||
|
private void CounterSign(FlowRuntime wfruntime, Tag tag, FlowInstance flowInstance)
|
||||||
|
{
|
||||||
|
var user = _auth.GetCurrentUser().User;
|
||||||
|
string instanceId = flowInstance.Id;
|
||||||
//会签时的【当前节点】一直是会签开始节点
|
//会签时的【当前节点】一直是会签开始节点
|
||||||
//TODO: 标记会签节点的状态,这个地方感觉怪怪的
|
//TODO: 标记会签节点的状态,这个地方感觉怪怪的
|
||||||
wfruntime.MakeTagNode(wfruntime.currentNodeId, tag);
|
wfruntime.MakeTagNode(wfruntime.currentNodeId, tag);
|
||||||
@@ -346,12 +374,12 @@ namespace OpenAuth.App
|
|||||||
AddOperationHis(instanceId, tag, content);
|
AddOperationHis(instanceId, tag, content);
|
||||||
|
|
||||||
wfruntime.MakeTagNode(canCheckId, tag); //标记审核节点状态
|
wfruntime.MakeTagNode(canCheckId, tag); //标记审核节点状态
|
||||||
string res = wfruntime.NodeConfluence(canCheckId, tag);
|
string res = wfruntime.NodeConfluence(_httpClientFactory.CreateClient(), canCheckId, tag);
|
||||||
if (res == TagState.No.ToString("D"))
|
if (res == TagState.No.ToString("D"))
|
||||||
{
|
{
|
||||||
flowInstance.IsFinish = FlowInstanceStatus.Disagree;
|
flowInstance.IsFinish = FlowInstanceStatus.Disagree;
|
||||||
}
|
}
|
||||||
else if (!string.IsNullOrEmpty(res))
|
else if (!string.IsNullOrEmpty(res)) //会签结束,当前活动节点变为会签结束节点的下一个节点
|
||||||
{
|
{
|
||||||
flowInstance.PreviousId = flowInstance.ActivityId;
|
flowInstance.PreviousId = flowInstance.ActivityId;
|
||||||
flowInstance.ActivityId = wfruntime.nextNodeId;
|
flowInstance.ActivityId = wfruntime.nextNodeId;
|
||||||
@@ -373,37 +401,9 @@ namespace OpenAuth.App
|
|||||||
}
|
}
|
||||||
|
|
||||||
flowInstance.SchemeContent = JsonHelper.Instance.Serialize(wfruntime.ToSchemeObj());
|
flowInstance.SchemeContent = JsonHelper.Instance.Serialize(wfruntime.ToSchemeObj());
|
||||||
}
|
|
||||||
|
|
||||||
#endregion 会签
|
|
||||||
|
|
||||||
#region 一般审核
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
VerifyNode(request, tag, flowInstance);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion 一般审核
|
|
||||||
|
|
||||||
//自定义开发表单,需要更新对应的数据库
|
|
||||||
if (!string.IsNullOrEmpty(request.FrmData) && flowInstance.FrmType == 1)
|
|
||||||
{
|
|
||||||
var t = Type.GetType("OpenAuth.App." + flowInstance.DbName + "App");
|
|
||||||
ICustomerForm icf = (ICustomerForm)_serviceProvider.GetService(t);
|
|
||||||
icf.Update(flowInstance.Id, flowInstance.FrmData);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SugarClient.Updateable(flowInstance).ExecuteCommand();
|
SugarClient.Updateable(flowInstance).ExecuteCommand();
|
||||||
//给流程创建人发送通知信息
|
|
||||||
_messageApp.SendMsgTo(flowInstance.CreateUserId,
|
|
||||||
$"你的流程[{flowInstance.CustomName}]已被{user.Name}处理。");
|
|
||||||
|
|
||||||
SugarClient.Ado.CommitTran();
|
SugarClient.Ado.CommitTran();
|
||||||
|
|
||||||
wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), tag);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -519,6 +519,9 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
flowInstance.SchemeContent = JsonHelper.Instance.Serialize(wfruntime.ToSchemeObj());
|
flowInstance.SchemeContent = JsonHelper.Instance.Serialize(wfruntime.ToSchemeObj());
|
||||||
|
|
||||||
|
SugarClient.Updateable(flowInstance).ExecuteCommand();
|
||||||
|
SugarClient.Ado.CommitTran();
|
||||||
|
|
||||||
//如果审批通过,且下一个审批人是自己,则自动审批
|
//如果审批通过,且下一个审批人是自己,则自动审批
|
||||||
if (tag.Taged == (int)TagState.Ok)
|
if (tag.Taged == (int)TagState.Ok)
|
||||||
{
|
{
|
||||||
@@ -527,7 +530,7 @@ namespace OpenAuth.App
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VerifyNode(request, tag, flowInstance);
|
NodeVerification(request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,7 +619,7 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
SugarClient.Ado.CommitTran();
|
SugarClient.Ado.CommitTran();
|
||||||
|
|
||||||
wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), tag);
|
wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), wfruntime.currentNode, tag);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user