package cn.hnthyy.thmz.mapper.his.mz;

import cn.hnthyy.thmz.entity.his.mz.JyZdItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface JyZdItemMapper {

    /**根据单个检验字典查询收费编码
     * @param code
     * @return
     */
    @Select("select rtrim(code) code,name,rtrim(class) class_code,rtrim(exec_unit) exec_unit,vessel,dosage,rtrim(sample_code) sample_code,py_code,d_code wb_code," +
            "rtrim(del_flag) del_flag,rtrim(zy_flag) zy_flag,zy_order_code,rtrim(mz_flag) mz_flag,mz_code,cx_times from jy_zd_item where code=#{code,jdbcType=CHAR}")
    JyZdItem selectJyZdItemByCode(@Param("code") String code);

    /**
     * 根据检验字典集合查询所含的收费编码集合
     * @param codes
     * @return
     */
    @Select({"<script>",
            "select rtrim(code) code,name,rtrim(class) class_code,rtrim(exec_unit) exec_unit,vessel,dosage,rtrim(sample_code) sample_code,py_code,d_code wb_code," +
                    "rtrim(del_flag) del_flag,rtrim(zy_flag) zy_flag,zy_order_code,rtrim(mz_flag) mz_flag,mz_code,cx_times from jy_zd_item",
            "<when test='codes!=null'>",
            " where code in",
            "<foreach item='item' index='index' collection='codes' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</when>",
            "</script>"})
    List<JyZdItem> selectJyZdItemByCodeList(@Param("codes") List<String> codes);





    /**
     * 根据检验字典集合查询抽血次数
     * @param codes
     * @return
     */
    @Select({"<script>",
            "select rtrim(code) code,name,rtrim(class) class_code,rtrim(exec_unit) exec_unit,vessel,dosage,rtrim(sample_code) sample_code,py_code,d_code wb_code," +
                    "rtrim(del_flag) del_flag,rtrim(zy_flag) zy_flag,zy_order_code,rtrim(mz_flag) mz_flag,mz_code,cx_times from jy_zd_item" +
                    " where vessel is not null and vessel <![CDATA[<>]]>  '' ",
            "<when test='codes!=null'>",
            " and code in",
            "<foreach item='item' index='index' collection='codes' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</when>",
            "</script>"})
    List<JyZdItem> selectCxTimesByCodeList(@Param("codes") List<String> codes);
}
