| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- 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; } = "FOLLOW";
- 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; }
- /// <summary>
- /// 命中归属模块码(S1-S7)。evaluator 可显式提供以覆盖 scene 默认派生;
- /// 留 null 时建单方按严格 S1-S7 派生:hit.SceneCode(仅 S1-S7)→ exception_type.scene_code。
- /// 不接受 legacy 复合 scene(S8-EXCEPTION-CREATION-MODULE-CODE-FIX-1)。
- /// </summary>
- public string? ModuleCode { get; set; }
- }
|