fix #I9KL18 当前审核人审核通过后,下个审核人还没审核,当前审核人可以撤回

This commit is contained in:
wintel
2025-03-08 15:01:17 +08:00
parent 4e6287808b
commit a76aa99cb9
5 changed files with 143 additions and 3 deletions

View File

@@ -538,6 +538,57 @@ namespace OpenAuth.App.Flow
}
}
/// <summary>
/// 撤销当前节点的审批
/// </summary>
public void UndoVerification()
{
// 已结束的流程不能撤销
if (flowInstance.IsFinish == FlowInstanceStatus.Finished
|| flowInstance.IsFinish == FlowInstanceStatus.Rejected)
{
throw new Exception("流程已结束,不能撤销");
}
if(Nodes[previousId].type == FlowNode.START)
{
throw new Exception("没有任何审批,不能撤销!你可以删除或召回这个流程");
}
// 恢复到上一个节点
currentNodeId = flowInstance.PreviousId;
flowInstance.ActivityId = currentNodeId;
flowInstance.ActivityType = GetNodeType(currentNodeId);
flowInstance.ActivityName = Nodes[currentNodeId].name;
//向前查找ActivityId的前一个结点即连线指向ActivityId的节点
flowInstance.PreviousId = GetPreNode().id;
flowInstance.MakerList = GetNodeMarkers(Nodes[currentNodeId]);
// 清除当前节点的审批状态
currentNode.setInfo.Taged = null;
currentNode.setInfo.UserId = "";
currentNode.setInfo.UserName = "";
currentNode.setInfo.Description = "";
currentNode.setInfo.TagedTime = "";
//删除当前节点的扭转记录
var user = AutofacContainerModule.GetService<IAuth>().GetCurrentUser().User;
var SugarClient = AutofacContainerModule.GetService<ISqlSugarClient>();
SugarClient.Deleteable<FlowInstanceTransitionHistory>().Where(u => u.InstanceId == flowInstanceId && u.CreateUserId == user.Id && u.FromNodeId == currentNodeId).ExecuteCommand();
//删除当前节点的审批记录(只删除最新的一条)
var latestRecord = SugarClient.Queryable<FlowInstanceOperationHistory>()
.Where(u => u.InstanceId == flowInstanceId && u.CreateUserId == user.Id)
.OrderByDescending(u => u.CreateDate)
.First();
if (latestRecord != null)
{
SugarClient.Deleteable<FlowInstanceOperationHistory>()
.Where(u => u.Id == latestRecord.Id)
.ExecuteCommand();
}
}
#endregion
#region