refactor 优化代码
This commit is contained in:
@@ -6,8 +6,6 @@ using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Entity.Visitor.Entity;
|
||||
using Dlhis.Scheduled.Api;
|
||||
using Dlhis.Scheduled.Api.Request;
|
||||
using Dlhis.Sys.Api;
|
||||
using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
@@ -26,7 +24,7 @@ public class GainfoService : IGainfoService
|
||||
private readonly IDataProtectionProvider _dataProtectionProvider;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
private readonly ITenantApi _tenantApi;
|
||||
private readonly IHangfireApi _hangfireApi;
|
||||
private readonly IJinkoSapService _jinkoSapService;
|
||||
private readonly IDevicePermissionService _devicePermissionService;
|
||||
private readonly IGainfoPermissionService _gainfoPermissionService;
|
||||
private readonly ILogger<GainfoService> _logger;
|
||||
@@ -36,7 +34,7 @@ public class GainfoService : IGainfoService
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
ICurrentUser currentUser,
|
||||
ITenantApi tenantApi,
|
||||
IHangfireApi hangfireApi,
|
||||
IJinkoSapService jinkoSapService,
|
||||
IDevicePermissionService devicePermissionService,
|
||||
IGainfoPermissionService gainfoPermissionService,
|
||||
ILogger<GainfoService> logger)
|
||||
@@ -46,7 +44,7 @@ public class GainfoService : IGainfoService
|
||||
_dataProtectionProvider = dataProtectionProvider;
|
||||
_currentUser = currentUser;
|
||||
_tenantApi = tenantApi;
|
||||
_hangfireApi = hangfireApi;
|
||||
_jinkoSapService = jinkoSapService;
|
||||
_devicePermissionService = devicePermissionService;
|
||||
_gainfoPermissionService = gainfoPermissionService;
|
||||
_logger = logger;
|
||||
@@ -166,8 +164,7 @@ public class GainfoService : IGainfoService
|
||||
.Select<GainfoAllPageResponse>()
|
||||
.ToPageListAsync(new PageDto { PageIndex = 1, PageSize = 1 });
|
||||
|
||||
var tenantsResult = await _tenantApi.GetTenantsInternalAsync();
|
||||
var tenants = tenantsResult.Data;
|
||||
var tenants = await _tenantApi.GetTenantsInternalAsync();
|
||||
|
||||
page.Data.ForEach(x =>
|
||||
{
|
||||
@@ -191,8 +188,9 @@ public class GainfoService : IGainfoService
|
||||
if (gainfo == null)
|
||||
{
|
||||
//开启同步处理
|
||||
await _hangfireApi.SyncSapPersonAsync(new SapNoRequest { Code = code });
|
||||
return null;
|
||||
await _jinkoSapService.GetPersonsByCodeAsync(code);
|
||||
gainfo = await _gainfoStore.Queryable().Where(x => x.Code == code).SingleAsync();
|
||||
if (gainfo == null) return null;
|
||||
}
|
||||
|
||||
var info = await _gainfoStore.Queryable(GainfoStatusEnumType.Working)
|
||||
@@ -217,11 +215,8 @@ public class GainfoService : IGainfoService
|
||||
{
|
||||
try
|
||||
{
|
||||
var tenantResult = await _tenantApi.GetTenantByCodeAsync(info.Factory);
|
||||
if (tenantResult is { Data: not null })
|
||||
{
|
||||
info.FactoryName = tenantResult.Data.Name;
|
||||
}
|
||||
var tenant = await _tenantApi.GetTenantByCodeAsync(info.Factory);
|
||||
info.FactoryName = tenant?.Name;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@@ -408,8 +403,7 @@ public class GainfoService : IGainfoService
|
||||
|
||||
try
|
||||
{
|
||||
var tenantsResult = await _tenantApi.GetTenantsInternalAsync();
|
||||
var tenants = tenantsResult.Data;
|
||||
var tenants = await _tenantApi.GetTenantsInternalAsync();
|
||||
|
||||
info.Workplace = tenants.FirstOrDefault(x => x.Code == info.Workplace)?.Name;
|
||||
info.Factory = tenants.FirstOrDefault(x => x.Code == info.Factory)?.Name;
|
||||
|
||||
Reference in New Issue
Block a user