namespace Admin.NET.Plugin.AiDOP.DataPlatform.S1Refresh; /// S1 全量重算不可为空的租户/工厂作用域。 public sealed record S1MdpRunScope(long TenantId, long FactoryId) { public static S1MdpRunScope Create(long tenantId, long factoryId) { if (tenantId <= 0) throw new InvalidOperationException("S1 全量重算必须指定有效 tenantId,禁止 tenantId=0"); if (factoryId <= 0) throw new InvalidOperationException("S1 全量重算必须指定有效 factoryId"); if (factoryId == tenantId) throw new InvalidOperationException("S1 全量重算的 factoryId 不能等于 tenantId"); return new S1MdpRunScope(tenantId, factoryId); } public string LockName => $"S1_MDP_FULL:{TenantId}:{FactoryId}"; public string ScopeKey => $"{TenantId}:{FactoryId}"; } public static class S1MdpRebuildStage { public const string Queued = "QUEUED"; public const string AcquiringLock = "ACQUIRING_LOCK"; public const string Preparing = "PREPARING"; public const string Staging = "STAGING"; public const string Standard = "STANDARD"; public const string Dwd = "DWD"; public const string Kpi = "KPI"; public const string Atomic = "ATOMIC"; public const string Finalizing = "FINALIZING"; public const string Success = "SUCCESS"; public const string Failed = "FAILED"; public const string Cancelled = "CANCELLED"; public const int StageTotal = 5; public static int ToStageIndex(string stage) => stage switch { Staging => 1, Standard => 2, Dwd => 3, Kpi => 4, Atomic or Finalizing or Success => 5, _ => 0 }; public static string ToChinese(string? stage) => stage switch { Queued => "排队中", AcquiringLock => "等待资源", Preparing => "准备运行环境", Staging => "拉取源数据", Standard => "标准化数据", Dwd => "生成 DWD 明细", Kpi => "重算 KPI", Atomic => "重建原子数据", Finalizing => "收尾", Success => "已完成", Failed => "失败", Cancelled => "已取消", _ => stage ?? "" }; } public sealed record S1MdpProgressUpdate( string Stage, int StageIndex, int ProgressPercent, string Message, int? Rows = null, string? CompletedStage = null); public sealed class S1MdpScopeRow { public long TenantId { get; set; } public long FactoryId { get; set; } }