diff --git a/Src/Dlhis.Basic/DataPermissions/GetDataPermissionService.cs b/Src/Dlhis.Basic/DataPermissions/GetDataPermissionService.cs index 61b77490..61290c74 100644 --- a/Src/Dlhis.Basic/DataPermissions/GetDataPermissionService.cs +++ b/Src/Dlhis.Basic/DataPermissions/GetDataPermissionService.cs @@ -125,12 +125,12 @@ public class MyDataPermissionService : IDataPermissionService { var codes = new List(); - var disableFilter = _currentUser.GetRole() is "admin" or "tenant-admin"; - if (!disableFilter) + var hasAllPermission = _currentUser.GetRole() is "admin" or "tenant-admin"; + if (!hasAllPermission) { codes = _getDataPermissions.GetData().FirstOrDefault().Value ?? new List(); } - return (!disableFilter, codes); + return (!hasAllPermission, codes); } } \ No newline at end of file diff --git a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs index 50a410a9..8a7df2b3 100644 --- a/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs +++ b/Src/Dlhis.Basic/Organization/Services/Implements/GainfoUpdateService.cs @@ -1,7 +1,7 @@ -using Dlhis.Basic.Device.Services; -using Dlhis.Basic.Organization.Comparers; +using Dlhis.Basic.Organization.Comparers; using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Basic.Enums; +using Dlhis.Entity.Device.Enums; using Dlhis.Entity.Sys.Entities; using Dlhis.Entity.Sys.Enums; using Dlhis.Jip.Api.Dto; @@ -18,7 +18,7 @@ public class GainfoUpdateService : IGainfoUpdateService private readonly ILogger _logger; private readonly ITenantApi _tenantApi; private readonly IJinkoSapService _jinkoSapService; - private readonly IDevicePermissionAnalyzeService _devicePermissionAnalyzeService; + private readonly IGainfoPermissionService _gainfoPermissionService; private readonly IIdentityUserSyncService _identityUserSyncService; private List _tenants; @@ -27,7 +27,7 @@ public class GainfoUpdateService : IGainfoUpdateService ILogger logger, ITenantApi tenantApi, IJinkoSapService jinkoSapService, - IDevicePermissionAnalyzeService devicePermissionAnalyzeService, + IGainfoPermissionService gainfoPermissionService, IIdentityUserSyncService identityUserSyncService) { _dbContext = dbContext; @@ -35,7 +35,7 @@ public class GainfoUpdateService : IGainfoUpdateService _logger = logger; _tenantApi = tenantApi; _jinkoSapService = jinkoSapService; - _devicePermissionAnalyzeService = devicePermissionAnalyzeService; + _gainfoPermissionService = gainfoPermissionService; _identityUserSyncService = identityUserSyncService; } @@ -171,11 +171,10 @@ public class GainfoUpdateService : IGainfoUpdateService if (item.isowner == "T") { - await _devicePermissionAnalyzeService.GenerateDeviceTasksAsync(async () => - { - await _dbContext.InsertAsync(info); - await _identityUserSyncService.SyncAccountAsync(info.Code, info.Name, info.IdNo, info.Factory); - }, new List { info.No }, "入职生成"); + await _dbContext.InsertAsync(info); + await _identityUserSyncService.SyncAccountAsync(info.Code, info.Name, info.IdNo, info.Factory); + + await _gainfoPermissionService.ResetPermissionsAsync(info.No, DeviceTaskEnumType.Add, null, "入职生成"); } else { @@ -260,55 +259,53 @@ public class GainfoUpdateService : IGainfoUpdateService { if (item.isowner == "T") { - await _devicePermissionAnalyzeService.GenerateDeviceTasksAsync(async () => + await _dbContext.Updateable().SetColumns(g => new GainfoEntity { - await _dbContext.Updateable().SetColumns(g => new GainfoEntity - { - InternalNo = item.PERNR, - Name = item.gname, - PositionNo = item.STELL, - Grade = item.ZZ_ZD, - Title = item.Z_ZJ, - Phone = item.phone, - DepartmentNo = item.appellation, - Remark = item.remark, - Degree = item.email, - Werks = item.WERKS, - CostId = item.KOSTL, - EntryDate = item.createdate, - ResignationDate = item.ZLZRQ, - Workplace = workplace, - Factory = factory, - CardType = SafeParseCardType(item.ZZ_KLX) - }).Where(x => x.Code == item.ename).ExecuteCommandAsync(); + InternalNo = item.PERNR, + Name = item.gname, + PositionNo = item.STELL, + Grade = item.ZZ_ZD, + Title = item.Z_ZJ, + Phone = item.phone, + DepartmentNo = item.appellation, + Remark = item.remark, + Degree = item.email, + Werks = item.WERKS, + CostId = item.KOSTL, + EntryDate = item.createdate, + ResignationDate = item.ZLZRQ, + Workplace = workplace, + Factory = factory, + CardType = SafeParseCardType(item.ZZ_KLX) + }).Where(x => x.Code == item.ename).ExecuteCommandAsync(); - await _identityUserSyncService.SyncAccountAsync(gainfo.Code, gainfo.Name, gainfo.IdNo, factory); - }, new List { gainfo.No }, "人员数据变更"); + await _identityUserSyncService.SyncAccountAsync(gainfo.Code, gainfo.Name, gainfo.IdNo, factory); + + await _gainfoPermissionService.ResetPermissionsAsync(info.No, DeviceTaskEnumType.Update, null, "人员数据变更"); } else { await _dbContext.Client.Ado.BeginTranAsync(); try { - await _devicePermissionAnalyzeService.GenerateDeviceTasksAsync(async () => + await _gainfoPermissionService.ResetPermissionsAsync(info.No, DeviceTaskEnumType.Delete, null, "人员离职生成"); + + //先写入离职表 + gainfo.IdentityUserId = (int)gainfo.Id; //记录原始id + gainfo.Id = 0; + gainfo.ResignationDate = item.ZLZRQ; + + if (!await _dbContext.Queryable().AnyAsync(x => x.Code == item.ename)) { - //先写入离职表 - gainfo.IdentityUserId = (int)gainfo.Id; //记录原始id - gainfo.Id = 0; - gainfo.ResignationDate = item.ZLZRQ; + await _dbContext.Client.Insertable(gainfo).AS("GainfoLeave").ExecuteCommandAsync(); + } - if (!await _dbContext.Queryable().AnyAsync(x => x.Code == item.ename)) - { - await _dbContext.Client.Insertable(gainfo).AS("GainfoLeave").ExecuteCommandAsync(); - } - - await _dbContext.Deleteable().Where(x => x.UserNo == gainfo.No).ExecuteCommandAsync(); - await _dbContext.Deleteable().Where(x => x.AssignType == AssignTypeEnumType.User && x.AssignValue == gainfo.No).ExecuteCommandAsync(); - - gainfo.Id = gainfo.IdentityUserId; - await _dbContext.DeleteReallyAsync(gainfo); - }, new List { gainfo.No }, "人员离职生成"); + await _dbContext.Deleteable().Where(x => x.UserNo == gainfo.No).ExecuteCommandAsync(); + await _dbContext.Deleteable().Where(x => x.AssignType == AssignTypeEnumType.User && x.AssignValue == gainfo.No).ExecuteCommandAsync(); + gainfo.Id = gainfo.IdentityUserId; + await _dbContext.DeleteReallyAsync(gainfo); + await _dbContext.Client.Ado.CommitTranAsync(); } catch (Exception ex)