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)]
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; }
/// 规则类型:TIMEOUT / SHORTAGE / OUT_OF_RANGE。R1 仅落列,evaluator 不分派。
[SugarColumn(ColumnName = "rule_type", Length = 32, IsNullable = true)]
public string? RuleType { get; set; }
/// 源对象类型(DEVICE / ORDER / MATERIAL / QUALITY_CHECK 等)。R1 与 watch_object_type 可保持一致。
[SugarColumn(ColumnName = "source_object_type", Length = 64, IsNullable = true)]
public string? SourceObjectType { get; set; }
/// 规则类型相关结构化参数 JSON。R1 仅预留,service 不解析。
[SugarColumn(ColumnName = "params_json", ColumnDataType = "mediumtext", IsNullable = true)]
public string? ParamsJson { get; set; }
}