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
@@ -20,6 +20,7 @@ from app.services.shipping_notice.document_layout.lifecycle import (
|
||||
schedule_document_layouts,
|
||||
sync_layout_after_job_recovery,
|
||||
)
|
||||
from app.services.shipping_notice.document_layout import lifecycle as layout_lifecycle
|
||||
|
||||
|
||||
def _document() -> ShippingNoticeDocument:
|
||||
@@ -151,22 +152,33 @@ def test_layout_schedule_localizes_same_owner_completed_layout_for_duplicate_doc
|
||||
assert ShippingDocumentLayoutVersion.query.count() == 2
|
||||
|
||||
|
||||
def test_layout_parser_revision_change_creates_new_version_without_force(app):
|
||||
"""运维提升 parser revision 后不得复用旧 Provider/模型结果。"""
|
||||
def test_layout_parser_fingerprint_change_creates_new_version_without_force(app, monkeypatch):
|
||||
"""布局实现指纹变化后自动创建新版本,不依赖人工修改环境变量。"""
|
||||
app.config['SHIPPING_NOTICE_LAYOUT_MINERU_ENABLED'] = True
|
||||
with app.app_context():
|
||||
document = _document()
|
||||
old = record_inline_layout_snapshot(
|
||||
document, _snapshot(),
|
||||
parser_key='mineru:pipeline:shipping_document_table_snapshot.v1:v1',
|
||||
parser_key='mineru:pipeline:shipping_document_table_snapshot.v1:sha256-old',
|
||||
)
|
||||
app.config['SHIPPING_NOTICE_LAYOUT_PARSER_REVISION'] = 'v2'
|
||||
monkeypatch.setattr(layout_lifecycle, 'layout_parser_implementation_fingerprint', lambda: 'newfingerprint')
|
||||
new = schedule_layout_version(document)
|
||||
db.session.commit()
|
||||
|
||||
assert new.id != old.id
|
||||
assert new.version == 2
|
||||
assert new.parser_key.endswith(':v2')
|
||||
assert new.parser_key.endswith(':sha256-newfingerprint')
|
||||
|
||||
|
||||
def test_layout_parser_fingerprint_ignores_unrelated_app_config(app):
|
||||
"""无关业务配置变化不能让所有 PDF 布局缓存失效。"""
|
||||
with app.app_context():
|
||||
before = layout_lifecycle.current_layout_parser_key()
|
||||
app.config['UNRELATED_CHAT_SETTING'] = 'changed'
|
||||
after = layout_lifecycle.current_layout_parser_key()
|
||||
|
||||
assert before == after
|
||||
assert ':sha256-' in before
|
||||
|
||||
|
||||
def test_layout_recovery_invalidates_old_lease_and_preserves_good_current(app):
|
||||
|
||||
Reference in new issue
Block a user