fix #I9J6WS 加签流程增加加签节点是否审批判断

This commit is contained in:
yubaolee 2024-09-29 21:34:42 +08:00
parent dbe5a04b9b
commit 55f3ee5b0a
7 changed files with 46 additions and 11 deletions

View File

@ -87,6 +87,11 @@ namespace OpenAuth.App
return approvers.Select(u => u.ApproverId).ToArray(); return approvers.Select(u => u.ApproverId).ToArray();
} }
/// <summary>
/// 获取当前可以审批的加签人列表
/// <para>如果是顺序执行,取第一个人</para>
/// <para>否则并行且/并行或都是返回所有加签人</para>
/// </summary>
public FlowApprover[] GetApprovers(QueryApproverReq req) public FlowApprover[] GetApprovers(QueryApproverReq req)
{ {
var query= Repository.AsQueryable() var query= Repository.AsQueryable()

View File

@ -1,24 +1,19 @@
using Infrastructure; using Infrastructure;
using OpenAuth.App.Flow; using OpenAuth.App.Flow;
using OpenAuth.App.Interface; using OpenAuth.App.Interface;
using OpenAuth.App.Request; using OpenAuth.App.Request;
using OpenAuth.App.Response; using OpenAuth.App.Response;
using OpenAuth.Repository.Domain; using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Castle.Core.Internal; 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;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using OpenAuth.Repository;
using SqlSugar; using SqlSugar;
using Yitter.IdGenerator; using Yitter.IdGenerator;
@ -39,6 +34,7 @@ namespace OpenAuth.App
private UserManagerApp _userManagerApp; private UserManagerApp _userManagerApp;
private OrgManagerApp _orgManagerApp; private OrgManagerApp _orgManagerApp;
private FlowApproverApp _flowApproverApp; private FlowApproverApp _flowApproverApp;
private RevelanceManagerApp _revelanceManagerApp;
#region API #region API
@ -429,23 +425,41 @@ namespace OpenAuth.App
bool isfinish = _flowApproverApp.Verify(new VerifyApproverReq() bool isfinish = _flowApproverApp.Verify(new VerifyApproverReq()
{ {
Id = approverInfo.Id, Id = approverInfo.Id,
Status = (int)TagState.Ok, Status = (int)TagState.Ok,
VerifyComment = tag.Description VerifyComment = tag.Description
}); });
if (!isfinish) //如果没有完成,不能到下一步 if (!isfinish) //如果没有完成,不能到下一步
{ {
canNext = false; canNext = false;
} }
else if (approverInfo.ReturnToSignNode == null || !approverInfo.ReturnToSignNode.Value)
{
//加签完成后,不需要返回原节点,则直接审批加签的节点
tag.UserId = approverInfo.CreateUserId;
tag.UserName = approverInfo.CreateUserName;
//把当前审批人变成加签人,从而可以自动审批
wfruntime.MakeTagNode(wfruntime.currentNodeId, tag);
}
} }
if (wfruntime.currentNode.setInfo.NodeDesignate == Setinfo.RUNTIME_MANY_PARENTS) if (wfruntime.currentNode.setInfo.NodeDesignate == Setinfo.RUNTIME_MANY_PARENTS)
{ {
var roles = _auth.GetCurrentUser().Roles; List<string> roles;
if (user.Id != tag.UserId)
{
//最后一个执行加签的用户tag.UserId就是加签人id需要找他的角色
roles = _revelanceManagerApp.Get(Define.USERROLE, true, tag.UserId);
}
else
{
roles = _auth.GetCurrentUser().Roles.Select(u => u.Id).ToList();
}
//如果是连续多级直属上级且还没到指定的角色,只改变执行人,不到下一个节点 //如果是连续多级直属上级且还没到指定的角色,只改变执行人,不到下一个节点
if (!wfruntime.currentNode.setInfo.NodeDesignateData.roles.Intersect(roles.Select(u => u.Id)).Any()) if (!wfruntime.currentNode.setInfo.NodeDesignateData.roles.Intersect(roles).Any())
{ {
canNext = false; canNext = false;
var parentId = _userManagerApp.GetParent(user.Id); var parentId = _userManagerApp.GetParent(tag.UserId);
flowInstance.MakerList = parentId; flowInstance.MakerList = parentId;
} }
} }
@ -1036,7 +1050,8 @@ namespace OpenAuth.App
public FlowInstanceApp(ISqlSugarClient client, IAuth auth, RevelanceManagerApp revelanceApp, public FlowInstanceApp(ISqlSugarClient client, IAuth auth, RevelanceManagerApp revelanceApp,
FlowSchemeApp flowSchemeApp, FormApp formApp, IHttpClientFactory httpClientFactory, FlowSchemeApp flowSchemeApp, FormApp formApp, IHttpClientFactory httpClientFactory,
SysMessageApp messageApp, UserManagerApp userManagerApp, OrgManagerApp orgManagerApp, SysMessageApp messageApp, UserManagerApp userManagerApp, OrgManagerApp orgManagerApp,
IServiceProvider serviceProvider, FlowApproverApp flowApproverApp) : base(client, auth) IServiceProvider serviceProvider, FlowApproverApp flowApproverApp,
RevelanceManagerApp revelanceManagerApp) : base(client, auth)
{ {
_revelanceApp = revelanceApp; _revelanceApp = revelanceApp;
_flowSchemeApp = flowSchemeApp; _flowSchemeApp = flowSchemeApp;
@ -1047,6 +1062,7 @@ namespace OpenAuth.App
_orgManagerApp = orgManagerApp; _orgManagerApp = orgManagerApp;
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
_flowApproverApp = flowApproverApp; _flowApproverApp = flowApproverApp;
_revelanceManagerApp = revelanceManagerApp;
} }
} }
} }

