fix(shipping-notice): 收口激活按 run_id 取 Run 修变量作用域

This commit is contained in:
hugo committed 2026-10-15 01:40:01 +08:00
1 parent 6502f73cb5
commit 3e8b12b954
1 file changed
+8 -4
@@ -870,8 +870,8 @@ def persist_order_extraction_result(
# 该钩子此前从未接线,导致工作台队列(按 Stream.current_case_id 平铺)看不到任何
# Case,单据永远不可见(回归 SNER-20261014-35E35017 → BB05A18B:9 Case 全部
# stream_id=NULL,工作台空白且停接收解析)。
if run.reparse_of_run_id is not None:
from app.models import ShippingOrderReviewCase
if run_id is not None:
from app.models import ShippingOrderProcessingRun, ShippingOrderReviewCase
from app.services.shipping_notice.candidate_service import (
is_current_reviewable_candidate,
)
@@ -881,8 +881,10 @@ def persist_order_extraction_result(
run_is_reparse_successor_of_case,
)
persisted_run = db.session.get(ShippingOrderProcessingRun, int(run_id))
if persisted_run is not None and persisted_run.reparse_of_run_id is not None:
reparse_cases = ShippingOrderReviewCase.query.filter(
ShippingOrderReviewCase.run_id == int(run.id),
ShippingOrderReviewCase.run_id == int(persisted_run.id),
ShippingOrderReviewCase.status != 'superseded',
ShippingOrderReviewCase.candidate_id.isnot(None),
).all()
@@ -901,7 +903,9 @@ def persist_order_extraction_result(
)
if (
current_case is not None
and run_is_reparse_successor_of_case(run=run, current_case=current_case)
and run_is_reparse_successor_of_case(
run=persisted_run, current_case=current_case,
)
):
declared_source = int(current_case.id)
activate_review_case(