فهرست منبع

refactor(s8): add s1-s7 scene code compatibility

YY968XX 2 ماه پیش
والد
کامیت
f6d9b5aed3
1فایلهای تغییر یافته به همراه87 افزوده شده و 18 حذف شده
  1. 87 18
      server/Plugins/Admin.NET.Plugin.AiDOP/Infrastructure/S8/S8SceneCode.cs

+ 87 - 18
server/Plugins/Admin.NET.Plugin.AiDOP/Infrastructure/S8/S8SceneCode.cs

@@ -1,44 +1,105 @@
 namespace Admin.NET.Plugin.AiDOP.Infrastructure.S8;
 
 /// <summary>
-/// S8 异常场景码常量。
-/// scene_code 格式:S{模块组}_场景域,方便前端按监控页分类。
+/// S8 异常场景码常量(双轨)。
+///
+/// 新单模块 scene(S1-S7)与旧复合 scene(S1S7_DELIVERY 等)共存:
+///   - 新代码请使用 S1-S7 单模块 scene;
+///   - 旧复合常量保留向下兼容,<see cref="Modules"/> / <see cref="Label"/>
+///     /<see cref="S8ModuleCode.FromScene"/> 等仍可识别。
+///
+/// 迁移轨道:S8-SCENE-MIGRATE-CODE-DUALRAIL-1(本轮,仅代码双轨,不动 DB)。
+/// 后续 S8-SCENE-MIGRATE-CONFIG-S1S7-1 才迁移 scene_config / exception_type / watch_rule。
 /// </summary>
 public static class S8SceneCode
 {
-    /// <summary>交付异常(S1 订单评审变更 + S7 成品出库交期)</summary>
+    // ─────────────── 新单模块 scene_code(S1-S7) ──────────────────────────────
+    /// <summary>S1 产销协同</summary>
+    public const string S1 = "S1";
+    /// <summary>S2 制造协同</summary>
+    public const string S2 = "S2";
+    /// <summary>S3 供应协同</summary>
+    public const string S3 = "S3";
+    /// <summary>S4 采购执行</summary>
+    public const string S4 = "S4";
+    /// <summary>S5 物料仓储</summary>
+    public const string S5 = "S5";
+    /// <summary>S6 生产执行</summary>
+    public const string S6 = "S6";
+    /// <summary>S7 成品仓储</summary>
+    public const string S7 = "S7";
+
+    // ─────────────── 旧复合 scene_code(保留兼容;新代码请勿使用) ─────────────
+    /// <summary>交付异常(S1 订单评审变更 + S7 成品出库交期)— 旧复合 scene,保留兼容。</summary>
     public const string S1S7Delivery = "S1S7_DELIVERY";
 
-    /// <summary>生产异常(S2 工单开工 + S6 完工/质量)</summary>
+    /// <summary>生产异常(S2 工单开工 + S6 完工/质量)— 旧复合 scene,保留兼容。</summary>
     public const string S2S6Production = "S2S6_PRODUCTION";
 
-    /// <summary>供应异常(S3 MRP套料 + S5 IQC/库存)</summary>
+    /// <summary>供应异常(S3 MRP套料 + S5 IQC/库存)— 旧复合 scene,保留兼容。</summary>
     public const string S3S5Supply = "S3S5_SUPPLY";
 
-    /// <summary>采购执行异常(S4 PO跟单/收货/退货)</summary>
+    /// <summary>采购执行异常(S4 PO跟单/收货/退货)— 旧复合 scene,保留兼容。</summary>
     public const string S4Purchase = "S4_PURCHASE";
 
-    /// <summary>scene_code → 中文名称</summary>
+    // 注:S2S6_QUALITY 是 dev DB 中存在但 C# 常量未定义的旧场景(demo rule 12 引用);
+    // 通过 Label() / Modules() 字面值识别保留兼容,不新增常量以免被新代码引用。
+
+    /// <summary>scene_code → 中文名称(双轨:S1-S7 业务名 + 旧复合保留)</summary>
     public static string Label(string sceneCode) => sceneCode switch
     {
+        S1 => "S1 产销协同",
+        S2 => "S2 制造协同",
+        S3 => "S3 供应协同",
+        S4 => "S4 采购执行",
+        S5 => "S5 物料仓储",
+        S6 => "S6 生产执行",
+        S7 => "S7 成品仓储",
         S1S7Delivery   => "交付异常",
         S2S6Production => "生产异常",
+        "S2S6_QUALITY" => "质量异常",
         S3S5Supply     => "供应异常",
         S4Purchase     => "采购执行异常",
         _              => sceneCode
     };
 
-    /// <summary>scene_code → 所属模块列表(用于页面展示列头)</summary>
+    /// <summary>
+    /// scene_code → 所属模块列表(双轨)。
+    /// 新单模块 scene 1:1 自映射;旧复合 scene 沿用历史映射。
+    /// </summary>
     public static string[] Modules(string sceneCode) => sceneCode switch
     {
+        S1 => new[] { S1 },
+        S2 => new[] { S2 },
+        S3 => new[] { S3 },
+        S4 => new[] { S4 },
+        S5 => new[] { S5 },
+        S6 => new[] { S6 },
+        S7 => new[] { S7 },
         S1S7Delivery   => new[] { "S1", "S7" },
         S2S6Production => new[] { "S2", "S6" },
+        "S2S6_QUALITY" => new[] { "S2", "S6" },
         S3S5Supply     => new[] { "S3", "S5" },
         S4Purchase     => new[] { "S4" },
         _              => Array.Empty<string>()
     };
 
-    /// <summary>所有 scene_code 有序列表(综合全景页列顺序)</summary>
+    /// <summary>新单模块 scene_code 列表(S1-S7)。新代码请使用此清单。</summary>
+    public static readonly string[] ModuleSceneCodes = { S1, S2, S3, S4, S5, S6, S7 };
+
+    /// <summary>旧复合 scene_code 列表(保留兼容;新代码请勿使用)。</summary>
+    public static readonly string[] LegacyCompositeSceneCodes =
+    {
+        S1S7Delivery,
+        S2S6Production,
+        S3S5Supply,
+        S4Purchase
+    };
+
+    /// <summary>
+    /// 历史 scene_code 有序列表(仅含旧复合,保兼容外部遍历调用);
+    /// 新代码请改用 <see cref="ModuleSceneCodes"/>。
+    /// </summary>
     public static readonly string[] All =
     {
         S1S7Delivery,
@@ -74,23 +135,31 @@ public static class S8ModuleCode
         _  => moduleCode
     };
 
-    /// <summary>module_code → 所属 scene_code</summary>
+    /// <summary>
+    /// module_code → 所属 scene_code。
+    /// S8-SCENE-MIGRATE-CODE-DUALRAIL-1 起:优先返回 S1-S7 单模块 scene,
+    /// 不再返回旧复合 scene;如需旧复合归属请直接引用 <see cref="S8SceneCode.S1S7Delivery"/> 等常量。
+    /// </summary>
     public static string SceneOf(string moduleCode) => moduleCode switch
     {
-        S1 or S7 => S8SceneCode.S1S7Delivery,
-        S2 or S6 => S8SceneCode.S2S6Production,
-        S3 or S5 => S8SceneCode.S3S5Supply,
-        S4       => S8SceneCode.S4Purchase,
-        _        => string.Empty
+        S1 => S8SceneCode.S1,
+        S2 => S8SceneCode.S2,
+        S3 => S8SceneCode.S3,
+        S4 => S8SceneCode.S4,
+        S5 => S8SceneCode.S5,
+        S6 => S8SceneCode.S6,
+        S7 => S8SceneCode.S7,
+        _  => string.Empty
     };
 
     /// <summary>所有模块码有序列表</summary>
     public static readonly string[] All = { S1, S2, S3, S4, S5, S6, S7 };
 
     /// <summary>
-    /// 场景码 → 代表模块码(取场景内 S8SceneCode.Modules 的首项)。
-    /// 用于建单时回填 module_code:scene 内含多个 module 时,取代表项作为聚合归属,
-    /// 不替代显式 module_code(caller 可在拿到此值前覆盖)。
+    /// 场景码 → 代表模块码(双轨)。
+    ///   - 新 S1-S7 scene:返回自身(<see cref="S8SceneCode.Modules"/> 1:1 自映射);
+    ///   - 旧复合 scene:返回代表模块(取 <see cref="S8SceneCode.Modules"/> 首项),保留历史行为;
+    /// 用于建单时回填 module_code,caller 可在拿到此值前显式覆盖。
     /// 未识别 scene 返回 null(caller 自决:留空或兜底)。
     /// </summary>
     public static string? FromScene(string? sceneCode)