package com.sw.mes.yb.turnstore.dao;

import com.sw.mes.core.base.BaseDao;
import com.sw.mes.yb.turnstore.entity.TurnstoreTray;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Author
 * @Description：
 * @Date:
 * @Modified By:
 */
public interface TurnstoreTrayDao extends BaseDao<TurnstoreTray, Integer> {
    @Query(value = "SELECT 1 FROM zhxx_turnstore_tray WHERE tray_no=?1 LIMIT 1", nativeQuery = true)
    Integer checkTrayNo(String trayNo);

    @Query(value = "SELECT max(order_num)+1 from zhxx_turnstore_tray where has_gone ='综计WMS'  AND  time >= CURRENT_DATE ", nativeQuery = true)
    Integer findOrderNumByWMS();

    @Query(value = "SELECT max(order_num)+1 from zhxx_turnstore_tray where has_gone !='综计WMS'  AND  time >= CURRENT_DATE ", nativeQuery = true)
    Integer findOrderNumByTime();


    List<TurnstoreTray> findByTrayNo(String trayNo);

    @Query(value = "SELECT * FROM zhxx_turnstore_tray where has_gone !='综计WMS' ORDER BY id DESC, tray_no DESC LIMIT 1", nativeQuery = true)
    TurnstoreTray queryDbNum();
}
