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
@@ -337,7 +337,7 @@ def test_serialize_task_summary_enriches_todo_and_can_handle(app):
|
||||
db.session.commit()
|
||||
|
||||
data = serialize_task_summary(task, viewer_user_id=11)
|
||||
assert data["todo_category"] == "in_progress"
|
||||
assert data["todo_category"] == "exception"
|
||||
assert data["created_by"] == 11
|
||||
assert data["can_handle"] is True
|
||||
# 无 Gate 且无 review_status:薄回退不投影 order_freeze
|
||||
@@ -1161,12 +1161,74 @@ def test_todo_category_sql_matches_formal_notice_facts(app):
|
||||
assert sql_category == expected
|
||||
|
||||
pending = list_my_todos(owner, bucket="pending", page=1, page_size=50)
|
||||
assert pending["total"] == 1
|
||||
assert pending["total"] == 2
|
||||
counts = count_my_todos(owner)
|
||||
assert counts["pending"] == 1
|
||||
assert counts["pending"] == 2
|
||||
assert counts["done"] == 1
|
||||
assert counts["processing"] == 0
|
||||
assert counts["total_pending_badge"] == 2
|
||||
|
||||
|
||||
def test_count_my_todos_running_gate_is_processing_and_not_double_counted(app):
|
||||
"""有 Notice 的 OT 只计 Notice 分支;active 库存准备进处理中。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
from app.models import ShippingProcessExecution
|
||||
from app.services.shipping_notice.query_service import count_my_todos, list_my_todos
|
||||
|
||||
owner = 91
|
||||
order_task = ShippingOrderTask(
|
||||
task_no="OT-RUN-ONCE", source_type="direct_pdf", user_id=owner,
|
||||
status="processing", stage="notification_preparation",
|
||||
)
|
||||
notice = ShippingNotice(task_no="SN-RUN-ONCE", source_type="manual", user_id=owner)
|
||||
db.session.add_all([order_task, notice])
|
||||
db.session.flush()
|
||||
notice.order_task_id = order_task.id
|
||||
db.session.add(ShippingProcessExecution(
|
||||
execution_no="SPE-RUN-ONCE",
|
||||
task_id=int(order_task.id),
|
||||
status="active",
|
||||
current_gate_code="inventory_preparation",
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
counts = count_my_todos(owner)
|
||||
assert counts["processing"] == 1
|
||||
assert counts["total_pending_badge"] == 1
|
||||
processing = list_my_todos(owner, bucket="processing", page=1, page_size=50)
|
||||
assert processing["total"] == 1
|
||||
assert processing["items"][0]["task_no"] in {"SN-RUN-ONCE", "OT-RUN-ONCE"}
|
||||
|
||||
|
||||
def test_list_my_todos_order_review_gate_stays_in_pending(app):
|
||||
"""订单复核 blocked Gate 进入待处理,不进处理中。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
from app.models import ShippingProcessExecution
|
||||
from app.services.shipping_notice.query_service import count_my_todos, list_my_todos
|
||||
|
||||
owner = 92
|
||||
order_task = ShippingOrderTask(
|
||||
task_no="OT-REVIEW-PENDING", source_type="direct_pdf", user_id=owner,
|
||||
status="waiting_review", stage="order_review",
|
||||
)
|
||||
db.session.add(order_task)
|
||||
db.session.flush()
|
||||
db.session.add(ShippingProcessExecution(
|
||||
execution_no="SPE-REVIEW-PENDING",
|
||||
task_id=int(order_task.id),
|
||||
status="blocked",
|
||||
current_gate_code="order_field_extraction",
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
counts = count_my_todos(owner)
|
||||
assert counts["processing"] == 0
|
||||
pending = list_my_todos(owner, bucket="pending", page=1, page_size=50)
|
||||
assert pending["total"] == 1
|
||||
assert pending["items"][0]["todo_category"] == "review"
|
||||
processing = list_my_todos(owner, bucket="processing", page=1, page_size=50)
|
||||
assert processing["total"] == 0
|
||||
|
||||
|
||||
def test_serialize_task_detail_workbench_view_drops_editor_fields(app):
|
||||
|
||||
Reference in new issue
Block a user