feat(appointments): track forecast impacts and handling history

This commit is contained in:
2026-10-10 15:33:13 +08:00
parent 331f750871
commit 0ac2b849c3
18 changed files with 1323 additions and 0 deletions
@@ -0,0 +1,19 @@
package com.baiyue.lastleg.fleet.business;
import com.baiyue.lastleg.appointmentplanning.AppointmentImpactTransportGateway;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class FleetAppointmentImpactAdapter implements AppointmentImpactTransportGateway {
private final FleetAppointmentImpactMapper mapper;
public FleetAppointmentImpactAdapter(FleetAppointmentImpactMapper mapper){this.mapper=mapper;}
public Links related(List<Dispatch> dispatches) {
if(dispatches==null || dispatches.size()>1000) throw new IllegalArgumentException("受影响排车范围过大,请按柜核对");
if(dispatches.isEmpty()) return new Links(List.of(),List.of());
var trips=mapper.trips(dispatches.stream().distinct().toList());
var bookings=trips.isEmpty()?List.<Booking>of():mapper.bookings(trips.stream().map(Trip::tripNo).toList());
if(bookings.size()>1000) throw new org.springframework.web.server.ResponseStatusException(org.springframework.http.HttpStatus.CONFLICT,"同车承诺超过读取上限,请进入车次逐项核对");
return new Links(trips,bookings);
}
}
@@ -0,0 +1,23 @@
package com.baiyue.lastleg.fleet.business;
import com.baiyue.lastleg.appointmentplanning.AppointmentImpactTransportGateway.*;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface FleetAppointmentImpactMapper {
@Select("""
<script>SELECT DISTINCT t.trip_no,t.status,t.planned_departure_at FROM ll_fleet_trip_dispatch d
JOIN ll_fleet_trip t ON t.id=d.trip_id WHERE t.status NOT IN ('CANCELLED','COMPLETED') AND
<foreach collection='rows' item='r' open='(' separator=' OR ' close=')'>(d.customer_id=#{r.customerId} AND d.dispatch_no=#{r.dispatchNo})</foreach>
ORDER BY t.trip_no</script>
""")
List<Trip> trips(@Param("rows") List<Dispatch> rows);
@Select("""
<script>SELECT trip_no,booking_no,customer_name,destination_label,status FROM ll_fleet_external_booking
WHERE status IN ('CONFIRMED','RECEIVED','BOUND') AND trip_no IN
<foreach collection='trips' item='t' open='(' separator=',' close=')'>#{t}</foreach>
ORDER BY trip_no,booking_no LIMIT 1001</script>
""")
List<Booking> bookings(@Param("trips") List<String> trips);
}