<?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.tofly.feesapi.yhgl.mapper.YhHfysLogMapper">
    <!--获取用户最大ID -->
    <select id="selectMaxId" resultType="int">
        select nvl(max(to_number(bh)), 0) bh
        from yh_hfys_log
    </select>
    <select id="selectDaCustomerBtPage" resultType="com.tofly.feesapi.yhgl.entity.vo.YhHfysLogSelect">
        select * from (
        select a.*,
        cbpq.cbpqmc as sscbpqname,
        cbb.cbbmc as sscbbname
        from yh_hfys_log a
        left join bm_cbpq cbpq on a.sscbpq=cbpq.cbpqbm
        left join bm_cbb cbb on a.sscbb=cbb.cbbbm
        where 1=1
        <!--模糊查询 -->
        <if test="filter.searchText != null and filter.searchText != ''">
            and ( a.yhbh like '%${filter.searchText}%' or
            a.yhxm like '%${filter.searchText}%' or
            a.yhdz like '%${filter.searchText}%' or
            a.lxdh like '%${filter.searchText}%' )
        </if>
        <!--公司 -->
        <if test="filter.ssgs !=null and filter.ssgs!='' and filter.ssgs!='all'">
            and a.ssgs=#{filter.ssgs}
        </if>
        <!--片区 -->
        <if test="filter.sscbpq !=null and filter.sscbpq!='' and filter.sscbpq!='all' ">
            and a.sscbpq=#{filter.sscbpq}
        </if>
        <!--抄表本 -->
        <if test="filter.sscbb !=null and filter.sscbb!='' and filter.sscbb!='all'">
            and a.sscbb=#{filter.sscbb}
        </if>
        <if test="filter.qyfzr!=null">
            and a.sscbb in(select cbbbm from bm_cbb where qyfzr=#{filter.qyfzr})
        </if>
        <!--申请日期-->
        <if test="filter.ksrq!=null and filter.ksrq!='' and filter.jsrq!=null and filter.jsrq!='' ">
            and a.sqrq between to_date(#{filter.ksrq},'yyyy-mm-dd hh24:mi:ss') and
            to_date(#{filter.jsrq},'yyyy-mm-dd hh24:mi:ss')
        </if>
        <if test="filter.czry!=null and filter.czry!=''">
            and a.czrybm=#{filter.czry}
        </if>
        )
    </select>
    <resultMap id="yhHfysLogMap" type="com.tofly.feesapi.yhgl.entity.YhHfysLog">
        <id property="bh" column="BH"/>
        <result property="ssgs" column="SSGS"/>
        <result property="sscbpq" column="SSCBPQ"/>
        <result property="sscbb" column="SSCBB"/>
        <result property="czrq" column="CZRQ"/>
        <result property="yhbh" column="YHBH"/>
        <result property="yhxm" column="YHXM"/>
        <result property="yhdz" column="YHDZ"/>
        <result property="lxdh" column="LXDH"/>
        <result property="sqrq" column="SQRQ"/>
        <result property="fyje" column="FYJE"/>
        <result property="fpz" column="FPZ"/>
        <result property="fph" column="FPH"/>
        <result property="dycs" column="DYCS"/>
        <result property="bz" column="BZ"/>
        <result property="sfryxm" column="SFRYXM"/>
        <result property="czrybm" column="CZRYBM"/>
        <result property="czryxm" column="CZRYXM"/>
    </resultMap>


</mapper>
