using Admin.NET.Core; using SqlSugar; namespace Admin.NET.Plugin.AiDOP.Entity; /// /// KPI 维度计算配置(DIMENSION_SQL 配置化)。为筛选/下钻产生可按维度拆分的结果, /// 与当前生效的汇总配置(ado_smart_ops_kpi_calc_config)版本绑定。 /// 独立于汇总配置模型,绝不改动 SUMMARY_SQL。 /// 同一 (TenantId, MetricCode) 仅一个 IsCurrent=1 的生效维度版本,由服务层事务保证。 /// [SugarTable("ado_smart_ops_kpi_dimension_config", "KPI 维度计算配置(DIMENSION_SQL 配置化)")] [SugarIndex("uk_kpi_dim_cfg_metric_sum_ver", nameof(MetricCode), OrderByType.Asc, nameof(TenantId), OrderByType.Asc, nameof(SummaryConfigId), OrderByType.Asc, nameof(DimensionConfigVersion), OrderByType.Asc, true)] public class AdoSmartOpsKpiDimensionConfig : 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 = "指标编码 如 S7_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 = "绑定的汇总配置 Id(ado_smart_ops_kpi_calc_config.Id)")] public long SummaryConfigId { get; set; } [SugarColumn(ColumnDescription = "绑定的汇总配置版本号")] public int SummaryConfigVersion { get; set; } [SugarColumn(ColumnDescription = "维度配置版本号(同 KPI+汇总版本内递增)")] public int DimensionConfigVersion { get; set; } [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 = "聚合类型 DIRECT_VALUE / RATIO_OF_SUMS / AVERAGE_OF_SUMS / SUMMARY_ONLY", Length = 30)] public string AggregationType { get; set; } = "SUMMARY_ONLY"; [SugarColumn(ColumnDescription = "支持维度声明 JSON 数组(如 [\"value_date\",\"order_no\"])", ColumnDataType = "text", IsNullable = true)] public string? SupportedDimensionsJson { get; set; } [SugarColumn(ColumnDescription = "输出契约声明 JSON(元数据)", ColumnDataType = "text", IsNullable = true)] public string? OutputContractJson { get; set; } [SugarColumn(ColumnDescription = "参数声明 JSON(元数据,运行绑定由引擎注入)", ColumnDataType = "text", IsNullable = true)] public string? ParameterContractJson { get; set; } [SugarColumn(ColumnDescription = "查询超时(秒),受系统上限约束")] public int TimeoutSeconds { get; set; } = 60; [SugarColumn(ColumnDescription = "发布状态 DRAFT / PUBLISHED / RETIRED", Length = 20)] public string PublishStatus { get; set; } = "DRAFT"; [SugarColumn(ColumnDescription = "是否当前生效版本(同 KPI 唯一)")] public bool IsCurrent { get; set; } [SugarColumn(ColumnDescription = "业务 SQL 来源", Length = 200, IsNullable = true)] public string? BusinessSqlSource { get; set; } [SugarColumn(ColumnDescription = "变更说明", ColumnDataType = "text", IsNullable = true)] public string? ChangeRemark { 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; } }