From 081ab58659bb90d177d201d17f0014c7ee8c18dc Mon Sep 17 00:00:00 2001 From: liguoyang Date: Wed, 21 May 2025 16:03:58 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E5=88=86=E9=85=8D=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E5=88=B0=E7=94=A8=E6=88=B7=E7=BB=84:=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=87=BA=E5=B7=AE=E4=BA=BA=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/Implements/GainfoGroupService.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs index 6bd5e2ab..efd2020f 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoGroupService.cs @@ -8,10 +8,13 @@ using Dlhis.Entity.Device.Entities; using Dlhis.Entity.Device.Enums; using Dlhis.Entity.Sys.Entities; using Dlhis.Entity.Sys.Enums; +using Dlhis.Entity.Visitor.Entity; +using Kurisu.AspNetCore; using Kurisu.AspNetCore.Authentication.Abstractions; using Kurisu.AspNetCore.DataAccess.SqlSugar.Services; using Kurisu.AspNetCore.Utils.Extensions; using Mapster; +using SqlSugar; namespace Dlhis.Basic.Organization.Services.Implements; @@ -104,10 +107,36 @@ public class GainfoGroupService : IGainfoGroupService .ToListAsync(); var presentUserNos = await _dbContext.Queryable() - .Where(x => request.UserNos.Contains(x.No) || request.UserNos.Contains(x.Code)) //NO和工号匹配 + .Where(x => request.UserNos.Contains(x.No) + || request.UserNos.Contains(x.Code) + ) //NO和工号匹配 .Select(x => x.No) .ToListAsync(); + var queryableSetting = App.GetServiceProvider().GetService(); + try + { + queryableSetting.EnableCrossTenant = false; + var factories = _currentUser.GetUserClaim("tenants").Split(",").ToList(); + + var businessUserNos = await _dbContext.Queryable() + .Where(x => request.UserNos.Contains(x.No) + || request.UserNos.Contains(x.Code) + ) + .Where(x => SqlFunc.Subqueryable() + .Where(p => p.Code == x.Code && factories.Contains(p.Destination) && SqlFunc.DateIsSame(p.BeginDate, DateTime.Now)) + .Any()) + .Select(x => x.No) + .ToListAsync(); + + presentUserNos.AddRange(businessUserNos); + } + finally + { + queryableSetting.EnableCrossTenant = true; + } + + //(userNos.Count != request.UserNos.Count).ThrowIfTrue("存在权限外人员,无法添加"); var r = await PermissionResetAsync(request.GroupCode, relations.Select(x => x.UserNo).Distinct().ToList(), presentUserNos);