From d4d5d7907033d7b21edcc64ba815ddb1ecddff25 Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Sat, 3 Oct 2026 10:18:48 +0800 Subject: [PATCH] fix(fleet): compare customer identities without collation conflicts --- .../com/baiyue/lastleg/fleet/trip/VehicleFulfillmentMapper.java | 2 +- .../baiyue/lastleg/fleet/trip/VehicleFulfillmentQueryTest.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lastleg-service/src/main/java/com/baiyue/lastleg/fleet/trip/VehicleFulfillmentMapper.java b/lastleg-service/src/main/java/com/baiyue/lastleg/fleet/trip/VehicleFulfillmentMapper.java index c86fa011e..3e6b5616c 100644 --- a/lastleg-service/src/main/java/com/baiyue/lastleg/fleet/trip/VehicleFulfillmentMapper.java +++ b/lastleg-service/src/main/java/com/baiyue/lastleg/fleet/trip/VehicleFulfillmentMapper.java @@ -11,7 +11,7 @@ public interface VehicleFulfillmentMapper { String DEPARTED = "EXISTS (SELECT 1 FROM ll_fleet_trip_history h WHERE h.trip_id=t.id AND h.action='DEPART' " + "AND JSON_UNQUOTE(JSON_EXTRACT(h.snapshot_json,'$.trip.vehicleId'))=#{vehicleKey})"; String DELIVERIES = " FROM ll_delivery_order d JOIN ll_fleet_trip_dispatch b " - + "ON b.dispatch_id=d.dispatch_order_id AND b.customer_id=d.customer_id " + + "ON b.dispatch_id=d.dispatch_order_id AND CAST(b.customer_id AS BINARY(128))=CAST(d.customer_id AS BINARY(128)) " + "JOIN ll_fleet_trip t ON t.id=b.trip_id WHERE ((t.status='PLANNED' AND t.vehicle_id=#{vehicleId}) OR " + DEPARTED + ")"; String PREVIOUS_VEHICLE = "JSON_UNQUOTE(JSON_EXTRACT(p.snapshot_json,'$.trip.vehicleId'))"; String NEXT_VEHICLE = "JSON_UNQUOTE(JSON_EXTRACT(h.snapshot_json,'$.trip.vehicleId'))"; diff --git a/lastleg-service/src/test/java/com/baiyue/lastleg/fleet/trip/VehicleFulfillmentQueryTest.java b/lastleg-service/src/test/java/com/baiyue/lastleg/fleet/trip/VehicleFulfillmentQueryTest.java index 609f72457..08773e1f1 100644 --- a/lastleg-service/src/test/java/com/baiyue/lastleg/fleet/trip/VehicleFulfillmentQueryTest.java +++ b/lastleg-service/src/test/java/com/baiyue/lastleg/fleet/trip/VehicleFulfillmentQueryTest.java @@ -59,6 +59,8 @@ public class VehicleFulfillmentQueryTest { } @Test void currentPlanUsesStableVehicleIdentityAndCustomerScopedDispatchJoin() { delivery(23,11,"WRONG-CUSTOMER"); + delivery(24,11,"CUSTOMER-A-OTHER"); + delivery(25,11,"customer-a"); var result = service.deliveries(8,new VehicleFulfillmentModels.Query(1,10)); assertThat(result.total()).isEqualTo(2); assertThat(result.records()).extracting(VehicleFulfillmentModels.Delivery::customerName).containsExactly("CUSTOMER-B","CUSTOMER-A");