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

import com.sw.mes.core.base.BaseDao;
import com.sw.mes.yb.alloy.entity.ResistanceOfThisRod;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.math.BigDecimal;
import java.util.List;

/**
* @Author
* @Description：
* @Date:
* @Modified By:
*/
public interface ResistanceOfThisRodDao extends BaseDao<ResistanceOfThisRod, Integer>{

    @Query(value = "select * from alloy_resistance_of_this_rod where furnace_code = :furnaceCode and heat_field=:heatField " +
            "and add_time=:addTime and material_short_name=:materialShortName and resistance_of_this_rod=:resistanceOfThisRod",nativeQuery=true)
    List<ResistanceOfThisRod> findAllByResistanceOfThisRod(@Param("furnaceCode") String furnaceCode,
                                                           @Param("heatField")  String heatField,
                                                           @Param("addTime") Integer addTime,
                                                           @Param("materialShortName") String materialShortName,
                                                           @Param("resistanceOfThisRod") BigDecimal resistanceOfThisRod);

    @Query(value = "select * from alloy_resistance_of_this_rod where furnace_code = ?1 and add_time = ?2 order by id desc limit 1",nativeQuery = true)
    ResistanceOfThisRod findByFurnaceCodeAndAddTime(String lotNo, int addTime);
}