From 263ff70f268129a8bbba415e64bd46e2f43c61a5 Mon Sep 17 00:00:00 2001 From: wintel Date: Sat, 19 Apr 2025 00:31:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=A1=BA=E5=BA=8F?= =?UTF-8?q?=E5=AE=A1=E6=89=B9=E6=97=B6=EF=BC=8C=E8=8A=82=E7=82=B9=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E4=BA=BA=E4=B8=BA=E5=85=A8=E9=83=A8=E5=8A=A0=E7=AD=BE?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Infrastructure/Define.cs | 238 ++++++++++++++++--- OpenAuth.App/Flow/FlowRuntime.cs | 2 +- OpenAuth.App/FlowInstance/FlowInstanceApp.cs | 94 ++++---- 3 files changed, 254 insertions(+), 80 deletions(-) diff --git a/Infrastructure/Define.cs b/Infrastructure/Define.cs index 8449aafa..4b0d4714 100644 --- a/Infrastructure/Define.cs +++ b/Infrastructure/Define.cs @@ -6,86 +6,246 @@ public static class Define { //Relevance关联KEY - public static string USERROLE = "UserRole"; //用户角色关联KEY - public const string ROLERESOURCE = "RoleResource"; //角色资源关联KEY - public const string USERORG = "UserOrg"; //用户机构关联KEY - public const string ROLEELEMENT = "RoleElement"; //角色菜单关联KEY - public const string ROLEMODULE = "RoleModule"; //角色模块关联KEY - public const string ROLEDATAPROPERTY = "RoleDataProperty"; //角色数据字段权限 - public const string MODULEPRINTERPLAN = "ModulePrinterPlan"; //模块配置打印方案 - public const string MODULE_FLOWSCHEME = "ModuleFlowScheme"; //模块挂载流程模板 + /// + /// 用户角色关联KEY + /// + public static string USERROLE = "UserRole"; + + /// + /// 角色资源关联KEY + /// + public const string ROLERESOURCE = "RoleResource"; + + /// + /// 用户机构关联KEY + /// + public const string USERORG = "UserOrg"; + + /// + /// 角色菜单关联KEY + /// + public const string ROLEELEMENT = "RoleElement"; + + /// + /// 角色模块关联KEY + /// + public const string ROLEMODULE = "RoleModule"; + + /// + /// 角色数据字段权限 + /// + public const string ROLEDATAPROPERTY = "RoleDataProperty"; + + /// + /// 模块配置打印方案 + /// + public const string MODULEPRINTERPLAN = "ModulePrinterPlan"; + + /// + /// 模块挂载流程模板 + /// + public const string MODULE_FLOWSCHEME = "ModuleFlowScheme"; //数据库类型 - public const string DBTYPE_SQLSERVER = "SqlServer"; //sql server - public const string DBTYPE_MYSQL = "MySql"; //mysql - public const string DBTYPE_PostgreSQL = "PostgreSQL"; //PostgreSQL - public const string DBTYPE_ORACLE = "Oracle"; //oracle + /// + /// 数据库类型:SQL Server + /// + public const string DBTYPE_SQLSERVER = "SqlServer"; + + /// + /// 数据库类型:MySQL + /// + public const string DBTYPE_MYSQL = "MySql"; + + /// + /// 数据库类型:PostgreSQL + /// + public const string DBTYPE_PostgreSQL = "PostgreSQL"; + + /// + /// 数据库类型:Oracle + /// + public const string DBTYPE_ORACLE = "Oracle"; - public const int INVALID_TOKEN = 50014; //token无效 + /// + /// Token无效错误码:50014 + /// + public const int INVALID_TOKEN = 50014; + /// + /// Token名称,用于HTTP请求头 + /// public const string TOKEN_NAME = "X-Token"; + + /// + /// 租户ID标识 + /// public const string TENANT_ID = "tenantId"; + /// + /// 系统用户名 + /// public const string SYSTEM_USERNAME = "System"; + + /// + /// 系统用户默认密码 + /// public const string SYSTEM_USERPWD = "123456"; - public const string DATAPRIVILEGE_LOGINUSER = "{loginUser}"; //数据权限配置中,当前登录用户的key - public const string DATAPRIVILEGE_LOGINROLE = "{loginRole}"; //数据权限配置中,当前登录用户角色的key - public const string DATAPRIVILEGE_LOGINORG = "{loginOrg}"; //数据权限配置中,当前登录用户部门的key + /// + /// 数据权限配置中,当前登录用户的key + /// + public const string DATAPRIVILEGE_LOGINUSER = "{loginUser}"; + + /// + /// 数据权限配置中,当前登录用户角色的key + /// + public const string DATAPRIVILEGE_LOGINROLE = "{loginRole}"; + + /// + /// 数据权限配置中,当前登录用户部门的key + /// + public const string DATAPRIVILEGE_LOGINORG = "{loginOrg}"; + /// + /// 任务调度映射键 + /// public const string JOBMAPKEY = "OpenJob"; + /// + /// 默认表单实例ID字段名 + /// public const string DEFAULT_FORM_INSTANCE_ID_NAME = "InstanceId"; //表单类型 - public const int FORM_TYPE_DYNAMIC = 0; //动态表单 - public const int FORM_TYPE_DEVELOP = 1; //自定义表单 - public const int FORM_TYPE_DRAG = 2; //vForm拖拽表单 - public const int FORM_TYPE_URL = 3; //URL表单 + /// + /// 表单类型:动态表单(0) + /// + public const int FORM_TYPE_DYNAMIC = 0; + + /// + /// 表单类型:自定义表单(1) + /// + public const int FORM_TYPE_DEVELOP = 1; + + /// + /// 表单类型:vForm拖拽表单(2) + /// + public const int FORM_TYPE_DRAG = 2; + + /// + /// 表单类型:URL表单(3) + /// + public const int FORM_TYPE_URL = 3; //节点类型 - public const string NODE_TYPE_START = "start"; //开始节点 - public const string NODE_TYPE_END = "end"; //结束节点 - public const string NODE_TYPE_TASK = "node"; //任务节点 - public const string NODE_TYPE_FORK = "fork"; //网关开始 - public const string NODE_TYPE_JOIN = "join"; //网关结束 - public const string NODE_TYPE_MULTI_INSTANCE = "multiInstance"; //多实例、会签节点 + /// + /// 节点类型:开始节点 + /// + public const string NODE_TYPE_START = "start"; + + /// + /// 节点类型:结束节点 + /// + public const string NODE_TYPE_END = "end"; + + /// + /// 节点类型:任务节点 + /// + public const string NODE_TYPE_TASK = "node"; + + /// + /// 节点类型:网关开始 + /// + public const string NODE_TYPE_FORK = "fork"; + + /// + /// 节点类型:网关结束 + /// + public const string NODE_TYPE_JOIN = "join"; + + /// + /// 节点类型:多实例、会签节点 + /// + public const string NODE_TYPE_MULTI_INSTANCE = "multiInstance"; - //流程实例知会用户 + /// + /// 流程实例知会用户 + /// public const string INSTANCE_NOTICE_USER = "INSTANCE_NOTICE_USER"; - //流程实例知会角色 + + /// + /// 流程实例知会角色 + /// public const string INSTANCE_NOTICE_ROLE = "INSTANCE_NOTICE_ROLE"; //流程节点执行权限类型 - public const string ALL_USER = "ALL_USER"; //所有用户 - public const string SPECIAL_ROLE = "SPECIAL_ROLE"; //指定角色 - public const string SPECIAL_USER = "SPECIAL_USER"; //指定用户 - public const string SPECIAL_SQL = "SPECIAL_SQL"; //指定SQL + /// + /// 流程节点执行权限类型:所有用户 + /// + public const string ALL_USER = "ALL_USER"; + + /// + /// 流程节点执行权限类型:指定角色 + /// + public const string SPECIAL_ROLE = "SPECIAL_ROLE"; + + /// + /// 流程节点执行权限类型:指定用户 + /// + public const string SPECIAL_USER = "SPECIAL_USER"; + + /// + /// 流程节点执行权限类型:指定SQL + /// + public const string SPECIAL_SQL = "SPECIAL_SQL"; + /// /// 连续多级直属上级 /// 不同于钉钉的各上级部门负责人审批,OpenAuth以用户的各级直属上级审批模式 /// public const string RUNTIME_MANY_PARENTS = "RUNTIME_MANY_PARENTS"; + /// /// 部门负责人 /// public const string RUNTIME_CHAIRMAN = "RUNTIME_CHAIRMAN"; + /// /// 上一节点执行人的直属上级 /// public const string RUNTIME_PARENT = "RUNTIME_PARENT"; - public const string RUNTIME_SPECIAL_ROLE = "RUNTIME_SPECIAL_ROLE"; //运行时指定角色 - public const string RUNTIME_SPECIAL_USER = "RUNTIME_SPECIAL_USER"; //运行时指定用户 + /// + /// 流程节点执行权限类型:运行时指定角色 + /// + public const string RUNTIME_SPECIAL_ROLE = "RUNTIME_SPECIAL_ROLE"; + + /// + /// 流程节点执行权限类型:运行时指定用户 + /// + public const string RUNTIME_SPECIAL_USER = "RUNTIME_SPECIAL_USER"; //加签类型 - public const string APPROVE_TYPE_SEQUENTIAL = "sequential"; //顺序 - public const string APPROVE_TYPE_ALL = "all"; //并行且 - public const string APPROVE_TYPE_ONE = "one"; //并行或 - - + /// + /// 加签类型:顺序审批 + /// + public const string APPROVE_TYPE_SEQUENTIAL = "sequential"; + + /// + /// 加签类型:并行且审批(所有人必须同意) + /// + public const string APPROVE_TYPE_ALL = "all"; + + /// + /// 加签类型:并行或审批(一人同意即可) + /// + public const string APPROVE_TYPE_ONE = "one"; + /// + /// API资源标识 + /// public const string API = "API_RESOURCE"; } } \ No newline at end of file diff --git a/OpenAuth.App/Flow/FlowRuntime.cs b/OpenAuth.App/Flow/FlowRuntime.cs index 4113da80..db44a980 100644 --- a/OpenAuth.App/Flow/FlowRuntime.cs +++ b/OpenAuth.App/Flow/FlowRuntime.cs @@ -773,7 +773,7 @@ namespace OpenAuth.App.Flow } /// - /// 计算节点执行人 + /// 这里专门处理由前端选择相关的节点执行人 /// /// /// diff --git a/OpenAuth.App/FlowInstance/FlowInstanceApp.cs b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs index 0dcc5300..0abcf76d 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-18 17:30:07 + * @LastEditTime: 2025-04-19 00:23:47 * Copyright (c) 2024 by yubaolee | ahfu~ , All Rights Reserved. */ @@ -696,22 +696,22 @@ namespace OpenAuth.App else if (SugarClient.CurrentConnectionConfig.DbType == DbType.Oracle) { groupConcatSql = $@" (select listagg(Account, ',') within group (order by Account) - from SysUser - where fi.MakerList like '%' || Id || '%') "; + from SysUser + where fi.MakerList like '%' || Id || '%') "; } else if (SugarClient.CurrentConnectionConfig.DbType == DbType.PostgreSQL) { groupConcatSql = $@" (select string_agg(Account, ',') - from SysUser - where fi.MakerList like '%' || Id || '%') "; + from SysUser + where fi.MakerList like '%' || Id || '%') "; } string sql = String.Empty; if (request.type == "wait") //待办事项(即需要我处理的流程) { - sql = $@" - SELECT fi.Id, + sql =$@" + SELECT fi.Id, fi.CreateUserName, fi.ActivityName, fi.CreateDate, @@ -722,24 +722,38 @@ namespace OpenAuth.App CASE WHEN fi.MakerList = '1' THEN '所有人' WHEN fi.MakerList = '00000000-0000-0000-0000-000000000000' THEN 'System' - ELSE {groupConcatSql} + ELSE {groupConcatSql} END AS MakerList FROM FlowInstance fi JOIN (SELECT fith.Id - FROM FlowInstance fith - WHERE (MakerList = '1' or MakerList LIKE '%{user.User.Id}%') - and (fith.IsFinish = {FlowInstanceStatus.Running} or fith.IsFinish = {FlowInstanceStatus.Rejected}) - and not exists (select 1 - from flowapprover - where fith.Id = InstanceId - and fith.ActivityId = ActivityId - and Status = 0) - UNION - SELECT fa.InstanceId - FROM FlowApprover fa - WHERE fa.Status = 0 - AND fa.ApproverId = '{user.User.Id}') UniqueInstanceIds - ON fi.Id = UniqueInstanceIds.Id"; + FROM FlowInstance fith + WHERE (MakerList = '1' or MakerList LIKE '%00000000-0000-0000-0000-000000000000%') + and (fith.IsFinish = {FlowInstanceStatus.Running} or fith.IsFinish = {FlowInstanceStatus.Rejected}) + and not exists (select 1 + from flowapprover + where fith.Id = InstanceId + and fith.ActivityId = ActivityId + and Status = 0) + union + select fa.instanceid + from flowapprover fa + where fa.status = 0 + and fa.approverid = '{user.User.Id}' + and fa.approvetype <> '{Define.APPROVE_TYPE_SEQUENTIAL}' + union + select fa.instanceid + from flowapprover fa + where not exists (select 1 + from flowapprover fa2 + where fa2.instanceid = fa.instanceid + and fa2.orderno < fa.orderno + and fa2.status = 0 + and fa2.approvetype = '{Define.APPROVE_TYPE_SEQUENTIAL}') + and fa.status = 0 + and fa.approverid = '{user.User.Id}' + and fa.approvetype = '{Define.APPROVE_TYPE_SEQUENTIAL}') UniqueInstanceIds + ON fi.Id = UniqueInstanceIds.Id + "; } else if (request.type == "disposed") //已办事项(即我参与过的流程) { @@ -758,15 +772,15 @@ namespace OpenAuth.App ELSE {groupConcatSql} END AS MakerList FROM FlowInstance fi - JOIN (SELECT fith.InstanceId - FROM FlowInstanceOperationHistory fith - WHERE fith.CreateUserId = '{user.User.Id}' - UNION - SELECT fa.InstanceId - FROM FlowApprover fa - WHERE fa.Status <> 0 - AND fa.ApproverId = '{user.User.Id}') UniqueInstanceIds - ON fi.Id = UniqueInstanceIds.InstanceId + JOIN (SELECT fith.InstanceId + FROM FlowInstanceOperationHistory fith + WHERE fith.CreateUserId = '{user.User.Id}' + UNION + SELECT fa.InstanceId + FROM FlowApprover fa + WHERE fa.Status <> 0 + AND fa.ApproverId = '{user.User.Id}') UniqueInstanceIds + ON fi.Id = UniqueInstanceIds.InstanceId "; } else //我的流程(我创建的及知会我的) @@ -786,25 +800,25 @@ namespace OpenAuth.App ELSE {groupConcatSql} END AS MakerList FROM FlowInstance fi - JOIN (select Id as InstanceId + JOIN (select Id as InstanceId from FlowInstance where CreateUserId = '{user.User.Id}' union select distinct FirstId as InstanceId from Relevance rel - inner join FlowInstance flow on rel.FirstId = flow.Id and flow.IsFinish = 1 + inner join FlowInstance flow on rel.FirstId = flow.Id and flow.IsFinish = 1 where RelKey = '{Define.INSTANCE_NOTICE_USER}' - and SecondId = '{user.User.Id}' + and SecondId = '{user.User.Id}' union select distinct a.FirstId as InstanceId from Relevance a - inner join (select SecondId as RoleId - from Relevance - where RelKey = 'UserRole' - and FirstId = '{user.User.Id}') b on a.SecondId = b.RoleId - inner join FlowInstance flow on a.FirstId = flow.Id and flow.IsFinish = 1 + inner join (select SecondId as RoleId + from Relevance + where RelKey = 'UserRole' + and FirstId = '{user.User.Id}') b on a.SecondId = b.RoleId + inner join FlowInstance flow on a.FirstId = flow.Id and flow.IsFinish = 1 where a.RelKey = '{Define.INSTANCE_NOTICE_ROLE}') UniqueInstanceIds - ON fi.Id = UniqueInstanceIds.InstanceId + ON fi.Id = UniqueInstanceIds.InstanceId "; }