fix sap人员同步拆分

This commit is contained in:
2024-04-03 15:29:03 +08:00
parent 77ec9c9fc9
commit 28a347e04a
11 changed files with 184 additions and 70 deletions

View File

@@ -1,11 +1,14 @@
using Dlhis.ScheduledTask.Common.Services;
using Dlhis.Entity.Basic.Entity;
using Dlhis.ScheduledTask.Common.Services;
using Hangfire;
using Kurisu.AspNetCore.Utils.Extensions;
using Kurisu.Scheduled;
using Kurisu.Scheduled.Attributes;
namespace Dlhis.ScheduledTask.Jobs;
/// <summary>
/// SAP人员信息同步
/// SAP人员信息同步(按人事范围拆分)
/// </summary>
[RecurringJob(nameof(SyncPersonJob), "0 0 3,12,18 * * ?", Name = "SAP人员信息同步")]
public class SyncPersonJob : BaseJob
@@ -16,7 +19,20 @@ public class SyncPersonJob : BaseJob
public override async Task RunAsync(IServiceProvider serviceProvider)
{
var gainfoUpdate = serviceProvider.GetService<IGainfoUpdateService>();
await gainfoUpdate.TodoAsync(null);
var werks = await DbContext.Queryable<WerkEntity>()
.Where(x => x.Enable)
.ToListAsync();
foreach (var werk in werks)
{
if (werk.BackgroundJobKey.IsEmpty())
{
var jobKey = BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByWerkAsync(werk.Werk));
werk.BackgroundJobKey = jobKey;
await DbContext.UpdateAsync(werk);
Logger.LogInformation("SAP创建人事范围{werk}后台调度任务", werk.Werk);
}
}
}
}