<?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.BwckdatailMapper">

    <resultMap id="bwckdatailMap" type="com.tofly.watermeter.entity.Bwckdatail">
        <id property="id" column="ID"/>
        <result property="bwLsbh" column="BW_LSBH"/>
        <result property="bwSbqh" column="BW_SBQH"/>
        <result property="bwSbzh" column="BW_SBZH"/>
        <result property="bwBhqz" column="BW_BHQZ"/>
        <result property="bwSbcj" column="BW_SBCJ"/>
        <result property="bwSblx" column="BW_SBLX"/>
        <result property="bwSbkj" column="BW_SBKJ"/>
        <result property="bwSl" column="BW_SL"/>
        <result property="bwLqbm" column="BW_LQBM"/>
        <result property="bwLqry" column="BW_LQRY"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createDate" column="CREATE_DATE"/>
        <result property="bwBz" column="BW_BZ"/>
        <result property="bwRkid" column="BW_RKID"/>
        <result property="isPart" column="IS_PART"/>
        <result property="contract" column="CONTRACT"/>
        <result property="contractCode" column="CONTRACT_CODE"/>
        <result property="meterUse" column="METER_USE"/>
        <association property="meterUseName" column="METER_USE"
                     select="getMeterUseName"/>
        <association property="lqryName" column="BW_LQRY"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
        <association property="sbcjName" column="BW_SBCJ"
                     select="com.tofly.watermeter.mapper.BwrksbdatailMapper.getVendor"/>
        <association property="sbkjName" column="BW_SBKJ"
                     select="com.tofly.watermeter.mapper.BwrksbdatailMapper.getCal"/>
        <association property="sblxName" column="BW_SBLX"
                     select="com.tofly.watermeter.mapper.BwrksbdatailMapper.getType"/>
    </resultMap>

    <select id="getMeterUseName" resultType="string">
        select CNAME
        from TF_YWPN_SYSCHILDCODE_D
        where PCID = 40043
          and CCODE = TO_CHAR(#{meterUse})
    </select>


    <update id="updateCk">
        <foreach collection="sbCkList" open="begin" close=";end;" item="sb" separator=";">
            update TF_YWPN_BWCKDATAIL_W
            <set>
                BW_SL=#{sb.num}
            </set>
            where ID=#{sb.ckId}
        </foreach>
    </update>
    <update id="updateGdZt">
        update TF_YWPN_GDINFO_W
        set IS_WATERMETER_STATUS = #{val}
        where GDBH = #{gdbh}
    </update>
    <select id="getGdbh" resultType="java.lang.String">
        select GDBH
        from TF_YWPN_GDGLINFO_W
        where ID = #{gdId}
    </select>
    <select id="ckPrefix" resultType="java.lang.String">
        select CCONTERT from TF_YWPN_SYSCHILDCODE_D where ID = #{cjId}
    </select>


</mapper>
