| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using Admin.NET.Plugin.AiDOP.Entity.S8;
- namespace Admin.NET.Plugin.AiDOP.Service.S8.Rules;
- /// <summary>
- /// R2 规则 evaluator 抽象。每个 rule_type 对应一个实现,由 S8WatchSchedulerService 按 rule_type 分派。
- /// 首版仅 TIMEOUT;OUT_OF_RANGE 走 S8WatchSchedulerService 内既有兼容分支,不接入此抽象。
- /// 不做事件触发、不做 SLA 升级、不做严重度阶梯。
- /// </summary>
- public interface IS8RuleEvaluator
- {
- /// <summary>支持的 rule_type 字符串(TIMEOUT / SHORTAGE / OUT_OF_RANGE)。</summary>
- string RuleType { get; }
- /// <summary>评估一条 WatchRule,产出 0..N 条命中。不做去重、不建单。</summary>
- Task<List<S8RuleHit>> EvaluateAsync(
- long tenantId,
- long factoryId,
- AdoS8WatchRule rule,
- IReadOnlyList<AdoS8AlertRule> alertRules,
- CancellationToken cancellationToken = default);
- }
- /// <summary>
- /// 内部命中模型。供 R2 evaluator 与 S8WatchSchedulerService 的 dedup/建单消费。
- /// 字段全部 nullable 以兼容 TIMEOUT / SHORTAGE / OUT_OF_RANGE 三类。R2 仅 TIMEOUT 路径写入。
- /// </summary>
- public sealed class S8RuleHit
- {
- public long SourceRuleId { get; set; }
- public string SourceRuleCode { get; set; } = string.Empty;
- public string SourceObjectType { get; set; } = string.Empty;
- public string SourceObjectId { get; set; } = string.Empty;
- public string RelatedObjectCode { get; set; } = string.Empty;
- public string ExceptionTypeCode { get; set; } = string.Empty;
- public string SceneCode { get; set; } = string.Empty;
- public string Severity { get; set; } = "MEDIUM";
- public string DedupKey { get; set; } = string.Empty;
- public string SourcePayload { get; set; } = "{}";
- public DateTime DetectedAt { get; set; } = DateTime.Now;
- public string Title { get; set; } = string.Empty;
- public long DataSourceId { get; set; }
- public long? OccurrenceDeptId { get; set; }
- public long? ResponsibleDeptId { get; set; }
- }
|