<?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.wzzx.mapper.WztjMapper">
    <select id="jwzbmlbtj" resultType="java.util.Map">
        select id, yh_id, yh_sfzh, yh_xm, zb, zbsl, dwrq, kssj, jssj, sc, lc, jd, wd, zhgxsj, ssbm, ssbmdm
        from mosty_wzzx.tb_wz_rywz where xt_sjzt='1' and xt_scbz='0'
        <if test="dto.ksrq != null and dto.ksrq != ''">
            and dwrq >= #{dto.ksrq}
        </if>
        <if test="dto.jsrq != null and dto.jsrq != ''">
            and dwrq &lt;= #{dto.jsrq}
        </if>
        <if test="dto.ksrq == null and dto.ksrq == '' and dto.jsrq == null and dto.jsrq == ''">
            and TO_DAYS(dwrq) = TO_DAYS(NOW())
        </if>
        <if test="dto.yhxm != null and dto.yhxm != ''">
            and yh_xm like concat('%',#{dto.yhxm},'%')
        </if>
        <if test="dto.kslc != null and dto.kslc != ''">
            and lc >= #{dto.kslc}
        </if>
        <if test="dto.jslc != null and dto.jslc != ''">
            and lc &lt;= #{dto.jslc}
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
    </select>

    <select id="xz" resultType="java.util.Map">
        select id, bb_id as bbId, yh_id as yhId, yh_sfzh as yhSfzh, yh_xm as yhXm,jz_id as jzId, jz_mc as jcMc, zb,
        zbsl, dwrq, kssj, jssj, sc, lc, jd, wd, zhgxsj, ssbm, ssbmdm
        from mosty_wzzx.tb_wz_xfwz where xt_sjzt='1' and xt_scbz='0'
        <if test="dto.ksrq != null and dto.ksrq != ''">
            and dwrq >= #{dto.ksrq}
        </if>
        <if test="dto.jsrq != null and dto.jsrq != ''">
            and dwrq &lt;= #{dto.jsrq}
        </if>
        <if test="dto.ksrq == null and dto.ksrq == '' and dto.jsrq == null and dto.jsrq == ''">
            and TO_DAYS(dwrq) = TO_DAYS(NOW())
        </if>
        <if test="dto.yhxm != null and dto.yhxm != ''">
            and yh_xm like concat('%',#{dto.yhxm},'%')
        </if>
        <if test="dto.kslc != null and dto.kslc != ''">
            and lc >= #{dto.kslc}
        </if>
        <if test="dto.jslc != null and dto.jslc != ''">
            and lc &lt;= #{dto.jslc}
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
    </select>

    <select id="jrlcs" resultType="java.util.Map">
        select COALESCE(sum(lc), 0) as lcs from mosty_wzzx.tb_wz_rywz where xt_sjzt='1' and xt_scbz='0'
        <if test="dto.ksrq != null and dto.ksrq != ''">
            and dwrq >= #{dto.ksrq}
        </if>
        <if test="dto.jsrq != null and dto.jsrq != ''">
            and dwrq &lt;= #{jsrq}
        </if>
        <if test="dto.ksrq == null and dto.ksrq == '' and dto.jsrq == null and dto.jsrq == ''">
            and TO_DAYS(dwrq) = TO_DAYS(NOW())
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
    </select>

    <select id="rslcxz" resultType="java.util.Map">
        select a.sl as wzrs,b.lcs as lcs,c.wzs as wzs from
        (
        select count(1) as sl from mosty_wzzx.tb_wz_rywz where xt_sjzt='1' and xt_scbz='0'
        <if test="dto.ksrq != null and dto.ksrq != ''">
            and dwrq >= #{dto.ksrq}
        </if>
        <if test="dto.jsrq != null and dto.jsrq != ''">
            and dwrq &lt;= #{dto.jsrq}
        </if>
        <if test="dto.ksrq == null and dto.ksrq == '' and dto.jsrq == null and dto.jsrq == ''">
            and TO_DAYS(dwrq) = TO_DAYS(NOW())
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
        ) a,
        (
        select COALESCE(sum(lc), 0) as lcs from mosty_wzzx.tb_wz_rywz where xt_sjzt='1' and xt_scbz='0'
        <if test="dto.ksrq != null and dto.ksrq != ''">
            and dwrq >= #{dto.ksrq}
        </if>
        <if test="dto.jsrq != null and dto.jsrq != ''">
            and dwrq &lt;= #{dto.jsrq}
        </if>
        <if test="dto.ksrq == null and dto.ksrq == '' and dto.jsrq == null and dto.jsrq == ''">
            and TO_DAYS(dwrq) = TO_DAYS(NOW())
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
        ) b,
        (
        select count(1) as wzs from mosty_wzzx.tb_wz_xfwz where xt_sjzt='1' and xt_scbz='0' and bb_id is not null
        <if test="dto.ksrq != null and dto.ksrq != ''">
            and dwrq >= #{dto.ksrq}
        </if>
        <if test="dto.jsrq != null and dto.jsrq != ''">
            and dwrq &lt;= #{dto.jsrq}
        </if>
        <if test="dto.ksrq == null and dto.ksrq == '' and dto.jsrq == null and dto.jsrq == ''">
            and TO_DAYS(dwrq) = TO_DAYS(NOW())
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
        ) c
    </select>

    <select id="jrwzrs" resultType="java.util.Map">
        select count(1) as sl from mosty_wzzx.tb_wz_rywz where xt_sjzt='1' and xt_scbz='0'
        <if test="dto.ksrq != null and dto.ksrq != ''">
            and dwrq >= #{dto.ksrq}
        </if>
        <if test="dto.jsrq != null and dto.jsrq != ''">
            and dwrq &lt;= #{dto.jsrq}
        </if>
        <if test="dto.ksrq == null and dto.ksrq == '' and dto.jsrq == null and dto.jsrq == ''">
            and TO_DAYS(dwrq) = TO_DAYS(NOW())
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
    </select>

    <select id="jrxzwzs" resultType="java.util.Map">
        select count(1) as wzs from mosty_wzzx.tb_wz_xfwz where xt_sjzt='1' and xt_scbz='0' and bb_id is not null
        <if test="dto.ksrq != null and dto.ksrq != ''">
            and dwrq >= #{dto.ksrq}
        </if>
        <if test="dto.jsrq != null and dto.jsrq != ''">
            and dwrq &lt;= #{dto.jsrq}
        </if>
        <if test="dto.ksrq == null and dto.ksrq == '' and dto.jsrq == null and dto.jsrq == ''">
            and TO_DAYS(dwrq) = TO_DAYS(NOW())
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
    </select>

    <select id="rywzlbCount" resultType="int">
        select count(1) from mosty_wzzx.tb_wz_rywz where xt_sjzt='1' and xt_scbz='0'
        <if test="dto.ksrq != null and dto.ksrq != ''">
            and dwrq >= #{dto.ksrq}
        </if>
        <if test="dto.jsrq != null and dto.jsrq != ''">
            and dwrq &lt;= #{dto.jsrq}
        </if>
        <if test="dto.ksrq == null and dto.ksrq == '' and dto.jsrq == null and dto.jsrq == ''">
            and TO_DAYS(dwrq) = TO_DAYS(NOW())
        </if>
        <if test="dto.yhxm != null and dto.yhxm != ''">
            and yh_xm like concat('%',#{dto.yhxm},'%')
        </if>
        <if test="dto.kslc != null and dto.kslc != ''">
            and lc >= #{dto.kslc}
        </if>
        <if test="dto.jslc != null and dto.jslc != ''">
            and lc &lt;= #{dto.jslc}
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
    </select>

    <select id="rywzlb" resultType="java.util.Map">
        select id, yh_id, yh_sfzh,yh_xm,zb,zbsl,dwrq,kssj,jssj,sc,lc,ssbm,ssbmdm,ssbmid
        from mosty_wzzx.tb_wz_rywz where xt_sjzt='1' and xt_scbz='0'
        <if test="dto.ksrq != null and dto.ksrq != ''">
            and dwrq >= #{dto.ksrq}
        </if>
        <if test="dto.jsrq != null and dto.jsrq != ''">
            and dwrq &lt;= #{dto.jsrq}
        </if>
        <if test="dto.ksrq == null and dto.ksrq == '' and dto.jsrq == null and dto.jsrq == ''">
            and TO_DAYS(dwrq) = TO_DAYS(NOW())
        </if>
        <if test="dto.yhxm != null and dto.yhxm != ''">
            and yh_xm like concat('%',#{dto.yhxm},'%')
        </if>
        <if test="dto.kslc != null and dto.kslc != ''">
            and lc >= #{dto.kslc}
        </if>
        <if test="dto.jslc != null and dto.jslc != ''">
            and lc &lt;= #{dto.jslc}
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
        limit #{pageIndex},#{pageSize}
    </select>

    <select id="bbgjcx" resultType="java.util.Map">
        select * from mosty_wzzx.tb_wz_xfwz where xt_sjzt='1' and xt_scbz='0'
        <if test="dto.bbid != null and dto.bbid != ''">
            and bb_id = #{dto.bbid}
        </if>
        <if test="dto.yhid != null and dto.yhid != ''">
            and yh_id = #{dto.yhid}
        </if>
        <if test="dto.yhsfzh != null and dto.yhsfzh != ''">
            and yh_sfzh = #{dto.yhsfzh}
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
        order by xt_cjsj desc
    </select>

    <select id="bbwzcx" resultType="java.util.Map">
        select * from mosty_wzzx.tb_wz_xfwz where xt_sjzt='1' and xt_scbz='0'
        <if test="dto.bbid != null and dto.bbid != ''">
            and bb_id = #{dto.bbid}
        </if>
        <if test="dto.yhid != null and dto.yhid != ''">
            and yh_id = #{dto.yhid}
        </if>
        <if test="dto.yhsfzh != null and dto.yhsfzh != ''">
            and yh_sfzh = #{dto.yhsfzh}
        </if>
        <if test="dto.kssj != null and dto.kssj != ''">
            and dwrq >= #{dto.kssj}
        </if>
        <if test="dto.jssj != null and dto.jssj != ''">
            and dwrq &lt;= #{dto.jssj}
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
        order by xt_cjsj desc
    </select>

    <select id="mjgjcx" resultType="java.util.Map">
        select * from mosty_wzzx.tb_wz_rywz where xt_sjzt='1' and xt_scbz='0'
        <if test="dto.yhid != null and dto.yhid != ''">
            and yh_id = #{dto.yhid}
        </if>
        <if test="dto.yhsfzh != null and dto.yhsfzh != ''">
            and yh_sfzh = #{dto.yhsfzh}
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
        order by xt_cjsj desc
    </select>

    <select id="wbbwz" resultType="java.util.Map">
        select * from mosty_wzzx.tb_wz_rywz where xt_sjzt='1' and xt_scbz='0'
        <if test="dto.yhid != null and dto.yhid != ''">
            and yh_id = #{dto.yhid}
        </if>
        <if test="dto.yhsfzh != null and dto.yhsfzh != ''">
            and yh_sfzh = #{dto.yhsfzh}
        </if>
        <if test="dto.kssj != null and dto.kssj != ''">
            and dwrq >= #{dto.kssj}
        </if>
        <if test="dto.jssj != null and dto.jssj != ''">
            and dwrq &lt;= #{dto.jssj}
        </if>
        <if test="dto.ssbmid != null and dto.ssbmid != ''">
            and ssbmid = #{dto.ssbmid}
        </if>
        ${useSql}
        order by xt_cjsj desc
    </select>


</mapper>