package com.sw.mes.fb.checkout.dao;

import com.sw.mes.core.base.BaseDao;
import com.sw.mes.fb.checkout.dto.SquareRodNumberDto;
import com.sw.mes.fb.checkout.entity.RecutDetail;
import com.sw.mes.fb.checkout.entity.SquareRodNumber;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

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

    @Query(value = "SELECT crystal_no FROM square_rod_number WHERE point =?1 ORDER BY id DESC LIMIT 1", nativeQuery = true)
    String findByPoint(String point);

    @Query(value = "SELECT * FROM square_rod_number WHERE point =?1 ORDER BY id DESC LIMIT 1", nativeQuery = true)
    SquareRodNumber findByPoint1(String point);

    @Query(value = "SELECT * FROM square_rod_number WHERE point =?1 ORDER BY id DESC", nativeQuery = true)
    List<SquareRodNumber> findByPoint2(String point);

    @Query(value = "SELECT * FROM square_rod_number WHERE crystal_no =?1", nativeQuery = true)
    List<SquareRodNumber> findBySectionNo(String sectionNo);

    @Query(value = "SELECT crystal_no, point FROM square_rod_number WHERE crystal_no =?1", nativeQuery = true)
    SquareRodNumberDto findByCrystalNo(String crystalNo);
}
