//package com.sw.mes.yb.pc.dao;
//
//
//import com.sw.mes.core.base.BaseDao;
//import com.sw.mes.yb.pc.entity.InspectData;
//import org.springframework.data.domain.Page;
//import org.springframework.data.domain.Pageable;
//import org.springframework.data.jpa.repository.Modifying;
//import org.springframework.data.jpa.repository.Query;
//import org.springframework.data.repository.query.Param;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.Date;
//import java.util.List;
//import java.util.Map;
//@Deprecated
//public interface InspectDataDAO extends BaseDao<InspectData, Integer> {
//
//    List<InspectData> findBySectionNo(String sectionNo);
//
//
//
//    @Query(value = "select * from yb_inspect_data " +
//            "where state = ?1 AND check_result=1 and actual_length is not null " +
//            "ORDER BY actual_length ASC LIMIT 1", nativeQuery = true)
//    InspectData getStockMinLenth(String state);
//
//    // 晶段编号找到等级
//    @Query(value = "select product_level from yb_inspect_data where section_no = ?1", nativeQuery = true)
//    String getProductLevelBySectionNo(String segmentNo);
//
//
//    @Query(value = "select is_cut_back from yb_inspect_data where section_no = ?1", nativeQuery = true)
//    Integer getLevelClassBySectionNo(String segmentNo);
//
//    @Query(value = "select * from yb_inspect_data " +
//            "where check_result=1 AND actual_length >= ?1 and actual_length < ?2 and state = ?3 " +
//            "ORDER BY actual_length ASC,code ASC", nativeQuery = true)
//    List<InspectData> findRangeLength(float minLength, float maxLength, String state);
//
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE section_no IN(?1) ", nativeQuery = true)
//    List<InspectData> findBySectionNoIn(List<String> sectionNos);
//
//    @Query(value = "SELECT * FROM yb_inspect_data " +
//            "WHERE state='已入库' AND `type`!='拼棒' AND check_result !=0 " +
//            "AND IF(check_result=2, state_update_time<DATE_SUB(NOW(),INTERVAL 80 MINUTE), 1=1) ", nativeQuery = true)
//    List<InspectData> findOutStore();
//
//    @Query(value = "SELECT * FROM yb_inspect_data " +
//            "WHERE store=?1 AND state='已入库' AND `type`!='拼棒' AND check_result !=0 " +
//            "AND IF(check_result=2, state_update_time<DATE_SUB(NOW(),INTERVAL 80 MINUTE), 1=1)", nativeQuery = true)
//    List<InspectData> findOutStore(String store);
//
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE section_no LIKE concat(?1, '%') ORDER BY section_no ASC ", nativeQuery = true)
//    List<InspectData> findBySectionNoLikeSectionNoAsc(String sectionNo);
//
////    @Query(value = "SELECT * FROM yb_inspect_data WHERE section_no LIKE concat(?1, '%') ORDER BY section_no DESC ", nativeQuery = true)
////    List<Inspect> findBySectionNoLikeSectionNoDesc(String sectionNo);
//
//    @Query(value = "select rfid from yb_inspect_data " +
//            "where state=?1 and check_result=1 and store=?4 " +
//            "group by rfid HAVING count( CASE when type=?2 then 1 else null end)=?3 ", nativeQuery = true)
//    List<String> findSplicingNumber(String state, String type, Integer size, String store);
//
//    @Query(value = "select * from yb_inspect_data where state=?1 and check_result=1 and store=?4 " +
//            "group by rfid,type HAVING count( CASE when type=?2 then 1 else null end)=?3", nativeQuery = true)
//    List<InspectData> findSplicingInspect(String state, String type, Integer size, String store);
//
//    @Query(value = "SELECT rfid FROM yb_inspect_data WHERE rfid=?1 AND type=?2 AND check_result=1 " +
//            "HAVING sum(actual_length) BETWEEN ?3 AND ?4 ", nativeQuery = true)
//    String findRangeTray(String rfid, String type, float max, float min);
//
//    List<InspectData> findByRfid(String trayRfid);
//
//    @Query(value = "SELECT DISTINCT(rfid) FROM yb_inspect_data WHERE state='已入库' AND FIND_IN_SET(id, ?1) ", nativeQuery = true)
//    List<String> findRfidByIds(String ids);
//
//    @Query(value = "SELECT * FROM yb_inspect_data " +
//            "WHERE section_no=?1 AND state='已入库' AND `type`!='拼棒' AND check_result !=0 " +
//            "AND IF(check_result=2, state_update_time<DATE_SUB(NOW(),INTERVAL 80 MINUTE), 1=1)", nativeQuery = true)
//    InspectData findOutStoreBySectionNo(String sectionNo);
//
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE state='已入库' AND FIND_IN_SET(id, ?1) ", nativeQuery = true)
//    List<InspectData> findByIds(String ids);
//
//    @Query(value = "SELECT GROUP_CONCAT(DISTINCT(code)) FROM yb_inspect_data WHERE state='已入库' AND section_no LIKE(?1) ", nativeQuery = true)
//    String findCodeBySectionNoLike(String sectionNo);
//
////    @Query(value = "SELECT * FROM yb_inspect_data WHERE crystal_no=?1 AND section_count=?2 ", nativeQuery = true)
////    List<Inspect> findByCrystalNoAndSectionCount(String crystalNo, Integer count);
//
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE piece_no_head=?1 ", nativeQuery = true)
//    List<InspectData> findByPieceNoHead(String pieceNo);
//
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE piece_no_tail=?1 ", nativeQuery = true)
//    List<InspectData> findByPieceNoTail(String pieceNo);
//
//    @Query(value = "select \n" +
//            " ?1 mode,\n" +
//            "inspectTime,\n" +
//            "inspector,count(crystal_no)crystalNum,sum(actualWeight)actualWeight,\n" +
//            "sum(actualLength)actualLength\n" +
//            "from (\n" +
//            "select DATE_FORMAT(DATE_SUB(inspect_time,INTERVAL 510 minute),?2) inspectTime  ,crystal_no,(actual_weight) actualWeight ,sum(actual_length) actualLength,inspector from yb_inspect_data\n" +
//            "where check_result<>0 and check_result<>'' and inspect_time<>''\n" +
//            "GROUP BY inspectTime,crystal_no,inspector\n" +
//            " ) inpsect\n" +
//            "group by inspectTime,inspector order by inspectTime desc limit ?3,?4 ", nativeQuery = true)
//    List<Map<String, Object>> checkOutput(String mode, String dateFormat, Long start, Integer rows);
//
//    @Query(value = "select count(*) count FROM ( \n" +
//            " SELECT * " +
//            "from (\n" +
//            "select DATE_FORMAT(DATE_SUB(inspect_time,INTERVAL 510 minute),?1) inspectTime  ,crystal_no,(actual_weight) actualWeight ,sum(actual_length) actualLength,inspector from yb_inspect_data\n" +
//            "where check_result<>0 and check_result<>'' and inspect_time<>''\n" +
//            "GROUP BY inspectTime,crystal_no,inspector\n" +
//            " ) inpsect\n" +
//            "group by inspectTime,inspector ) a ", nativeQuery = true)
//    List<Map<String, Object>> countCheckOutput(String dateFormat);
//
//    @Query(value = "select \n" +
//            " ?1 mode,\n" +
//            "inspectTime,\n" +
//            "inspector,count(crystal_no)crystalNum,sum(actualWeight)actualWeight,\n" +
//            "sum(actualLength)actualLength\n" +
//            "from (\n" +
//            "select DATE_FORMAT(DATE_SUB(inspect_time,INTERVAL 510 minute),?2) inspectTime  ,crystal_no,(actual_weight) actualWeight ,sum(actual_length) actualLength,inspector from yb_inspect_data\n" +
//            "where check_result<>0 and check_result<>'' and inspect_time<>''\n" +
//            "GROUP BY inspectTime,crystal_no,inspector\n" +
//            " ) inpsect \n" +
//            "WHERE inspector LIKE concat('%',?3,'%')" +
//            "group by inspectTime,inspector order by inspectTime desc limit ?4,?5 ", nativeQuery = true)
//    List<Map<String, Object>> checkOutput(String mode, String dateFormat, String inspector, Long start, Integer rows);
//
//    @Query(value = "select  count(*) count FROM ( \n" +
//            " SELECT * " +
//            "from (\n" +
//            "select DATE_FORMAT(DATE_SUB(inspect_time,INTERVAL 510 minute),?1) inspectTime  ,crystal_no,(actual_weight) actualWeight ,sum(actual_length) actualLength,inspector from yb_inspect_data\n" +
//            "where check_result<>0 and check_result<>'' and inspect_time<>''\n" +
//            "GROUP BY inspectTime,crystal_no,inspector\n" +
//            " ) inpsect \n" +
//            "WHERE inspector LIKE concat('%',?2,'%') " +
//            "group by inspectTime,inspector ) a", nativeQuery = true)
//    List<Map<String, Object>> countCheckOutput(String dateFormat, String inspector);
//
//    @Query(value = "select \n" +
//            " ?1 mode,\n" +
//            "inspectTime,\n" +
//            "inspector,count(crystal_no)crystalNum,sum(actualWeight)actualWeight,\n" +
//            "sum(actualLength)actualLength\n" +
//            "from (\n" +
//            "select DATE_FORMAT(DATE_SUB(inspect_time,INTERVAL 510 minute),?2) inspectTime  ,crystal_no,(actual_weight) actualWeight ,sum(actual_length) actualLength,inspector from yb_inspect_data\n" +
//            "where check_result<>0 and check_result<>'' and inspect_time<>'' " +
//            " and inspect_time>=?4 and inspect_time<?5 \n" +
//            "GROUP BY inspectTime,crystal_no,inspector\n" +
//            "  ) inpsect \n" +
//            "WHERE inspector LIKE concat('%',?3,'%') " +
//            "group by inspectTime,inspector order by inspectTime desc limit ?6,?7 ", nativeQuery = true)
//    List<Map<String, Object>> checkOutput(String mode, String dateFormat, String inspector, String startTime, String endTime, Long start, Integer rows);
//
//    @Query(value = "select count(*)count FROM (\n" +
//            " SELECT * " +
//            "from (\n" +
//            "select DATE_FORMAT(DATE_SUB(inspect_time,INTERVAL 510 minute),?1) inspectTime  ,crystal_no,(actual_weight) actualWeight ,sum(actual_length) actualLength,inspector from yb_inspect_data\n" +
//            "where check_result<>0 and check_result<>'' and inspect_time<>''\n" +
//            " and inspect_time>=?3 and inspect_time<?4 \n" +
//            "GROUP BY inspectTime,crystal_no,inspector\n" +
//            " ) inpsect \n" +
//            "WHERE inspector LIKE concat('%',?2,'%') " +
//            "group by inspectTime,inspector ) a ", nativeQuery = true)
//    List<Map<String, Object>> countCheckOutput(String dateFormat, String inspector, String startTime, String endTime);
//
//    @Query(value = "select \n" +
//            " ?1 mode,\n" +
//            "inspectTime,\n" +
//            "inspector,count(crystal_no)crystalNum,sum(actualWeight)actualWeight,\n" +
//            "sum(actualLength)actualLength\n" +
//            "from (\n" +
//            "select DATE_FORMAT(DATE_SUB(inspect_time,INTERVAL 510 minute),?2) inspectTime  ,crystal_no,(actual_weight) actualWeight ,sum(actual_length) actualLength,inspector from yb_inspect_data\n" +
//            "where check_result<>0 and check_result<>'' and inspect_time<>'' " +
//            " and inspect_time>=?3 and inspect_time<?4 \n" +
//            "GROUP BY inspectTime,crystal_no,inspector\n" +
//            "  ) inpsect \n" +
//            "group by inspectTime,inspector order by inspectTime desc limit ?5,?6 ", nativeQuery = true)
//    List<Map<String, Object>> checkOutput(String mode, String dateFormat, String startTime, String endTime, Long start, Integer rows);
//
//    @Query(value = "select count(*)count FROM (\n" +
//            " SELECT * " +
//            "from (\n" +
//            "select DATE_FORMAT(DATE_SUB(inspect_time,INTERVAL 510 minute),?1) inspectTime  ,crystal_no,(actual_weight) actualWeight ,sum(actual_length) actualLength,inspector from yb_inspect_data\n" +
//            "where check_result<>0 and check_result<>'' and inspect_time<>''\n" +
//            " and inspect_time>=?2 and inspect_time<?3 \n" +
//            "GROUP BY inspectTime,crystal_no,inspector\n" +
//            " ) inpsect \n" +
//            "group by inspectTime,inspector ) a ", nativeQuery = true)
//    List<Map<String, Object>> countCheckOutput(String dateFormat, String startTime, String endTime);
//
//    @Modifying
//    @Transactional
//    @Query(value = "UPDATE yb_inspect_data SET state=?2 WHERE rfid=?1 AND state='已入库' ", nativeQuery = true)
//    void updateState(String rfid, String state);
//
//    @Modifying
//    @Transactional
//    @Query(value = "UPDATE yb_inspect_data SET re_check_type='复检单晶' WHERE section_no IN(?1)", nativeQuery = true)
//    void updateReCheckTypeBySectionNos(List<String> sectionNos);
//
//    @Query(value = "SELECT count(id) FROM yb_inspect_data WHERE section_no LIKE ?1", nativeQuery = true)
//    int findCountBySectionNoLike(String sectionNo);
//
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE state=?1 and type=?2 AND check_result=1 and store=?3", nativeQuery = true)
//    List<InspectData> findMateSplicing(String state, String type, String store);
//
////    @Query(value = "SELECT * FROM yb_inspect_data WHERE check_result=0 AND state!='已入库' " +
////            "AND (timestampdiff( HOUR, inspect_time , now()) < ?1 )", nativeQuery = true)
////    List<Inspect> findByCheckResultAndInspectTime(int hour);
//
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE check_result=0 " +
//            "AND inspect_time>DATE_SUB(NOW(),INTERVAL ?1 HOUR)", nativeQuery = true)
//    List<InspectData> findByCheckResultAndInspectTime(int hour);
//
////    @Query(value = "SELECT * FROM yb_inspect_data WHERE crystal_no=?1 AND section_count=?2 ORDER BY section_no DESC ", nativeQuery = true)
////    List<Inspect> findByCrystalNoAndSectionCountOrderByNo(String crystalNo, Integer count);
//
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE FIND_IN_SET(section_no,?1) AND inspect_time>=?2", nativeQuery = true)
//    List<InspectData> getInfoBatch(String sectionNos, Date date);
//
//    //周转库批量获取晶段信息
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE section_no IN(?1) AND inspect_time>=?2", nativeQuery = true)
//    List<InspectData> turnstoreGetInfoBatch(List<String> sectionNos, Date date);
//
//    //周转库单个获取晶段信息
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE section_no=?1 AND inspect_time>=?2", nativeQuery = true)
//    List<InspectData> turnstoreGetInfo(String sectionNos, Date date);
//
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE section_no=?1", nativeQuery = true)
//    List<InspectData> turnstoreGetInfoNew(String sectionNos);
//
//    /**
//     * 方棒获取最近一个月实验等级等级方法
//     **/
//    @Query(value = "SELECT DISTINCT product_level_experiment AS productLevelExperiment FROM yb_inspect_data \n" +
//            "WHERE create_time >= DATE_SUB(now(),INTERVAL 1 MONTH) \n" +
//            "AND product_level_experiment IS NOT NULL \n" +
//            "AND product_level_experiment<>''", nativeQuery = true)
//    List<String> getProductLevelExperimentList();
//
//    @Query(value = "SELECT section_no AS sectionNo, sinton_tail1 AS sintonTail1, sinton_tail2 AS sintonTail2, " +
//            "center_tail AS centerTail, border_tail1 AS borderTail1, border_tail4 AS borderTail4  " +
//            "FROM yb_inspect_data WHERE section_no LIKE concat(?1, '%')", nativeQuery = true)
//    List<Map<String, Object>> findSintonValueBySectionNoLike(String firstSectionNo);
//
//    @Query(value = "SELECT section_no AS sectionNo, sinton_tail1 AS sintonTail1, sinton_tail2 AS sintonTail2, " +
//            "center_tail AS centerTail, border_tail1 AS borderTail1, border_tail4 AS borderTail4  " +
//            "FROM yb_inspect_data WHERE section_no LIKE concat(?1, '%')", nativeQuery = true)
//    List<Map<String, Object>> findFirstValueBySectionNoLike(String firstSectionNo);
//
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE check_result=0 AND state='已入库' " +
//            "AND piece_no_head IS NOT NULL AND piece_no_tail IS NOT NULL " +
//            "AND create_time>DATE_SUB(NOW(),INTERVAL ?1 HOUR) ", nativeQuery = true)
//    List<InspectData> findByCheckResultAndState(int hour);
//
//    /**
//     * 远程查询晶棒数据
//     *
//     * @param lotNo
//     * @return
//     */
//    @Query(value = "SELECT section_no,center_head,center_tail FROM yb_inspect_data WHERE lot_no = ?1 ", nativeQuery = true)
//    List<Map<String, Object>> findInspectByLotNo(String lotNo);
//
//    @Query(value = "SELECT * FROM yb_inspect_data " +
//            "WHERE store=?1 AND check_result=?2 AND TIMESTAMPDIFF(MINUTE, state_update_time, now()) > 80 " +
//            "AND (state='已入库' OR state='可出库锁定')", nativeQuery = true)
//    List<InspectData> findOutStoreAndCheckResult(String store, Integer checkResult);
//
//    @Query(value = "SELECT * FROM yb_inspect_data_view_history ", nativeQuery = true)
//    List<InspectData> findViewHistoryData();
//
//    @Modifying
//    @Transactional
//    @Query(value = "DELETE FROM yb_inspect_data WHERE id<=?1 " +
//            "AND (create_time IS NULL OR (timestampdiff(DAY, create_time, now())>90) )", nativeQuery = true)
//    void deleteLessThanId(Long id);
//
//
//    @Query(value = "SELECT actual_length,draw_length,inspect_time FROM yb_inspect_data WHERE section_no like ?1% ", nativeQuery = true)
//    List<Map<String, Object>> findPrecisionByCrystalNo(String crystalNo);
//
//
//    @Query(value = "SELECT slopet,slopew,inspect_time FROM yb_inspect_data WHERE section_no like ?1% ", nativeQuery = true)
//    List<Map<String, Object>> findSlopeByCrystalNo(String crystalNo);
//
//    @Query(value = "SELECT crystal_no,section_no,device_no,center_head,center_tail,diameter_max,diameter_min,inspect_time,sinton_head1  FROM yb_inspect_data " +
//            "where section_no like ?1% AND inspect_time >=?2 AND inspect_time <=?3 ORDER BY section_no ASC", nativeQuery = true)
//    List<Map<String, Object>> getInspectCrystalNo(String crystalNo, String startTime, String endTime);
//
//    @Query(value = "SELECT crystal_no,section_no,device_no,center_head,center_tail,diameter_max,diameter_min,inspect_time,sinton_head1 FROM yb_inspect_data " +
//            "where device_no =?1 AND inspect_time >=?2 AND inspect_time <=?3 ORDER BY section_no ASC", nativeQuery = true)
//    List<Map<String, Object>> getInspectDeviceNo(String deviceNo, String startTime, String endTime);
//
//    @Query(value = "SELECT crystal_no,section_no,device_no,center_head,center_tail,diameter_max,diameter_min,inspect_time,sinton_head1  FROM yb_inspect_data " +
//            "where lot_no =?1 AND inspect_time >=?2 AND inspect_time <=?3 ORDER BY section_no ASC", nativeQuery = true)
//    List<Map<String, Object>> getInspectLotNo(String lotNo, String startTime, String endTime);
//
//    @Query(value = "SELECT crystal_no,section_no,device_no,center_head,center_tail,diameter_max,diameter_min,inspect_time,sinton_head1  FROM yb_inspect_data " +
//            "where device_no like ?1% AND inspect_time >=?2 AND inspect_time <=?3 ORDER BY section_no ASC", nativeQuery = true)
//    List<Map<String, Object>> getInspectSeries(String series, String startTime, String endTime);
//
//    @Query(value = "SELECT crystal_no,section_no,device_no,center_head,center_tail,diameter_max,diameter_min,inspect_time,sinton_head1  FROM yb_inspect_data " +
//            "where inspect_time >=?1 AND inspect_time <=?2 ORDER BY section_no ASC", nativeQuery = true)
//    List<Map<String, Object>> getInspectTiming(String startTime, String endTime);
//
//    @Query(value = "SELECT experiment_remark FROM yb_inspect_data WHERE section_no=?1 ", nativeQuery = true)
//    String getExperimentRemarkBySectionNo(String sectionNo);
//
//    @Query(value = "SELECT COUNT(1) FROM yb_inspect_data WHERE crystal_no=?1 AND section_count=?2 ", nativeQuery = true)
//    Integer getCountByCrystalNoAndSectionCount(String crystalNo, Integer sectionCount);
//
//    @Query(value = "SELECT product_level FROM yb_inspect_data WHERE section_no=?1  ", nativeQuery = true)
//    String getProductLevelSecond(String sectionNo);
//
//    @Query(value = "SELECT experiment_remark FROM yb_inspect_data WHERE section_no=?1  ", nativeQuery = true)
//    String getExperimentRemark(String sectionNo);
//
//    @Modifying
//    @Transactional
//    @Query(value = "UPDATE yb_inspect_data SET rfid='', code='' WHERE rfid=?1 ", nativeQuery = true)
//    void unBindingRfid(String rfid);
//
//    @Query(value = "call pro_inspect_query(:sectionNo,:crystalNo,:startTime,:endTime,:inspector,:code,:checkResult,:start,:rows)", nativeQuery = true)
//    List<InspectData> getListNew(@Param("sectionNo") String sectionNo, @Param("crystalNo") String crystalNo,
//                                 @Param("startTime") String startTime, @Param("endTime") String endTime,
//                                 @Param("inspector") String inspector, @Param("code") String code,
//                                 @Param("checkResult") String checkResult,
//                                 @Param("start") Long start, @Param("rows") Integer rows);
//
//    @Query(value = "call pro_inspect_query_count(:sectionNo,:crystalNo,:startTime,:endTime,:inspector,:code,:checkResult)", nativeQuery = true)
//    List<Map<String, Object>> getListNewCount(@Param("sectionNo") String sectionNo, @Param("crystalNo") String crystalNo,
//                                              @Param("startTime") String startTime, @Param("endTime") String endTime,
//                                              @Param("inspector") String inspector, @Param("code") String code,
//                                              @Param("checkResult") String checkResult);
//
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE crystal_no=?1 ", nativeQuery = true)
//    List<InspectData> findByCrystalNo(String crystalNo);
//
//    @Query(value = "SELECT * FROM yb_inspect_data where is_grade = true",
//            countQuery ="SELECT COUNT(1) FROM yb_inspect_data where grade_status = ?1" , nativeQuery = true)
//    Page<List<Map<String, Object>>> findByInspectDataPage(Integer gradeStatus, Pageable pageable);
//
//    @Query(value = "SELECT * FROM yb_inspect_data WHERE crystal_no IN(?1)", nativeQuery = true)
//    List<InspectData> findBySections(List<String> sectionNoList);
//}
