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

    <resultMap id="bwsjdatailMap" type="com.tofly.watermeter.entity.Bwsjdatail">
        <id property="id" column="ID"/>
        <result property="bwRkid" column="BW_RKID"/>
        <result property="bwPcbh" column="BW_PCBH"/>
        <result property="bwSbcj" column="BW_SBCJ"/>
        <result property="bwSblx" column="BW_SBLX"/>
        <result property="bwSbkj" column="BW_SBKJ"/>
        <result property="bwSbsl" column="BW_SBSL"/>
        <result property="bwCjsl" column="BW_CJSL"/>
        <result property="bwCjbl" column="BW_CJBL"/>
        <result property="bwHgsl" column="BW_HGSL"/>
        <result property="bwHgbl" column="BW_HGBL"/>
        <result property="bwJybm" column="BW_JYBM"/>
        <result property="bwJyrq" column="BW_JYRQ"/>
        <result property="operateUser" column="OPERATE_USER"/>
        <result property="operateDate" column="OPERATE_DATE"/>
        <result property="bwBz" column="BW_BZ"/>
        <result property="isCheck" column="IS_CHECK"/>
        <result property="wbbm" column="WBBM"/>
        <result property="bwBhgs" column="BW_BHGS"/>
        <result property="createDate" column="CREATE_DATE"/>
        <association column="IS_CHECK" property="state" select="getState"/>
        <association property="operateUserName" column="OPERATE_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
<!--        根据入库记录明细表ID查询批次名称-->
        <association property="pcName" column="BW_RKID" select="getPcName"/>
        <association property="sbcjName" column="BW_SBCJ" select="getCodeById"/>
        <association property="sbkjName" column="BW_SBKJ" select="getCodeById"/>
        <association property="sblxName" column="BW_SBLX" select="getCodeById"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
    </resultMap>
    <select id="getCodeById" resultType="string">
        select CNAME from TF_YWPN_SYSCHILDCODE_D where ID=#{id}
    </select>

    <select id="getState" resultType="string">
        select DECODE(#{isCheck}, '0','未处理','1','已处理') from dual
    </select>
    <select id="getPcName" resultType="string">
        select BW_PCMC from TF_YWPN_BWRKDETAIL_W where ID=#{rkId}
    </select>
    <select id="getSjData" resultMap="bwsjdatailMap">
        select ID,BW_RKID,BW_PCBH,BW_SBCJ,BW_SBLX,BW_SBKJ,BW_SBSL,BW_CJSL,BW_CJBL,BW_HGSL,BW_HGBL,BW_JYBM,BW_JYRQ,IS_CHECK
        from TF_YWPN_BWSJDATAIL_W
    </select>



</mapper>
