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


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

import java.util.List;

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

    @Query(value = "select * from surplus_info where device_no = ?1 AND del =0  ORDER BY id DESC LIMIT 1", nativeQuery = true)
    SurplusInfo queryLimitInfoByDeviceNo(String deviceNo);

    @Query(value = "select * from surplus_info where surplus_code = ?1 AND del =0  LIMIT 1", nativeQuery = true)
    SurplusInfo queryLimitInfoBySurplusCode(String surplusCode);

    @Query(value = "select * from surplus_info where lot_no = ?1 AND del =0  ORDER BY create_time ASC LIMIT 1", nativeQuery = true)
    SurplusInfo queryLimitInfoByLotNo(String lotNo);

    @Query(value = "select * from surplus_info where work_order_no = ?1 AND surplus_type IN ( ?2 ) AND del =0  LIMIT 1", nativeQuery = true)
    SurplusInfo queryLimitInfoByWorkOrderNoAndSurplusType(String workOrderNo, List<String> surplusTypes);
}