View File

@ -116,5 +116,12 @@ namespace OpenAuth.Repository.Domain
/// </summary> /// </summary>
[Description("加签人Id")] [Description("加签人Id")]
public string CreateUserId { get; set; } public string CreateUserId { get; set; }
/// <summary>
///是否回到加签节点
/// <para>如果不需要,则加签完成后自动审批完成,否则还需要当前节点审批</para>
/// </summary>
[Description("是否回到加签节点")]
public bool? ReturnToSignNode { get; set; }
} }
} }

View File

@ -386,6 +386,7 @@ CREATE TABLE flowapprover(
`ParentId` VARCHAR(50) COMMENT '父节点ID应对多次加签' , `ParentId` VARCHAR(50) COMMENT '父节点ID应对多次加签' ,
`ParentName` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '父节点名称,应对多次加签结构' , `ParentName` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '父节点名称,应对多次加签结构' ,
`Name` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '加签节点名称,应对多次加签结构' , `Name` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci COMMENT '加签节点名称,应对多次加签结构' ,
`ReturnToSignNode` tinyint(4) COMMENT '是否回到加签节点',
PRIMARY KEY (Id) PRIMARY KEY (Id)
) COMMENT = '工作流加签'; ) COMMENT = '工作流加签';

View File

@ -62,6 +62,7 @@ CREATE TABLE FlowApprover(
ParentId VARCHAR2(50), ParentId VARCHAR2(50),
ParentName VARCHAR2(100), ParentName VARCHAR2(100),
Name VARCHAR2(100), Name VARCHAR2(100),
ReturnToSignNode NUMBER(4,0)
PRIMARY KEY (Id) PRIMARY KEY (Id)
); );
@ -84,6 +85,7 @@ COMMENT ON COLUMN FlowApprover.CascadeId IS '层级ID应对多次加签';
COMMENT ON COLUMN FlowApprover.ParentId IS '父节点ID应对多次加签'; COMMENT ON COLUMN FlowApprover.ParentId IS '父节点ID应对多次加签';
COMMENT ON COLUMN FlowApprover.ParentName IS '父节点名称,应对多次加签结构'; COMMENT ON COLUMN FlowApprover.ParentName IS '父节点名称,应对多次加签结构';
COMMENT ON COLUMN FlowApprover.Name IS '加签节点名称,应对多次加签结构'; COMMENT ON COLUMN FlowApprover.Name IS '加签节点名称,应对多次加签结构';
COMMENT ON COLUMN FlowApprover.ReturnToSignNode IS '是否回到加签节点';

View File

@ -117,6 +117,7 @@ CREATE TABLE [dbo].[FlowApprover](
CascadeId VARCHAR(100) NOT NULL, CascadeId VARCHAR(100) NOT NULL,
ParentId VARCHAR(50), ParentId VARCHAR(50),
ParentName VARCHAR(100), ParentName VARCHAR(100),
ReturnToSignNode bit DEFAULT 1 NOT NULL,
Name VARCHAR(100), Name VARCHAR(100),
PRIMARY KEY (Id) PRIMARY KEY (Id)
); );
@ -140,6 +141,7 @@ EXEC sp_addextendedproperty 'MS_Description', '层级ID应对多次加签', '
EXEC sp_addextendedproperty 'MS_Description', '父节点ID应对多次加签', 'SCHEMA', dbo, 'table', FlowApprover, 'column', ParentId; EXEC sp_addextendedproperty 'MS_Description', '父节点ID应对多次加签', 'SCHEMA', dbo, 'table', FlowApprover, 'column', ParentId;
EXEC sp_addextendedproperty 'MS_Description', '父节点名称,应对多次加签结构', 'SCHEMA', dbo, 'table', FlowApprover, 'column', ParentName; EXEC sp_addextendedproperty 'MS_Description', '父节点名称,应对多次加签结构', 'SCHEMA', dbo, 'table', FlowApprover, 'column', ParentName;
EXEC sp_addextendedproperty 'MS_Description', '加签节点名称,应对多次加签结构', 'SCHEMA', dbo, 'table', FlowApprover, 'column', Name; EXEC sp_addextendedproperty 'MS_Description', '加签节点名称,应对多次加签结构', 'SCHEMA', dbo, 'table', FlowApprover, 'column', Name;
EXEC sp_addextendedproperty 'MS_Description', '是否回到加签节点', 'SCHEMA', dbo, 'table', FlowApprover, 'column', ReturnToSignNode;

View File

@ -51,6 +51,7 @@ CREATE TABLE FlowApprover(
ParentId VARCHAR(50), ParentId VARCHAR(50),
ParentName VARCHAR(100), ParentName VARCHAR(100),
Name VARCHAR(100), Name VARCHAR(100),
ReturnToSignNode int2,
PRIMARY KEY (Id) PRIMARY KEY (Id)
); );
@ -73,6 +74,7 @@ COMMENT ON COLUMN FlowApprover.CascadeId IS '层级ID应对多次加签';
COMMENT ON COLUMN FlowApprover.ParentId IS '父节点ID应对多次加签'; COMMENT ON COLUMN FlowApprover.ParentId IS '父节点ID应对多次加签';
COMMENT ON COLUMN FlowApprover.ParentName IS '父节点名称,应对多次加签结构'; COMMENT ON COLUMN FlowApprover.ParentName IS '父节点名称,应对多次加签结构';
COMMENT ON COLUMN FlowApprover.Name IS '加签节点名称,应对多次加签结构'; COMMENT ON COLUMN FlowApprover.Name IS '加签节点名称,应对多次加签结构';
COMMENT ON COLUMN FlowApprover.ReturnToSignNode IS '是否回到加签节点';
-- ---------------------------- -- ----------------------------