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

@@ -32,7 +32,10 @@ def _eligible_sources(task: ScheduleTask) -> list[tuple[ShippingInventorySource,
return [(source, config) for source, config in rows if not wanted or source.source_code.upper() in wanted]
def _build_unit(source: ShippingInventorySource, config: ShippingReceiptReportConfig, warehouse_id: str | None) -> ShippingReceiptRpaUnitRun:
def _build_unit(
source: ShippingInventorySource, config: ShippingReceiptReportConfig,
warehouse_id: str | None, schedule_run_id: int,
) -> ShippingReceiptRpaUnitRun:
"""冻结可审计的收料执行单元;DBS 日期字段不进入查询快照。"""
callback_id = f'receipt:{uuid.uuid4().hex}'
snapshot = {
@@ -41,7 +44,7 @@ def _build_unit(source: ShippingInventorySource, config: ShippingReceiptReportCo
'warehouse_id': warehouse_id, 'rpa_profile_id': source.rpa_profile_id,
}
return ShippingReceiptRpaUnitRun(
schedule_run_id=0, inventory_source_id=source.id, source_code=source.source_code,
schedule_run_id=schedule_run_id, inventory_source_id=source.id, source_code=source.source_code,
connector_type=source.connector_type, warehouse_id=warehouse_id, callback_id=callback_id,
status='awaiting_rpa', config_snapshot_json=snapshot,
)
@@ -81,9 +84,7 @@ def run_freight_receipt_rpa_schedule(task: ScheduleTask, run: ScheduleRun) -> Sc
# Warehouse 条件即逐仓拆分维度:运行时从条件派生仓库清单,不读取持久化列表。
warehouses = receipt_warehouse_values(config) if source.connector_type == 'dbs' else [None]
for warehouse_id in warehouses:
unit = _build_unit(source, config, str(warehouse_id) if warehouse_id else None)
unit.schedule_run_id = run.id
units.append(unit)
units.append(_build_unit(source, config, str(warehouse_id) if warehouse_id else None, run.id))
if not units:
return 0, 0, 0, 1, [], ['no enabled receipt report sources'], [{'step': 'freight_receipt_rpa', 'status': 'skipped'}]
db.session.add_all(units)