feat(shipping-notice): 完成货代发货通知全门禁恢复MVP收口

完成全门禁恢复MVP版本交付:调整自动上传与重试配置,重构正式执行链路;修复多处代码bug,新增测试与审计工具;更新全流程文档与契约规范。
This commit is contained in:
hugo committed 2026-08-11 14:04:39 +08:00
1 parent 8e0bbf7a81
commit c94d173f92
181 files changed
+12947 -1724

No files matched your search

+22 -45
View File
@@ -1126,65 +1126,42 @@ def workspace_auto_progress_shipping_task(task_no: str):
@workspace_shipping_notice_bp.route('/shipping-tasks/<task_no>/match-inventory', methods=['POST'])
def workspace_match_shipping_inventory(task_no: str):
"""执行库存匹配,并在生成 Excel 后补充前端可直接下载的链接。"""
"""兼容旧匹配入口:只提交当前 Gate 自动推进,不直接执行库存匹配。"""
user = _require_user()
task = get_task_for_user(task_no, user.id)
if not task:
raise NotFoundError('Not found')
_assert_fulfillment_task_ownership(task, user.id)
from app.services.shipping_notice import tools as shipping_tools
from app.services.shipping_notice.state_machine import action_buttons_for_checkpoint, human_options_for_checkpoint
matched = shipping_tools.match_inventory({
'task_id': task.task_no,
AUTO_CHAIN_FALLBACK: True,
'_trusted_user_id': user.id,
'operator_id': user.id,
'event_source': 'workspace_api',
})
if not isinstance(matched, dict):
return _ok(matched)
data = matched.get('data')
if isinstance(data, dict) and data.get('export_file_path'):
matched = {**matched, 'data': {**data, 'download_url': f'/api/workspace/shipping-tasks/{task.task_no}/export'}}
checkpoint = matched.get('checkpoint') or CP_EXPORT_GENERATED
if matched.get('status') == 'ok' and data and data.get('export_file_path'):
matched['checkpoint'] = checkpoint
if 'human_options' not in matched:
options = human_options_for_checkpoint(checkpoint)
if options is not None:
matched['human_options'] = options
if 'action_buttons' not in matched:
# [STEP] 已有 ProcessExecution 时不再补充旧 STP 恢复按钮。
from app.models import ShippingProcessExecution
has_execution = (
ShippingProcessExecution.query
.filter_by(task_id=int(task.id))
.first()
) is not None
if not has_execution:
buttons = action_buttons_for_checkpoint(checkpoint)
if buttons:
matched['action_buttons'] = buttons
return _ok(matched)
from app.services.shipping_notice.auto_progress_controller import (
audit_legacy_forwarded_entrypoint,
submit_auto_progress,
)
audit_legacy_forwarded_entrypoint(
task=task, action_code='match_inventory', actor_id=user.id,
request_id=getattr(g, 'request_id', None),
)
result = submit_auto_progress(task=task, trigger='legacy_match_inventory', operator_id=user.id)
return _ok({'deprecated': True, 'projection_refresh_required': True, **result})
@workspace_shipping_notice_bp.route('/shipping-tasks/<task_no>/generate-excel', methods=['POST'])
def workspace_generate_shipping_excel(task_no: str):
"""为指定任务生成出货 Excel,并补充工作台下载链接。"""
"""兼容旧导出入口:只提交当前 Gate 自动推进,不直接生成 Excel。"""
user = _require_user()
task = get_task_for_user(task_no, user.id)
if not task:
raise NotFoundError('Not found')
_assert_fulfillment_task_ownership(task, user.id)
from app.services.shipping_notice import tools as shipping_tools
result = shipping_tools.generate_excel({'task_id': task.task_no})
if isinstance(result, dict) and result.get('status') == 'ok':
data = result.get('data')
if not isinstance(data, dict):
data = {}
result['data'] = data
data['download_url'] = f'/api/workspace/shipping-tasks/{task.task_no}/export'
return _ok(result)
from app.services.shipping_notice.auto_progress_controller import (
audit_legacy_forwarded_entrypoint,
submit_auto_progress,
)
audit_legacy_forwarded_entrypoint(
task=task, action_code='generate_excel', actor_id=user.id,
request_id=getattr(g, 'request_id', None),
)
result = submit_auto_progress(task=task, trigger='legacy_generate_excel', operator_id=user.id)
return _ok({'deprecated': True, 'projection_refresh_required': True, **result})
@workspace_shipping_notice_bp.route('/shipping-tasks/<task_no>/mark-manual-uploaded', methods=['POST'])