fix 优化同步速度
This commit is contained in:
@@ -125,12 +125,12 @@ public class MyDataPermissionService : IDataPermissionService
|
|||||||
{
|
{
|
||||||
var codes = new List<Guid>();
|
var codes = new List<Guid>();
|
||||||
|
|
||||||
var disableFilter = _currentUser.GetRole() is "admin" or "tenant-admin";
|
var hasAllPermission = _currentUser.GetRole() is "admin" or "tenant-admin";
|
||||||
if (!disableFilter)
|
if (!hasAllPermission)
|
||||||
{
|
{
|
||||||
codes = _getDataPermissions.GetData<DeviceGroupEntity>().FirstOrDefault().Value ?? new List<Guid>();
|
codes = _getDataPermissions.GetData<DeviceGroupEntity>().FirstOrDefault().Value ?? new List<Guid>();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (!disableFilter, codes);
|
return (!hasAllPermission, codes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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.Entity;
|
||||||
using Dlhis.Entity.Basic.Enums;
|
using Dlhis.Entity.Basic.Enums;
|
||||||
|
using Dlhis.Entity.Device.Enums;
|
||||||
using Dlhis.Entity.Sys.Entities;
|
using Dlhis.Entity.Sys.Entities;
|
||||||
using Dlhis.Entity.Sys.Enums;
|
using Dlhis.Entity.Sys.Enums;
|
||||||
using Dlhis.Jip.Api.Dto;
|
using Dlhis.Jip.Api.Dto;
|
||||||
@@ -18,7 +18,7 @@ public class GainfoUpdateService : IGainfoUpdateService
|
|||||||
private readonly ILogger<GainfoUpdateService> _logger;
|
private readonly ILogger<GainfoUpdateService> _logger;
|
||||||
private readonly ITenantApi _tenantApi;
|
private readonly ITenantApi _tenantApi;
|
||||||
private readonly IJinkoSapService _jinkoSapService;
|
private readonly IJinkoSapService _jinkoSapService;
|
||||||
private readonly IDevicePermissionAnalyzeService _devicePermissionAnalyzeService;
|
private readonly IGainfoPermissionService _gainfoPermissionService;
|
||||||
private readonly IIdentityUserSyncService _identityUserSyncService;
|
private readonly IIdentityUserSyncService _identityUserSyncService;
|
||||||
|
|
||||||
private List<TenantResponse> _tenants;
|
private List<TenantResponse> _tenants;
|
||||||
@@ -27,7 +27,7 @@ public class GainfoUpdateService : IGainfoUpdateService
|
|||||||
ILogger<GainfoUpdateService> logger,
|
ILogger<GainfoUpdateService> logger,
|
||||||
ITenantApi tenantApi,
|
ITenantApi tenantApi,
|
||||||
IJinkoSapService jinkoSapService,
|
IJinkoSapService jinkoSapService,
|
||||||
IDevicePermissionAnalyzeService devicePermissionAnalyzeService,
|
IGainfoPermissionService gainfoPermissionService,
|
||||||
IIdentityUserSyncService identityUserSyncService)
|
IIdentityUserSyncService identityUserSyncService)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
@@ -35,7 +35,7 @@ public class GainfoUpdateService : IGainfoUpdateService
|
|||||||
_logger = logger;
|
_logger = logger;
|
||||||
_tenantApi = tenantApi;
|
_tenantApi = tenantApi;
|
||||||
_jinkoSapService = jinkoSapService;
|
_jinkoSapService = jinkoSapService;
|
||||||
_devicePermissionAnalyzeService = devicePermissionAnalyzeService;
|
_gainfoPermissionService = gainfoPermissionService;
|
||||||
_identityUserSyncService = identityUserSyncService;
|
_identityUserSyncService = identityUserSyncService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,12 +170,11 @@ public class GainfoUpdateService : IGainfoUpdateService
|
|||||||
var info = GainfoSapToGainfo(item);
|
var info = GainfoSapToGainfo(item);
|
||||||
|
|
||||||
if (item.isowner == "T")
|
if (item.isowner == "T")
|
||||||
{
|
|
||||||
await _devicePermissionAnalyzeService.GenerateDeviceTasksAsync(async () =>
|
|
||||||
{
|
{
|
||||||
await _dbContext.InsertAsync(info);
|
await _dbContext.InsertAsync(info);
|
||||||
await _identityUserSyncService.SyncAccountAsync(info.Code, info.Name, info.IdNo, info.Factory);
|
await _identityUserSyncService.SyncAccountAsync(info.Code, info.Name, info.IdNo, info.Factory);
|
||||||
}, new List<string> { info.No }, "入职生成");
|
|
||||||
|
await _gainfoPermissionService.ResetPermissionsAsync(info.No, DeviceTaskEnumType.Add, null, "入职生成");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -259,8 +258,6 @@ public class GainfoUpdateService : IGainfoUpdateService
|
|||||||
if (gainfo != null)
|
if (gainfo != null)
|
||||||
{
|
{
|
||||||
if (item.isowner == "T")
|
if (item.isowner == "T")
|
||||||
{
|
|
||||||
await _devicePermissionAnalyzeService.GenerateDeviceTasksAsync(async () =>
|
|
||||||
{
|
{
|
||||||
await _dbContext.Updateable<GainfoEntity>().SetColumns(g => new GainfoEntity
|
await _dbContext.Updateable<GainfoEntity>().SetColumns(g => new GainfoEntity
|
||||||
{
|
{
|
||||||
@@ -283,15 +280,16 @@ public class GainfoUpdateService : IGainfoUpdateService
|
|||||||
}).Where(x => x.Code == item.ename).ExecuteCommandAsync();
|
}).Where(x => x.Code == item.ename).ExecuteCommandAsync();
|
||||||
|
|
||||||
await _identityUserSyncService.SyncAccountAsync(gainfo.Code, gainfo.Name, gainfo.IdNo, factory);
|
await _identityUserSyncService.SyncAccountAsync(gainfo.Code, gainfo.Name, gainfo.IdNo, factory);
|
||||||
}, new List<string> { gainfo.No }, "人员数据变更");
|
|
||||||
|
await _gainfoPermissionService.ResetPermissionsAsync(info.No, DeviceTaskEnumType.Update, null, "人员数据变更");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
await _dbContext.Client.Ado.BeginTranAsync();
|
await _dbContext.Client.Ado.BeginTranAsync();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _devicePermissionAnalyzeService.GenerateDeviceTasksAsync(async () =>
|
await _gainfoPermissionService.ResetPermissionsAsync(info.No, DeviceTaskEnumType.Delete, null, "人员离职生成");
|
||||||
{
|
|
||||||
//先写入离职表
|
//先写入离职表
|
||||||
gainfo.IdentityUserId = (int)gainfo.Id; //记录原始id
|
gainfo.IdentityUserId = (int)gainfo.Id; //记录原始id
|
||||||
gainfo.Id = 0;
|
gainfo.Id = 0;
|
||||||
@@ -307,7 +305,6 @@ public class GainfoUpdateService : IGainfoUpdateService
|
|||||||
|
|
||||||
gainfo.Id = gainfo.IdentityUserId;
|
gainfo.Id = gainfo.IdentityUserId;
|
||||||
await _dbContext.DeleteReallyAsync(gainfo);
|
await _dbContext.DeleteReallyAsync(gainfo);
|
||||||
}, new List<string> { gainfo.No }, "人员离职生成");
|
|
||||||
|
|
||||||
await _dbContext.Client.Ado.CommitTranAsync();
|
await _dbContext.Client.Ado.CommitTranAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user