<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mosty.yjzl.mapper.TbFzycMapper">
    <select id="selectListBm" resultType="com.mosty.base.model.entity.yjzl.TbFzyc">
        SELECT  *   FROM `tb_fzyc`  WHERE  xt_sjzt = '1' and xt_scbz = '0'
        <if test="ssbmdm != null and ssbmdm != ''">
            and  id IN (  SELECT DISTINCT  fzyc_id  FROM tb_fzyc_jsdx  WHERE xt_scbz = '0'
               and  ssbmdm  like concat(#{ssbmdm},'%')
                <if test="keyWord != null and keyWord != ''">
                    and (
                        ssbm like concat('%',#{keyWord},'%')
                      or  xfq_mc like concat('%',#{keyWord},'%')
                    )
                </if>
            )
        </if>
        <if test="kssj != null and kssj != ''">
            and real_date >= #{kssj}
        </if>
        <if test="jssj != null and jssj != ''">
            and real_date &lt;= #{jssj}
        </if>
        <if test="gridType != null and gridType != ''">
            and grid_type = #{gridType}
        </if>
        <if test="bc != null and bc != ''">
            and bc = #{bc}
        </if>
        <if test="sfxl != null and sfxl != ''">
            and sfxl = #{sfxl}
        </if>
        <if test="bcList != null and bcList.size() > 0">
            and  bc in
            <foreach collection="bcList" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        order by real_date desc
    </select>

    <select id="getFzyjCount" resultType="int">

        SELECT  count(1)  FROM `tb_fzyc`  WHERE  xt_sjzt = '1' and xt_scbz = '0'
        <if test="ssbmdm != null and ssbmdm != ''">
            and  id IN (  SELECT DISTINCT  fzyc_id  FROM tb_fzyc_jsdx  WHERE
            ssbmdm  like concat(#{ssbmdm},'%')
            )
        </if>
        <if test="kssj != null and kssj != ''">
            and real_date >= #{kssj}
        </if>
        <if test="jssj != null and jssj != ''">
            and real_date &lt;= #{jssj}
        </if>
        <if test="gridType != null and gridType != ''">
            and grid_type = #{gridType}
        </if>
        <if test="bc != null and bc != ''">
            and bc = #{bc}
        </if>
        <if test="sfxl != null and sfxl != ''">
            and sfxl = #{sfxl}
        </if>
    </select>
</mapper>
