feat(warehouse-overseas): reserve inbound pallet batches
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
package com.baiyue.warehouse.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baiyue.warehouse.entity.WarehousePalletBatchItemEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface WarehousePalletBatchItemMapper extends BaseMapper<WarehousePalletBatchItemEntity> {
|
||||
@Select("SELECT * FROM wh_pallet_batch_item WHERE batch_id=#{batchId} ORDER BY sequence_no,id FOR UPDATE")
|
||||
List<WarehousePalletBatchItemEntity> lockByBatch(@Param("batchId") long batchId);
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.baiyue.warehouse.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baiyue.warehouse.entity.WarehousePalletBatchEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface WarehousePalletBatchMapper extends BaseMapper<WarehousePalletBatchEntity> {
|
||||
@Insert("INSERT IGNORE INTO wh_pallet_batch " +
|
||||
"(id,warehouse_id,batch_key,request_hash,status,attempt_no,created_at,updated_at) VALUES " +
|
||||
"(#{id},#{warehouseId},#{batchKey},#{requestHash},#{status},#{attemptNo},#{createdAt},#{updatedAt})")
|
||||
int insertIgnore(WarehousePalletBatchEntity entity);
|
||||
|
||||
@Select("SELECT * FROM wh_pallet_batch WHERE warehouse_id=#{warehouseId} AND batch_key=#{batchKey} " +
|
||||
"LIMIT 1 FOR UPDATE")
|
||||
WarehousePalletBatchEntity lockByKey(@Param("warehouseId") long warehouseId,
|
||||
@Param("batchKey") String batchKey);
|
||||
}
|
||||
+7
@@ -13,4 +13,11 @@ public interface WarehousePalletBindingMapper extends BaseMapper<WarehousePallet
|
||||
"AND business_type=#{businessType} AND business_id=#{businessId} LIMIT 1")
|
||||
WarehousePalletBindingEntity find(@Param("customerId") long customerId, @Param("warehouseId") long warehouseId,
|
||||
@Param("businessType") String businessType, @Param("businessId") String businessId);
|
||||
|
||||
@Select("SELECT * FROM wh_pallet_business_binding WHERE customer_id=#{customerId} AND warehouse_id=#{warehouseId} " +
|
||||
"AND business_type=#{businessType} AND business_id=#{businessId} LIMIT 1 FOR UPDATE")
|
||||
WarehousePalletBindingEntity lockByBusiness(@Param("customerId") long customerId,
|
||||
@Param("warehouseId") long warehouseId,
|
||||
@Param("businessType") String businessType,
|
||||
@Param("businessId") String businessId);
|
||||
}
|
||||
|
||||
+6
-1
@@ -18,6 +18,9 @@ public interface WarehouseResourceLockMapper extends BaseMapper<WarehouseResourc
|
||||
WarehouseResourceLockEntity findByReservationKey(@Param("customerId") long customerId,
|
||||
@Param("reservationKey") String reservationKey);
|
||||
|
||||
@Select("SELECT * FROM wh_resource_lock WHERE customer_id=#{customerId} AND id=#{id} LIMIT 1 FOR UPDATE")
|
||||
WarehouseResourceLockEntity lockById(@Param("customerId") long customerId, @Param("id") long id);
|
||||
|
||||
@Select("SELECT * FROM wh_resource_lock WHERE customer_id=#{customerId} AND pallet_id=#{palletId} " +
|
||||
"AND status='ACTIVE' ORDER BY locked_at DESC LIMIT 1")
|
||||
WarehouseResourceLockEntity findActiveByPallet(@Param("customerId") long customerId,
|
||||
@@ -96,7 +99,9 @@ public interface WarehouseResourceLockMapper extends BaseMapper<WarehouseResourc
|
||||
|
||||
@Update("""
|
||||
UPDATE wh_resource_lock
|
||||
SET status = #{status}, released_at = CURRENT_TIMESTAMP(3), updated_at = CURRENT_TIMESTAMP(3)
|
||||
SET status = #{status},
|
||||
released_at = CASE WHEN #{status} IN ('RELEASED','SCRAPPED') THEN CURRENT_TIMESTAMP(3) ELSE released_at END,
|
||||
updated_at = CURRENT_TIMESTAMP(3)
|
||||
WHERE id = #{id} AND status = 'ACTIVE'
|
||||
""")
|
||||
int closeLock(@Param("id") long id, @Param("status") String status);
|
||||
|
||||
Reference in New Issue
Block a user