| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using Admin.NET.Plugin.AiDOP.Entity.S8.OrderFlow;
- namespace Admin.NET.Plugin.AiDOP.SeedData;
- /// <summary>
- /// ORDER-FLOW-S8-INTEGRATED-DOMAIN-RESET-1 t2c:S8 订单执行链路材料采购透视表 baseline 种子。
- /// 3 materials (XX/YY/ZZ) × 4 suppliers (A/B/C/TOTAL) × 4 specs (L4.5*11.2/MT2*6.3/MT1*5.4/TOTAL) = 48 行。
- /// YY 16 单元为 PPT 第 4 页真值;XX/ZZ 16 单元各自按确定性 multiplier 派生(无随机 / 无 Now)。
- /// status 在 seed 时确定,不允许 service/前端动态重判;按 cycle_days 三档阈值固化(≤15 green / 15..20 yellow / >20 red)。
- /// order_id / order_code 全部 NULL(baseline 行)。
- /// </summary>
- [IncreSeed]
- public class S8OrderFlowProcurementPivotSeedData : ISqlSugarEntitySeedData<AdoS8OrderFlowProcurementPivot>
- {
- public IEnumerable<AdoS8OrderFlowProcurementPivot> HasData() => S8OrderFlowProcurementPivotDataset.BuildRows();
- }
- internal static class S8OrderFlowProcurementPivotDataset
- {
- internal const long PivotIdBase = 1329909140000L;
- internal static readonly string[] Suppliers = { "A", "B", "C", "TOTAL" };
- internal static readonly string[] Specs = { "L4.5*11.2", "MT2*6.3", "MT1*5.4", "TOTAL" };
- /// <summary>YY (PPT 第 4 页) 真值矩阵 [supplierIdx, specIdx];保留 3 位小数精度。</summary>
- private static readonly decimal[,] YyCycleDays =
- {
- // L4.5*11.2 | MT2*6.3 | MT1*5.4 | TOTAL
- { 14.800m, 11.000m, 11.000m, 13.000m }, // A
- { 14.050m, 17.150m, 17.150m, 15.600m }, // B
- { 14.050m, 23.925m, 23.850m, 20.100m }, // C
- { 14.500m, 17.400m, 14.800m, 15.300m }, // TOTAL
- };
- /// <summary>派生 XX / ZZ 单元值的 multiplier。XX 偏低、ZZ 偏高,便于 DEMO 拉开差异。</summary>
- private const decimal XxMultiplier = 0.85m;
- private const decimal ZzMultiplier = 1.10m;
- /// <summary>
- /// BASELINE_PPT 关键材料 grand 单元的"影响台次 / 准时齐套率"业务基线。
- /// 仅在 supplier_code=TOTAL && spec_code=TOTAL 行写入,其余 45 行保持 NULL。
- /// </summary>
- private static readonly Dictionary<string, (int ImpactCount, decimal KitRate)> GrandUnitBaseline = new()
- {
- ["XX"] = (55, 0.8500m),
- ["YY"] = (23, 0.8400m),
- ["ZZ"] = (10, 0.9700m),
- };
- public static IEnumerable<AdoS8OrderFlowProcurementPivot> BuildRows()
- {
- long seq = 0;
- foreach (var (material, scenario, mult) in new[]
- {
- ("XX", "DEMO", XxMultiplier),
- ("YY", "PPT", 1.0m),
- ("ZZ", "DEMO", ZzMultiplier),
- })
- {
- for (var s = 0; s < Suppliers.Length; s++)
- {
- for (var p = 0; p < Specs.Length; p++)
- {
- var rawCycle = YyCycleDays[s, p];
- var cycleDays = material == "YY"
- ? rawCycle
- : decimal.Round(rawCycle * mult, 3);
- var isGrand = Suppliers[s] == "TOTAL" && Specs[p] == "TOTAL";
- int? impactCount = null;
- decimal? kitRate = null;
- if (isGrand && GrandUnitBaseline.TryGetValue(material, out var baseline))
- {
- impactCount = baseline.ImpactCount;
- kitRate = baseline.KitRate;
- }
- yield return new AdoS8OrderFlowProcurementPivot
- {
- Id = PivotIdBase + (++seq),
- OrderId = null,
- OrderCode = null,
- MaterialCode = material,
- SupplierCode = Suppliers[s],
- SpecCode = Specs[p],
- CycleDays = cycleDays,
- Status = ClassifyStatus(cycleDays),
- ImpactCount = impactCount,
- KitRate = kitRate,
- ScenarioCode = scenario,
- DataSource = "SEED",
- TenantId = 1,
- FactoryId = 1,
- CreatedAt = S8OrderFlowDataset.CreatedAt,
- UpdatedAt = null,
- IsDeleted = false,
- };
- }
- }
- }
- }
- /// <summary>fixture 级 status 分类(seed-time once),运行期不再重算。</summary>
- private static string ClassifyStatus(decimal cycleDays)
- {
- if (cycleDays <= 15.0m) return "green";
- if (cycleDays <= 20.0m) return "yellow";
- return "red";
- }
- }
|