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

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

import java.util.List;

public interface JcJyItemChargeMapper {
    /**根据单个编号查询收费编码
     * @param code
     * @param reqType
     * @param tableName
     * @return
     */
    @Select("select rtrim(code) code,rtrim(charge_code) charge_code,amount,rtrim(charge_type) charge_type,rtrim(tc_no) tc_no,rtrim(zy_flag) zy_flag," +
            "rtrim(mz_flag) mz_flag,${reqType} as req_type from ${tableName} where code=#{code,jdbcType=CHAR}")
    JcJyItemCharge selectJcItemChargeByCode(@Param("code") String code, @Param("reqType") String reqType,@Param("tableName") String tableName);

    /**
     * 根据项目编码集合查询所含的收费编码集合
     * @param codes
     * @param reqType
     * @param tableName
     * @return
     */
    @Select({"<script>",
            "select rtrim(code) code,rtrim(charge_code) charge_code,amount,rtrim(charge_type) charge_type,rtrim(tc_no) tc_no,rtrim(zy_flag) zy_flag,",
            "rtrim(mz_flag) mz_flag,${reqType} as req_type from ${tableName} where  charge_code <![CDATA[<>]]> '' and charge_code is not null ",
            "<when test='codes!=null'>",
            " and code in",
            "<foreach item='item' index='index' collection='codes' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</when>",
            "</script>"})
    List<JcJyItemCharge> selectJcItemChargeByCodeList(@Param("codes") List<String> codes, @Param("reqType") String reqType, @Param("tableName") String tableName);
}
