From 591ae5a09acd4b49d9103101e8ef0ec77ac5e5f2 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Thu, 15 May 2025 15:39:15 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4FlowinstanceTrans?= =?UTF-8?q?itionHistory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/Flow/FlowRuntime.cs | 35 +----- OpenAuth.App/FlowInstance/FlowInstanceApp.cs | 5 - .../Domain/FlowInstanceTransitionHistory.cs | 101 ------------------ OpenAuth.Repository/OpenAuthDBContext.cs | 1 - newdocs/docs/notes/core/flowinstancedev.md | 5 +- 5 files changed, 3 insertions(+), 144 deletions(-) delete mode 100644 OpenAuth.Repository/Domain/FlowInstanceTransitionHistory.cs diff --git a/OpenAuth.App/Flow/FlowRuntime.cs b/OpenAuth.App/Flow/FlowRuntime.cs index db44a980..0311fc6c 100644 --- a/OpenAuth.App/Flow/FlowRuntime.cs +++ b/OpenAuth.App/Flow/FlowRuntime.cs @@ -375,7 +375,6 @@ namespace OpenAuth.App.Flow flowInstance.ActivityName = Nodes[rejectNode].name; flowInstance.MakerList = GetNodeMarkers(Nodes[rejectNode], flowInstance.CreateUserId); - SaveTransitionHis(); } flowInstance.SchemeContent = JsonHelper.Instance.Serialize(ToSchemeObj()); @@ -405,8 +404,6 @@ namespace OpenAuth.App.Flow flowInstance.ActivityName = Nodes[startNodeId].name; flowInstance.MakerList = GetNodeMarkers(Nodes[startNodeId], flowInstance.CreateUserId); - SaveTransitionHis(); - var sugarClient = AutofacContainerModule.GetService(); sugarClient.Updateable(flowInstance).ExecuteCommand(); @@ -478,32 +475,6 @@ namespace OpenAuth.App.Flow SaveOperationHis(user.Id, user.Name, opHis); } - /// - /// 保存本次扭转记录 - /// - /// - public void SaveTransitionHis() - { - var user = AutofacContainerModule.GetService().GetCurrentUser().User; - var SugarClient = AutofacContainerModule.GetService(); - var transitionHistory = new FlowInstanceTransitionHistory - { - InstanceId = flowInstanceId, - CreateUserId = user.Id, - CreateUserName = user.Name, - FromNodeId = currentNodeId, - FromNodeName = currentNode.name, - FromNodeType = GetCurrentNodeType(), - ToNodeId = nextNodeId, - ToNodeName = nextNode?.name, - ToNodeType = GetNextNodeType(), - IsFinish = IsFinish() ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running, - TransitionSate = 0 - }; - - SugarClient.Insertable(transitionHistory).ExecuteCommand(); - } - /// /// 通知三方系统,节点执行情况 /// @@ -580,12 +551,10 @@ namespace OpenAuth.App.Flow currentNode.setInfo.Description = ""; currentNode.setInfo.TagedTime = ""; - //删除当前节点的扭转记录 + //删除当前节点的审批记录(只删除最新的一条) var user = AutofacContainerModule.GetService().GetCurrentUser().User; var SugarClient = AutofacContainerModule.GetService(); - SugarClient.Deleteable().Where(u => u.InstanceId == flowInstanceId && u.CreateUserId == user.Id && u.FromNodeId == currentNodeId).ExecuteCommand(); - - //删除当前节点的审批记录(只删除最新的一条) + var latestRecord = SugarClient.Queryable() .Where(u => u.InstanceId == flowInstanceId && u.CreateUserId == user.Id) .OrderByDescending(u => u.CreateDate) diff --git a/OpenAuth.App/FlowInstance/FlowInstanceApp.cs b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs index 5828b70b..10d9fb13 100644 --- a/OpenAuth.App/FlowInstance/FlowInstanceApp.cs +++ b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs @@ -219,7 +219,6 @@ namespace OpenAuth.App wfruntime.SaveOperationHis($"【创建】{user.User.Name}创建了流程实例【{addFlowInstanceReq.CustomName}】"); - wfruntime.SaveTransitionHis(); SugarClient.Ado.CommitTran(); return flowInstance.Id; } @@ -408,14 +407,11 @@ namespace OpenAuth.App : FlowInstanceStatus.Running; flowInstance.MakerList = wfruntime.IsFinish() ? "" : wfruntime.GetNextMakers(); - - wfruntime.SaveTransitionHis(); } else { //网关过程中,需要更新用户 flowInstance.MakerList = wfruntime.GetForkNodeMakers(wfruntime.currentNodeId); - wfruntime.SaveTransitionHis(); } flowInstance.SchemeContent = JsonHelper.Instance.Serialize(wfruntime.ToSchemeObj()); @@ -898,7 +894,6 @@ namespace OpenAuth.App #endregion 根据运行实例改变当前节点状态 wfruntime.SaveOperationHis($"【启动】由用户{user.User.Name}启动"); - wfruntime.SaveTransitionHis(); SugarClient.Ado.CommitTran(); } diff --git a/OpenAuth.Repository/Domain/FlowInstanceTransitionHistory.cs b/OpenAuth.Repository/Domain/FlowInstanceTransitionHistory.cs deleted file mode 100644 index 2155a90f..00000000 --- a/OpenAuth.Repository/Domain/FlowInstanceTransitionHistory.cs +++ /dev/null @@ -1,101 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a CodeSmith Template. -// -// DO NOT MODIFY contents of this file. Changes to this -// file will be lost if the code is regenerated. -// Author:Yubao Li -// -//------------------------------------------------------------------------------ -using System; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations.Schema; -using Infrastructure.Const; -using OpenAuth.Repository.Core; - -namespace OpenAuth.Repository.Domain -{ - /// - /// 流程实例流转记录 - /// 记录某个流程实例所有已审批的从一个活动节点到下一个活动节点的操作人、操作时间 - /// - [Table("FlowInstanceTransitionHistory")] - public partial class FlowInstanceTransitionHistory : StringEntity - { - public FlowInstanceTransitionHistory() - { - this.InstanceId = string.Empty; - this.FromNodeId = string.Empty; - this.FromNodeName = string.Empty; - this.ToNodeId = string.Empty; - this.ToNodeName = string.Empty; - this.TransitionSate = 0; - this.IsFinish = FlowInstanceStatus.Running; - this.CreateDate = DateTime.Now; - this.CreateUserId = string.Empty; - this.CreateUserName = string.Empty; - } - - /// - /// 实例Id - /// - [Description("实例Id")] - public string InstanceId { get; set; } - /// - /// 开始节点Id - /// - [Description("开始节点Id")] - public string FromNodeId { get; set; } - /// - /// 开始节点类型 - /// - [Description("开始节点类型")] - public string FromNodeType { get; set; } - /// - /// 开始节点名称 - /// - [Description("开始节点名称")] - public string FromNodeName { get; set; } - /// - /// 结束节点Id - /// - [Description("结束节点Id")] - public string ToNodeId { get; set; } - /// - /// 结束节点类型 - /// - [Description("结束节点类型")] - public string ToNodeType { get; set; } - /// - /// 结束节点名称 - /// - [Description("结束节点名称")] - public string ToNodeName { get; set; } - /// - /// 转化状态 - /// - [Description("转化状态")] - public int TransitionSate { get; set; } - /// - /// 是否结束 - /// - [Description("是否结束")] - public int IsFinish { get; set; } - /// - /// 转化时间 - /// - [Description("转化时间")] - public System.DateTime CreateDate { get; set; } - /// - /// 操作人Id - /// - [Description("操作人Id")] - public string CreateUserId { get; set; } - /// - /// 操作人名称 - /// - [Description("操作人名称")] - public string CreateUserName { get; set; } - - } -} \ No newline at end of file diff --git a/OpenAuth.Repository/OpenAuthDBContext.cs b/OpenAuth.Repository/OpenAuthDBContext.cs index e096a369..58257fd2 100644 --- a/OpenAuth.Repository/OpenAuthDBContext.cs +++ b/OpenAuth.Repository/OpenAuthDBContext.cs @@ -143,7 +143,6 @@ namespace OpenAuth.Repository public virtual DbSet CategoryTypes { get; set; } public virtual DbSet FlowInstances { get; set; } public virtual DbSet FlowInstanceOperationHistorys { get; set; } - public virtual DbSet FlowInstanceTransitionHistorys { get; set; } public virtual DbSet FlowSchemes { get; set; } public virtual DbSet
Forms { get; set; } public virtual DbSet Modules { get; set; } diff --git a/newdocs/docs/notes/core/flowinstancedev.md b/newdocs/docs/notes/core/flowinstancedev.md index 2399d968..aabf003a 100644 --- a/newdocs/docs/notes/core/flowinstancedev.md +++ b/newdocs/docs/notes/core/flowinstancedev.md @@ -183,10 +183,7 @@ stop ### ActivityId: 当前活动节点,即待审批的节点 -与流程实例密切相关的还有两个表:流程实例的操作记录FlowInstanceOperationHistory及流转记录FlowInstanceTransitionHistory。它们有不同的作用: +与流程实例密切相关的还有:流程实例的操作记录FlowInstanceOperationHistory。 ## 操作记录FlowInstanceOperationHistory 该表记录了流程实例的所有操作记录,包括流程的创建、撤回、驳回、同意、不同意等操作。 - -## 流转记录FlowInstanceTransitionHistory -记录某个流程实例所有已审批的从一个活动节点到下一个活动节点的操作人、操作时间。