| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- namespace Admin.NET.Plugin.AiDOP.Infrastructure.S8;
- /// <summary>
- /// 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
- {
- // ─────────────── 新单模块 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 完工/质量)— 旧复合 scene,保留兼容。</summary>
- public const string S2S6Production = "S2S6_PRODUCTION";
- /// <summary>供应异常(S3 MRP套料 + S5 IQC/库存)— 旧复合 scene,保留兼容。</summary>
- public const string S3S5Supply = "S3S5_SUPPLY";
- /// <summary>采购执行异常(S4 PO跟单/收货/退货)— 旧复合 scene,保留兼容。</summary>
- public const string S4Purchase = "S4_PURCHASE";
- // 注: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 → 所属模块列表(双轨)。
- /// 新单模块 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 列表(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,
- S2S6Production,
- S3S5Supply,
- S4Purchase
- };
- }
- /// <summary>
- /// S8 模块码常量(对应 S1-S7 业务模块)。
- /// </summary>
- public static class S8ModuleCode
- {
- public const string S1 = "S1";
- public const string S2 = "S2";
- public const string S3 = "S3";
- public const string S4 = "S4";
- public const string S5 = "S5";
- public const string S6 = "S6";
- public const string S7 = "S7";
- /// <summary>module_code → 业务名称(与侧栏菜单 S{N} 看板标题对齐,统一字面)</summary>
- public static string Label(string moduleCode) => moduleCode switch
- {
- S1 => "S1 产销协同",
- S2 => "S2 制造协同",
- S3 => "S3 供应协同",
- S4 => "S4 采购执行",
- S5 => "S5 物料仓储",
- S6 => "S6 生产执行",
- S7 => "S7 成品仓储",
- _ => moduleCode
- };
- /// <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 => 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>
- /// 场景码 → 代表模块码(双轨)。
- /// - 新 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)
- {
- if (string.IsNullOrWhiteSpace(sceneCode)) return null;
- var modules = S8SceneCode.Modules(sceneCode);
- return modules.Length == 0 ? null : modules[0];
- }
- }
|