| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using Admin.NET.Plugin.AiDOP.MaterialWarehouse;
- using Furion.Schedule;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Logging;
- namespace Admin.NET.Plugin.AiDOP.Job;
- /// <summary>S5 库存日终对账:每天 01:15,165 vs mdp_std_inventory。</summary>
- [JobDetail("job_s5_inventory_daily_recon",
- Description = "S5库存日终对账",
- GroupName = "default", Concurrent = false)]
- [Cron("15 1 * * *",
- TriggerId = "trigger_s5_inventory_daily_recon",
- Description = "每天01:15")]
- public sealed class S5InventoryDailyReconJob : IJob
- {
- private readonly IServiceScopeFactory _scopeFactory;
- private readonly ILogger _logger;
- public S5InventoryDailyReconJob(IServiceScopeFactory scopeFactory, ILoggerFactory loggerFactory)
- {
- _scopeFactory = scopeFactory;
- _logger = loggerFactory.CreateLogger(nameof(S5InventoryDailyReconJob));
- }
- public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
- {
- using var scope = _scopeFactory.CreateScope();
- var recon = scope.ServiceProvider.GetRequiredService<InventoryReconService>();
- try
- {
- var diffs = await recon.RunDailyReconAsync(stoppingToken);
- _logger.LogInformation("[S5InventoryDailyReconJob] done diffs={Diffs}", diffs);
- }
- catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
- {
- throw;
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "[S5InventoryDailyReconJob] failed");
- }
- }
- }
|