using Admin.NET.Core; using SqlSugar; namespace Admin.NET.Plugin.AiDOP.Entity; /// /// KPI 计算配置(SQL 配置化引擎)。一 KPI 多版本,含发布状态机与审计。 /// 独立于 ado_smart_ops_kpi_master(看板热路径),SQL 敏感配置单独承载。 /// 同一 (TenantId, MetricCode) 仅一个 IsCurrent=1 的生效版本,由服务层事务保证。 /// [SugarTable("ado_smart_ops_kpi_calc_config", "KPI 计算配置(SQL 配置化)")] [SugarIndex("uk_kpi_calc_cfg_metric_ver", nameof(MetricCode), OrderByType.Asc, nameof(TenantId), OrderByType.Asc, nameof(VersionNo), OrderByType.Asc, true)] public class AdoSmartOpsKpiCalcConfig : ITenantIdFilter { [SugarColumn(ColumnDescription = "主键", IsPrimaryKey = true, IsIdentity = true, ColumnDataType = "bigint")] public long Id { get; set; } [SugarColumn(ColumnDescription = "租户 ID", ColumnDataType = "bigint", IsNullable = true)] public long? TenantId { get; set; } [SugarColumn(ColumnDescription = "指标编码 如 S5_L1_001", Length = 50)] public string MetricCode { get; set; } = string.Empty; [SugarColumn(ColumnDescription = "模块 S1~S9", Length = 20)] public string ModuleCode { get; set; } = string.Empty; [SugarColumn(ColumnDescription = "版本号(同 KPI 内递增)")] public int VersionNo { get; set; } [SugarColumn(ColumnDescription = "计算引擎 LEGACY_CODE / CONFIG_SQL / LEGACY_TVF", Length = 20)] public string CalcEngineType { get; set; } = "CONFIG_SQL"; [SugarColumn(ColumnDescription = "数据源编码(已登记数据源,禁连接串)", Length = 100, IsNullable = true)] public string? DataSourceCode { get; set; } [SugarColumn(ColumnDescription = "只读 SQL 脚本", ColumnDataType = "text", IsNullable = true)] public string? SqlScript { get; set; } [SugarColumn(ColumnDescription = "参数声明 JSON(元数据,运行绑定由引擎注入)", ColumnDataType = "text", IsNullable = true)] public string? SqlParametersJson { get; set; } [SugarColumn(ColumnDescription = "查询超时(秒),受系统上限约束")] public int TimeoutSeconds { get; set; } = 30; [SugarColumn(ColumnDescription = "发布状态 DRAFT / PUBLISHED / RETIRED", Length = 20)] public string PublishStatus { get; set; } = "DRAFT"; [SugarColumn(ColumnDescription = "是否当前生效版本(同 KPI 唯一)")] public bool IsCurrent { get; set; } [SugarColumn(ColumnDescription = "备注", ColumnDataType = "text", IsNullable = true)] public string? Remark { get; set; } [SugarColumn(ColumnDescription = "创建人", Length = 100, IsNullable = true)] public string? CreatedBy { get; set; } [SugarColumn(ColumnDescription = "创建时间")] public DateTime CreatedAt { get; set; } [SugarColumn(ColumnDescription = "更新人", Length = 100, IsNullable = true)] public string? UpdatedBy { get; set; } [SugarColumn(ColumnDescription = "更新时间", IsNullable = true)] public DateTime? UpdatedAt { get; set; } [SugarColumn(ColumnDescription = "发布人", Length = 100, IsNullable = true)] public string? PublishedBy { get; set; } [SugarColumn(ColumnDescription = "发布时间", IsNullable = true)] public DateTime? PublishedAt { get; set; } [SugarColumn(ColumnDescription = "停用人", Length = 100, IsNullable = true)] public string? RetiredBy { get; set; } [SugarColumn(ColumnDescription = "停用时间", IsNullable = true)] public DateTime? RetiredAt { get; set; } }