namespace Admin.NET.Plugin.AiDOP.Dto.SmartOps; /// 维度配置读出 DTO。 public sealed class KpiDimensionConfigDto { public long Id { get; set; } public long? TenantId { get; set; } public string MetricCode { get; set; } = string.Empty; public string ModuleCode { get; set; } = string.Empty; public long SummaryConfigId { get; set; } public int SummaryConfigVersion { get; set; } public int DimensionConfigVersion { get; set; } public string? DataSourceCode { get; set; } public string? SqlScript { get; set; } public string AggregationType { get; set; } = "SUMMARY_ONLY"; public string? SupportedDimensionsJson { get; set; } public string? OutputContractJson { get; set; } public string? ParameterContractJson { get; set; } public int TimeoutSeconds { get; set; } public string PublishStatus { get; set; } = "DRAFT"; public bool IsCurrent { get; set; } public string? BusinessSqlSource { get; set; } public string? ChangeRemark { get; set; } public string? Remark { get; set; } public string? CreatedBy { get; set; } public DateTime CreatedAt { get; set; } public string? PublishedBy { get; set; } public DateTime? PublishedAt { get; set; } } /// 维度配置新增/编辑草稿 DTO。 public sealed class KpiDimensionConfigUpsertDto { public string MetricCode { get; set; } = string.Empty; public string ModuleCode { get; set; } = string.Empty; public string? DataSourceCode { get; set; } public string? SqlScript { get; set; } public string AggregationType { get; set; } = "SUMMARY_ONLY"; public string? SupportedDimensionsJson { get; set; } public string? OutputContractJson { get; set; } public string? ParameterContractJson { get; set; } public int TimeoutSeconds { get; set; } public string? BusinessSqlSource { get; set; } public string? ChangeRemark { get; set; } public string? Remark { get; set; } } /// 维度试算入参。 public sealed class KpiDimensionPreviewDto { public string MetricCode { get; set; } = string.Empty; public string ModuleCode { get; set; } = string.Empty; public string? DataSourceCode { get; set; } public string? SqlScript { get; set; } public string AggregationType { get; set; } = "SUMMARY_ONLY"; public int TimeoutSeconds { get; set; } public DateTime? BizDate { get; set; } } /// 维度试算结果(含前 N 行样本 + 契约校验)。 public sealed class KpiDimensionPreviewResultDto { public bool Ok { get; set; } public string MetricCode { get; set; } = string.Empty; public string? DataSourceCode { get; set; } public string BizDate { get; set; } = string.Empty; public string ValidationStatus { get; set; } = string.Empty; public string ResultStatus { get; set; } = string.Empty; public long DurationMs { get; set; } public int RowCount { get; set; } public List OutputColumns { get; set; } = new(); public List SupportedDimensions { get; set; } = new(); public List> SampleRows { get; set; } = new(); public string? ErrorCode { get; set; } public string? ErrorMessage { get; set; } public string ExecutedParameters { get; set; } = string.Empty; } /// KPI 维度能力(驱动前端筛选/下钻可用性)。 public sealed class KpiDimensionCapabilityDto { public string MetricCode { get; set; } = string.Empty; public string ModuleCode { get; set; } = string.Empty; /// 是否已配置并激活维度(PENDING_DIMENSION_SQL 时 false)。 public bool Supported { get; set; } /// 能力状态 PENDING_DIMENSION_SQL / CONFIGURED / SUMMARY_ONLY / VERSION_MISMATCH。 public string CapabilityStatus { get; set; } = "PENDING_DIMENSION_SQL"; /// 【兼容旧字段】= 维度配置绑定的汇总版本(历史调用方勿依赖其为“当前汇总版本”)。新调用方改用 BoundSummaryConfigVersion / CurrentSummaryConfigVersion。 public int? SummaryConfigVersion { get; set; } /// 维度配置绑定的汇总配置 Id。 public long? BoundSummaryConfigId { get; set; } /// 维度配置绑定的汇总版本。 public int? BoundSummaryConfigVersion { get; set; } /// 当前生效的汇总配置 Id(可能已推进超过维度绑定)。 public long? CurrentSummaryConfigId { get; set; } /// 当前生效的汇总版本。 public int? CurrentSummaryConfigVersion { get; set; } /// 维度绑定汇总(Id+Version)是否与当前生效汇总一致;false 表示汇总已推进、维度需重绑。 public bool IsSummaryBindingConsistent { get; set; } public int? DimensionConfigVersion { get; set; } public List SupportedDimensions { get; set; } = new(); public string? AggregationType { get; set; } public string? LastRunStatus { get; set; } public DateTime? LastRunAt { get; set; } } /// 维度明细单行(只读查询)。 public sealed class KpiDimensionDetailRowDto { public string ValueDate { get; set; } = string.Empty; public string DimensionType { get; set; } = string.Empty; public string DimensionCode { get; set; } = string.Empty; public string? DimensionName { get; set; } public decimal? MetricValue { get; set; } public decimal? Numerator { get; set; } public decimal? Denominator { get; set; } public decimal? SumValue { get; set; } public int? SampleCount { get; set; } public string? SourceKey { get; set; } public string? BatchId { get; set; } } /// 维度明细只读查询结果(含按 AggregationType 复算的聚合值 + 分页明细)。 public sealed class KpiDimensionDetailResultDto { public string MetricCode { get; set; } = string.Empty; /// OK / NOT_CONFIGURED。 public string Status { get; set; } = "OK"; public int? SummaryConfigVersion { get; set; } public int? DimensionConfigVersion { get; set; } public string? AggregationType { get; set; } /// 当前筛选范围按 AggregationType 复算的聚合值(后端算,前端只展示)。 public decimal? AggregateValue { get; set; } public int Total { get; set; } public List List { get; set; } = new(); }