From d32ef5b78dd31b5eb534da13f27c412800df977d Mon Sep 17 00:00:00 2001 From: yubaolee Date: Thu, 17 Apr 2025 13:55:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=8E=BB=E6=8E=89=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E5=AE=9E=E4=BE=8B=E7=9A=84ActivityType=EF=BC=8C?= =?UTF-8?q?=E9=87=8D=E6=9E=84=E8=8A=82=E7=82=B9=E7=B1=BB=E5=9E=8B=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/Flow/FlowRuntime.cs | 63 ++++++------------- OpenAuth.App/FlowInstance/FlowInstanceApp.cs | 25 +++----- OpenAuth.Repository/Domain/FlowInstance.cs | 5 -- .../Domain/FlowInstanceTransitionHistory.cs | 4 +- 4 files changed, 30 insertions(+), 67 deletions(-) diff --git a/OpenAuth.App/Flow/FlowRuntime.cs b/OpenAuth.App/Flow/FlowRuntime.cs index 2b9e3546..1a924ace 100644 --- a/OpenAuth.App/Flow/FlowRuntime.cs +++ b/OpenAuth.App/Flow/FlowRuntime.cs @@ -33,7 +33,6 @@ namespace OpenAuth.App.Flow InitNodes(schemeContentJson); currentNodeId = instance.ActivityId == "" ? startNodeId : instance.ActivityId; - currentNodeType = GetNodeType(currentNodeId); FrmData = instance.FrmData; title = schemeContentJson.title; initNum = schemeContentJson.initNum ?? 0; @@ -41,15 +40,13 @@ namespace OpenAuth.App.Flow flowInstanceId = instance.Id; //会签开始节点和流程结束节点没有下一步 - if (currentNodeType == 0 || currentNodeType == 4) + if (GetCurrentNodeType() == Define.NODE_TYPE_FORK || GetCurrentNodeType() == Define.NODE_TYPE_END) { nextNodeId = "-1"; - nextNodeType = -1; } else { nextNodeId = GetNextNodeId(); //下一个节点 - nextNodeType = GetNodeType(nextNodeId); } } @@ -154,14 +151,14 @@ namespace OpenAuth.App.Flow /// 获取实例接下来运行的状态 /// /// -1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束 - public int GetNextNodeType() + public string GetNextNodeType() { if (nextNodeId != "-1") { return GetNodeType(nextNodeId); } - return -1; + return "error"; } /// @@ -169,26 +166,18 @@ namespace OpenAuth.App.Flow /// /// /// - public int GetNodeType(string nodeId) + public string GetNodeType(string nodeId) { - switch (Nodes[nodeId].type) - { - //会签开始节点 - case Define.NODE_TYPE_FORK: - return 0; - //会签结束节点 - case Define.NODE_TYPE_JOIN: - return 1; - //结束节点 - case Define.NODE_TYPE_END: - return 4; - //开始节点 - case Define.NODE_TYPE_START: - return 3; + return Nodes[nodeId].type; + } - default: - return 2; - } + /// + /// 获取当前节点类型 + /// + /// + public string GetCurrentNodeType() + { + return GetNodeType(currentNodeId); } /// @@ -305,12 +294,10 @@ namespace OpenAuth.App.Flow tag.Taged = (int)TagState.Ok; MakeTagNode(nextNode.id, tag); nextNodeId = res; - nextNodeType = GetNodeType(res); } else { nextNodeId = nextNode.id; - nextNodeType = GetNodeType(nextNode.id); } if (!string.IsNullOrEmpty(res)) //会签结束节点配置了回调,则发起通知 @@ -378,7 +365,6 @@ namespace OpenAuth.App.Flow { flowInstance.PreviousId = flowInstance.ActivityId; flowInstance.ActivityId = rejectNode; - flowInstance.ActivityType = GetNodeType(rejectNode); flowInstance.ActivityName = Nodes[rejectNode].name; flowInstance.MakerList = GetNodeMarkers(Nodes[rejectNode], flowInstance.CreateUserId); @@ -409,7 +395,6 @@ namespace OpenAuth.App.Flow 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); @@ -501,11 +486,11 @@ namespace OpenAuth.App.Flow CreateUserName = user.Name, FromNodeId = currentNodeId, FromNodeName = currentNode.name, - FromNodeType = currentNodeType, + // FromNodeType = GetCurrentNodeType(), ToNodeId = nextNodeId, ToNodeName = nextNode?.name, - ToNodeType = nextNodeType, - IsFinish = nextNodeType == 4 ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running, + // ToNodeType = GetNextNodeType(), + IsFinish = GetNextNodeType() == Define.NODE_TYPE_END ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running, TransitionSate = 0 }; @@ -576,7 +561,6 @@ namespace OpenAuth.App.Flow // 恢复到上一个节点 currentNodeId = flowInstance.PreviousId; flowInstance.ActivityId = currentNodeId; - flowInstance.ActivityType = GetNodeType(currentNodeId); flowInstance.ActivityName = Nodes[currentNodeId].name; //向前查找ActivityId的前一个结点,即连线指向ActivityId的节点 flowInstance.PreviousId = GetPreNode().id; @@ -624,7 +608,7 @@ namespace OpenAuth.App.Flow throw new Exception("无法寻找到下一个节点"); } - if (nextNodeType == 0) //如果是会签节点 + if (GetNextNodeType() == Define.NODE_TYPE_FORK) //如果是会签节点 { makerList = GetForkNodeMakers(nextNodeId); } @@ -908,12 +892,7 @@ namespace OpenAuth.App.Flow /// 到达节点的线段集合 /// private Dictionary> ToNodeLines { get; set; } - - /// - /// 当前节点类型 0会签开始,1会签结束,2一般节点,开始节点,4流程运行结束 - /// - private int currentNodeType { get; set; } - + /// /// 表单数据 /// @@ -939,12 +918,6 @@ namespace OpenAuth.App.Flow /// public string nextNodeId { get; set; } - /// - /// 下一个节点类型 -1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束 - /// - /// The type of the next node. - public int nextNodeType { get; set; } - /// /// 下一个节点对象 /// diff --git a/OpenAuth.App/FlowInstance/FlowInstanceApp.cs b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs index e628c9df..b8294920 100644 --- a/OpenAuth.App/FlowInstance/FlowInstanceApp.cs +++ b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs @@ -112,7 +112,6 @@ namespace OpenAuth.App #region 根据运行实例改变当前节点状态 flowInstance.ActivityId = wfruntime.nextNodeId; - flowInstance.ActivityType = wfruntime.GetNextNodeType(); flowInstance.ActivityName = wfruntime.nextNode.name; flowInstance.PreviousId = wfruntime.currentNodeId; flowInstance.CreateUserId = user.User.Id; @@ -121,8 +120,8 @@ namespace OpenAuth.App addFlowInstanceReq.CreateUserName = user.User.Account; flowInstance.MakerList = - wfruntime.GetNextNodeType() != 4 ? wfruntime.GetNextMakers(addFlowInstanceReq) : ""; - flowInstance.IsFinish = wfruntime.GetNextNodeType() == 4 + wfruntime.GetNextNodeType() != Define.NODE_TYPE_END ? wfruntime.GetNextMakers(addFlowInstanceReq) : ""; + flowInstance.IsFinish = wfruntime.GetNextNodeType() == Define.NODE_TYPE_END ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running; @@ -329,7 +328,7 @@ namespace OpenAuth.App FlowRuntime wfruntime = new FlowRuntime(flowInstance); - if (flowInstance.ActivityType == 0) //当前节点是会签节点 + if (wfruntime.GetCurrentNodeType() == Define.NODE_TYPE_FORK) //当前节点是网关开始节点 { CounterSign(wfruntime, tag, flowInstance); } @@ -403,13 +402,12 @@ namespace OpenAuth.App { flowInstance.PreviousId = flowInstance.ActivityId; flowInstance.ActivityId = wfruntime.nextNodeId; - flowInstance.ActivityType = wfruntime.nextNodeType; flowInstance.ActivityName = wfruntime.nextNode.name; - flowInstance.IsFinish = wfruntime.nextNodeType == 4 + flowInstance.IsFinish = wfruntime.GetNextNodeType() == Define.NODE_TYPE_END ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running; flowInstance.MakerList = - wfruntime.nextNodeType == 4 ? "" : wfruntime.GetNextMakers(); + wfruntime.GetNextNodeType() == Define.NODE_TYPE_END ? "" : wfruntime.GetNextMakers(); wfruntime.SaveTransitionHis(); } @@ -503,10 +501,9 @@ namespace OpenAuth.App { flowInstance.PreviousId = flowInstance.ActivityId; flowInstance.ActivityId = wfruntime.nextNodeId; - flowInstance.ActivityType = wfruntime.nextNodeType; flowInstance.ActivityName = wfruntime.nextNode.name; - flowInstance.MakerList = wfruntime.nextNodeType == 4 ? "" : wfruntime.GetNextMakers(request); - flowInstance.IsFinish = wfruntime.nextNodeType == 4 + flowInstance.MakerList = wfruntime.GetNextNodeType() == Define.NODE_TYPE_END ? "" : wfruntime.GetNextMakers(request); + flowInstance.IsFinish = wfruntime.GetNextNodeType() == Define.NODE_TYPE_END ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running; } @@ -515,7 +512,6 @@ namespace OpenAuth.App { flowInstance.IsFinish = FlowInstanceStatus.Disagree; wfruntime.nextNodeId = "-1"; - wfruntime.nextNodeType = 4; } var content = @@ -641,7 +637,7 @@ namespace OpenAuth.App resp.CanWriteFormItemIds = runtime.currentNode.setInfo.CanWriteFormItemIds; } - if (runtime.nextNode != null && runtime.nextNode.setInfo != null && runtime.nextNodeType != 4) + if (runtime.nextNode != null && runtime.nextNode.setInfo != null && runtime.GetNextNodeType() != Define.NODE_TYPE_END) { resp.NextNodeDesignateType = runtime.nextNode.setInfo.NodeDesignate; resp.CanWriteFormItemIds = runtime.currentNode.setInfo.CanWriteFormItemIds; @@ -869,13 +865,12 @@ namespace OpenAuth.App #region 根据运行实例改变当前节点状态 flowInstance.ActivityId = wfruntime.nextNodeId; - flowInstance.ActivityType = wfruntime.GetNextNodeType(); flowInstance.ActivityName = wfruntime.nextNode.name; flowInstance.PreviousId = wfruntime.currentNodeId; flowInstance.CreateUserId = user.User.Id; flowInstance.CreateUserName = user.User.Account; - flowInstance.MakerList = wfruntime.GetNextNodeType() != 4 ? wfruntime.GetNextMakers() : ""; - flowInstance.IsFinish = wfruntime.GetNextNodeType() == 4 + flowInstance.MakerList = wfruntime.GetNextNodeType() != Define.NODE_TYPE_END ? wfruntime.GetNextMakers() : ""; + flowInstance.IsFinish = wfruntime.GetNextNodeType() == Define.NODE_TYPE_END ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running; diff --git a/OpenAuth.Repository/Domain/FlowInstance.cs b/OpenAuth.Repository/Domain/FlowInstance.cs index 66485884..1b81ce1a 100644 --- a/OpenAuth.Repository/Domain/FlowInstance.cs +++ b/OpenAuth.Repository/Domain/FlowInstance.cs @@ -70,11 +70,6 @@ namespace OpenAuth.Repository.Domain [Description("当前节点ID")] public string ActivityId { get; set; } /// - /// 当前节点类型(0会签节点) - /// - [Description("当前节点类型(0会签节点)")] - public int? ActivityType { get; set; } - /// /// 当前节点名称 /// [Description("当前节点名称")] diff --git a/OpenAuth.Repository/Domain/FlowInstanceTransitionHistory.cs b/OpenAuth.Repository/Domain/FlowInstanceTransitionHistory.cs index 678b0b89..2155a90f 100644 --- a/OpenAuth.Repository/Domain/FlowInstanceTransitionHistory.cs +++ b/OpenAuth.Repository/Domain/FlowInstanceTransitionHistory.cs @@ -50,7 +50,7 @@ namespace OpenAuth.Repository.Domain /// 开始节点类型 /// [Description("开始节点类型")] - public int? FromNodeType { get; set; } + public string FromNodeType { get; set; } /// /// 开始节点名称 /// @@ -65,7 +65,7 @@ namespace OpenAuth.Repository.Domain /// 结束节点类型 /// [Description("结束节点类型")] - public int? ToNodeType { get; set; } + public string ToNodeType { get; set; } /// /// 结束节点名称 ///