| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- namespace Admin.NET.Plugin.AiDOP.Entity.S8;
- /// <summary>
- /// S8 规则检测抗抖累计状态(建单前阶段)。
- /// 用途:在"持续 N 次命中才建单 / 持续 N 次未命中才标 recovered"路径上,
- /// 承载每条 (rule_code, dedup_key) 在还未建单时的累计计数。
- /// 本表无软删字段;唯一记录由 (tenant_id, factory_id, rule_code, dedup_key) 决定。
- /// 已建单后的抗抖累计落在 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(FactoryId), OrderByType.Asc,
- nameof(RuleCode), OrderByType.Asc,
- nameof(DedupKey), OrderByType.Asc,
- IsUnique = true)]
- [SugarIndex("idx_s8_rule_detection_state_rule",
- nameof(TenantId), OrderByType.Asc,
- nameof(FactoryId), 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; }
- [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; }
- }
|