<?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.qwzx.mapper.TbQwBmjlbbMapper">

    <resultMap id="BaseResultMap" type="com.mosty.base.model.vo.qwzx.TbQwBmjlbbVo">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="bbrq" property="bbrq" />
        <result column="sfjjr" property="sfjjr" />
        <result column="jjrmc" property="jjrmc" />
        <result column="qwdj_id" property="qwdjId" />
        <result column="qwdjdm" property="qwdjdm" />
        <result column="qwdj" property="qwdj" />
        <result column="kssj" property="kssj" />
        <result column="jssj" property="jssj" />
        <result column="zgmjsl" property="zgmjsl" />
        <result column="zgmj" property="zgmj" />
        <result column="zgfjsl" property="zgfjsl" />
        <result column="zgfj" property="zgfj" />
        <result column="zbjlsl" property="zbjlsl" />
        <result column="zbjl" property="zbjl" />
        <result column="bzmjlsl" property="bzmjlsl" />
        <result column="bzgmj" property="bzgmj" />
        <result column="bzgfjsl" property="bzgfjsl" />
        <result column="bzgfj" property="bzgfj" />
        <result column="ssbm" property="ssbm" />
        <result column="ssbmdm" property="ssbmdm" />
        <result column="ssxgaj" property="ssxgaj" />
        <result column="ssxgajdm" property="ssxgajdm" />
        <result column="sssgaj" property="sssgaj" />
        <result column="sssgajdm" property="sssgajdm" />
        <result column="bz" property="bz" />
        <collection property="zbjlList" ofType="com.mosty.base.model.dto.qwzx.TbQwBmjlbbJlmxDto">
            <result column="id" property="id" />
            <result column="jlbb_id" property="jlbbId" />
            <result column="jl_id" property="jlId" />
            <result column="jllx" property="jllx" />
            <result column="jlxm" property="jlxm" />
            <result column="sfzh" property="sfzh" />
            <result column="jh" property="jh" />
            <result column="xbdm" property="xbdm" />
            <result column="nl" property="nl" />
            <result column="jlzt" property="jlzt" />
            <result column="bblx" property="bblx" />
        </collection>
        <collection property="zgjlList" ofType="com.mosty.base.model.dto.qwzx.TbQwBmjlbbJlmxDto">
            <result column="id" property="id" />
            <result column="jlbb_id" property="jlbbId" />
            <result column="jl_id" property="jlId" />
            <result column="jllx" property="jllx" />
            <result column="jlxm" property="jlxm" />
            <result column="sfzh" property="sfzh" />
            <result column="jh" property="jh" />
            <result column="xbdm" property="xbdm" />
            <result column="nl" property="nl" />
            <result column="jlzt" property="jlzt" />
            <result column="bblx" property="bblx" />
        </collection>
        <collection property="bzgjlList" ofType="com.mosty.base.model.dto.qwzx.TbQwBmjlbbJlmxDto">
            <result column="id" property="id" />
            <result column="jlbb_id" property="jlbbId" />
            <result column="jl_id" property="jlId" />
            <result column="jllx" property="jllx" />
            <result column="jlxm" property="jlxm" />
            <result column="sfzh" property="sfzh" />
            <result column="jh" property="jh" />
            <result column="xbdm" property="xbdm" />
            <result column="nl" property="nl" />
            <result column="jlzt" property="jlzt" />
            <result column="bblx" property="bblx" />
        </collection>
    </resultMap>

    <select id="selectOnCop" resultType="com.mosty.base.model.vo.qwzx.Gzqk">
        select count(1) zgmjsl,
        (select count(1) zgfjsl from tb_qw_bmjlbb_jlmx a where DATE_FORMAT(a.bbrq,'%Y-%m-%d')=
        DATE_FORMAT(NOW(),'%Y-%m-%d') and a.xt_scbz = '0' and a.xt_sjzt = '1' and a.jlzt = '1' and
        a.jllx = '02'
        <if test="ssbmdm != null and ssbmdm != ''">
            and a.ssbmdm like concat(#{ssbmdm,jdbcType=VARCHAR},'%')
        </if>
        ) as zgfjsl
        from tb_qw_bmjlbb_jlmx a where DATE_FORMAT(a.bbrq,'%Y-%m-%d')=
        DATE_FORMAT(NOW(),'%Y-%m-%d') and a.xt_scbz = '0' and a.xt_sjzt = '1' and a.jlzt = '1'
        and a.jllx = '01'
        <if test="ssbmdm != null and ssbmdm != ''">
            and a.ssbmdm like concat(#{ssbmdm,jdbcType=VARCHAR},'%')
        </if>

    </select>

    <select id="jlbbCount" resultType="com.mosty.base.model.vo.qwzx.TbQwBmjlbbCountVo">
        select SUM(zgmjsl) as zgmjs,SUM(zgfjsl) as zgfjs,SUM(bzmjlsl) as bzgmjs,SUM(bzgfjsl) as bzgfjs
        from tb_qw_bmjlbb
        <if test="params.kssj != null and params.jssj == null">
            and a.bbrq &gt;= #{params.kssj,jdbcType=DATE}
        </if>
        <if test="params.kssj == null and params.jssj != null">
            and a.bbrq &lt;= #{params.jssj,jdbcType=DATE}
        </if>
        <if test="params.kssj != null and params.jssj != null">
            and a.bbrq between #{params.kssj,jdbcType=DATE} and #{params.jssj,jdbcType=DATE}
        </if>
    </select>

</mapper>
