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

import com.sw.mes.core.base.BaseDao;
import com.sw.mes.yb.alloy.entity.FixLogic;
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 FixLogicDao extends BaseDao<FixLogic, Integer> {

    @Query(value = "select * from alloy_fix_logic where heat_field=:heatField and material_short_name=:materialShortName and " +
            "add_time=:addTime", nativeQuery = true)
    List<FixLogic> findAllByFixLogic(@Param("heatField") String heatField,
                                     @Param("materialShortName") String materialShortName,
                                     @Param("addTime") String addTime);

    @Query(value = "select * from alloy_fix_logic where fix_upper_limit >= ?1 and fix_lower_limit <= ?1",nativeQuery = true)
    FixLogic findByFixUpperLimit(BigDecimal tResistivity);

    @Query(value = "select * from alloy_fix_logic where heat_field=:heatField and material_short_name=:materialShortName and " +
            "add_time=:addTime limit 1", nativeQuery = true)
    FixLogic findByHeatFieldAndMaterialShortNameAndAddTime(@Param("heatField") String heatField,
                                                           @Param("materialShortName") String materialShortName,
                                                           @Param("addTime") Integer addTime);
}