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

import com.sw.mes.core.base.BaseDao;
import com.sw.mes.core.dto.PieceCheckDto1;
import com.sw.mes.yb.check.entity.PieceCheck;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;

public interface PieceCheckDAO extends BaseDao<PieceCheck, Long> {
    @Query(value = "SELECT * FROM zhxx_operate_piece_check WHERE piece_no = ?1 ", nativeQuery = true)
    List<PieceCheck> findByPieceNo(String pieceNo);

    @Query(value = "SELECT COUNT(id) FROM zhxx_operate_piece_check WHERE piece_no IN (?1) ", nativeQuery = true)
    int findCountByPieceNo(List<String> samples);

    @Query(value = "SELECT * FROM zhxx_operate_piece_check WHERE mother_crystal_no = ?1", nativeQuery = true)
    List<PieceCheck> findCountByMotherCrystalNo(String samples);

    @Query(value = "SELECT * FROM zhxx_operate_piece_check WHERE piece_no IN (?1) ", nativeQuery = true)
    List<PieceCheck> findPieceNosByPieceNo(List<String> samples);

    @Query(value = "SELECT COUNT(1) FROM zhxx_operate_piece_check WHERE piece_no LIKE ?1 ", nativeQuery = true)
    Integer countByPieceNoLike(String pieceNo);

    @Query(value = "SELECT lot_no FROM zhxx_operate_piece_check WHERE check_time1>?1 and check_time1<?2 group by lot_no", nativeQuery = true)
    List<String> findPieceCheckLotNoList(Date beginTime, Date endTime);
}
