From 68aa427b40d14afc84fff8e9613bedbf253117a5 Mon Sep 17 00:00:00 2001 From: wintel Date: Sun, 6 Apr 2025 02:55:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=9A=E5=8A=A1=E5=8D=95=E6=8D=AE?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=AD=A3=E5=B8=B8=E9=80=81=E5=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/Flow/FlowRuntime.cs | 3 + OpenAuth.App/FlowInstance/FlowInstanceApp.cs | 22 +- OpenAuth.Repository/Domain/FlowInstance.cs | 329 ++++++++++--------- 3 files changed, 192 insertions(+), 162 deletions(-) diff --git a/OpenAuth.App/Flow/FlowRuntime.cs b/OpenAuth.App/Flow/FlowRuntime.cs index a458570a..a9a2cfdf 100644 --- a/OpenAuth.App/Flow/FlowRuntime.cs +++ b/OpenAuth.App/Flow/FlowRuntime.cs @@ -119,6 +119,9 @@ namespace OpenAuth.App.Flow { throw new Exception("无法寻找到下一个节点"); } + + //URL表单暂时不支持URL表单 + if(flowInstance.FrmType == Define.FORM_TYPE_URL) return lines[0].to; if (FrmData == "" || FrmData == "{}") return lines[0].to; diff --git a/OpenAuth.App/FlowInstance/FlowInstanceApp.cs b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs index 6d9cbcd7..45ca7e3b 100644 --- a/OpenAuth.App/FlowInstance/FlowInstanceApp.cs +++ b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs @@ -2,7 +2,7 @@ * @Author: yubaolee | ahfu~ <954478625@qq.com> * @Date: 2024-12-13 16:55:17 * @Description: 工作流实例表操作 - * @LastEditTime: 2025-04-05 15:22:30 + * @LastEditTime: 2025-04-06 02:25:02 * Copyright (c) 2024 by yubaolee | ahfu~ , All Rights Reserved. */ @@ -51,6 +51,14 @@ namespace OpenAuth.App /// public string CreateInstance(AddFlowInstanceReq addFlowInstanceReq) { + //如果业务ID不为空,则需要检查该业务ID对应的审批是否存在 + if(!string.IsNullOrEmpty(addFlowInstanceReq.BusinessId)){ + //如果业务ID不为空,则需要检查业务ID是否存在 + var business = Repository.GetFirst(u => u.BusinessId == addFlowInstanceReq.BusinessId && u.SchemeId == addFlowInstanceReq.SchemeId); + if(business != null){ + throw new Exception("该业务ID已经送审过该类型的流程,请不要重复送审"); + } + } CheckNodeDesignate(addFlowInstanceReq); FlowScheme scheme = null; if (!string.IsNullOrEmpty(addFlowInstanceReq.SchemeId)) @@ -69,6 +77,7 @@ namespace OpenAuth.App } addFlowInstanceReq.SchemeContent = scheme.SchemeContent; + addFlowInstanceReq.FrmType = scheme.FrmType; FormResp form = null; if (scheme.FrmType != Define.FORM_TYPE_URL) @@ -83,6 +92,17 @@ namespace OpenAuth.App addFlowInstanceReq.FrmType = form.FrmType; addFlowInstanceReq.FrmId = form.Id; } + else{ + if(string.IsNullOrEmpty(scheme.FrmUrlTemplate)){ //流程设计的时候没有URL表单模板 + if(addFlowInstanceReq.FrmData.IsNullOrEmpty()){ + throw new Exception("该流程使用的是URL表单,但流程设计时没有指定URL表单模板,需要修改流程模板或前端调用时直接传业务详情的URL地址"); + } + } + else{ + //流程设计的时候有URL表单模板,则使用URL表单模板,并替换模板中的{id}为业务详情的ID + addFlowInstanceReq.FrmData = scheme.FrmUrlTemplate.Replace("{id}", addFlowInstanceReq.BusinessId); + } + } var flowInstance = addFlowInstanceReq.MapTo(); diff --git a/OpenAuth.Repository/Domain/FlowInstance.cs b/OpenAuth.Repository/Domain/FlowInstance.cs index a8e843e0..66485884 100644 --- a/OpenAuth.Repository/Domain/FlowInstance.cs +++ b/OpenAuth.Repository/Domain/FlowInstance.cs @@ -16,167 +16,174 @@ using OpenAuth.Repository.Core; namespace OpenAuth.Repository.Domain { - /// - /// 工作流流程实例表 - /// - [Table("FlowInstance")] - public partial class FlowInstance : StringEntity + /// + /// 工作流流程实例表 + /// + [Table("FlowInstance")] + public partial class FlowInstance : StringEntity + { + public FlowInstance() { - public FlowInstance() - { - this.InstanceSchemeId= string.Empty; - this.Code= string.Empty; - this.CustomName= string.Empty; - this.ActivityId= string.Empty; - this.ActivityName= string.Empty; - this.PreviousId= string.Empty; - this.SchemeContent= string.Empty; - this.SchemeId= string.Empty; - this.DbName= string.Empty; - this.FrmData= string.Empty; - this.FrmType= 0; - this.FrmContentData= string.Empty; - this.FrmContentParse= string.Empty; - this.FrmId= string.Empty; - this.SchemeType= string.Empty; - this.Disabled= 0; - this.CreateDate= DateTime.Now; - this.CreateUserId= string.Empty; - this.CreateUserName= string.Empty; - this.FlowLevel= 0; - this.Description= string.Empty; - this.IsFinish= FlowInstanceStatus.Running; - this.MakerList= string.Empty; - } - - /// - /// 流程实例模板Id【已废弃】 - /// - [Description("流程实例模板Id")] - public string InstanceSchemeId { get; set; } - /// - /// 实例编号 - /// - [Description("实例编号")] - public string Code { get; set; } - /// - /// 自定义名称 - /// - [Description("自定义名称")] - public string CustomName { get; set; } - /// - /// 当前节点ID - /// - [Description("当前节点ID")] - public string ActivityId { get; set; } - /// - /// 当前节点类型(0会签节点) - /// - [Description("当前节点类型(0会签节点)")] - public int? ActivityType { get; set; } - /// - /// 当前节点名称 - /// - [Description("当前节点名称")] - public string ActivityName { get; set; } - /// - /// 前一个ID - /// - [Description("前一个ID")] - public string PreviousId { get; set; } - /// - /// 流程模板内容 - /// - [Description("流程模板内容")] - public string SchemeContent { get; set; } - /// - /// 流程模板ID - /// - [Description("流程模板ID")] - public string SchemeId { get; set; } - /// - /// 数据库名称 - /// - [Description("数据库名称")] - public string DbName { get; set; } - /// - /// 表单数据 - /// - [Description("表单数据")] - public string FrmData { get; set; } - /// - /// 表单类型 - /// 0:动态表单;1:开发者自定义表单;2:拖动表单 - /// 当类型为1时,流程实例必需有DbName,用于直接向对应数据库表中写入数据 - /// - [Description("表单类型:0:动态表单;1:开发者自定义表单;2:拖动表单")] - public int FrmType { get; set; } - /// - /// 表单中的控件属性描述 - /// - [Description("表单中的控件属性描述")] - public string FrmContentData { get; set; } - /// - /// 表单控件位置模板 - /// - [Description("表单控件位置模板")] - public string FrmContentParse { get; set; } - /// - /// 表单ID - /// - [Description("表单ID")] - public string FrmId { get; set; } - /// - /// 流程类型 - /// - [Description("流程类型")] - public string SchemeType { get; set; } - /// - /// 有效标志 - /// - [Description("有效标志")] - public int Disabled { get; set; } - /// - /// 创建时间 - /// - [Description("创建时间")] - public System.DateTime CreateDate { get; set; } - /// - /// 创建用户主键 - /// - [Description("创建用户主键")] - public string CreateUserId { get; set; } - /// - /// 创建用户 - /// - [Description("创建用户")] - public string CreateUserName { get; set; } - /// - /// 等级 - /// - [Description("等级")] - public int FlowLevel { get; set; } - /// - /// 实例备注 - /// - [Description("实例备注")] - public string Description { get; set; } - /// - /// 是否完成,当前节点的状态也通过该值表示 - /// - [Description("是否完成,当前节点的状态也通过该值表示")] - public int IsFinish { get; set; } - /// - /// 执行人 - /// - [Description("执行人")] - public string MakerList { get; set; } - - /// - /// 所属部门 - /// - [Description("所属部门")] - public string OrgId { get; set; } - + this.InstanceSchemeId = string.Empty; + this.Code = string.Empty; + this.CustomName = string.Empty; + this.ActivityId = string.Empty; + this.ActivityName = string.Empty; + this.PreviousId = string.Empty; + this.SchemeContent = string.Empty; + this.SchemeId = string.Empty; + this.DbName = string.Empty; + this.FrmData = string.Empty; + this.FrmType = 0; + this.FrmContentData = string.Empty; + this.FrmContentParse = string.Empty; + this.FrmId = string.Empty; + this.SchemeType = string.Empty; + this.Disabled = 0; + this.CreateDate = DateTime.Now; + this.CreateUserId = string.Empty; + this.CreateUserName = string.Empty; + this.FlowLevel = 0; + this.Description = string.Empty; + this.IsFinish = FlowInstanceStatus.Running; + this.MakerList = string.Empty; } + + /// + /// 流程实例模板Id【已废弃】 + /// + [Description("流程实例模板Id")] + public string InstanceSchemeId { get; set; } + /// + /// 实例编号 + /// + [Description("实例编号")] + public string Code { get; set; } + /// + /// 自定义名称 + /// + [Description("自定义名称")] + public string CustomName { get; set; } + /// + /// 当前节点ID + /// + [Description("当前节点ID")] + public string ActivityId { get; set; } + /// + /// 当前节点类型(0会签节点) + /// + [Description("当前节点类型(0会签节点)")] + public int? ActivityType { get; set; } + /// + /// 当前节点名称 + /// + [Description("当前节点名称")] + public string ActivityName { get; set; } + /// + /// 前一个ID + /// + [Description("前一个ID")] + public string PreviousId { get; set; } + /// + /// 流程模板内容 + /// + [Description("流程模板内容")] + public string SchemeContent { get; set; } + /// + /// 流程模板ID + /// + [Description("流程模板ID")] + public string SchemeId { get; set; } + /// + /// 数据库名称 + /// + [Description("数据库名称")] + public string DbName { get; set; } + /// + /// 表单数据 + /// + [Description("表单数据")] + public string FrmData { get; set; } + /// + /// 表单类型 + /// 0:动态表单;1:开发者自定义表单;2:拖动表单 + /// 当类型为1时,流程实例必需有DbName,用于直接向对应数据库表中写入数据 + /// + [Description("表单类型:0:动态表单;1:开发者自定义表单;2:拖动表单")] + public int FrmType { get; set; } + /// + /// 表单中的控件属性描述 + /// + [Description("表单中的控件属性描述")] + public string FrmContentData { get; set; } + /// + /// 表单控件位置模板 + /// + [Description("表单控件位置模板")] + public string FrmContentParse { get; set; } + /// + /// 表单ID + /// + [Description("表单ID")] + public string FrmId { get; set; } + /// + /// 流程类型 + /// + [Description("流程类型")] + public string SchemeType { get; set; } + + /// + /// 业务ID + /// 当流程实例与业务单据关联时,记录关联的业务ID + /// + [Description("业务ID")] + public string BusinessId { get; set; } + /// + /// 有效标志 + /// + [Description("有效标志")] + public int Disabled { get; set; } + /// + /// 创建时间 + /// + [Description("创建时间")] + public System.DateTime CreateDate { get; set; } + /// + /// 创建用户主键 + /// + [Description("创建用户主键")] + public string CreateUserId { get; set; } + /// + /// 创建用户 + /// + [Description("创建用户")] + public string CreateUserName { get; set; } + /// + /// 等级 + /// + [Description("等级")] + public int FlowLevel { get; set; } + /// + /// 实例备注 + /// + [Description("实例备注")] + public string Description { get; set; } + /// + /// 是否完成,当前节点的状态也通过该值表示 + /// + [Description("是否完成,当前节点的状态也通过该值表示")] + public int IsFinish { get; set; } + /// + /// 执行人 + /// + [Description("执行人")] + public string MakerList { get; set; } + + /// + /// 所属部门 + /// + [Description("所属部门")] + public string OrgId { get; set; } + + } } \ No newline at end of file