refactor 优化代码
This commit is contained in:
@@ -29,8 +29,7 @@ public class CreateDefinitelyGroupJob : BaseJob
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
{
|
||||
//获取所有基地信息
|
||||
var tenantResult = await _tenantApi.GetTenantsInternalAsync();
|
||||
var tenants = tenantResult.Data;
|
||||
var tenants = await _tenantApi.GetTenantsInternalAsync();
|
||||
|
||||
Logger.LogInformation("获取基地信息:{json}", JsonConvert.SerializeObject(tenants));
|
||||
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Dlhis.Jip.Api;
|
||||
using Dlhis.Jip.Api.Request;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Request;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
using Hangfire;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
|
||||
@@ -17,12 +16,12 @@ namespace Dlhis.ScheduledTask.Jobs;
|
||||
[RecurringJob(nameof(MealSupplementHandlerJob), "0 0/30 * * * ?", Name = "餐补核算")]
|
||||
public class MealSupplementHandlerJob : BaseJob
|
||||
{
|
||||
private readonly IJinkoJipService _jinkoJIPService;
|
||||
private readonly IJinkoJipApi _jinkoJipApi;
|
||||
|
||||
public MealSupplementHandlerJob(IServiceProvider serviceProvider,
|
||||
IJinkoJipService jinkoJIPService) : base(serviceProvider)
|
||||
IJinkoJipApi jinkoJipApi) : base(serviceProvider)
|
||||
{
|
||||
_jinkoJIPService = jinkoJIPService;
|
||||
_jinkoJipApi = jinkoJipApi;
|
||||
}
|
||||
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
@@ -59,7 +58,7 @@ public class MealSupplementHandlerJob : BaseJob
|
||||
{
|
||||
try
|
||||
{
|
||||
var r = await _jinkoJIPService.SyncMealSupplementRecordsAsync(new List<SyncMealSupplementRecordRequest>
|
||||
var r = await _jinkoJipApi.SyncMealSupplementRecordsAsync(new List<SyncMealSupplementRecordRequest>
|
||||
{
|
||||
new()
|
||||
{
|
||||
@@ -79,6 +78,7 @@ public class MealSupplementHandlerJob : BaseJob
|
||||
}
|
||||
catch
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -121,8 +121,8 @@ public class MealSupplementHandlerJob : BaseJob
|
||||
|
||||
IsDeleted = false,
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
if (!await DbContext.Queryable<UserBalanceEntity>().Where(x => x.UserCode == gainfo.Code).AnyAsync())
|
||||
{
|
||||
await DbContext.InsertAsync(new UserBalanceEntity
|
||||
@@ -153,8 +153,8 @@ public class MealSupplementHandlerJob : BaseJob
|
||||
.Where(x => x.UserCode == gainfo.Code && x.Version == version)
|
||||
.ExecuteCommandThrowVersionAsync();
|
||||
}, 5);
|
||||
|
||||
var r = await _jinkoJIPService.SyncMealSupplementRecordsAsync(new List<SyncMealSupplementRecordRequest>
|
||||
|
||||
var r = await _jinkoJipApi.SyncMealSupplementRecordsAsync(new List<SyncMealSupplementRecordRequest>
|
||||
{
|
||||
new()
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Dlhis.Basic.Api;
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
@@ -8,23 +8,23 @@ namespace Dlhis.ScheduledTask.Jobs;
|
||||
[RecurringJob(nameof(SyncBusinessTripJob), "0 0 1 1/1 * ? ", Name = "SAP同步出差信息")]
|
||||
public class SyncBusinessTripJob : BaseJob
|
||||
{
|
||||
private readonly ISyncApi _syncApi;
|
||||
|
||||
/// <inheritdoc />
|
||||
public SyncBusinessTripJob(IServiceProvider serviceProvider) : base(serviceProvider)
|
||||
public SyncBusinessTripJob(IServiceProvider serviceProvider, ISyncApi syncApi) : base(serviceProvider)
|
||||
{
|
||||
_syncApi = syncApi;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
{
|
||||
// var sapBusinessTripService = serviceProvider.GetService<ISapBusinessTripService>();
|
||||
//
|
||||
// var identityDbContext = DbContext.ChangeDb("identity");
|
||||
// var factories = await identityDbContext.Queryable<TenantEntity>().Where(x => !SqlFunc.IsNullOrEmpty(x.PCode)).ToListAsync();
|
||||
//
|
||||
// foreach (var factory in factories)
|
||||
// {
|
||||
// await sapBusinessTripService.HandlerBusinessTripsByFactoryAsync(factory.Code);
|
||||
// }
|
||||
var identityDbContext = DbContext.ChangeDb("identity");
|
||||
var factories = await identityDbContext.Queryable<TenantEntity>().Where(x => !SqlFunc.IsNullOrEmpty(x.PCode)).ToListAsync();
|
||||
|
||||
foreach (var factory in factories)
|
||||
{
|
||||
await _syncApi.HandlerBusinessTripsAsync(factory.Code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Basic.Api;
|
||||
using Dlhis.Basic.Api.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Dto;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
|
||||
@@ -11,16 +11,16 @@ namespace Dlhis.ScheduledTask.Jobs;
|
||||
[RecurringJob(nameof(SyncOrganizationJob), "0 0 0 * * ?", Name = "SAP组织架构数据同步")]
|
||||
public class SyncOrganizationJob : BaseJob
|
||||
{
|
||||
private readonly IJinkoSapService _jinkoSapService;
|
||||
private readonly ISyncApi _syncApi;
|
||||
|
||||
public SyncOrganizationJob(IServiceProvider serviceProvider, IJinkoSapService jinkoSapService) : base(serviceProvider)
|
||||
public SyncOrganizationJob(IServiceProvider serviceProvider, ISyncApi syncApi) : base(serviceProvider)
|
||||
{
|
||||
_jinkoSapService = jinkoSapService;
|
||||
_syncApi = syncApi;
|
||||
}
|
||||
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
{
|
||||
var orgResult = await _jinkoSapService.GetSapOrganizationsAsync();
|
||||
var orgResult = await _syncApi.SyncOrganizationsAsync();
|
||||
|
||||
if (orgResult.Org != null && orgResult.Org.Items.Count > 0)
|
||||
{
|
||||
@@ -53,4 +53,4 @@ public class SyncOrganizationJob : BaseJob
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Dlhis.Jip.Api;
|
||||
using Dlhis.Jip.Api.Requests;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Request;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
@@ -14,11 +14,11 @@ namespace Dlhis.ScheduledTask.Jobs;
|
||||
[RecurringJob(nameof(SyncOriginCardInfoJob), "0 0/1 * * * ?", Name = "上传考勤记录")]
|
||||
public class SyncOriginCardInfoJob : BaseJob
|
||||
{
|
||||
private readonly IJinkoJipService _jinkoJipService;
|
||||
private readonly IJinkoJipApi _jinkoJipApi;
|
||||
|
||||
public SyncOriginCardInfoJob(IJinkoJipService jinkoJipService, IServiceProvider serviceProvider) : base(serviceProvider)
|
||||
public SyncOriginCardInfoJob(IJinkoJipApi jinkoJipApi, IServiceProvider serviceProvider) : base(serviceProvider)
|
||||
{
|
||||
_jinkoJipService = jinkoJipService;
|
||||
_jinkoJipApi = jinkoJipApi;
|
||||
}
|
||||
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
@@ -52,7 +52,7 @@ public class SyncOriginCardInfoJob : BaseJob
|
||||
try
|
||||
{
|
||||
var ids = items.Select(x => x.Id).ToList();
|
||||
var r = await _jinkoJipService.UploadAttendancesAsync(new UploadAttendanceRequest { Data = items.ToList() });
|
||||
var r = await _jinkoJipApi.UploadAttendancesAsync(new UploadAttendanceRequest { Data = items.ToList() });
|
||||
if (r.OLX == "0")
|
||||
{
|
||||
await DbContext.Updateable<DeviceUploadLogEntity>()
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
using Hangfire;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Basic.Api;
|
||||
using Dlhis.Basic.Api.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
using Dlhis.ScheduledTask.Common.Dto;
|
||||
using Dlhis.ScheduledTask.Common.Services;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
|
||||
@@ -11,16 +11,16 @@ namespace Dlhis.ScheduledTask.Jobs;
|
||||
[RecurringJob(nameof(SyncPositionJob), "0 0 0 * * ?", Name = "SAP岗位信息同步")]
|
||||
public class SyncPositionJob : BaseJob
|
||||
{
|
||||
private readonly IJinkoSapService _jinkoSapService;
|
||||
private readonly ISyncApi _syncApi;
|
||||
|
||||
public SyncPositionJob(IServiceProvider serviceProvider, IJinkoSapService jinkoSapService) : base(serviceProvider)
|
||||
public SyncPositionJob(IServiceProvider serviceProvider, ISyncApi syncApi) : base(serviceProvider)
|
||||
{
|
||||
_jinkoSapService = jinkoSapService;
|
||||
_syncApi = syncApi;
|
||||
}
|
||||
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
{
|
||||
var positionResult = await _jinkoSapService.GetPositionsAsync();
|
||||
var positionResult = await _syncApi.GetPositionsAsync();
|
||||
|
||||
if (positionResult.Position != null && positionResult.Position.Items.Count > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user