| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- 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")]
- public long Id { get; set; }
- [SugarColumn(ColumnName = "tenant_id", ColumnDataType = "bigint")]
- public long TenantId { get; set; }
- [SugarColumn(ColumnName = "factory_id", ColumnDataType = "bigint")]
- public long FactoryId { get; set; }
- [SugarColumn(ColumnName = "rule_code", Length = 64)]
- public string RuleCode { get; set; } = string.Empty;
- [SugarColumn(ColumnName = "scene_code", Length = 64)]
- public string SceneCode { get; set; } = string.Empty;
- [SugarColumn(ColumnName = "data_source_id", ColumnDataType = "bigint")]
- public long DataSourceId { get; set; }
- [SugarColumn(ColumnName = "watch_object_type", Length = 64)]
- public string WatchObjectType { get; set; } = string.Empty;
- [SugarColumn(ColumnName = "expression", Length = 2000, IsNullable = true)]
- public string? Expression { get; set; }
- [SugarColumn(ColumnName = "severity", Length = 32)]
- public string Severity { get; set; } = "MEDIUM";
- [SugarColumn(ColumnName = "poll_interval_seconds")]
- public int PollIntervalSeconds { get; set; } = 300;
- [SugarColumn(ColumnName = "enabled", ColumnDataType = "boolean")]
- public bool Enabled { get; set; }
- [SugarColumn(ColumnName = "created_at")]
- public DateTime CreatedAt { get; set; } = DateTime.Now;
- [SugarColumn(ColumnName = "updated_at", IsNullable = true)]
- public DateTime? UpdatedAt { get; set; }
- /// <summary>规则类型:TIMEOUT / SHORTAGE / OUT_OF_RANGE。R1 仅落列,evaluator 不分派。</summary>
- [SugarColumn(ColumnName = "rule_type", Length = 32, IsNullable = true)]
- public string? RuleType { get; set; }
- /// <summary>源对象类型(DEVICE / ORDER / MATERIAL / QUALITY_CHECK 等)。R1 与 watch_object_type 可保持一致。</summary>
- [SugarColumn(ColumnName = "source_object_type", Length = 64, IsNullable = true)]
- public string? SourceObjectType { get; set; }
- /// <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;
- }
|