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