AdoS8Exception.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. namespace Admin.NET.Plugin.AiDOP.Entity.S8;
  2. /// <summary>
  3. /// 异常主表(业务实体;列表为查询该表及关联展示字段,非独立「列表视图表」)。
  4. /// </summary>
  5. [SugarTable("ado_s8_exception", "S8 异常主表")]
  6. [SugarIndex("uk_ado_s8_exception_tenant_factory_code", nameof(TenantId), OrderByType.Asc, nameof(FactoryId), OrderByType.Asc, nameof(ExceptionCode), OrderByType.Asc, IsUnique = true)]
  7. [SugarIndex("idx_ado_s8_exception_type_time", nameof(TenantId), OrderByType.Asc, nameof(FactoryId), OrderByType.Asc, nameof(ExceptionTypeCode), OrderByType.Asc, nameof(CreatedAt), OrderByType.Desc)]
  8. [SugarIndex("idx_s8_exception_dedup_key", nameof(TenantId), OrderByType.Asc, nameof(FactoryId), OrderByType.Asc, nameof(DedupKey), OrderByType.Asc)]
  9. [SugarIndex("idx_s8_exception_source_rule_code", nameof(TenantId), OrderByType.Asc, nameof(FactoryId), OrderByType.Asc, nameof(SourceRuleCode), OrderByType.Asc)]
  10. [SugarIndex("idx_s8_exception_source_object", nameof(TenantId), OrderByType.Asc, nameof(FactoryId), OrderByType.Asc, nameof(SourceObjectType), OrderByType.Asc, nameof(SourceObjectId), OrderByType.Asc)]
  11. [SugarIndex("idx_s8_exception_last_detected_at", nameof(LastDetectedAt), OrderByType.Asc)]
  12. public class AdoS8Exception
  13. {
  14. [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true, ColumnDataType = "bigint")]
  15. public long Id { get; set; }
  16. [SugarColumn(ColumnName = "tenant_id", ColumnDataType = "bigint")]
  17. public long TenantId { get; set; }
  18. [SugarColumn(ColumnName = "factory_id", ColumnDataType = "bigint")]
  19. public long FactoryId { get; set; }
  20. [SugarColumn(ColumnName = "exception_code", Length = 64)]
  21. public string ExceptionCode { get; set; } = string.Empty;
  22. [SugarColumn(ColumnName = "title", Length = 256)]
  23. public string Title { get; set; } = string.Empty;
  24. [SugarColumn(ColumnName = "description", Length = 4000, IsNullable = true)]
  25. public string? Description { get; set; }
  26. [SugarColumn(ColumnName = "scene_code", Length = 64)]
  27. public string SceneCode { get; set; } = string.Empty;
  28. [SugarColumn(ColumnName = "source_type", Length = 32)]
  29. public string SourceType { get; set; } = "MANUAL";
  30. [SugarColumn(ColumnName = "status", Length = 32)]
  31. public string Status { get; set; } = "NEW";
  32. [SugarColumn(ColumnName = "severity", Length = 32)]
  33. public string Severity { get; set; } = "MEDIUM";
  34. [SugarColumn(ColumnName = "priority_score", ColumnDataType = "decimal(10,2)")]
  35. public decimal PriorityScore { get; set; }
  36. [SugarColumn(ColumnName = "priority_level", Length = 16)]
  37. public string PriorityLevel { get; set; } = "P3";
  38. [SugarColumn(ColumnName = "occurrence_dept_id", ColumnDataType = "bigint")]
  39. public long OccurrenceDeptId { get; set; }
  40. [SugarColumn(ColumnName = "responsible_dept_id", ColumnDataType = "bigint")]
  41. public long ResponsibleDeptId { get; set; }
  42. [SugarColumn(ColumnName = "responsible_group_id", ColumnDataType = "bigint", IsNullable = true)]
  43. public long? ResponsibleGroupId { get; set; }
  44. [SugarColumn(ColumnName = "assignee_id", ColumnDataType = "bigint", IsNullable = true)]
  45. public long? AssigneeId { get; set; }
  46. [SugarColumn(ColumnName = "reporter_id", ColumnDataType = "bigint", IsNullable = true)]
  47. public long? ReporterId { get; set; }
  48. [SugarColumn(ColumnName = "sla_deadline", IsNullable = true)]
  49. public DateTime? SlaDeadline { get; set; }
  50. [SugarColumn(ColumnName = "timeout_flag", ColumnDataType = "boolean")]
  51. public bool TimeoutFlag { get; set; }
  52. [SugarColumn(ColumnName = "created_at")]
  53. public DateTime CreatedAt { get; set; } = DateTime.Now;
  54. [SugarColumn(ColumnName = "updated_at", IsNullable = true)]
  55. public DateTime? UpdatedAt { get; set; }
  56. [SugarColumn(ColumnName = "assigned_at", IsNullable = true)]
  57. public DateTime? AssignedAt { get; set; }
  58. [SugarColumn(ColumnName = "closed_at", IsNullable = true)]
  59. public DateTime? ClosedAt { get; set; }
  60. /// <summary>所属模块码(S1-S7),标识异常产生于哪个业务环节</summary>
  61. [SugarColumn(ColumnName = "module_code", Length = 16, IsNullable = true)]
  62. public string? ModuleCode { get; set; }
  63. [SugarColumn(ColumnName = "process_node_code", Length = 64, IsNullable = true)]
  64. public string? ProcessNodeCode { get; set; }
  65. [SugarColumn(ColumnName = "related_object_code", Length = 64, IsNullable = true)]
  66. public string? RelatedObjectCode { get; set; }
  67. /// <summary>当前进行中的审批实例ID(用于并发控制)</summary>
  68. [SugarColumn(ColumnName = "active_flow_instance_id", IsNullable = true)]
  69. public long? ActiveFlowInstanceId { get; set; }
  70. /// <summary>当前进行中的审批业务类型(EXCEPTION_ESCALATION / EXCEPTION_CLOSURE)</summary>
  71. [SugarColumn(ColumnName = "active_flow_biz_type", Length = 32, IsNullable = true)]
  72. public string? ActiveFlowBizType { get; set; }
  73. [SugarColumn(ColumnName = "is_deleted", ColumnDataType = "boolean")]
  74. public bool IsDeleted { get; set; }
  75. [SugarColumn(ColumnName = "created_by", Length = 64, IsNullable = true)]
  76. public string? CreatedBy { get; set; }
  77. [SugarColumn(ColumnName = "updated_by", Length = 64, IsNullable = true)]
  78. public string? UpdatedBy { get; set; }
  79. /// <summary>异常类型编码(关联 ado_s8_exception_type.type_code)。配置化改造后新增。</summary>
  80. [SugarColumn(ColumnName = "exception_type_code", Length = 64, IsNullable = true)]
  81. public string? ExceptionTypeCode { get; set; }
  82. /// <summary>来源数据源 ID(自动建单时填充;人工提报为空)。关联 ado_s8_data_source.id</summary>
  83. [SugarColumn(ColumnName = "source_data_source_id", ColumnDataType = "bigint", IsNullable = true)]
  84. public long? SourceDataSourceId { get; set; }
  85. /// <summary>来源监视规则 ID(自动建单时填充)。关联 ado_s8_watch_rule.id</summary>
  86. [SugarColumn(ColumnName = "source_rule_id", ColumnDataType = "bigint", IsNullable = true)]
  87. public long? SourceRuleId { get; set; }
  88. /// <summary>命中规则时的原始数据快照(JSON 文本,便于追溯)</summary>
  89. [SugarColumn(ColumnName = "source_payload", Length = 4000, IsNullable = true)]
  90. public string? SourcePayload { get; set; }
  91. /// <summary>检验人ID(提交复检时手选)</summary>
  92. [SugarColumn(ColumnName = "verifier_id", ColumnDataType = "bigint", IsNullable = true)]
  93. public long? VerifierId { get; set; }
  94. /// <summary>提交复检时间</summary>
  95. [SugarColumn(ColumnName = "verification_assigned_at", IsNullable = true)]
  96. public DateTime? VerificationAssignedAt { get; set; }
  97. /// <summary>检验完成时间</summary>
  98. [SugarColumn(ColumnName = "verified_at", IsNullable = true)]
  99. public DateTime? VerifiedAt { get; set; }
  100. /// <summary>检验结果(APPROVED / REJECTED)</summary>
  101. [SugarColumn(ColumnName = "verification_result", Length = 32, IsNullable = true)]
  102. public string? VerificationResult { get; set; }
  103. /// <summary>检验意见</summary>
  104. [SugarColumn(ColumnName = "verification_remark", Length = 2000, IsNullable = true)]
  105. public string? VerificationRemark { get; set; }
  106. /// <summary>R1 持久化去重键(首版仅普通列,唯一约束在后续小步加)。</summary>
  107. [SugarColumn(ColumnName = "dedup_key", Length = 128, IsNullable = true)]
  108. public string? DedupKey { get; set; }
  109. /// <summary>R1 最近一次被规则检测命中的时间(首版仅落列,service 暂不写)。</summary>
  110. [SugarColumn(ColumnName = "last_detected_at", IsNullable = true)]
  111. public DateTime? LastDetectedAt { get; set; }
  112. /// <summary>R1 规则恢复时间(首版仅落列,service 暂不写)。</summary>
  113. [SugarColumn(ColumnName = "recovered_at", IsNullable = true)]
  114. public DateTime? RecoveredAt { get; set; }
  115. /// <summary>R1 来源规则人读编码(与 source_rule_id 配合,首版仅落列)。</summary>
  116. [SugarColumn(ColumnName = "source_rule_code", Length = 64, IsNullable = true)]
  117. public string? SourceRuleCode { get; set; }
  118. /// <summary>R1 源对象类型(DEVICE / ORDER 等,首版仅落列)。</summary>
  119. [SugarColumn(ColumnName = "source_object_type", Length = 64, IsNullable = true)]
  120. public string? SourceObjectType { get; set; }
  121. /// <summary>R1 源对象主键或业务 ID(字符串以适配跨表/跨域,首版仅落列)。</summary>
  122. [SugarColumn(ColumnName = "source_object_id", Length = 64, IsNullable = true)]
  123. public string? SourceObjectId { get; set; }
  124. // ============================================================
  125. // S8-SCHED-SCHEMA-1:已建异常的抗抖累计字段(仅落列,本轮不接逻辑)
  126. // 仅用于已建异常后的刷新/恢复抗抖;建单前抗抖落在 AdoS8RuleDetectionState。
  127. // ============================================================
  128. /// <summary>已建异常被规则连续命中的次数(用于刷新阶段抗抖)。</summary>
  129. [SugarColumn(ColumnName = "consecutive_hit_count")]
  130. public int ConsecutiveHitCount { get; set; } = 1;
  131. /// <summary>已建异常被规则连续未命中的次数(用于恢复阶段抗抖)。</summary>
  132. [SugarColumn(ColumnName = "consecutive_miss_count")]
  133. public int ConsecutiveMissCount { get; set; } = 0;
  134. }