S8WatchSchedulerService.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Admin.NET.Plugin.AiDOP.Entity.S8;
  2. namespace Admin.NET.Plugin.AiDOP.Service.S8;
  3. /// <summary>
  4. /// 监视规则轮询调度服务(首轮存根)。
  5. /// 后续接入 Admin.NET 定时任务机制后,由调度器周期调用 <see cref="RunOnceAsync"/>,
  6. /// 按各规则的 PollIntervalSeconds 逐条评估并生成异常记录。
  7. /// </summary>
  8. public class S8WatchSchedulerService : ITransient
  9. {
  10. private readonly SqlSugarRepository<AdoS8WatchRule> _ruleRep;
  11. private readonly SqlSugarRepository<AdoS8Exception> _exceptionRep;
  12. private readonly S8NotificationService _notificationService;
  13. public S8WatchSchedulerService(
  14. SqlSugarRepository<AdoS8WatchRule> ruleRep,
  15. SqlSugarRepository<AdoS8Exception> exceptionRep,
  16. S8NotificationService notificationService)
  17. {
  18. _ruleRep = ruleRep;
  19. _exceptionRep = exceptionRep;
  20. _notificationService = notificationService;
  21. }
  22. /// <summary>
  23. /// 单次轮询入口。当前为存根,返回已启用规则数量,不做实际数据采集。
  24. /// </summary>
  25. public async Task<int> RunOnceAsync()
  26. {
  27. var enabledRules = await _ruleRep.AsQueryable()
  28. .Where(x => x.Enabled)
  29. .CountAsync();
  30. // TODO: 逐条评估规则、生成异常、触发通知
  31. return enabledRules;
  32. }
  33. }