package com.sw.mes.fls.dao;

import com.sw.mes.core.base.BaseDao;
import com.sw.mes.fls.entity.ProductionBindingTray;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
* @Author
* @Description：
* @Date:
* @Modified By:
*/
public interface ProductionBindingTrayDao extends BaseDao<ProductionBindingTray, Long>{

    List<ProductionBindingTray> findByTrayNo(String trayNo);

    @Query(value = "SELECT * FROM `production_binding_tray` WHERE tray_no =?1 and (crystal_no is not null and crystal_no != '')",nativeQuery = true)
    List<ProductionBindingTray> findByTrayNoAndCrystalNo(String trayNo);

    @Query(value = "SELECT crystal_no FROM `production_binding_tray` WHERE tray_no = ?1 and (crystal_no is not null or crystal_no != '' ) order by id desc",nativeQuery = true)
    List<String> findCrystalNoByTrayNo(String trayNo);

	ProductionBindingTray getByTrayNoAndLocationNo(String pailNum, String locationNo);

    List<ProductionBindingTray> findByCrystalNo(String crystalNo);

    ProductionBindingTray findByTrayNoAndCrystalNo(String trayNo, String crystalNo);
}
