diff --git a/backend/app/crud/outbound_release_review.py b/backend/app/crud/outbound_release_review.py index 33db171d..c5777c36 100644 --- a/backend/app/crud/outbound_release_review.py +++ b/backend/app/crud/outbound_release_review.py @@ -9,6 +9,7 @@ from typing import Any, Dict, List, Optional from sqlalchemy import and_, exists, func, or_ from sqlalchemy.orm import Session +from app.core.db_collation import eq_unicode from app.core.utils import generate_uuid from app.models.models import ( BizOutboundReleaseReview, @@ -105,7 +106,10 @@ def _outbound_qc_unfinished_exists_for_schedule(tenant_no: str): BizQcWorkOrder.del_flag == 0, BizQcWorkOrder.qc_biz_type == "outbound", BizQcWorkOrder.trigger_source == "schedule", - BizQcWorkOrder.infusion_schedule_id == BizPilotInfusionSchedule.id, + # 跨表 id 排序规则可能不同(general_ci vs unicode_ci) + eq_unicode( + BizQcWorkOrder.infusion_schedule_id, BizPilotInfusionSchedule.id + ), BizQcWorkOrder.work_order_status.in_(("dpz", "ypz")), ) ) @@ -121,8 +125,10 @@ def _outbound_production_unfinished_exists_for_schedule(tenant_no: str): BizProductionWorkOrder.tenant_no == tenant_no, BizProductionWorkOrder.del_flag == 0, BizProductionWorkOrder.work_order_type == "outbound", - BizProductionWorkOrder.infusion_schedule_id - == BizPilotInfusionSchedule.id, + eq_unicode( + BizProductionWorkOrder.infusion_schedule_id, + BizPilotInfusionSchedule.id, + ), BizProductionWorkOrder.work_order_status.in_(("dpz", "jxz")), ) ) @@ -136,7 +142,7 @@ def _outbound_qc_all_void_for_schedule(tenant_no: str): BizQcWorkOrder.del_flag == 0, BizQcWorkOrder.qc_biz_type == "outbound", BizQcWorkOrder.trigger_source == "schedule", - BizQcWorkOrder.infusion_schedule_id == BizPilotInfusionSchedule.id, + eq_unicode(BizQcWorkOrder.infusion_schedule_id, BizPilotInfusionSchedule.id), ] any_wo = exists().where(and_(*base)).correlate(BizPilotInfusionSchedule) any_non_void = ( @@ -160,7 +166,9 @@ def _outbound_production_all_void_for_schedule(tenant_no: str): BizProductionWorkOrder.tenant_no == tenant_no, BizProductionWorkOrder.del_flag == 0, BizProductionWorkOrder.work_order_type == "outbound", - BizProductionWorkOrder.infusion_schedule_id == BizPilotInfusionSchedule.id, + eq_unicode( + BizProductionWorkOrder.infusion_schedule_id, BizPilotInfusionSchedule.id + ), ] any_wo = exists().where(and_(*base)).correlate(BizPilotInfusionSchedule) any_non_void = (