<?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.watermeter.mapper.ReadmetereashisMapper">

    <resultMap id="readmetereashisMap" type="com.tofly.watermeter.entity.Readmetereashis">
        <result property="yhbh" column="YHBH"/>
        <result property="cbkh" column="CBKH"/>
        <result property="cbxh" column="CBXH"/>
        <result property="yhxm" column="YHXM"/>
        <result property="yhdz" column="YHDZ"/>
        <result property="lxdh" column="LXDH"/>
        <result property="sbbh" column="SBBH"/>
        <result property="sbcj" column="SBCJ"/>
        <result property="sblx" column="SBLX"/>
        <result property="sbkj" column="SBKJ"/>
        <result property="ysxz" column="YSXZ"/>
        <result property="xzxf" column="XZXF"/>
        <result property="cbpq" column="CBPQ"/>
        <result property="cbb" column="CBB"/>
        <result property="cwrq" column="CWRQ"/>
        <result property="scds" column="SCDS"/>
        <result property="bcds" column="BCDS"/>
        <result property="bcjjl" column="BCJJL"/>
        <result property="cbbz" column="CBBZ"/>
        <result property="jfzt" column="JFZT"/>
        <result property="cbry" column="CBRY"/>
        <result property="cbrq" column="CBRQ"/>
        <result property="jhrq" column="JHRQ"/>
        <result property="xzbs" column="XZBS"/>
        <result property="fileid" column="FILEID"/>
        <result property="cbfsCode" column="CBFS_CODE"/>
        <result property="shbz" column="SHBZ"/>
        <result property="auditUser" column="AUDIT_USER"/>
        <result property="auditCause" column="AUDIT_CAUSE"/>
        <result property="cbyf" column="CBYF"/>
        <result property="cbsl" column="CBSL"/>
        <result property="ysje" column="YSJE"/>
        <result property="auditResult" column="AUDIT_RESULT"/>
        <result property="auditReason" column="AUDIT_REASON"/>
        <result property="issyn" column="ISSYN"/>
        <result property="bz" column="BZ"/>
        <result property="lsbh" column="LSBH"/>
        <result property="sxjmessage" column="SXJMESSAGE"/>
        <result property="x" column="X"/>
        <result property="y" column="Y"/>
        <result property="addressState" column="ADDRESS_STATE"/>
        <result property="isGeneral" column="IS_GENERAL"/>
        <result property="month1" column="MONTH1"/>
        <result property="month2" column="MONTH2"/>
        <result property="month3" column="MONTH3"/>
        <result property="sinDouMonth" column="SIN_DOU_MONTH"/>
        <result property="startDay" column="START_DAY"/>
        <result property="endDay" column="END_DAY"/>
        <result property="cbqyMc" column="CBQY_MC"/>
        <result property="cbqyBm" column="CBQY_BM"/>
        <result property="cbqydBm" column="CBQYD_BM"/>
        <result property="monthPlan" column="MONTH_PLAN"/>
        <result property="cbryName" column="CBRY_NAME"/>
        <result property="qydmc" column="QYDMC"/>
        <result property="isOffline" column="IS_OFFLINE"/>
        <result property="startRq" column="START_RQ"/>
        <result property="endRq" column="END_RQ"/>
        <result property="cbrq1" column="CBRQ1"/>
        <result property="cbrq2" column="CBRQ2"/>
        <result property="cbrq3" column="CBRQ3"/>
        <result property="jbzd" column="JBZD"/>
        <result property="xbqd" column="XBQD"/>
        <result property="hblx" column="HBLX"/>
        <result property="hbrq" column="HBRQ"/>
        <result property="zeroCount" column="ZERO_COUNT"/>
        <result property="continuityUp" column="CONTINUITY_UP"/>
        <result property="continuityDown" column="CONTINUITY_DOWN"/>
        <result property="continuityEqual" column="CONTINUITY_EQUAL"/>
        <result property="diffTime" column="DIFF_TIME"/>
        <result property="yearonyear1" column="YEARONYEAR1"/>
        <result property="yearonyear2" column="YEARONYEAR2"/>
        <result property="yearonyear3" column="YEARONYEAR3"/>
        <result property="yearonmonth1" column="YEARONMONTH1"/>
        <result property="yearonmonth2" column="YEARONMONTH2"/>
        <result property="yearonmonth3" column="YEARONMONTH3"/>
        <result property="auditTime" column="AUDIT_TIME"/>
        <result property="auditType" column="AUDIT_TYPE"/>
        <result property="qualityCount" column="QUALITY_COUNT"/>
        <result property="updateWater" column="UPDATE_WATER"/>
        <result property="uploadDay" column="UPLOAD_DAY"/>
        <result property="abnomalId" column="ABNOMAL_ID"/>
        <result property="sjsl" column="SJSL"/>
        <result property="updateBcds" column="UPDATE_BCDS"/>
        <result property="updateScds" column="UPDATE_SCDS"/>
        <result property="isUpdatecbsl" column="IS_UPDATECBSL"/>
        <result property="isUpdateid" column="IS_UPDATEID"/>
        <result property="isfirst" column="ISFIRST"/>
        <result property="isbreakRead" column="ISBREAK_READ"/>
        <result property="orderIds" column="ORDER_IDS"/>
        <result property="sxjSbqd" column="SXJ_SBQD"/>
        <result property="cbrq4" column="CBRQ4"/>
        <result property="isEstimate" column="IS_ESTIMATE"/>
        <result property="imgUrl" column="IMG_URL"/>
        <result property="isModel" column="IS_MODEL"/>
        <result property="auditPassReson" column="AUDIT_PASS_RESON"/>
        <result property="soleSign" column="SOLE_SIGN"/>
        <result property="gdId" column="GD_ID"/>
    </resultMap>

    <select id="getHisInfo" resultType="com.tofly.watermeter.entity.Readmetereashis">
        select r.YHBH,q.YHXM,CBSL,CBYF
        from TF_YWPN_READMETEREASHIS_W r
        left join TF_YWPN_QFKHJBXX_W q on r.YHBH = q.YHBH
        where r.YHBH = #{yhbh}
        <if test="start != null and start != '' and end != null and end != ''">
            and cbyf between #{start} and #{end}
        </if>
        order by cbyf
    </select>

    <select id="getLastWaterVal" resultType="long">
        select distinct BCJJL
        from TF_YWPN_READMETEREASHIS_W
        where YHBH = #{yhbh}
          and cbyf = to_char(add_months(to_date(#{cbyf}, 'yyyy-mm'), #{lastNumber}), 'yyyymm')
    </select>

    <select id="readmetereashisInfo" resultType="com.tofly.watermeter.custom.dto.ReadFarDo" fetchSize="1000">
        select distinct YHBH,
                        BCDS,
                        SCDS,
                        CBRQ,
                        CBYF,
                        BCJJL     bczl,
                        CBFS_CODE cbfscode,
                        BZ
        from TF_YWPN_READMETEREASHIS_W
        where CBYF in (${month})
    </select>

    <select id="getNumber" resultType="map">
        select nvl(CONTINUITY_UP, 0)    up,
               nvl(CONTINUITY_DOWN, 0)  down,
               nvl(CONTINUITY_EQUAL, 0) equal,
               nvl(ZERO_COUNT, 0)       zero
        from TF_YWPN_READMETEREASHIS_W
        where YHBH = #{yhbh}
          and cbyf = to_char(add_months(to_date(#{cbyf}, 'yyyy-mm'), #{lastNumber}), 'yyyymm')
    </select>

</mapper>
