feat(freight-rpa): 批次R解耦编排层并切换 onhand/inbound 契约

将 RPA 编排收编至 freight_rpa,回调迁 /api/freight-rpa/*。
共享目录与 Worker 契约一次切换至 onhand/inbound/upload,
并补 outbound 骨架与 tt16 排程 job key 迁移。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-10-17 23:18:48 +08:00
1 parent bf3154033b
commit ffc0d4a430
147 files changed
+4221 -2678

No files matched your search

@@ -1,8 +1,8 @@
"""
backend/tests/test_shipping_receipt_rpa_archive.py
backend/tests/test_freight_inbound_rpa_archive.py
用途:收料 RPA 原始收料 ZIP 归档、summary 可见性与 admin API 路由单测。
依赖:shipping_receipt_rpa_archive、api/schedule/runs、freight_receipt_rpa_finalize。
依赖:freight_inbound_rpa_archive、api/schedule/runs、freight_inbound_rpa_finalize。
逻辑:finalize 预生成 ZIP;下载 send_file 归档路径;包内条目为序号_source_code。
"""
@@ -26,7 +26,7 @@ from app.models import (
ShippingReceiptRpaUnitRun,
User,
)
from app.services.schedule.shipping_receipt_rpa_archive import (
from app.services.schedule.freight_inbound_rpa_archive import (
get_receipt_archive_dir,
persist_receipt_rpa_raw_zip_archive,
receipt_raw_zip_available_from_summary,
@@ -80,7 +80,7 @@ def _make_receipt_run_with_file(
schedule_no=schedule_no,
name=f'Receipt archive {schedule_no}',
schedule_type='platform_job',
platform_api_path='freight-receipt-rpa',
platform_api_path='freight-rpa-inbound',
owner_user_id=owner.id,
cron_expr='0 8 * * *',
schedule_timezone='Asia/Shanghai',
@@ -142,11 +142,11 @@ def test_get_receipt_archive_dir_falls_back_when_config_none(app, tmp_path, monk
monkeypatch.setattr(
Config,
'FREIGHT_RPA_RECEIPT_ARCHIVE_DIR',
'FREIGHT_RPA_INBOUND_ARCHIVE_DIR',
str(tmp_path / 'receipt_archives_fallback'),
)
with app.app_context():
app.config['FREIGHT_RPA_RECEIPT_ARCHIVE_DIR'] = None
app.config['FREIGHT_RPA_INBOUND_ARCHIVE_DIR'] = None
archive_dir = Path(get_receipt_archive_dir())
assert archive_dir.is_dir()
assert archive_dir == (tmp_path / 'receipt_archives_fallback').resolve()
@@ -155,7 +155,7 @@ def test_get_receipt_archive_dir_falls_back_when_config_none(app, tmp_path, monk
def test_config_exposes_freight_rpa_receipt_archive_dir(app):
"""Flask Config 必须声明收料归档目录,否则 env 不会进 app.config。"""
with app.app_context():
value = app.config.get('FREIGHT_RPA_RECEIPT_ARCHIVE_DIR')
value = app.config.get('FREIGHT_RPA_INBOUND_ARCHIVE_DIR')
assert value is not None
assert str(value).strip() != ''
@@ -172,7 +172,7 @@ def test_serialize_run_reads_receipt_raw_zip_available_from_summary(app):
schedule_no='ARCH-RCP-SER',
name='Receipt archive serialize',
schedule_type='platform_job',
platform_api_path='freight-receipt-rpa',
platform_api_path='freight-rpa-inbound',
owner_user_id=user.id,
cron_expr='0 8 * * *',
)
@@ -204,9 +204,9 @@ def test_build_zip_entry_name_prefers_source_code():
def test_persist_receipt_rpa_raw_zip_archive_writes_zip_and_summary(app, tmp_path, monkeypatch):
"""finalize 预生成应落盘 ZIP(含 manifest)并返回 summary 字段。"""
archive_dir = tmp_path / 'receipt_archives'
app.config['FREIGHT_RPA_RECEIPT_ARCHIVE_DIR'] = str(archive_dir)
app.config['FREIGHT_RPA_INBOUND_ARCHIVE_DIR'] = str(archive_dir)
monkeypatch.setattr(
'app.services.schedule.shipping_receipt_rpa_archive.file_asset_storage.get_bytes',
'app.services.schedule.freight_inbound_rpa_archive.file_asset_storage.get_bytes',
lambda _key: b'fake-receipt-xlsx',
)
@@ -239,7 +239,7 @@ def test_persist_receipt_rpa_raw_zip_archive_writes_zip_and_summary(app, tmp_pat
def test_resolve_receipt_raw_zip_download_rejects_missing_summary(app, tmp_path):
"""summary 未标记可用时应 404。"""
app.config['FREIGHT_RPA_RECEIPT_ARCHIVE_DIR'] = str(tmp_path / 'receipt_archives')
app.config['FREIGHT_RPA_INBOUND_ARCHIVE_DIR'] = str(tmp_path / 'receipt_archives')
with app.app_context():
run, _ = _make_receipt_run_with_file(
schedule_no='SCH-RCP-ARCH-MISS',
@@ -268,9 +268,9 @@ def test_receipt_attachment_stem_uses_local_timezone(app):
def test_admin_can_download_receipt_raw_zip(app, client, admin_jwt_headers, tmp_path, monkeypatch):
"""管理端 receipt-raw-zip 应返回 ZIP 与展示名。"""
archive_dir = tmp_path / 'receipt_archives'
app.config['FREIGHT_RPA_RECEIPT_ARCHIVE_DIR'] = str(archive_dir)
app.config['FREIGHT_RPA_INBOUND_ARCHIVE_DIR'] = str(archive_dir)
monkeypatch.setattr(
'app.services.schedule.shipping_receipt_rpa_archive.file_asset_storage.get_bytes',
'app.services.schedule.freight_inbound_rpa_archive.file_asset_storage.get_bytes',
lambda _key: b'fake-receipt-xlsx',
)