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