feat(shipping-notice): 增强发货通知与订单抽取功能,支持多进程处理与紧急停止
- 移除不再使用的 SHIPPING_NOTICE_LAYOUT_PARSER_REVISION 配置 - 在环境配置中新增 SHIPPING_NOTICE_WORKER_CONCURRENCY 和 SHIPPING_NOTICE_JOB_RUNNING_TIMEOUT_SECONDS - 实现发货通知 worker 进程,支持并发处理订单抽取任务 - 引入紧急停止功能,允许管理员在运行中控制订单解析状态 - 更新相关 API,支持读取与设置紧急停止状态 - 增强文档与代码注释,反映新的业务逻辑与功能要求
This commit is contained in:
1 parent
d0fe084999
commit
b352c281d5
149 files changed
+12550
-1874
No files matched your search
@@ -514,6 +514,15 @@ def authorize_order_document_profile_frozen_sample_preview_pages(profile_id: int
|
||||
))
|
||||
|
||||
|
||||
@admin_bp.route('/shipping-notice/order-document-profiles/<int:profile_id>/samples/<int:sample_binding_id>/region-diagnostics/<int:page_no>', methods=['GET'])
|
||||
@require_admin
|
||||
def get_order_document_profile_frozen_sample_region_diagnostics(profile_id: int, sample_binding_id: int, page_no: int):
|
||||
"""读取模板定义内受控区域的冻结识别值,供版本画布排错。"""
|
||||
return _private_ok(preview_service.frozen_sample_region_diagnostics(
|
||||
profile_id, sample_binding_id=sample_binding_id, page_no=page_no, actor_id=_actor_id(),
|
||||
))
|
||||
|
||||
|
||||
@admin_bp.route('/shipping-notice/order-document-profiles/<int:profile_id>/samples/<int:sample_binding_id>/preview-pages/<int:page_no>', methods=['GET'])
|
||||
@require_admin
|
||||
def get_order_document_profile_frozen_sample_preview_page(profile_id: int, sample_binding_id: int, page_no: int):
|
||||
|
||||
@@ -105,6 +105,59 @@ def admin_cancel_shipping_order_extraction_run(run_no: str):
|
||||
return ok({'run': serialize_order_extraction_run(run)}, request_id=getattr(g, 'request_id', None), status=202)
|
||||
|
||||
|
||||
@admin_bp.route('/shipping-notice/order-extraction/emergency-stop', methods=['GET'])
|
||||
@require_admin
|
||||
def get_shipping_order_extraction_emergency_stop():
|
||||
"""读取订单解析紧急停止与分路径自动冻结开关状态(只读投影)。"""
|
||||
from app.services.shipping_notice.tool_common import (
|
||||
extraction_emergency_stop_enabled,
|
||||
generic_auto_freeze_enabled,
|
||||
generic_extraction_enabled,
|
||||
llm_review_enabled,
|
||||
profile_auto_selection_enabled,
|
||||
)
|
||||
|
||||
return ok({
|
||||
'emergency_stop': extraction_emergency_stop_enabled(),
|
||||
'generic_extraction_enabled': generic_extraction_enabled(),
|
||||
'generic_auto_freeze_enabled': generic_auto_freeze_enabled(),
|
||||
'profile_auto_selection_enabled': profile_auto_selection_enabled(),
|
||||
'llm_review_enabled': llm_review_enabled(),
|
||||
}, request_id=getattr(g, 'request_id', None))
|
||||
|
||||
|
||||
@admin_bp.route('/shipping-notice/order-extraction/emergency-stop', methods=['POST'])
|
||||
@require_admin
|
||||
def set_shipping_order_extraction_emergency_stop():
|
||||
"""
|
||||
运行期紧急停止开关(进程内覆盖)。
|
||||
|
||||
核心逻辑:写入 Flask config,立即阻断新 Run 自动冻结;持久化仍依赖环境变量/部署配置。
|
||||
"""
|
||||
body = request.get_json(silent=True) or {}
|
||||
enabled = body.get('enabled')
|
||||
if not isinstance(enabled, bool):
|
||||
raise ValidationError('enabled must be a boolean')
|
||||
from flask import current_app
|
||||
from app.services.shipping_notice.audit_service import append_shipping_audit_event
|
||||
|
||||
before = bool(current_app.config.get('SHIPPING_NOTICE_EXTRACTION_EMERGENCY_STOP'))
|
||||
current_app.config['SHIPPING_NOTICE_EXTRACTION_EMERGENCY_STOP'] = enabled
|
||||
append_shipping_audit_event(
|
||||
event_type='extraction_emergency_stop_changed',
|
||||
aggregate_type='order_extraction_policy',
|
||||
aggregate_id='global',
|
||||
actor_type='admin',
|
||||
actor_id=str(g.current_user.id),
|
||||
reason_code='admin_emergency_stop' if enabled else 'admin_emergency_resume',
|
||||
before={'enabled': before},
|
||||
after={'enabled': enabled},
|
||||
metadata={'request_id': getattr(g, 'request_id', None)},
|
||||
)
|
||||
db.session.commit()
|
||||
return ok({'emergency_stop': enabled}, request_id=getattr(g, 'request_id', None))
|
||||
|
||||
|
||||
@admin_bp.route('/shipping-notice/order-extraction-quality-batches', methods=['GET'])
|
||||
@require_admin
|
||||
def list_shipping_order_extraction_quality_batches():
|
||||
|
||||
Reference in new issue
Block a user