diff --git a/OpenAuth.App/Flow/FlowRuntime.cs b/OpenAuth.App/Flow/FlowRuntime.cs
index 53dee5e9..2acb9e02 100644
--- a/OpenAuth.App/Flow/FlowRuntime.cs
+++ b/OpenAuth.App/Flow/FlowRuntime.cs
@@ -1,20 +1,4 @@
-// ***********************************************************************
-// Assembly : OpenAuth.App
-// Author : 李玉宝
-// Created : 07-19-2018
-//
-// Last Modified By : 李玉宝
-// Last Modified On : 07-19-2018
-// ***********************************************************************
-//
-// Copyright (c) http://www.openauth.net.cn. All rights reserved.
-//
-//
-// 一个正在运行中的流程实例
-//
-// ***********************************************************************
-
-using Infrastructure;
+using Infrastructure;
using Newtonsoft.Json.Linq;
using OpenAuth.Repository.Domain;
using System;
@@ -23,14 +7,16 @@ using System.Linq;
using System.Net.Http;
using System.Text;
using Castle.Core.Internal;
+using Infrastructure.Const;
namespace OpenAuth.App.Flow
{
+ ///
+ /// 一个正在运行中的流程实例
+ /// 该类只能通过new实例化,禁止通过容器获取
+ ///
public class FlowRuntime
{
- ///
- /// 构造函数
- ///
public FlowRuntime(FlowInstance instance)
{
dynamic schemeContentJson = instance.SchemeContent.ToJson(); //获取工作流模板内容的json对象;
@@ -384,6 +370,29 @@ namespace OpenAuth.App.Flow
};
}
+ ///
+ /// 生成一个扭转记录
+ ///
+ /// 当前执行的用户
+ ///
+ public FlowInstanceTransitionHistory GenTransitionHistory(User user)
+ {
+ return new FlowInstanceTransitionHistory
+ {
+ InstanceId = flowInstanceId,
+ CreateUserId = user.Id,
+ CreateUserName = user.Name,
+ FromNodeId = currentNodeId,
+ FromNodeName = currentNode.name,
+ FromNodeType = currentNodeType,
+ ToNodeId = nextNodeId,
+ ToNodeName = nextNode?.name,
+ ToNodeType = nextNodeType,
+ IsFinish = nextNodeType == 4 ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running,
+ TransitionSate = 0
+ };
+ }
+
///
/// 通知三方系统,节点执行情况
///
@@ -418,14 +427,14 @@ namespace OpenAuth.App.Flow
#region 属性
- public string title { get; set; }
+ private string title { get; set; }
- public int initNum { get; set; }
+ private int initNum { get; set; }
///
/// 运行实例的Id
///
- public string flowInstanceId { get; set; }
+ private string flowInstanceId { get; set; }
///
/// 开始节点的ID
@@ -466,7 +475,7 @@ namespace OpenAuth.App.Flow
///
/// 上一个节点
///
- public string previousId { get; set; }
+ private string previousId { get; set; }
///
/// 实例节点集合
@@ -476,7 +485,7 @@ namespace OpenAuth.App.Flow
///
/// 流程实例中所有的线段
///
- public List Lines { get; set; }
+ private List Lines { get; set; }
///
/// 从节点发出的线段集合
@@ -486,7 +495,7 @@ namespace OpenAuth.App.Flow
///
/// 到达节点的线段集合
///
- public Dictionary> ToNodeLines { get; set; }
+ private Dictionary> ToNodeLines { get; set; }
///
/// 表单数据
diff --git a/OpenAuth.App/FlowInstance/FlowInstanceApp.cs b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs
index 8a1d11f9..04d334a0 100644
--- a/OpenAuth.App/FlowInstance/FlowInstanceApp.cs
+++ b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs
@@ -1,3 +1,11 @@
+/*
+ * @Author: yubaolee | ahfu~ <954478625@qq.com>
+ * @Date: 2024-12-13 16:55:17
+ * @Description: 工作流实例表操作
+ * @LastEditTime: 2024-12-24 10:58:01
+ * Copyright (c) 2024 by yubaolee | ahfu~ , All Rights Reserved.
+ */
+
using Infrastructure;
using OpenAuth.App.Flow;
using OpenAuth.App.Interface;
@@ -13,7 +21,6 @@ using Castle.Core.Internal;
using Infrastructure.Const;
using Infrastructure.Extensions;
using Infrastructure.Helpers;
-using Microsoft.EntityFrameworkCore.Diagnostics;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Yitter.IdGenerator;
@@ -101,7 +108,6 @@ namespace OpenAuth.App
SugarClient.Ado.BeginTran();
SugarClient.Insertable(flowInstance).ExecuteCommand();
- wfruntime.flowInstanceId = flowInstance.Id;
//知会
if (!addFlowInstanceReq.NoticeType.IsNullOrEmpty() && addFlowInstanceReq.NoticeIds != null)
@@ -122,7 +128,7 @@ namespace OpenAuth.App
{
icf.Add(flowInstance.Id, flowInstance.FrmData);
}
- catch (Exception e)
+ catch (Exception)
{
throw new Exception("流程表单数据解析失败,请检查表单是否填写完整");
}
@@ -199,11 +205,7 @@ namespace OpenAuth.App
CreateUserId = user.User.Id,
CreateUserName = user.User.Name,
CreateDate = DateTime.Now,
- Content = "【创建】"
- + user.User.Name
- + "创建了一个流程进程【"
- + addFlowInstanceReq.Code + "/"
- + addFlowInstanceReq.CustomName + "】"
+ Content = $"【创建】{user.User.Name}创建了流程实例【{addFlowInstanceReq.CustomName}】"
};
SugarClient.Insertable(processOperationHistoryEntity).ExecuteCommand();
@@ -369,7 +371,7 @@ namespace OpenAuth.App
}
var content =
- $"{user.Account}-{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}审批了【{wfruntime.Nodes[canCheckId].name}】" +
+ $"{user.Account}-{DateTime.Now:yyyy-MM-dd HH:mm}审批了【{wfruntime.Nodes[canCheckId].name}】" +
$"结果:{(tag.Taged == 1 ? "同意" : "不同意")},备注:{tag.Description}";
AddOperationHis(instanceId, tag, content);
@@ -572,8 +574,8 @@ namespace OpenAuth.App
FlowRuntime wfruntime = new FlowRuntime(flowInstance);
- string rejectNode = ""; //驳回的节点
- rejectNode = string.IsNullOrEmpty(reqest.NodeRejectStep)
+ //驳回的节点
+ string rejectNode = string.IsNullOrEmpty(reqest.NodeRejectStep)
? wfruntime.RejectNode(reqest.NodeRejectType)
: reqest.NodeRejectStep;
@@ -607,10 +609,7 @@ namespace OpenAuth.App
CreateUserId = user.Id,
CreateUserName = user.Name,
CreateDate = DateTime.Now,
- Content = "【"
- + wfruntime.currentNode.name
- + "】【" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "】驳回,备注:"
- + reqest.VerificationOpinion
+ Content = $"【{wfruntime.currentNode.name}】【{DateTime.Now:yyyy-MM-dd HH:mm}】驳回,备注:{reqest.VerificationOpinion}"
}).ExecuteCommand();
//给流程创建人发送通知信息
@@ -694,7 +693,6 @@ namespace OpenAuth.App
throw new Exception("前端提交的节点权限类型异常,请检查流程");
}
- FlowInstance flowInstance = Get(wfruntime.flowInstanceId);
var chairmanIds = _orgManagerApp.GetChairmanId(wfruntime.nextNode.setInfo.NodeDesignateData.orgs);
makerList = GenericHelpers.ArrayToString(chairmanIds, makerList);
}
@@ -819,7 +817,6 @@ namespace OpenAuth.App
///
/// 审核流程
- /// 李玉宝于2017-01-20 15:44:45
///
public void Verification(VerificationReq request)
{
@@ -982,21 +979,8 @@ namespace OpenAuth.App
///
private void AddTransHistory(FlowRuntime wfruntime)
{
- var tag = _auth.GetCurrentUser().User;
- SugarClient.Insertable(new FlowInstanceTransitionHistory
- {
- InstanceId = wfruntime.flowInstanceId,
- CreateUserId = tag.Id,
- CreateUserName = tag.Name,
- FromNodeId = wfruntime.currentNodeId,
- FromNodeName = wfruntime.currentNode.name,
- FromNodeType = wfruntime.currentNodeType,
- ToNodeId = wfruntime.nextNodeId,
- ToNodeName = wfruntime.nextNode?.name,
- ToNodeType = wfruntime.nextNodeType,
- IsFinish = wfruntime.nextNodeType == 4 ? FlowInstanceStatus.Finished : FlowInstanceStatus.Running,
- TransitionSate = 0
- }).ExecuteCommand();
+ var user = _auth.GetCurrentUser().User;
+ SugarClient.Insertable(wfruntime.GenTransitionHistory(user)).ExecuteCommand();
}
private void AddOperationHis(string instanceId, Tag tag, string content)
diff --git a/OpenAuth.Repository/Core/StringEntity.cs b/OpenAuth.Repository/Core/StringEntity.cs
index e77cc08f..0a92bab3 100644
--- a/OpenAuth.Repository/Core/StringEntity.cs
+++ b/OpenAuth.Repository/Core/StringEntity.cs
@@ -24,6 +24,7 @@ namespace OpenAuth.Repository.Core
///
/// 创建默认的主键值
+ /// 当构造函数执行时如果Id为空,则会自动执行该函数
///
public override void GenerateDefaultKeyVal()
{