package com.ruoyi.wms.repository;

import com.ruoyi.wms.po.ShelfInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Lock;
import org.springframework.stereotype.Repository;

import javax.persistence.LockModeType;
import java.util.List;

/**
 * @Verasion:1.0
 * @Author:DZY
 * @Date:2023/6/27
 **/
@Repository
public interface ShelfInfoRepository extends JpaRepository<ShelfInfo,Long>, JpaSpecificationExecutor {
    ShelfInfo findByShelfCode(String shelfCode);
    /**
     * 新增悲观锁
     * @param task
     * @param status
     * @return
     */
    @Lock(LockModeType.PESSIMISTIC_WRITE)
    List<ShelfInfo> findByProductionTaskAndOrderStatus(String task,Integer status);
    List<ShelfInfo> findByProductionTaskIsNullAndStationCodeIsNotNull();
    List<ShelfInfo> findByOrderStatus(Integer Status);
    List<ShelfInfo> findByProductionTask(String productionTask);
    List<ShelfInfo> findByStationCode(String stationCode);
    List<ShelfInfo> findByProductionTaskAndOrderStatusOrderByUpdatedDtDesc(String productionTask, Integer orderStatus);
    List<ShelfInfo> findByShelfStatus(Integer shelfStatus);
}
