From d6764e56ba56b4e81133829a8c65f7244a3dc4a2 Mon Sep 17 00:00:00 2001 From: "z.zhang" Date: Fri, 9 Oct 2026 22:48:31 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=AF=95=E6=8E=92=E8=BD=A8?= =?UTF-8?q?=E9=81=93=E5=88=A4=E5=AE=9A=E6=94=B6=E6=95=9B=E4=B8=BA=20params?= =?UTF-8?q?.is=5Ftrial=5Fworld=20=E5=94=AF=E4=B8=80=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit run_flex_schedule 与 rush.apply 不再各自读 planningContext.trialOnly, 统一经 params.is_trial_world 分流,消除双处字段判断漂移的隐患。 rush/flex/params golden 全过。 --- server/aps_domain/flex.py | 4 +++- server/aps_domain/params.py | 10 ++++++++++ server/aps_domain/rush.py | 5 +++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/server/aps_domain/flex.py b/server/aps_domain/flex.py index 1d40508..3dec7db 100644 --- a/server/aps_domain/flex.py +++ b/server/aps_domain/flex.py @@ -298,8 +298,10 @@ def run_flex_schedule(store, sort_mode: str | None = None, order_ids: list[int] from server.state.seed import ensure_flex_seed ensure_flex_seed(store.data) + from server.aps_domain.params import is_trial_world + planning_context = store.data.get("planningContext") or {} - if planning_context.get("trialOnly"): + if is_trial_world(store.data): trial = True if start_date is None and planning_context.get("planStart"): start_date = str(planning_context["planStart"])[:10] diff --git a/server/aps_domain/params.py b/server/aps_domain/params.py index 9b0486b..35c437a 100644 --- a/server/aps_domain/params.py +++ b/server/aps_domain/params.py @@ -26,6 +26,16 @@ def default_schedule_params() -> dict[str, Any]: } +def is_trial_world(world: World) -> bool: + """是否试排世界(文件夹快试导入):排产/重排统一走柔性能力池草稿轨。 + + 轨道判定唯一入口:run_flex_schedule、rush.apply 等所有排产触发点 + 都经此函数分流,避免各处自写字段判断导致同一世界走出两条轨道。 + """ + planning_context = world.get("planningContext") or {} + return bool(planning_context.get("trialOnly")) + + def get_schedule_params(world: World) -> dict[str, Any]: """合并默认值后的排产参数投影(P0)。""" base = default_schedule_params() diff --git a/server/aps_domain/rush.py b/server/aps_domain/rush.py index f25c153..9f7d345 100644 --- a/server/aps_domain/rush.py +++ b/server/aps_domain/rush.py @@ -328,8 +328,9 @@ def apply_rush(world: World, next_id, payload: dict[str, Any]) -> dict[str, Any] rush = resolve_rush_payload(world, payload.get("payload") or payload) strategy = str(payload.get("strategy") or "DELIVERY_FIRST").upper() order = inject_rush_trunk(world, next_id, rush) - planning_context = world.get("planningContext") or {} - if planning_context.get("trialOnly"): + from server.aps_domain.params import is_trial_world + + if is_trial_world(world): # 试排世界必须走柔性能力池引擎:主轨 RULE 引擎读不到 flex* 主数据, # 全量重排只会产出 0 工单的空壳版本,排产推演/查看排产结果都看不到急单。 # 改为先把主干急单桥接进柔性订单池,再重跑 PoolEngine 试排(与 run_flex_schedule 同轨)。