| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using Furion.Schedule;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Logging;
- using System.Text.Json;
- namespace Admin.NET.Plugin.AiDOP.Job;
- /// <summary>
- /// S5/S6/S7 定时入队完整重算。T8 入站硬门与共享锁由各模块 Handler / AidopT8KpiManualRefreshService 执行。
- /// </summary>
- [JobDetail("job_s5_t8_kpi_refresh",
- Description = "S5/S6/S7 数据重算入队(Handler 内 T8 inbound 硬门;5 次/天:02/07/12/17/22)",
- GroupName = "default",
- Concurrent = false)]
- [Cron("0 2,7,12,17,22 * * *",
- TriggerId = "trigger_s5_t8_kpi_refresh",
- Description = "每日 02:00/07:00/12:00/17:00/22:00 触发(5 字段:分 时 日 月 周,默认 CronStringFormat.Default)")]
- public class S5MdpRefreshJob : IJob
- {
- private readonly IServiceScopeFactory _scopeFactory;
- private readonly ILogger _logger;
- public S5MdpRefreshJob(IServiceScopeFactory scopeFactory, ILoggerFactory loggerFactory)
- {
- _scopeFactory = scopeFactory;
- _logger = loggerFactory.CreateLogger(nameof(S5MdpRefreshJob));
- }
- public async Task ExecuteAsync(JobExecutingContext context, CancellationToken stoppingToken)
- {
- using var scope = _scopeFactory.CreateScope();
- try
- {
- foreach (var module in new[] { "S5", "S6", "S7" })
- {
- stoppingToken.ThrowIfCancellationRequested();
- var payload = await Admin.NET.Plugin.AiDOP.DataPlatform.MdpRebuild.ModuleRebuildJobRunner
- .EnqueueEnabledScopesAsync(scope.ServiceProvider, module, "AUTO", stoppingToken, _logger);
- _logger.LogInformation("S5MdpRefreshJob {Module} 入队 {Payload}", module, JsonSerializer.Serialize(payload));
- }
- }
- catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
- {
- _logger.LogInformation("S5MdpRefreshJob 收到停止信号,本轮结束");
- throw;
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "S5MdpRefreshJob 入队失败");
- }
- }
- }
|