namespace Admin.NET.Plugin.AiDOP.Dto.SmartOps;
/// 新增/编辑草稿。
public sealed class KpiCalcConfigUpsertDto
{
public string MetricCode { get; set; } = string.Empty;
public string ModuleCode { get; set; } = string.Empty;
public string CalcEngineType { get; set; } = "CONFIG_SQL";
public string? DataSourceCode { get; set; }
public string? SqlScript { get; set; }
public string? SqlParametersJson { get; set; }
public int TimeoutSeconds { get; set; } = 30;
public string? Remark { get; set; }
}
/// 配置版本输出。
public sealed class KpiCalcConfigDto
{
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 int VersionNo { get; set; }
public string CalcEngineType { get; set; } = string.Empty;
public string? DataSourceCode { get; set; }
public string? SqlScript { get; set; }
public string? SqlParametersJson { get; set; }
public int TimeoutSeconds { get; set; }
public string PublishStatus { get; set; } = string.Empty;
public bool IsCurrent { 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; }
}
/// SQL 校验入参。
public sealed class KpiSqlValidateDto
{
public string? SqlScript { get; set; }
}
/// SQL 校验结果。
public sealed class KpiSqlValidateResultDto
{
public bool Ok { get; set; }
public string ValidationStatus { get; set; } = string.Empty; // VALID / INVALID
public string? ErrorCode { get; set; }
public string? ErrorMessage { get; set; }
public List ReferencedTables { get; set; } = new();
}
/// 试算入参(服务端重读/重校验,不信任前端 tenant/权限)。
public sealed class KpiSqlPreviewDto
{
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 int TimeoutSeconds { get; set; } = 20;
public DateTime? BizDate { get; set; }
}
/// 试算结果(不写正式 KPI 值)。
public sealed class KpiSqlPreviewResultDto
{
public bool Ok { get; set; }
public string ValidationStatus { get; set; } = string.Empty;
public string MetricCode { get; set; } = string.Empty;
public string EngineType { get; set; } = "CONFIG_SQL";
public string? DataSourceCode { get; set; }
public string BizDate { get; set; } = string.Empty;
public long DurationMs { get; set; }
public int RowCount { get; set; }
public decimal? MetricValue { get; set; }
public decimal? NumeratorValue { get; set; }
public decimal? DenominatorValue { get; set; }
public string ResultStatus { get; set; } = string.Empty; // SUCCESS / NO_DATA / FAILED
public string? ResultMessage { get; set; }
public string? ExecutedParameters { get; set; }
public string? ErrorCode { get; set; }
public string? ErrorMessage { get; set; }
}