mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-15 23:13:40 +08:00
优化撤销、驳回
This commit is contained in:
parent
fe37f200c0
commit
ecc6d60e57
@ -25,6 +25,7 @@ namespace OpenAuth.App.Flow
|
|||||||
{
|
{
|
||||||
public FlowRuntime(FlowInstance instance)
|
public FlowRuntime(FlowInstance instance)
|
||||||
{
|
{
|
||||||
|
flowInstance = instance;
|
||||||
dynamic schemeContentJson = instance.SchemeContent.ToJson(); //获取工作流模板内容的json对象;
|
dynamic schemeContentJson = instance.SchemeContent.ToJson(); //获取工作流模板内容的json对象;
|
||||||
|
|
||||||
InitLines(schemeContentJson);
|
InitLines(schemeContentJson);
|
||||||
@ -331,38 +332,91 @@ namespace OpenAuth.App.Flow
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 驳回
|
/// 驳回
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rejectType">驳回类型。null:使用节点配置的驳回类型/0:前一步/1:第一步/2:指定节点,使用NodeRejectStep</param>
|
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string RejectNode(string rejectType)
|
public void RejectNode(HttpClient client, VerificationReq reqest)
|
||||||
{
|
{
|
||||||
dynamic node = Nodes[currentNodeId];
|
//默认驳回到指定节点
|
||||||
if (node.setInfo != null && string.IsNullOrEmpty(rejectType))
|
string rejectNode = reqest.NodeRejectStep;
|
||||||
|
|
||||||
|
//如果不是指定到节点
|
||||||
|
if (string.IsNullOrEmpty(rejectNode))
|
||||||
{
|
{
|
||||||
rejectType = node.setInfo.NodeRejectType;
|
string rejectType = reqest.NodeRejectType;
|
||||||
|
dynamic node = Nodes[currentNodeId];
|
||||||
|
if (node.setInfo != null && string.IsNullOrEmpty(reqest.NodeRejectType))
|
||||||
|
{
|
||||||
|
rejectType = node.setInfo.NodeRejectType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rejectType == "0") //前一步
|
||||||
|
{
|
||||||
|
rejectNode = previousId;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rejectType == "1") //第一步
|
||||||
|
{
|
||||||
|
rejectNode = GetNextNodeId(startNodeId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rejectType == "0")
|
var user = AutofacContainerModule.GetService<IAuth>().GetCurrentUser().User;
|
||||||
|
var tag = new Tag
|
||||||
{
|
{
|
||||||
return previousId;
|
Description = reqest.VerificationOpinion,
|
||||||
|
Taged = (int)TagState.Reject,
|
||||||
|
UserId = user.Id,
|
||||||
|
UserName = user.Name
|
||||||
|
};
|
||||||
|
|
||||||
|
MakeTagNode(currentNodeId, tag);
|
||||||
|
flowInstance.IsFinish = FlowInstanceStatus.Rejected; //4表示驳回(需要申请者重新提交表单)
|
||||||
|
if (rejectNode != "")
|
||||||
|
{
|
||||||
|
flowInstance.PreviousId = flowInstance.ActivityId;
|
||||||
|
flowInstance.ActivityId = rejectNode;
|
||||||
|
flowInstance.ActivityType = GetNodeType(rejectNode);
|
||||||
|
flowInstance.ActivityName = Nodes[rejectNode].name;
|
||||||
|
flowInstance.MakerList =
|
||||||
|
GetNodeMarkers(Nodes[rejectNode], flowInstance.CreateUserId);
|
||||||
|
SaveTransitionHis();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rejectType == "1")
|
flowInstance.SchemeContent = JsonHelper.Instance.Serialize(ToSchemeObj());
|
||||||
{
|
|
||||||
return GetNextNodeId(startNodeId);
|
|
||||||
}
|
|
||||||
|
|
||||||
return previousId;
|
var sugarClient = AutofacContainerModule.GetService<ISqlSugarClient>();
|
||||||
|
sugarClient.Updateable(flowInstance).ExecuteCommand();
|
||||||
|
|
||||||
|
SaveOperationHis(
|
||||||
|
$"{user.Account}-{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}驳回了【{currentNode.name}】");
|
||||||
|
|
||||||
|
NotifyThirdParty(client, currentNode, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 撤销流程,清空所有节点
|
/// 撤销流程,清空所有节点
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ReCall()
|
public void ReCall(RecallFlowInstanceReq request)
|
||||||
{
|
{
|
||||||
foreach (var item in Nodes)
|
foreach (var item in Nodes)
|
||||||
{
|
{
|
||||||
item.Value.setInfo = null;
|
item.Value.setInfo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flowInstance.IsFinish = FlowInstanceStatus.Draft;
|
||||||
|
flowInstance.PreviousId = flowInstance.ActivityId;
|
||||||
|
flowInstance.ActivityId = startNodeId;
|
||||||
|
flowInstance.ActivityType = GetNodeType(startNodeId);
|
||||||
|
flowInstance.ActivityName = Nodes[startNodeId].name;
|
||||||
|
flowInstance.MakerList = GetNodeMarkers(Nodes[startNodeId], flowInstance.CreateUserId);
|
||||||
|
|
||||||
|
SaveTransitionHis();
|
||||||
|
|
||||||
|
var sugarClient = AutofacContainerModule.GetService<ISqlSugarClient>();
|
||||||
|
sugarClient.Updateable(flowInstance).ExecuteCommand();
|
||||||
|
|
||||||
|
SaveOperationHis($"【撤回】备注:{request.Description}");
|
||||||
|
|
||||||
|
sugarClient.Ado.CommitTran();
|
||||||
}
|
}
|
||||||
|
|
||||||
///<summary>
|
///<summary>
|
||||||
@ -712,6 +766,8 @@ namespace OpenAuth.App.Flow
|
|||||||
|
|
||||||
#region 属性
|
#region 属性
|
||||||
|
|
||||||
|
private FlowInstance flowInstance { get; set; }
|
||||||
|
|
||||||
private string title { get; set; }
|
private string title { get; set; }
|
||||||
|
|
||||||
private int initNum { get; set; }
|
private int initNum { get; set; }
|
||||||
@ -726,6 +782,11 @@ namespace OpenAuth.App.Flow
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private string previousId { get; set; }
|
private string previousId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 实例节点集合
|
||||||
|
/// </summary>
|
||||||
|
private Dictionary<string, FlowNode> Nodes { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 流程实例中所有的线段
|
/// 流程实例中所有的线段
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -754,7 +815,7 @@ namespace OpenAuth.App.Flow
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开始节点的ID
|
/// 开始节点的ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string startNodeId { get; set; }
|
private string startNodeId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前节点的ID
|
/// 当前节点的ID
|
||||||
@ -782,11 +843,6 @@ namespace OpenAuth.App.Flow
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public FlowNode nextNode => nextNodeId != "-1" ? Nodes[nextNodeId] : null;
|
public FlowNode nextNode => nextNodeId != "-1" ? Nodes[nextNodeId] : null;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 实例节点集合
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<string, FlowNode> Nodes { get; set; }
|
|
||||||
|
|
||||||
#endregion 属性
|
#endregion 属性
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,7 +40,6 @@ namespace OpenAuth.App
|
|||||||
private SysMessageApp _messageApp;
|
private SysMessageApp _messageApp;
|
||||||
private DbExtension _dbExtension;
|
private DbExtension _dbExtension;
|
||||||
private UserManagerApp _userManagerApp;
|
private UserManagerApp _userManagerApp;
|
||||||
private OrgManagerApp _orgManagerApp;
|
|
||||||
private FlowApproverApp _flowApproverApp;
|
private FlowApproverApp _flowApproverApp;
|
||||||
private RevelanceManagerApp _revelanceManagerApp;
|
private RevelanceManagerApp _revelanceManagerApp;
|
||||||
|
|
||||||
@ -504,7 +503,7 @@ namespace OpenAuth.App
|
|||||||
/// 如果NodeRejectStep不为空,优先使用;否则按照NodeRejectType驳回
|
/// 如果NodeRejectStep不为空,优先使用;否则按照NodeRejectType驳回
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool NodeReject(VerificationReq reqest)
|
public bool RejectNode(VerificationReq reqest)
|
||||||
{
|
{
|
||||||
var user = _auth.GetCurrentUser().User;
|
var user = _auth.GetCurrentUser().User;
|
||||||
FlowInstance flowInstance = Get(reqest.FlowInstanceId);
|
FlowInstance flowInstance = Get(reqest.FlowInstanceId);
|
||||||
@ -514,39 +513,7 @@ namespace OpenAuth.App
|
|||||||
}
|
}
|
||||||
|
|
||||||
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
|
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
|
||||||
|
wfruntime.RejectNode(_httpClientFactory.CreateClient(),reqest);
|
||||||
//驳回的节点
|
|
||||||
string rejectNode = string.IsNullOrEmpty(reqest.NodeRejectStep)
|
|
||||||
? wfruntime.RejectNode(reqest.NodeRejectType)
|
|
||||||
: reqest.NodeRejectStep;
|
|
||||||
|
|
||||||
var tag = new Tag
|
|
||||||
{
|
|
||||||
Description = reqest.VerificationOpinion,
|
|
||||||
Taged = (int)TagState.Reject,
|
|
||||||
UserId = user.Id,
|
|
||||||
UserName = user.Name
|
|
||||||
};
|
|
||||||
|
|
||||||
wfruntime.MakeTagNode(wfruntime.currentNodeId, tag);
|
|
||||||
flowInstance.IsFinish = FlowInstanceStatus.Rejected; //4表示驳回(需要申请者重新提交表单)
|
|
||||||
if (rejectNode != "")
|
|
||||||
{
|
|
||||||
flowInstance.PreviousId = flowInstance.ActivityId;
|
|
||||||
flowInstance.ActivityId = rejectNode;
|
|
||||||
flowInstance.ActivityType = wfruntime.GetNodeType(rejectNode);
|
|
||||||
flowInstance.ActivityName = wfruntime.Nodes[rejectNode].name;
|
|
||||||
flowInstance.MakerList =
|
|
||||||
wfruntime.GetNodeMarkers(wfruntime.Nodes[rejectNode], flowInstance.CreateUserId);
|
|
||||||
|
|
||||||
wfruntime.SaveTransitionHis();
|
|
||||||
}
|
|
||||||
|
|
||||||
flowInstance.SchemeContent = JsonHelper.Instance.Serialize(wfruntime.ToSchemeObj());
|
|
||||||
SugarClient.Updateable(flowInstance).ExecuteCommand();
|
|
||||||
|
|
||||||
wfruntime.SaveOperationHis(
|
|
||||||
$"{user.Account}-{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}驳回了【{wfruntime.currentNode.name}】");
|
|
||||||
|
|
||||||
//给流程创建人发送通知信息
|
//给流程创建人发送通知信息
|
||||||
_messageApp.SendMsgTo(flowInstance.CreateUserId,
|
_messageApp.SendMsgTo(flowInstance.CreateUserId,
|
||||||
@ -554,8 +521,6 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
SugarClient.Ado.CommitTran();
|
SugarClient.Ado.CommitTran();
|
||||||
|
|
||||||
wfruntime.NotifyThirdParty(_httpClientFactory.CreateClient(), wfruntime.currentNode, tag);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,7 +540,7 @@ namespace OpenAuth.App
|
|||||||
bool isReject = TagState.Reject.Equals((TagState)Int32.Parse(request.VerificationFinally));
|
bool isReject = TagState.Reject.Equals((TagState)Int32.Parse(request.VerificationFinally));
|
||||||
if (isReject) //驳回
|
if (isReject) //驳回
|
||||||
{
|
{
|
||||||
NodeReject(request);
|
RejectNode(request);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -732,7 +697,6 @@ namespace OpenAuth.App
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ReCall(RecallFlowInstanceReq request)
|
public void ReCall(RecallFlowInstanceReq request)
|
||||||
{
|
{
|
||||||
var user = _auth.GetCurrentUser().User;
|
|
||||||
FlowInstance flowInstance = Get(request.FlowInstanceId);
|
FlowInstance flowInstance = Get(request.FlowInstanceId);
|
||||||
if (flowInstance.IsFinish == FlowInstanceStatus.Draft
|
if (flowInstance.IsFinish == FlowInstanceStatus.Draft
|
||||||
|| flowInstance.IsFinish == FlowInstanceStatus.Finished)
|
|| flowInstance.IsFinish == FlowInstanceStatus.Finished)
|
||||||
@ -741,25 +705,7 @@ namespace OpenAuth.App
|
|||||||
}
|
}
|
||||||
|
|
||||||
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
|
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
|
||||||
|
wfruntime.ReCall(request);
|
||||||
string startNodeId = wfruntime.startNodeId; //起始节点
|
|
||||||
|
|
||||||
wfruntime.ReCall();
|
|
||||||
|
|
||||||
flowInstance.IsFinish = FlowInstanceStatus.Draft;
|
|
||||||
flowInstance.PreviousId = flowInstance.ActivityId;
|
|
||||||
flowInstance.ActivityId = startNodeId;
|
|
||||||
flowInstance.ActivityType = wfruntime.GetNodeType(startNodeId);
|
|
||||||
flowInstance.ActivityName = wfruntime.Nodes[startNodeId].name;
|
|
||||||
flowInstance.MakerList = wfruntime.GetNodeMarkers(wfruntime.Nodes[startNodeId], flowInstance.CreateUserId);
|
|
||||||
|
|
||||||
wfruntime.SaveTransitionHis();
|
|
||||||
|
|
||||||
SugarClient.Updateable(flowInstance).ExecuteCommand();
|
|
||||||
|
|
||||||
wfruntime.SaveOperationHis($"【撤回】由{user.Name}撤回,备注:{request.Description}");
|
|
||||||
|
|
||||||
SugarClient.Ado.CommitTran();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>启动流程</summary>
|
/// <summary>启动流程</summary>
|
||||||
@ -805,7 +751,7 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
public FlowInstanceApp(ISqlSugarClient client, IAuth auth, RevelanceManagerApp revelanceApp,
|
public FlowInstanceApp(ISqlSugarClient client, IAuth auth, RevelanceManagerApp revelanceApp,
|
||||||
FlowSchemeApp flowSchemeApp, FormApp formApp, IHttpClientFactory httpClientFactory,
|
FlowSchemeApp flowSchemeApp, FormApp formApp, IHttpClientFactory httpClientFactory,
|
||||||
SysMessageApp messageApp, UserManagerApp userManagerApp, OrgManagerApp orgManagerApp,
|
SysMessageApp messageApp, UserManagerApp userManagerApp,
|
||||||
IServiceProvider serviceProvider, FlowApproverApp flowApproverApp,
|
IServiceProvider serviceProvider, FlowApproverApp flowApproverApp,
|
||||||
RevelanceManagerApp revelanceManagerApp, DbExtension dbExtension) : base(client, auth)
|
RevelanceManagerApp revelanceManagerApp, DbExtension dbExtension) : base(client, auth)
|
||||||
{
|
{
|
||||||
@ -815,7 +761,6 @@ namespace OpenAuth.App
|
|||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_messageApp = messageApp;
|
_messageApp = messageApp;
|
||||||
_userManagerApp = userManagerApp;
|
_userManagerApp = userManagerApp;
|
||||||
_orgManagerApp = orgManagerApp;
|
|
||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
_flowApproverApp = flowApproverApp;
|
_flowApproverApp = flowApproverApp;
|
||||||
_revelanceManagerApp = revelanceManagerApp;
|
_revelanceManagerApp = revelanceManagerApp;
|
||||||
|
Loading…
Reference in New Issue
Block a user