feat(shipping-notice): 完善处理投影与待办轮询
- 统一处理阶段、Gate 状态及跨页面投影 - 优化订单提取自动推进与待办分类查询 - 完善任务中心待办与批次轮询逻辑 - 补充后端投影、Gate、查询及 Worker 测试 - 新增待办轮询设计文档并更新技术文档
This commit is contained in:
1 parent
9d2fa522fa
commit
fbca0b485c
22 files changed
+1454
-225
No files matched your search
@@ -412,3 +412,102 @@ def test_user_mode_review_status_must_human():
|
||||
review_status=rs,
|
||||
lifecycle_stage=None,
|
||||
) == 'must_human'
|
||||
|
||||
|
||||
def test_sql_todo_category_review_gate_blocked_is_review(app):
|
||||
"""订单复核 Gate 阻断必须进 review,不得落入 in_progress。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
from app.models import ShippingOrderTask, ShippingProcessExecution
|
||||
from app.services.shipping_notice.query_service import _order_task_todo_category_sql_expr
|
||||
from tests.test_shipping_order_extraction_runs import _seed_run_input
|
||||
|
||||
user, _agent, session, _intake, _document = _seed_run_input(suffix='SQL-REVIEW-BLOCK')
|
||||
ot = ShippingOrderTask(
|
||||
task_no='OT-SQL-REVIEW-BLOCK',
|
||||
user_id=user.id,
|
||||
conversation_id=session.session_id,
|
||||
status='waiting_review',
|
||||
stage='order_review',
|
||||
progress_version=1,
|
||||
)
|
||||
db.session.add(ot)
|
||||
db.session.flush()
|
||||
db.session.add(
|
||||
ShippingProcessExecution(
|
||||
execution_no='SPE-SQL-REVIEW-BLOCK',
|
||||
task_id=int(ot.id),
|
||||
status='blocked',
|
||||
current_gate_code='order_field_extraction',
|
||||
)
|
||||
)
|
||||
db.session.commit()
|
||||
cat = (
|
||||
db.session.query(_order_task_todo_category_sql_expr())
|
||||
.filter(ShippingOrderTask.id == ot.id)
|
||||
.scalar()
|
||||
)
|
||||
assert cat == 'review'
|
||||
|
||||
|
||||
def test_sql_todo_category_running_inventory_prep_is_in_progress(app):
|
||||
"""库存准备 Execution=active 才是系统处理中。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
from app.models import ShippingOrderTask, ShippingProcessExecution
|
||||
from app.services.shipping_notice.query_service import _order_task_todo_category_sql_expr
|
||||
from tests.test_shipping_order_extraction_runs import _seed_run_input
|
||||
|
||||
user, _agent, session, _intake, _document = _seed_run_input(suffix='SQL-RUNNING')
|
||||
ot = ShippingOrderTask(
|
||||
task_no='OT-SQL-RUNNING-PREP',
|
||||
user_id=user.id,
|
||||
conversation_id=session.session_id,
|
||||
status='processing',
|
||||
stage='notification_preparation',
|
||||
progress_version=1,
|
||||
)
|
||||
db.session.add(ot)
|
||||
db.session.flush()
|
||||
db.session.add(
|
||||
ShippingProcessExecution(
|
||||
execution_no='SPE-SQL-RUNNING-PREP',
|
||||
task_id=int(ot.id),
|
||||
status='active',
|
||||
current_gate_code='inventory_preparation',
|
||||
)
|
||||
)
|
||||
db.session.commit()
|
||||
cat = (
|
||||
db.session.query(_order_task_todo_category_sql_expr())
|
||||
.filter(ShippingOrderTask.id == ot.id)
|
||||
.scalar()
|
||||
)
|
||||
assert cat == 'in_progress'
|
||||
|
||||
|
||||
def test_sql_todo_category_without_gate_is_not_in_progress(app):
|
||||
"""无 Gate 的 OT 不得进入处理中桶。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
from app.models import ShippingOrderTask
|
||||
from app.services.shipping_notice.query_service import _order_task_todo_category_sql_expr
|
||||
from tests.test_shipping_order_extraction_runs import _seed_run_input
|
||||
|
||||
user, _agent, session, _intake, _document = _seed_run_input(suffix='SQL-NO-GATE')
|
||||
ot = ShippingOrderTask(
|
||||
task_no='OT-SQL-NO-GATE',
|
||||
user_id=user.id,
|
||||
conversation_id=session.session_id,
|
||||
status='waiting_review',
|
||||
stage='order_review',
|
||||
progress_version=1,
|
||||
)
|
||||
db.session.add(ot)
|
||||
db.session.commit()
|
||||
cat = (
|
||||
db.session.query(_order_task_todo_category_sql_expr())
|
||||
.filter(ShippingOrderTask.id == ot.id)
|
||||
.scalar()
|
||||
)
|
||||
assert cat == 'exception'
|
||||
Reference in new issue
Block a user