AdoSmartOpsKpiCalcRunLog.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using Admin.NET.Core;
  2. using SqlSugar;
  3. namespace Admin.NET.Plugin.AiDOP.Entity;
  4. /// <summary>
  5. /// KPI 计算 SQL 执行运行日志(单 KPI 粒度,含配置版本 + SQL 指纹 + 分子分母)。
  6. /// mdp_transform_run_log 是批次级、表达不了 per-KPI + config version,故独立此表。
  7. /// 只记 SqlHash + ConfigId,不落 SQL 明文(SQL 原文在受权限控制的配置表)。
  8. /// </summary>
  9. [SugarTable("ado_smart_ops_kpi_calc_run_log", "KPI 计算 SQL 运行日志")]
  10. [SugarIndex("uk_kpi_calc_run_metric_batch", nameof(MetricCode), OrderByType.Asc, nameof(BatchId), OrderByType.Asc, true)]
  11. [SugarIndex("idx_kpi_calc_run_metric_time", nameof(MetricCode), OrderByType.Asc, nameof(StartedAt), OrderByType.Desc, false)]
  12. public class AdoSmartOpsKpiCalcRunLog : ITenantIdFilter
  13. {
  14. [SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true, IsIdentity = true, ColumnDataType = "bigint")]
  15. public long Id { get; set; }
  16. [SugarColumn(ColumnDescription = "租户 ID", ColumnDataType = "bigint", IsNullable = true)]
  17. public long? TenantId { get; set; }
  18. [SugarColumn(ColumnDescription = "批次 ID(关联 mdp_transform_run_log.batch_id)", Length = 100)]
  19. public string BatchId { get; set; } = string.Empty;
  20. [SugarColumn(ColumnDescription = "模块 S1~S9", Length = 20)]
  21. public string ModuleCode { get; set; } = string.Empty;
  22. [SugarColumn(ColumnDescription = "指标编码", Length = 50)]
  23. public string MetricCode { get; set; } = string.Empty;
  24. [SugarColumn(ColumnDescription = "计算配置 ID(LEGACY 无配置时可空)", ColumnDataType = "bigint", IsNullable = true)]
  25. public long? ConfigId { get; set; }
  26. [SugarColumn(ColumnDescription = "配置版本号", IsNullable = true)]
  27. public int? VersionNo { get; set; }
  28. [SugarColumn(ColumnDescription = "引擎 LEGACY_CODE / CONFIG_SQL / LEGACY_TVF", Length = 20)]
  29. public string EngineType { get; set; } = string.Empty;
  30. [SugarColumn(ColumnDescription = "数据源编码", Length = 100, IsNullable = true)]
  31. public string? DataSourceCode { get; set; }
  32. [SugarColumn(ColumnDescription = "业务日期", ColumnDataType = "date")]
  33. public DateTime BizDate { get; set; }
  34. [SugarColumn(ColumnDescription = "开始时间")]
  35. public DateTime StartedAt { get; set; }
  36. [SugarColumn(ColumnDescription = "结束时间", IsNullable = true)]
  37. public DateTime? FinishedAt { get; set; }
  38. [SugarColumn(ColumnDescription = "耗时毫秒")]
  39. public long DurationMs { get; set; }
  40. [SugarColumn(ColumnDescription = "状态 SUCCESS / NO_DATA / FAILED", Length = 20)]
  41. public string Status { get; set; } = string.Empty;
  42. [SugarColumn(ColumnDescription = "返回行数")]
  43. public int RowCount { get; set; }
  44. [SugarColumn(ColumnDescription = "指标值", ColumnDataType = "decimal(18,4)", IsNullable = true)]
  45. public decimal? MetricValue { get; set; }
  46. [SugarColumn(ColumnDescription = "分子", ColumnDataType = "decimal(18,4)", IsNullable = true)]
  47. public decimal? NumeratorValue { get; set; }
  48. [SugarColumn(ColumnDescription = "分母", ColumnDataType = "decimal(18,4)", IsNullable = true)]
  49. public decimal? DenominatorValue { get; set; }
  50. [SugarColumn(ColumnDescription = "错误码", Length = 50, IsNullable = true)]
  51. public string? ErrorCode { get; set; }
  52. [SugarColumn(ColumnDescription = "错误摘要", Length = 500, IsNullable = true)]
  53. public string? ErrorMessage { get; set; }
  54. [SugarColumn(ColumnDescription = "SQL 指纹 SHA256(不落明文)", Length = 64, IsNullable = true)]
  55. public string? SqlHash { get; set; }
  56. [SugarColumn(ColumnDescription = "参数快照 JSON", ColumnDataType = "text", IsNullable = true)]
  57. public string? ParameterSnapshot { get; set; }
  58. [SugarColumn(ColumnDescription = "触发类型 AUTO / MANUAL / PREVIEW", Length = 20)]
  59. public string TriggerType { get; set; } = string.Empty;
  60. [SugarColumn(ColumnDescription = "创建时间")]
  61. public DateTime CreateTime { get; set; }
  62. }