diff --git a/backend/app/api/tools/shipping_notice.py b/backend/app/api/tools/shipping_notice.py index 8827e9d9..911427f9 100644 --- a/backend/app/api/tools/shipping_notice.py +++ b/backend/app/api/tools/shipping_notice.py @@ -334,6 +334,26 @@ def rpa_receipt_batch_ready(): return jsonify({'success': True, 'data': ingest_receipt_callback(_payload())}) +@shipping_notice_bp.route('/rpa/receipt-unit-progress', methods=['POST']) +def rpa_receipt_unit_progress(): + """收料单元领取/导出中:awaiting_rpa → processing,供管理端实时看到进行中。 + + 本路由同时是收料超时对账的活动锚数据源(mark 落单元 started_at); + 曾因重构分叉合并丢失(2026-10-08),Worker 上报全程 404,勿再从旧路径文件删除。 + """ + from app.services.schedule.freight_receipt_rpa_finalize import mark_receipt_unit_processing + + return jsonify({'success': True, 'data': mark_receipt_unit_processing(_payload())}) + + +@shipping_notice_bp.route('/rpa/receipt-batch-progress', methods=['POST']) +def rpa_receipt_batch_progress(): + """收料 RPA 每完成一笔导出的累计进度回写(非终态,对齐库存 inventory-batch-progress)。""" + from app.services.schedule.freight_receipt_rpa_finalize import report_receipt_batch_progress + + return jsonify({'success': True, 'data': report_receipt_batch_progress(_payload())}) + + @shipping_notice_bp.route('/rpa/inventory-batch-claimed', methods=['POST']) def rpa_inventory_batch_claimed(): """v2 Worker 领取回调:仅记录 Attempt 执行阶段。""" diff --git a/backend/tests/test_freight_receipt_rpa_callback.py b/backend/tests/test_freight_receipt_rpa_callback.py index 43c02feb..b55f0b56 100644 --- a/backend/tests/test_freight_receipt_rpa_callback.py +++ b/backend/tests/test_freight_receipt_rpa_callback.py @@ -266,3 +266,25 @@ def test_ingest_empty_persists_no_receipt_data(app): assert saved.status == 'empty' assert saved.error_code == 'no_receipt_data' assert saved.error_message == 'no_receipt_data' + + +def test_receipt_progress_routes_are_registered(app): + """回归锁:receipt-unit-progress / receipt-batch-progress 必须注册在 Tool 蓝图上。 + + 2026-10-08 事故:重构分叉合并丢失两路由,Worker 上报全程 404、活动锚失效、 + 在飞批次被超时对账误杀——本用例保证路由缺失在任何部署前即红。 + """ + app.config['SHIPPING_NOTICE_TOOL_API_KEY'] = 'test-tool-key' + client = app.test_client() + headers = {'X-Integration-Key': 'test-tool-key'} + for path, payload in ( + ('/api/shipping-notice/rpa/receipt-unit-progress', + {'schema_version': 'shipping_receipt_rpa.v1', 'callback_id': 'no-such-callback'}), + ('/api/shipping-notice/rpa/receipt-batch-progress', + {'schema_version': 'shipping_receipt_rpa.v1', 'schedule_run_id': 999999999}), + ): + # [断言意图] 路由必须存在且鉴权通过(非 401/403/404);无匹配数据时服务层 + # 返回 200 + updated=False(注册性探针,不依赖任何夹具数据)。 + resp = client.post(path, json=payload, headers=headers) + assert resp.status_code == 200, (path, resp.status_code, resp.get_json()) + assert resp.get_json()['data']['updated'] is False