!13 feat(shipping-freight-auto-upload): 新增货代发货Excel连接级自动上传全链路功能
Merge pull request !13 from 曹惠鹏/hugo-shipping-notice
This commit is contained in:
93 files changed
+4867
-601
No files matched your search
@@ -351,6 +351,13 @@ def rpa_inventory_batch_claimed():
|
||||
return jsonify({'success': True, 'data': claim_inventory_batch(_payload())})
|
||||
|
||||
|
||||
@shipping_notice_bp.route('/rpa/inventory-batch-progress', methods=['POST'])
|
||||
def rpa_inventory_batch_progress():
|
||||
"""RPA 批量库存导出进度回调:实时回写排程 run 计数(非终态,最终以 batch-ready 为准)。"""
|
||||
from app.services.shipping_notice.inventory_rpa_workflow import report_inventory_batch_progress
|
||||
return jsonify(report_inventory_batch_progress(_payload()))
|
||||
|
||||
|
||||
@shipping_notice_bp.route('/rpa/inventory-configuration-test-ready', methods=['POST'])
|
||||
def rpa_inventory_configuration_test_ready():
|
||||
"""RPA 配置测试回调:仅分析文件结构,不创建生产库存快照或任务关联。"""
|
||||
|
||||
@@ -548,10 +548,9 @@ def workspace_shipping_task_detail(task_no: str):
|
||||
task = get_task_visible_to_user(task_no, user.id, is_admin=is_admin)
|
||||
if not task:
|
||||
raise NotFoundError('Not found')
|
||||
return _ok({
|
||||
**serialize_task_detail(task, viewer_user_id=user.id, is_admin=is_admin),
|
||||
'ui_state': build_task_ui_state(task, include_stage_context=True),
|
||||
})
|
||||
return _ok(serialize_task_detail(
|
||||
task, viewer_user_id=user.id, is_admin=is_admin, include_stage_context=True,
|
||||
))
|
||||
|
||||
|
||||
@workspace_shipping_notice_bp.route('/shipping-tasks/<task_no>/audit-timeline', methods=['GET'])
|
||||
@@ -877,9 +876,43 @@ def workspace_mark_manual_uploaded(task_no: str):
|
||||
run_task_auto_progress(
|
||||
str(task.task_no), trigger='manual_upload_confirmed', operator_id=int(user.id),
|
||||
)
|
||||
# 终态兜底:确认上传必须收口正式 Execution Gate,不允许依赖 auto_progress/Job 链。
|
||||
_ensure_uploaded_execution_gates_closed(task, actor_id=int(user.id))
|
||||
return _ok(result)
|
||||
|
||||
|
||||
def _ensure_uploaded_execution_gates_closed(task: ShippingNotice, *, actor_id: int) -> None:
|
||||
"""人工确认上传(终态)后兜底收口正式 Execution 门禁,禁止依赖 auto_progress/Job 链。
|
||||
|
||||
核心逻辑:upload_manual_confirmed 是业务终态事实;只有把正式 Execution 的前置履约
|
||||
Gate 一并收口,批次中心/对话卡才不会因陈旧「库存不足」Gate 把阶段回退成「通知准备」。
|
||||
``auto_progress_enabled()`` 可能为 False(``run_task_auto_progress`` 提前返回),
|
||||
或 ``submit_auto_progress`` 存在活动 Job / 候选集等早退分支而跳过 sync,故此处兜底:
|
||||
仅当 Execution 尚未 completed 时显式同步(幂等,重复无害)。已 completed 时不重复处理,
|
||||
避免与 ``_active_execution_for_task`` 将 completed Execution 误判为可重建。
|
||||
|
||||
Args:
|
||||
task: 已确认人工上传的正式 ShippingNotice。
|
||||
actor_id: 触发确认的服务端用户主键。
|
||||
"""
|
||||
from app.services.shipping_notice.process_gate_bridge import (
|
||||
find_execution_for_task,
|
||||
sync_fulfillment_gates_from_task,
|
||||
)
|
||||
|
||||
execution = find_execution_for_task(task)
|
||||
if execution is None:
|
||||
return
|
||||
if str(getattr(execution, 'status', '') or '').strip().lower() == 'completed':
|
||||
return
|
||||
sync_fulfillment_gates_from_task(
|
||||
execution=execution,
|
||||
actor_type='user',
|
||||
actor_id=actor_id,
|
||||
)
|
||||
db.session.flush()
|
||||
|
||||
|
||||
def _confirm_notice_uploaded(*, business_no: str, user_id: int, artifact_id: int | None = None) -> dict[str, Any]:
|
||||
"""
|
||||
按发货通知单号确认唯一 Excel 已上传;内部 task_no 仅用于既有状态机和审计追溯。
|
||||
@@ -916,6 +949,8 @@ def _confirm_notice_uploaded(*, business_no: str, user_id: int, artifact_id: int
|
||||
run_task_auto_progress(
|
||||
str(task.task_no), trigger='manual_upload_confirmed', operator_id=user_id,
|
||||
)
|
||||
# 终态兜底:确认上传必须收口正式 Execution Gate,不允许依赖 auto_progress/Job 链。
|
||||
_ensure_uploaded_execution_gates_closed(task, actor_id=user_id)
|
||||
return {'business_no': str(task.business_no), **dict(result or {})}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user