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

import com.sw.mes.core.base.BaseDao;
import com.sw.mes.fb.product.entity.ProductModelView;
import org.springframework.data.jpa.repository.Query;

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

public interface ProductModelViewDao extends BaseDao<ProductModelView,Integer> {


    @Query(value = "SELECT * FROM zhxx_fb_product_model_view " +
            "WHERE product_type_name=?1 AND product_level=?2 AND product_level_experiment=?3 " +
            "AND conductive_type=?4  AND length_min<=?5 AND length_max>=?5 " +
            "ORDER BY id DESC",nativeQuery = true)
    List<ProductModelView> automationGetProductModel(String productTypeName, String productLevel, String productLevelExperiment,
                                                     String conductiveType, BigDecimal length);

    @Query(value = "SELECT * FROM zhxx_fb_product_model_view " +
            "WHERE product_level_experiment IS NULL AND product_type_name=?1 AND product_level=?2 " +
            "AND conductive_type=?3 AND length_min<=?4 AND length_max>=?4 " +
            "ORDER BY id DESC",nativeQuery = true)
    List<ProductModelView> automationGetProductModel(String productTypeName, String productLevel, String conductiveType, BigDecimal length);
}
