From b40cf6b43d219d54181332e6dbd19222d39fd7c1 Mon Sep 17 00:00:00 2001 From: yubaolee Date: Thu, 10 Oct 2024 12:14:08 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=20#IAGT6Z=20=E6=B5=81=E7=A8=8B=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E5=90=8E=EF=BC=8C=E9=80=9A=E7=9F=A5=E7=9F=A5=E4=BC=9A?= =?UTF-8?q?=E7=9A=84=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenAuth.App/FlowInstance/FlowInstanceApp.cs | 53 +++++++++++++------- OpenAuth.App/UserManager/UserManagerApp.cs | 39 ++++++++++++++ 2 files changed, 74 insertions(+), 18 deletions(-) diff --git a/OpenAuth.App/FlowInstance/FlowInstanceApp.cs b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs index fdd7c602..2e59051b 100644 --- a/OpenAuth.App/FlowInstance/FlowInstanceApp.cs +++ b/OpenAuth.App/FlowInstance/FlowInstanceApp.cs @@ -37,7 +37,6 @@ namespace OpenAuth.App private FlowApproverApp _flowApproverApp; private RevelanceManagerApp _revelanceManagerApp; - #region 流程处理API /// @@ -503,6 +502,21 @@ namespace OpenAuth.App $"{user.Account}-{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}审批了【{wfruntime.currentNode.name}】" + $"结果:{(tag.Taged == 1 ? "同意" : "不同意")},备注:{tag.Description}"; AddOperationHis(flowInstance.Id, tag, content); + + if (flowInstance.IsFinish == 1) + { + //给知会人员发送通知信息 + var userids = _userManagerApp.GetNoticeUsers(flowInstance.Id); + if (userids.Count > 0) + { + foreach (var userid in userids) + { + _messageApp.SendMsgTo(userid, + $"[{flowInstance.CustomName}]已完成,您可以在我的流程中查看。"); + } + } + } + flowInstance.SchemeContent = JsonHelper.Instance.Serialize(wfruntime.ToSchemeObj()); //如果审批通过,且下一个审批人是自己,则自动审批 @@ -920,35 +934,38 @@ namespace OpenAuth.App SELECT fi.* FROM FlowInstance fi JOIN (select Id as InstanceId - from FlowInstance - where CreateUserId = '{user.User.Id}' - union - select FirstId as InstanceId - from Relevance - where `Key` = '{Define.INSTANCE_NOTICE_USER}' - and SecondId = '{user.User.Id}' - union - select a.FirstId as InstanceId - from Relevance a - inner join (select SecondId as RoleId - from Relevance - where `Key` = '{Define.USERROLE}' - and FirstId = '{user.User.Id}') b on a.SecondId = b.RoleId - where a.`Key` = '{Define.INSTANCE_NOTICE_ROLE}') AS UniqueInstanceIds + 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 + where `Key` = '{Define.INSTANCE_NOTICE_USER}' + and SecondId = '{user.User.Id}' + union + select distinct a.FirstId as InstanceId + from Relevance a + inner join (select SecondId as RoleId + from Relevance + where `Key` = '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.`Key` = '{Define.INSTANCE_NOTICE_ROLE}') AS UniqueInstanceIds ON fi.Id = UniqueInstanceIds.InstanceId "; if (SugarClient.CurrentConnectionConfig.DbType == DbType.SqlServer) { sql = sql.Replace("`Key`", "[Key]"); - }else if (SugarClient.CurrentConnectionConfig.DbType == DbType.Oracle) + } + else if (SugarClient.CurrentConnectionConfig.DbType == DbType.Oracle) { sql = sql.Replace("`Key`", "\"Key\""); } var finalQuery = SugarClient.SqlQueryable(sql) .WhereIF(!string.IsNullOrEmpty(request.key), t => t.CustomName.Contains(request.key)); - + result.count = await finalQuery.CountAsync(); result.data = await finalQuery.OrderByDescending(u => u.CreateDate) .ToPageListAsync(request.page, request.limit); diff --git a/OpenAuth.App/UserManager/UserManagerApp.cs b/OpenAuth.App/UserManager/UserManagerApp.cs index 3076887c..ad9b07fe 100644 --- a/OpenAuth.App/UserManager/UserManagerApp.cs +++ b/OpenAuth.App/UserManager/UserManagerApp.cs @@ -313,5 +313,44 @@ namespace OpenAuth.App } return Repository.FirstOrDefault(u => u.Id == userid).ParentId; } + + + /// + /// 获取流程实例通知的用户 + /// + /// + /// + public List GetNoticeUsers(string instanceId) + { + var sql = $@" + select u.* + from `USER` u + join (select distinct SecondId as UserId + from Relevance + where `Key` = '{Define.INSTANCE_NOTICE_USER}' + and FirstId = '{instanceId}' + union + select distinct FirstId as UserId + from Relevance a + inner join (select SecondId as RoleId + from Relevance + where `Key` = '{Define.INSTANCE_NOTICE_ROLE}' + and FirstId = '{instanceId}') b on a.SecondId = b.RoleId + where `Key` = 'UserRole') userids on u.Id = userids.UserId"; + + if (UnitWork.GetDbContext().Database.GetDbConnection().GetType().Name == "SqlConnection") + { + sql = sql.Replace(" `USER` ", " [USER] "); + sql = sql.Replace("`Key`", "[Key]"); + } + else if (UnitWork.GetDbContext().Database.GetDbConnection().GetType().Name == "OracleConnection") + { + sql = sql.Replace(" `USER` ", " \"USER\" "); + sql = sql.Replace("`Key`", "\"Key\""); + } + + var users = UnitWork.FromSql(sql); + return users.Select(u=>u.Id).ToList(); + } } } \ No newline at end of file