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

@@ -160,9 +160,13 @@ class ShippingInventorySourceParsingBindingAudit(Base):
class ShippingInventoryParsingProfile(Base):
"""可跨源复用的通用文件解析规则(库存/异动按 purpose 区分)。
注意:表名中的 inventory 是历史命名——本表实为"通用文件解析规则表",
用途以 purpose 字段为准,勿按表名推断只服务库存。
purpose='inventory':端点用 ShippingInventoryField 库存字段目录(既有语义);
purpose='movement':端点用定死领域字段(MOVEMENT_FIELDS,doc_no/line_no/.../movement_date),
供收料/异动文件映射,不依赖库存字段目录。校验逻辑按 purpose 分支。
绑定入口:库存站点 ShippingInventorySource.parsing_profile_id /
收料配置 ShippingReceiptReportConfig.parsing_profile_id(后者必须 purpose='movement')。
"""
__tablename__ = 'shipping_inventory_parsing_profiles'
@@ -52,7 +52,10 @@ class ShippingReceiptReportConfig(Base):
class ShippingReceiptRpaUnitRun(Base):
"""一次收料排程内的站点或站点-Warehouse 不可重复执行单元。"""
"""一次收料执行的站点或站点-Warehouse 不可重复执行单元。
schedule_run_id 指向排程 run;调拨按需触发(重试/预检补抓)无排程,保持 NULL。
"""
__tablename__ = 'shipping_receipt_rpa_unit_runs'
__table_args__ = (
@@ -66,7 +69,7 @@ class ShippingReceiptRpaUnitRun(Base):
)
id: Mapped[int] = mapped_column(primary_key=True)
schedule_run_id: Mapped[int] = mapped_column(ForeignKey('schedule_runs.id'), nullable=False, index=True)
schedule_run_id: Mapped[Optional[int]] = mapped_column(ForeignKey('schedule_runs.id'), nullable=True, index=True)
inventory_source_id: Mapped[int] = mapped_column(ForeignKey('shipping_inventory_sources.id'), nullable=False, index=True)
retry_of_id: Mapped[Optional[int]] = mapped_column(
ForeignKey('shipping_receipt_rpa_unit_runs.id'), nullable=True, index=True,
@@ -85,7 +88,7 @@ class ShippingReceiptRpaUnitRun(Base):
finished_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
schedule_run: Mapped['ScheduleRun'] = relationship(foreign_keys=[schedule_run_id])
schedule_run: Mapped[Optional['ScheduleRun']] = relationship(foreign_keys=[schedule_run_id])
inventory_source: Mapped['ShippingInventorySource'] = relationship()
retry_of: Mapped[Optional['ShippingReceiptRpaUnitRun']] = relationship(remote_side=[id])
files: Mapped[list['ShippingReceiptReportFile']] = relationship(