AdoS8Exception.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. /// <summary>S8-SEVERITY-FOLLOW-SERIOUS-STANDARDIZE-EXEC-1:业务枚举 FOLLOW(关注)/ SERIOUS(严重)。</summary>
  33. [SugarColumn(ColumnName = "severity", Length = 32)]
  34. public string Severity { get; set; } = "FOLLOW";
  35. [SugarColumn(ColumnName = "priority_score", ColumnDataType = "decimal(10,2)")]
  36. public decimal PriorityScore { get; set; }
  37. [SugarColumn(ColumnName = "priority_level", Length = 16)]
  38. public string PriorityLevel { get; set; } = "P3";
  39. [SugarColumn(ColumnName = "occurrence_dept_id", ColumnDataType = "bigint")]
  40. public long OccurrenceDeptId { get; set; }
  41. [SugarColumn(ColumnName = "responsible_dept_id", ColumnDataType = "bigint")]
  42. public long ResponsibleDeptId { get; set; }
  43. [SugarColumn(ColumnName = "responsible_group_id", ColumnDataType = "bigint", IsNullable = true)]
  44. public long? ResponsibleGroupId { get; set; }
  45. [SugarColumn(ColumnName = "assignee_id", ColumnDataType = "bigint", IsNullable = true)]
  46. public long? AssigneeId { get; set; }
  47. [SugarColumn(ColumnName = "reporter_id", ColumnDataType = "bigint", IsNullable = true)]
  48. public long? ReporterId { get; set; }
  49. [SugarColumn(ColumnName = "sla_deadline", IsNullable = true)]
  50. public DateTime? SlaDeadline { get; set; }
  51. [SugarColumn(ColumnName = "timeout_flag", ColumnDataType = "boolean")]
  52. public bool TimeoutFlag { get; set; }
  53. [SugarColumn(ColumnName = "created_at")]
  54. public DateTime CreatedAt { get; set; } = DateTime.Now;
  55. [SugarColumn(ColumnName = "updated_at", IsNullable = true)]
  56. public DateTime? UpdatedAt { get; set; }
  57. [SugarColumn(ColumnName = "assigned_at", IsNullable = true)]
  58. public DateTime? AssignedAt { get; set; }
  59. [SugarColumn(ColumnName = "closed_at", IsNullable = true)]
  60. public DateTime? ClosedAt { get; set; }
  61. /// <summary>所属模块码(S1-S7),标识异常产生于哪个业务环节</summary>
  62. [SugarColumn(ColumnName = "module_code", Length = 16, IsNullable = true)]
  63. public string? ModuleCode { get; set; }
  64. [SugarColumn(ColumnName = "process_node_code", Length = 64, IsNullable = true)]
  65. public string? ProcessNodeCode { get; set; }
  66. [SugarColumn(ColumnName = "related_object_code", Length = 64, IsNullable = true)]
  67. public string? RelatedObjectCode { get; set; }
  68. /// <summary>当前进行中的审批实例ID(用于并发控制)</summary>
  69. [SugarColumn(ColumnName = "active_flow_instance_id", IsNullable = true)]
  70. public long? ActiveFlowInstanceId { get; set; }
  71. /// <summary>当前进行中的审批业务类型(EXCEPTION_ESCALATION / EXCEPTION_CLOSURE)</summary>
  72. [SugarColumn(ColumnName = "active_flow_biz_type", Length = 32, IsNullable = true)]
  73. public string? ActiveFlowBizType { get; set; }
  74. [SugarColumn(ColumnName = "is_deleted", ColumnDataType = "boolean")]
  75. public bool IsDeleted { get; set; }
  76. [SugarColumn(ColumnName = "created_by", Length = 64, IsNullable = true)]
  77. public string? CreatedBy { get; set; }
  78. [SugarColumn(ColumnName = "updated_by", Length = 64, IsNullable = true)]
  79. public string? UpdatedBy { get; set; }
  80. /// <summary>异常类型编码(关联 ado_s8_exception_type.type_code)。配置化改造后新增。</summary>
  81. [SugarColumn(ColumnName = "exception_type_code", Length = 64, IsNullable = true)]
  82. public string? ExceptionTypeCode { get; set; }
  83. /// <summary>来源数据源 ID(自动建单时填充;人工提报为空)。关联 ado_s8_data_source.id</summary>
  84. [SugarColumn(ColumnName = "source_data_source_id", ColumnDataType = "bigint", IsNullable = true)]
  85. public long? SourceDataSourceId { get; set; }
  86. /// <summary>来源监视规则 ID(自动建单时填充)。关联 ado_s8_watch_rule.id</summary>
  87. [SugarColumn(ColumnName = "source_rule_id", ColumnDataType = "bigint", IsNullable = true)]
  88. public long? SourceRuleId { get; set; }
  89. /// <summary>命中规则时的原始数据快照(JSON 文本,便于追溯)</summary>
  90. [SugarColumn(ColumnName = "source_payload", Length = 4000, IsNullable = true)]
  91. public string? SourcePayload { get; set; }
  92. /// <summary>检验人ID(提交复检时手选)</summary>
  93. [SugarColumn(ColumnName = "verifier_id", ColumnDataType = "bigint", IsNullable = true)]
  94. public long? VerifierId { get; set; }
  95. /// <summary>提交复检时间</summary>
  96. [SugarColumn(ColumnName = "verification_assigned_at", IsNullable = true)]
  97. public DateTime? VerificationAssignedAt { get; set; }
  98. /// <summary>检验完成时间</summary>
  99. [SugarColumn(ColumnName = "verified_at", IsNullable = true)]
  100. public DateTime? VerifiedAt { get; set; }
  101. /// <summary>检验结果(APPROVED / REJECTED)</summary>
  102. [SugarColumn(ColumnName = "verification_result", Length = 32, IsNullable = true)]
  103. public string? VerificationResult { get; set; }
  104. /// <summary>检验意见</summary>
  105. [SugarColumn(ColumnName = "verification_remark", Length = 2000, IsNullable = true)]
  106. public string? VerificationRemark { get; set; }
  107. /// <summary>R1 持久化去重键(首版仅普通列,唯一约束在后续小步加)。</summary>
  108. [SugarColumn(ColumnName = "dedup_key", Length = 128, IsNullable = true)]
  109. public string? DedupKey { get; set; }
  110. /// <summary>R1 最近一次被规则检测命中的时间(首版仅落列,service 暂不写)。</summary>
  111. [SugarColumn(ColumnName = "last_detected_at", IsNullable = true)]
  112. public DateTime? LastDetectedAt { get; set; }
  113. /// <summary>R1 规则恢复时间(首版仅落列,service 暂不写)。</summary>
  114. [SugarColumn(ColumnName = "recovered_at", IsNullable = true)]
  115. public DateTime? RecoveredAt { get; set; }
  116. /// <summary>R1 来源规则人读编码(与 source_rule_id 配合,首版仅落列)。</summary>
  117. [SugarColumn(ColumnName = "source_rule_code", Length = 64, IsNullable = true)]
  118. public string? SourceRuleCode { get; set; }
  119. /// <summary>R1 源对象类型(DEVICE / ORDER 等,首版仅落列)。</summary>
  120. [SugarColumn(ColumnName = "source_object_type", Length = 64, IsNullable = true)]
  121. public string? SourceObjectType { get; set; }
  122. /// <summary>R1 源对象主键或业务 ID(字符串以适配跨表/跨域,首版仅落列)。</summary>
  123. [SugarColumn(ColumnName = "source_object_id", Length = 64, IsNullable = true)]
  124. public string? SourceObjectId { get; set; }
  125. // ============================================================
  126. // S8-SCHED-SCHEMA-1:已建异常的抗抖累计字段(仅落列,本轮不接逻辑)
  127. // 仅用于已建异常后的刷新/恢复抗抖;建单前抗抖落在 AdoS8RuleDetectionState。
  128. // ============================================================
  129. /// <summary>已建异常被规则连续命中的次数(用于刷新阶段抗抖)。</summary>
  130. [SugarColumn(ColumnName = "consecutive_hit_count")]
  131. public int ConsecutiveHitCount { get; set; } = 1;
  132. /// <summary>已建异常被规则连续未命中的次数(用于恢复阶段抗抖)。</summary>
  133. [SugarColumn(ColumnName = "consecutive_miss_count")]
  134. public int ConsecutiveMissCount { get; set; } = 0;
  135. }