| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- namespace Admin.NET.Plugin.AiDOP.Entity.S8;
- /// <summary>
- /// S8 规则检测抗抖累计状态(建单前阶段)。
- /// 用途:在"持续 N 次命中才建单 / 持续 N 次未命中才标 recovered"路径上,
- /// 承载每条 (rule_code, dedup_key) 在还未建单时的累计计数。
- /// 本表无软删字段;唯一记录由 (tenant_id, rule_code, dedup_key) 决定。
- /// S8-TENANT-ONLY-BATCH5:factory_id 已退出唯一键。它此前把同一 (tenant, rule, dedup)
- /// 按工厂切成多行,抗抖计数因此可能分裂在两行上、trigger/recover 阈值静默失效。
- /// 已建单后的抗抖累计落在 ado_s8_exception.consecutive_hit_count / consecutive_miss_count。
- /// </summary>
- [SugarTable("ado_s8_rule_detection_state", "S8 规则检测抗抖状态")]
- [SugarIndex("uk_s8_rule_detection_state_dedup",
- nameof(TenantId), OrderByType.Asc,
- nameof(RuleCode), OrderByType.Asc,
- nameof(DedupKey), OrderByType.Asc,
- IsUnique = true)]
- [SugarIndex("idx_s8_rule_detection_state_rule",
- nameof(TenantId), OrderByType.Asc,
- nameof(RuleCode), OrderByType.Asc)]
- [SugarIndex("idx_s8_rule_detection_state_active_exception",
- nameof(ActiveExceptionId), OrderByType.Asc)]
- public class AdoS8RuleDetectionState
- {
- [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; }
- /// <summary>
- /// 历史兼容列。S8-TENANT-ONLY-BATCH5 起**不再参与唯一键与任何查询谓词**,
- /// 仅作元数据保留(写入时取规则行的 factory_id)。列不删除,等后续 schema 清理。
- /// </summary>
- [SugarColumn(ColumnName = "factory_id", ColumnDataType = "bigint")]
- public long FactoryId { get; set; }
- /// <summary>规则人读编码(关联 ado_s8_watch_rule.rule_code)。</summary>
- [SugarColumn(ColumnName = "rule_code", Length = 64)]
- public string RuleCode { get; set; } = string.Empty;
- /// <summary>命中去重键,与 ado_s8_exception.dedup_key 同模型。</summary>
- [SugarColumn(ColumnName = "dedup_key", Length = 128)]
- public string DedupKey { get; set; } = string.Empty;
- /// <summary>源对象类型(DEVICE / ORDER / MATERIAL / QUALITY_CHECK 等)。</summary>
- [SugarColumn(ColumnName = "source_object_type", Length = 64, IsNullable = true)]
- public string? SourceObjectType { get; set; }
- /// <summary>源对象主键或业务 ID(字符串以适配跨表/跨域)。</summary>
- [SugarColumn(ColumnName = "source_object_id", Length = 64, IsNullable = true)]
- public string? SourceObjectId { get; set; }
- /// <summary>建单前的连续命中次数;累计到 trigger_count_required 才建单。</summary>
- [SugarColumn(ColumnName = "consecutive_hit_count")]
- public int ConsecutiveHitCount { get; set; } = 0;
- /// <summary>建单前的连续未命中次数;用于尚未建单但抖动归零的场景。</summary>
- [SugarColumn(ColumnName = "consecutive_miss_count")]
- public int ConsecutiveMissCount { get; set; } = 0;
- /// <summary>当前活跃的异常 Id(建单后写入;建单前为 NULL)。</summary>
- [SugarColumn(ColumnName = "active_exception_id", ColumnDataType = "bigint", IsNullable = true)]
- public long? ActiveExceptionId { get; set; }
- /// <summary>最近一次评估时间(命中或未命中均刷新)。</summary>
- [SugarColumn(ColumnName = "last_seen_at", IsNullable = true)]
- public DateTime? LastSeenAt { get; set; }
- /// <summary>最近一次命中时间。</summary>
- [SugarColumn(ColumnName = "last_hit_at", IsNullable = true)]
- public DateTime? LastHitAt { get; set; }
- /// <summary>最近一次未命中时间。</summary>
- [SugarColumn(ColumnName = "last_miss_at", IsNullable = true)]
- public DateTime? LastMissAt { get; set; }
- [SugarColumn(ColumnName = "created_at")]
- public DateTime CreatedAt { get; set; } = DateTime.Now;
- [SugarColumn(ColumnName = "updated_at", IsNullable = true)]
- public DateTime? UpdatedAt { get; set; }
- }
|