package com.baiyue.lastleg.appointmentplanning; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Options; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; @Mapper public interface AppointmentCargoVerificationMapper extends BaseMapper { /** Same canonical source row used by allocation; flush pre-lock observations before re-reading. */ @Select("SELECT id FROM ll_order WHERE id=#{orderId} FOR UPDATE") @Options(flushCache = Options.FlushCachePolicy.TRUE, useCache = false) Long lockSourceOrder(@Param("orderId") Long orderId); @Select("SELECT * FROM ll_appointment_cargo_verification WHERE customer_id=#{customerId} AND source_key=#{sourceKey} ORDER BY version DESC LIMIT 1") AppointmentCargoVerification latest(@Param("customerId") String customerId,@Param("sourceKey") String sourceKey); @Select(""" """) java.util.List latestBatch(@Param("refs") java.util.List refs); @Select("SELECT * FROM ll_appointment_cargo_verification WHERE customer_id=#{customerId} AND source_key=#{sourceKey} AND command_key=#{key}") AppointmentCargoVerification command(@Param("customerId") String customerId,@Param("sourceKey") String sourceKey,@Param("key") String key); record Allocation(long packages, long unknownItems) { } @Select(""" SELECT COALESCE(SUM(package_count),0) AS packages, COUNT(*)-COUNT(package_count) AS unknownItems FROM ll_inbound_fba_appointment_item WHERE customer_id=#{customerId} AND source_key=#{sourceKey} AND active=1 """) Allocation allocated(@Param("customerId") String customerId,@Param("sourceKey") String sourceKey); record SourceAllocation(String customerId,String sourceKey,long packages,long unknownItems) { } @Select(""" """) java.util.List allocatedBatch(@Param("refs") java.util.List refs); }