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

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

/**
 * @Author
 * @Description：
 * @Date:
 * @Modified By:
 */
public interface RecheckInspectReceiveDetailDao extends BaseDao<RecheckInspectReceiveDetail, Integer> {
    /**
     * 根据单晶编号查询
     *
     * @param crystalNo
     * @return
     */
    RecheckInspectReceiveDetail findByCrystalNo(String crystalNo);


    // 根据单晶编号查询复检退库次数
    @Query(value = "SELECT COUNT(*) FROM `recheck_inspect_receive_detail` d LEFT JOIN recheck_inspect_receive r  ON d.tray_no = r.tray_no  WHERE d.crystal_no = ?1 and d.quit_type = '退库复检' and  r.state = 1",nativeQuery = true)
    Integer findByFjTkCount(String crystalNo);
}
