mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 01:58:01 +08:00
fix #IAYJL2
This commit is contained in:
@@ -76,6 +76,7 @@ namespace OpenAuth.App.Flow
|
||||
{
|
||||
Nodes.Add(node.id, node);
|
||||
}
|
||||
|
||||
if (node.type == FlowNode.START)
|
||||
{
|
||||
this.startNodeId = node.id;
|
||||
@@ -162,6 +163,7 @@ namespace OpenAuth.App.Flow
|
||||
{
|
||||
return GetNodeType(nextNodeId);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -198,7 +200,7 @@ namespace OpenAuth.App.Flow
|
||||
/// <param name="nodeId">会签时,currentNodeId是会签开始节点。这个表示当前正在处理的节点</param>
|
||||
/// <param name="tag"></param>
|
||||
/// <returns>-1不通过,1等待,其它通过</returns>
|
||||
public string NodeConfluence(string nodeId, Tag tag)
|
||||
public string NodeConfluence(HttpClient httpClient, string nodeId, Tag tag)
|
||||
{
|
||||
var forkNode = Nodes[currentNodeId]; //会签开始节点
|
||||
FlowNode nextNode = GetNextNode(nodeId); //获取当前处理的下一个节点
|
||||
@@ -287,6 +289,12 @@ namespace OpenAuth.App.Flow
|
||||
nextNodeId = nextNode.id;
|
||||
nextNodeType = GetNodeType(nextNode.id);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(res)) //会签结束节点配置了回调,则发起通知
|
||||
{
|
||||
NotifyThirdParty(httpClient, nextNode, tag);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -298,6 +306,7 @@ namespace OpenAuth.App.Flow
|
||||
{
|
||||
throw new Exception("无法找到上一个点");
|
||||
}
|
||||
|
||||
return Nodes[lines[0].from];
|
||||
}
|
||||
|
||||
@@ -318,10 +327,12 @@ namespace OpenAuth.App.Flow
|
||||
{
|
||||
return previousId;
|
||||
}
|
||||
|
||||
if (rejectType == "1")
|
||||
{
|
||||
return GetNextNodeId(startNodeId);
|
||||
}
|
||||
|
||||
return previousId;
|
||||
}
|
||||
|
||||
@@ -350,6 +361,7 @@ namespace OpenAuth.App.Flow
|
||||
{
|
||||
item.Value.setInfo = new Setinfo();
|
||||
}
|
||||
|
||||
item.Value.setInfo.Taged = tag.Taged;
|
||||
item.Value.setInfo.UserId = tag.UserId;
|
||||
item.Value.setInfo.UserName = tag.UserName;
|
||||
@@ -375,9 +387,9 @@ namespace OpenAuth.App.Flow
|
||||
/// <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;
|
||||
}
|
||||
@@ -385,20 +397,20 @@ namespace OpenAuth.App.Flow
|
||||
var postData = new
|
||||
{
|
||||
flowInstanceId,
|
||||
nodeName=currentNode.name,
|
||||
nodeId = currentNodeId,
|
||||
nodeName = node.name,
|
||||
nodeId = node.id,
|
||||
userId = tag.UserId,
|
||||
userName = tag.UserName,
|
||||
result = tag.Taged, //1:通过;2:不通过;3驳回
|
||||
description = tag.Description,
|
||||
execTime = tag.TagedTime,
|
||||
isFinish = currentNodeType == 4
|
||||
isFinish = node.type == FlowNode.END
|
||||
};
|
||||
|
||||
using (HttpContent httpContent = new StringContent(JsonHelper.Instance.Serialize(postData), Encoding.UTF8))
|
||||
{
|
||||
httpContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
|
||||
client.PostAsync(currentNode.setInfo.ThirdPartyUrl, httpContent);
|
||||
client.PostAsync(node.setInfo.ThirdPartyUrl, httpContent);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -318,10 +318,38 @@ namespace OpenAuth.App
|
||||
|
||||
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
|
||||
|
||||
#region 会签
|
||||
|
||||
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: 标记会签节点的状态,这个地方感觉怪怪的
|
||||
wfruntime.MakeTagNode(wfruntime.currentNodeId, tag);
|
||||
@@ -346,12 +374,12 @@ namespace OpenAuth.App
|
||||
AddOperationHis(instanceId, tag, content);
|
||||
|
||||
wfruntime.MakeTagNode(canCheckId, tag); //标记审核节点状态
|
||||
string res = wfruntime.NodeConfluence(canCheckId, tag);
|
||||
string res = wfruntime.NodeConfluence(_httpClientFactory.CreateClient(), canCheckId, tag);
|
||||
if (res == TagState.No.ToString("D"))
|
||||
{
|
||||
flowInstance.IsFinish = FlowInstanceStatus.Disagree;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(res))
|
||||
else if (!string.IsNullOrEmpty(res)) //会签结束,当前活动节点变为会签结束节点的下一个节点
|
||||
{
|
||||
flowInstance.PreviousId = flowInstance.ActivityId;
|
||||
flowInstance.ActivityId = wfruntime.nextNodeId;
|
||||
@@ -373,37 +401,9 @@ namespace OpenAuth.App
|
||||
}
|
||||
|
||||
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();
|
||||
//给流程创建人发送通知信息
|
||||
_messageApp.SendMsgTo(flowInstance.CreateUserId,
|
||||
$"你的流程[{flowInstance.CustomName}]已被{user.Name}处理。");
|
||||
|
||||
SugarClient.Ado.CommitTran();
|
||||
|
||||
wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -519,6 +519,9 @@ namespace OpenAuth.App
|
||||
|
||||
flowInstance.SchemeContent = JsonHelper.Instance.Serialize(wfruntime.ToSchemeObj());
|
||||
|
||||
SugarClient.Updateable(flowInstance).ExecuteCommand();
|
||||
SugarClient.Ado.CommitTran();
|
||||
|
||||
//如果审批通过,且下一个审批人是自己,则自动审批
|
||||
if (tag.Taged == (int)TagState.Ok)
|
||||
{
|
||||
@@ -527,7 +530,7 @@ namespace OpenAuth.App
|
||||
return;
|
||||
}
|
||||
|
||||
VerifyNode(request, tag, flowInstance);
|
||||
NodeVerification(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -616,7 +619,7 @@ namespace OpenAuth.App
|
||||
|
||||
SugarClient.Ado.CommitTran();
|
||||
|
||||
wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), tag);
|
||||
wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), wfruntime.currentNode, tag);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user