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
@@ -0,0 +1,27 @@
|
||||
"""merge extraction scoring/llm and manual upload heads
|
||||
|
||||
Revision ID: a7b8c9d0e1f3
|
||||
Revises: d4e5f6a7b8c0, f6a7b8c9d0e1
|
||||
Create Date: 2026-07-31
|
||||
|
||||
用途:合并订单解析评分/LLM 建议分支与手动上传生命周期分支的双 head。
|
||||
依赖:d4e5f6a7b8c0(manual upload)、f6a7b8c9d0e1(review suggestions)。
|
||||
逻辑:空合并;两边 DDL 无冲突,仅统一 Alembic head 供 upgrade/deploy。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
revision = 'a7b8c9d0e1f3'
|
||||
down_revision = ('d4e5f6a7b8c0', 'f6a7b8c9d0e1')
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""空合并:两侧迁移已各自完成 schema 变更。"""
|
||||
pass
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""空合并无需回滚 DDL。"""
|
||||
pass
|
||||
@@ -0,0 +1,59 @@
|
||||
"""add profile scoring scope and expand route match_status
|
||||
|
||||
Revision ID: e5f6a7b8c9d0
|
||||
Revises: 9d2f4a6b8c0e
|
||||
Create Date: 2026-07-31
|
||||
|
||||
用途:为订单坐标模板增加可选客户范围与评分策略版本;扩展路由 match_status 约束。
|
||||
依赖:shipping_order_document_profiles、shipping_order_extraction_route_decisions。
|
||||
逻辑:客户范围可选;新匹配态 selected_by_score / no_special_profile_feature 写入 CHECK。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = 'e5f6a7b8c9d0'
|
||||
down_revision = '9d2f4a6b8c0e'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""追加模板评分列并扩展 match_status 允许值。"""
|
||||
with op.batch_alter_table('shipping_order_document_profiles', recreate='auto') as batch_op:
|
||||
batch_op.add_column(sa.Column('customer_ids_json', sa.JSON(), nullable=True))
|
||||
batch_op.add_column(
|
||||
sa.Column(
|
||||
'scoring_policy_version',
|
||||
sa.String(length=64),
|
||||
nullable=False,
|
||||
server_default='order-profile-scoring.v1',
|
||||
),
|
||||
)
|
||||
|
||||
with op.batch_alter_table('shipping_order_extraction_route_decisions', recreate='auto') as batch_op:
|
||||
batch_op.drop_constraint('ck_shipping_order_extraction_route_match_status', type_='check')
|
||||
batch_op.create_check_constraint(
|
||||
'ck_shipping_order_extraction_route_match_status',
|
||||
"match_status IN ("
|
||||
"'unique_match', 'selected_by_score', 'no_special_profile_feature', "
|
||||
"'no_match', 'ambiguous', 'layout_drift', 'evidence_insufficient'"
|
||||
")",
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""回滚评分列与 match_status 约束。"""
|
||||
with op.batch_alter_table('shipping_order_extraction_route_decisions', recreate='auto') as batch_op:
|
||||
batch_op.drop_constraint('ck_shipping_order_extraction_route_match_status', type_='check')
|
||||
batch_op.create_check_constraint(
|
||||
'ck_shipping_order_extraction_route_match_status',
|
||||
"match_status IN ('unique_match', 'no_match', 'ambiguous', 'layout_drift', 'evidence_insufficient')",
|
||||
)
|
||||
|
||||
with op.batch_alter_table('shipping_order_document_profiles', recreate='auto') as batch_op:
|
||||
batch_op.drop_column('scoring_policy_version')
|
||||
batch_op.drop_column('customer_ids_json')
|
||||
@@ -0,0 +1,91 @@
|
||||
"""add shipping order review suggestions
|
||||
|
||||
Revision ID: f6a7b8c9d0e1
|
||||
Revises: e5f6a7b8c9d0
|
||||
Create Date: 2026-07-31
|
||||
|
||||
用途:新增订单复核 LLM 最小证据建议表。
|
||||
依赖:shipping_order_review_cases、shipping_notice_documents、users。
|
||||
逻辑:建议仅预填草稿;L4 整份 PDF 默认禁止;裁决 modify/reject 须原因。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = 'f6a7b8c9d0e1'
|
||||
down_revision = 'e5f6a7b8c9d0'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""创建 shipping_order_review_suggestions。"""
|
||||
op.create_table(
|
||||
'shipping_order_review_suggestions',
|
||||
sa.Column('id', sa.Integer(), primary_key=True),
|
||||
sa.Column('suggestion_no', sa.String(length=64), nullable=False),
|
||||
sa.Column('review_case_id', sa.Integer(), nullable=False),
|
||||
sa.Column('document_id', sa.Integer(), nullable=False),
|
||||
sa.Column('run_id', sa.Integer(), nullable=True),
|
||||
sa.Column('field_id', sa.String(length=64), nullable=False),
|
||||
sa.Column('line_key', sa.String(length=64), nullable=True),
|
||||
sa.Column('scope', sa.String(length=16), server_default='header', nullable=False),
|
||||
sa.Column('evidence_level', sa.String(length=16), server_default='L1_field', nullable=False),
|
||||
sa.Column('status', sa.String(length=32), server_default='pending', nullable=False),
|
||||
sa.Column('contract_version', sa.String(length=64), nullable=False),
|
||||
sa.Column('draft_version_at_request', sa.Integer(), nullable=True),
|
||||
sa.Column('request_json', sa.JSON(), nullable=False),
|
||||
sa.Column('response_json', sa.JSON(), nullable=True),
|
||||
sa.Column('validated_suggestions_json', sa.JSON(), nullable=False),
|
||||
sa.Column('validation_issues_json', sa.JSON(), nullable=False),
|
||||
sa.Column('suggested_value_json', sa.JSON(), nullable=True),
|
||||
sa.Column('decision', sa.String(length=16), nullable=True),
|
||||
sa.Column('decision_reason', sa.Text(), nullable=True),
|
||||
sa.Column('decision_note', sa.String(length=1024), nullable=True),
|
||||
sa.Column('decided_by_id', sa.Integer(), nullable=True),
|
||||
sa.Column('decided_at', sa.DateTime(), nullable=True),
|
||||
sa.Column('requested_by_id', sa.Integer(), nullable=True),
|
||||
sa.Column('error_code', sa.String(length=64), nullable=True),
|
||||
sa.Column('error_message', sa.String(length=512), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['decided_by_id'], ['users.id']),
|
||||
sa.ForeignKeyConstraint(['requested_by_id'], ['users.id']),
|
||||
sa.ForeignKeyConstraint(['review_case_id'], ['shipping_order_review_cases.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['document_id'], ['shipping_notice_documents.id']),
|
||||
sa.ForeignKeyConstraint(['run_id'], ['shipping_order_extraction_runs.id']),
|
||||
sa.UniqueConstraint('suggestion_no', name='uq_shipping_order_review_suggestions_no'),
|
||||
sa.CheckConstraint(
|
||||
"status IN ('pending', 'validated', 'validation_failed', 'accepted', 'modified', "
|
||||
"'rejected', 'failed', 'provider_unavailable')",
|
||||
name='ck_shipping_order_review_suggestions_status',
|
||||
),
|
||||
sa.CheckConstraint(
|
||||
"evidence_level IN ('L1_field', 'L2_table', 'L3_page', 'L4_pdf')",
|
||||
name='ck_shipping_order_review_suggestions_evidence_level',
|
||||
),
|
||||
sa.CheckConstraint(
|
||||
"decision IS NULL OR decision IN ('accept', 'modify', 'reject')",
|
||||
name='ck_shipping_order_review_suggestions_decision',
|
||||
),
|
||||
)
|
||||
op.create_index(
|
||||
'ix_shipping_order_review_suggestions_case',
|
||||
'shipping_order_review_suggestions',
|
||||
['review_case_id', 'created_at'],
|
||||
)
|
||||
op.create_index(
|
||||
'ix_shipping_order_review_suggestions_document',
|
||||
'shipping_order_review_suggestions',
|
||||
['document_id', 'id'],
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""删除建议表。"""
|
||||
op.drop_index('ix_shipping_order_review_suggestions_document', table_name='shipping_order_review_suggestions')
|
||||
op.drop_index('ix_shipping_order_review_suggestions_case', table_name='shipping_order_review_suggestions')
|
||||
op.drop_table('shipping_order_review_suggestions')
|
||||
Reference in new issue
Block a user