feat(shipping-notice): 收料异动解析配置闭环与按需触发FK违例修复

- 收料单元 schedule_run_id 改可空,修复按需触发 FK 违例
- 收料配置绑定已发布异动解析规则(校验/回显/审计快照)
- 预检未绑异动规则 fail-closed,不再徒劳触发 RPA
- 标准异动字段目录只读接口;解析规则用途切换与批号映射表单(四语言)
- movement 解析规则可发布(跳过订单匹配键校验);站点启停门禁仅限库存站点页签
- 只读映射卡三列布局修复
This commit is contained in:
hugo committed 2026-09-21 19:12:29 +08:00
1 parent ab57ab3b1f
commit 20835dcfc0
28 files changed
+987 -73

No files matched your search

@@ -0,0 +1,39 @@
"""
backend/migrations/versions/rc3c4d5e6f7a_allow_null_receipt_unit_schedule_run.py
用途:收料 RPA 执行单元 schedule_run_id 改为可空,支持无排程的按需触发。
依赖:Alembic revision rc2b3c4d5e6f;shipping_receipt_rpa_unit_runs 已存在。
逻辑:调拨重试/预检补抓按需触发不产生 ScheduleRun,原 NOT NULL+FK 下只能写
0 占位并被 PostgreSQL 外键拒绝(0 不在 schedule_runs);改为 NULL 表示无排程。
降级前必须先确认表内不存在 schedule_run_id 为 NULL 的行。
Revision ID: rc3c4d5e6f7a
Revises: rc2b3c4d5e6f
Create Date: 2026-09-21 09:00:00.000000
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
revision = "rc3c4d5e6f7a"
down_revision = "rc2b3c4d5e6f"
branch_labels = None
depends_on = None
def upgrade() -> None:
"""放开 shipping_receipt_rpa_unit_runs.schedule_run_id 的 NOT NULL 约束。"""
op.alter_column(
'shipping_receipt_rpa_unit_runs', 'schedule_run_id',
existing_type=sa.Integer(), nullable=True,
)
def downgrade() -> None:
"""恢复 NOT NULL;执行前必须清理 schedule_run_id 为 NULL 的按需触发单元行。"""
op.alter_column(
'shipping_receipt_rpa_unit_runs', 'schedule_run_id',
existing_type=sa.Integer(), nullable=False,
)