Files
baiyue-firstleg/warehouse-overseas-service/src/main/java/com/baiyue/warehouse/mapper/WarehousePalletTransitionMapper.java
T
2026-09-14 09:58:30 +08:00

45 lines
2.6 KiB
Java

package com.baiyue.warehouse.mapper;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baiyue.warehouse.entity.WarehousePalletEntity;
import com.baiyue.warehouse.entity.WarehouseLocationEntity;
import com.baiyue.warehouse.entity.WarehousePalletOperationEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
@Mapper
public interface WarehousePalletTransitionMapper extends BaseMapper<WarehousePalletOperationEntity> {
@Select("SELECT * FROM wh_pallet_operation WHERE operation_key=#{operationKey} LIMIT 1")
WarehousePalletOperationEntity findOperation(@Param("operationKey") String operationKey);
@Select("SELECT * FROM wh_pallet_operation WHERE operation_key=#{operationKey} LIMIT 1 FOR UPDATE")
WarehousePalletOperationEntity lockOperation(@Param("operationKey") String operationKey);
@Select("SELECT * FROM wh_pallet WHERE id=#{palletId} AND customer_id=0 " +
"AND warehouse_id=#{warehouseId} AND deleted=0 LIMIT 1 FOR UPDATE")
WarehousePalletEntity lockPublicPallet(@Param("warehouseId") long warehouseId,
@Param("palletId") long palletId);
@Select("SELECT * FROM wh_location WHERE id=#{locationId} AND customer_id=0 " +
"AND warehouse_id=#{warehouseId} AND deleted=0 LIMIT 1 FOR UPDATE")
WarehouseLocationEntity lockPublicLocation(@Param("warehouseId") long warehouseId,
@Param("locationId") long locationId);
@Update("UPDATE wh_location SET status=#{targetStatus},version=version+1,updated_at=CURRENT_TIMESTAMP(3) " +
"WHERE id=#{locationId} AND customer_id=0 AND warehouse_id=#{warehouseId} " +
"AND status=#{expectedStatus} AND deleted=0")
int transitionLocation(@Param("warehouseId") long warehouseId, @Param("locationId") long locationId,
@Param("expectedStatus") String expectedStatus,
@Param("targetStatus") String targetStatus);
@Update("UPDATE wh_pallet SET status=#{targetStatus},location_id=#{targetLocationId},version=version+1," +
"updated_at=CURRENT_TIMESTAMP(3) WHERE id=#{palletId} AND customer_id=0 " +
"AND warehouse_id=#{warehouseId} AND version=#{expectedVersion} AND status<>'SCRAPPED' AND deleted=0")
int transition(@Param("warehouseId") long warehouseId, @Param("palletId") long palletId,
@Param("targetStatus") String targetStatus, @Param("targetLocationId") Long targetLocationId,
@Param("expectedVersion") int expectedVersion);
}