S8OrderFlowSubstepUnitSeedData.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using Admin.NET.Plugin.AiDOP.Entity.S8.OrderFlow;
  2. namespace Admin.NET.Plugin.AiDOP.SeedData;
  3. /// <summary>
  4. /// ORDER-FLOW-S8-INTEGRATED-DOMAIN-RESET-1 t2b:OPINION_REVIEW 子节点下 L3 责任单元种子。
  5. /// 20 单 × 4 责任单元 = 80 行,全部挂在 substep_code = OPINION_REVIEW;SO-2026-001 按 PPT 第 2 页真值,
  6. /// 其余 19 单按 (orderIdx, unitIdx) 派生 multiplier,确定性、可重入。
  7. /// </summary>
  8. [IncreSeed]
  9. public class S8OrderFlowSubstepUnitSeedData : ISqlSugarEntitySeedData<AdoS8OrderFlowSubstepUnit>
  10. {
  11. public IEnumerable<AdoS8OrderFlowSubstepUnit> HasData() => S8OrderFlowSubstepUnitDataset.BuildUnits();
  12. }
  13. internal static class S8OrderFlowSubstepUnitDataset
  14. {
  15. internal const long UnitIdBase = 1329909130000L;
  16. internal const string FlowCode = "ORDER_REVIEW_PLAN_CALC";
  17. internal const string SubstepCode = "OPINION_REVIEW";
  18. /// <summary>L3 四方责任单元固定顺序与 PI 基线工时。</summary>
  19. internal static readonly (string Code, string Name, decimal PiHours)[] L3Def =
  20. {
  21. ("LEGAL", "法律事务部", 2m),
  22. ("TECH_PRESALE", "技术售前组", 3m),
  23. ("GENERAL_PLAN", "综合主计划", 1m),
  24. ("LAB", "试验站", 2m),
  25. };
  26. /// <summary>SO-2026-001 PPT 第 2 页 L3 真值:actual_hours / status,与 L3Def 同序。</summary>
  27. private static readonly (decimal Actual, string Status)[] Ppt001L3 =
  28. {
  29. (2.0m, "green"),
  30. (9.2m, "red"),
  31. (1.2m, "yellow"),
  32. (2.0m, "green"),
  33. };
  34. /// <summary>
  35. /// 19 个非 PPT 单的 L3 派生 multiplier 桶。
  36. /// bucketIdx = (idx - 2 + unitIdx) mod 4,对应 4 种 (multiplier, status) 组合。
  37. /// status 满足:multiplier ≤ 1.00 = green;1.00 &lt; multiplier ≤ 1.25 = yellow;&gt; 1.25 = red。
  38. /// </summary>
  39. private static readonly (decimal Mult, string Status)[] L3Buckets =
  40. {
  41. (0.95m, "green"),
  42. (1.15m, "yellow"),
  43. (1.35m, "red"),
  44. (1.05m, "yellow"),
  45. };
  46. public static IEnumerable<AdoS8OrderFlowSubstepUnit> BuildUnits()
  47. {
  48. long seq = 0;
  49. foreach (var spec in S8OrderFlowDataset.Specs)
  50. {
  51. var orderId = S8OrderFlowDataset.OrderIdBase + spec.Idx;
  52. var substepId = S8OrderFlowSubstepDataset.OpinionReviewSubstepId(spec.Idx);
  53. var isPpt = spec.OrderCode == "SO-2026-001";
  54. var scenario = isPpt ? "PPT" : "DEMO";
  55. for (var i = 0; i < L3Def.Length; i++)
  56. {
  57. var (code, name, piHours) = L3Def[i];
  58. decimal actual;
  59. string status;
  60. if (isPpt)
  61. {
  62. actual = Ppt001L3[i].Actual;
  63. status = Ppt001L3[i].Status;
  64. }
  65. else
  66. {
  67. var bucketIdx = ((spec.Idx - 2) + i) % L3Buckets.Length;
  68. var bucket = L3Buckets[bucketIdx];
  69. actual = decimal.Round(piHours * bucket.Mult, 1);
  70. status = bucket.Status;
  71. }
  72. yield return new AdoS8OrderFlowSubstepUnit
  73. {
  74. Id = UnitIdBase + (++seq),
  75. SubstepId = substepId,
  76. OrderId = orderId,
  77. OrderCode = spec.OrderCode,
  78. OrderFlowCode = FlowCode,
  79. SubstepCode = SubstepCode,
  80. UnitCode = code,
  81. UnitName = name,
  82. PiHours = piHours,
  83. ActualHours = actual,
  84. Status = status,
  85. SortNo = i + 1,
  86. ScenarioCode = scenario,
  87. DataSource = "SEED",
  88. TenantId = 1,
  89. FactoryId = 1,
  90. CreatedAt = S8OrderFlowDataset.CreatedAt,
  91. UpdatedAt = null,
  92. IsDeleted = false,
  93. };
  94. }
  95. }
  96. }
  97. }