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

import com.sw.mes.core.base.BaseDao;
import com.sw.mes.yb.pc.entity.HeadTailMaterialRule;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @Author
 * @Description：
 * @Date:
 * @Modified By:
 */
public interface HeadTailMaterialRuleDao extends BaseDao<HeadTailMaterialRule, Integer> {
    /**
     * 查询是否存在
     *
     * @param bracketNo 拖位号
     * @return 条数
     */
    @Query(value = "SELECT 1 FROM head_tail_material_rule WHERE bracket_no=?1 LIMIT 1", nativeQuery = true)
    Integer findCountByBracketNo(Integer bracketNo);

    @Query(value = "SELECT * FROM head_tail_material_rule WHERE dopant=?1 ", nativeQuery = true)
    List<HeadTailMaterialRule> findByDopant(String dopant);

    @Query(value = "SELECT * FROM head_tail_material_rule WHERE dopant=?1 AND line=?2 AND region_code=?3 AND product_type=?4", nativeQuery = true)
    List<HeadTailMaterialRule> findByDopantAndLineAndRegionCodeAndProductType(String dopant, String line, String regionCode, String productType);

}
