31 lines
1.7 KiB
Java
31 lines
1.7 KiB
Java
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<AppointmentCargoVerification> {
|
||
|
|
/** 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("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);
|
||
|
|
}
|