feat(shipping-notice): 增强订单抽取与审计功能,支持取消与保留策略
- 在环境配置中新增进度细化、订单提取取消与审计导出相关的开关 - 实现订单抽取运行的取消功能,允许管理员在运行中进行操作 - 引入审计事件的保留策略,支持三年保留期的自动清理 - 更新相关模型与服务,确保新功能的完整性与可追溯性 - 增强文档与代码注释,反映新的业务逻辑与审计要求
This commit is contained in:
1 parent
c85997884b
commit
95cdfe66b0
158 files changed
+19005
-1201
No files matched your search
@@ -727,6 +727,23 @@ def _sync_parse_intake_after_job_mutation(job_id: int) -> None:
|
||||
sync_intake_after_parse_job_recovery(job)
|
||||
|
||||
|
||||
def _sync_shipping_order_extraction_run_after_job_failure(job_id: int) -> None:
|
||||
"""将最终失败的订单抽取 Job 收口到对应 Run,避免用户界面永久轮询。"""
|
||||
job = db.session.get(Job, int(job_id))
|
||||
if job is None or str(job.job_type or '') != JobType.SHIPPING_ORDER_EXTRACTION.value:
|
||||
return
|
||||
db.session.expire(job)
|
||||
db.session.refresh(job)
|
||||
if str(job.status or '') != 'failed':
|
||||
return
|
||||
|
||||
from app.services.shipping_notice.order_extraction_run_service import (
|
||||
sync_order_extraction_run_after_job_failure,
|
||||
)
|
||||
|
||||
sync_order_extraction_run_after_job_failure(job)
|
||||
|
||||
|
||||
def finish_job(
|
||||
job: Job | int,
|
||||
*,
|
||||
@@ -934,6 +951,8 @@ def fail_job(
|
||||
rowcount = int(db.session.execute(fail_stmt).rowcount or 0)
|
||||
if rowcount == 1:
|
||||
_sync_parse_intake_after_job_mutation(job_id)
|
||||
# 订单抽取的用户态以 Run 为准;Job 耗尽重试后必须同事务收口。
|
||||
_sync_shipping_order_extraction_run_after_job_failure(job_id)
|
||||
db.session.commit()
|
||||
_expire_cached()
|
||||
return rowcount == 1
|
||||
|
||||
Reference in new issue
Block a user