|
|
@@ -3,6 +3,9 @@ namespace Admin.NET.Plugin.AiDOP.Entity.S8;
|
|
|
[SugarTable("ado_s8_watch_rule", "S8 监视规则")]
|
|
|
[SugarIndex("idx_s8_watch_rule_type", nameof(TenantId), OrderByType.Asc, nameof(FactoryId), OrderByType.Asc, nameof(RuleType), OrderByType.Asc)]
|
|
|
[SugarIndex("idx_s8_watch_rule_source_object", nameof(TenantId), OrderByType.Asc, nameof(FactoryId), OrderByType.Asc, nameof(SourceObjectType), OrderByType.Asc)]
|
|
|
+[SugarIndex("idx_s8_watch_rule_dispatch", nameof(Enabled), OrderByType.Asc, nameof(PausedUntil), OrderByType.Asc, nameof(NextRunAt), OrderByType.Asc)]
|
|
|
+[SugarIndex("idx_s8_watch_rule_lock_until", nameof(LockUntil), OrderByType.Asc)]
|
|
|
+[SugarIndex("idx_s8_watch_rule_rule_code", nameof(RuleCode), OrderByType.Asc)]
|
|
|
public class AdoS8WatchRule
|
|
|
{
|
|
|
[SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true, ColumnDataType = "bigint")]
|
|
|
@@ -55,4 +58,68 @@ public class AdoS8WatchRule
|
|
|
/// <summary>规则类型相关结构化参数 JSON。R1 仅预留,service 不解析。</summary>
|
|
|
[SugarColumn(ColumnName = "params_json", ColumnDataType = "mediumtext", IsNullable = true)]
|
|
|
public string? ParamsJson { get; set; }
|
|
|
+
|
|
|
+ // ============================================================
|
|
|
+ // S8-SCHED-SCHEMA-1:调度运行态字段(仅落列,本轮不接调度逻辑)
|
|
|
+ // ============================================================
|
|
|
+
|
|
|
+ /// <summary>下次到期执行时间。NULL 视为可立即执行。</summary>
|
|
|
+ [SugarColumn(ColumnName = "next_run_at", IsNullable = true)]
|
|
|
+ public DateTime? NextRunAt { get; set; }
|
|
|
+
|
|
|
+ /// <summary>上次执行时间。</summary>
|
|
|
+ [SugarColumn(ColumnName = "last_run_at", IsNullable = true)]
|
|
|
+ public DateTime? LastRunAt { get; set; }
|
|
|
+
|
|
|
+ /// <summary>上次执行状态:SUCCESS / FAILED / SKIPPED。</summary>
|
|
|
+ [SugarColumn(ColumnName = "last_status", Length = 20, IsNullable = true)]
|
|
|
+ public string? LastStatus { get; set; }
|
|
|
+
|
|
|
+ /// <summary>上次执行错误摘要。</summary>
|
|
|
+ [SugarColumn(ColumnName = "last_error", Length = 500, IsNullable = true)]
|
|
|
+ public string? LastError { get; set; }
|
|
|
+
|
|
|
+ /// <summary>上次执行耗时(毫秒)。</summary>
|
|
|
+ [SugarColumn(ColumnName = "last_duration_ms", IsNullable = true)]
|
|
|
+ public int? LastDurationMs { get; set; }
|
|
|
+
|
|
|
+ /// <summary>上次执行 RunId(关联 detection_log)。</summary>
|
|
|
+ [SugarColumn(ColumnName = "last_run_id", Length = 64, IsNullable = true)]
|
|
|
+ public string? LastRunId { get; set; }
|
|
|
+
|
|
|
+ /// <summary>调度抢占租约 token(多实例并发安全)。</summary>
|
|
|
+ [SugarColumn(ColumnName = "lock_token", Length = 64, IsNullable = true)]
|
|
|
+ public string? LockToken { get; set; }
|
|
|
+
|
|
|
+ /// <summary>持有租约的实例标识。</summary>
|
|
|
+ [SugarColumn(ColumnName = "locked_by", Length = 128, IsNullable = true)]
|
|
|
+ public string? LockedBy { get; set; }
|
|
|
+
|
|
|
+ /// <summary>租约失效时间;超过此时间视为可被其他实例抢占(僵尸自愈)。</summary>
|
|
|
+ [SugarColumn(ColumnName = "lock_until", IsNullable = true)]
|
|
|
+ public DateTime? LockUntil { get; set; }
|
|
|
+
|
|
|
+ /// <summary>本次运行开始时间(与 LockUntil 配合用于僵尸判定)。</summary>
|
|
|
+ [SugarColumn(ColumnName = "running_started_at", IsNullable = true)]
|
|
|
+ public DateTime? RunningStartedAt { get; set; }
|
|
|
+
|
|
|
+ /// <summary>连续失败计数;用于到达阈值后写 PausedUntil 自动暂停。</summary>
|
|
|
+ [SugarColumn(ColumnName = "consecutive_failure_count")]
|
|
|
+ public int ConsecutiveFailureCount { get; set; } = 0;
|
|
|
+
|
|
|
+ /// <summary>暂停至何时;NULL 表示未暂停;远未来值表示手工暂停。</summary>
|
|
|
+ [SugarColumn(ColumnName = "paused_until", IsNullable = true)]
|
|
|
+ public DateTime? PausedUntil { get; set; }
|
|
|
+
|
|
|
+ /// <summary>暂停原因(auto_failure / manual / ...)。</summary>
|
|
|
+ [SugarColumn(ColumnName = "pause_reason", Length = 64, IsNullable = true)]
|
|
|
+ public string? PauseReason { get; set; }
|
|
|
+
|
|
|
+ /// <summary>持续命中 N 次才建单(抗抖触发);默认 1 = 立即建单。</summary>
|
|
|
+ [SugarColumn(ColumnName = "trigger_count_required")]
|
|
|
+ public int TriggerCountRequired { get; set; } = 1;
|
|
|
+
|
|
|
+ /// <summary>持续未命中 N 次才标 recovered(抗抖恢复);默认 1 = 立即恢复。</summary>
|
|
|
+ [SugarColumn(ColumnName = "recover_count_required")]
|
|
|
+ public int RecoverCountRequired { get; set; } = 1;
|
|
|
}
|