<?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.custom.mapper.ZySbInfoMapper">
    <resultMap id="zysbjddatailMap" type="com.tofly.watermeter.custom.entity.ZySbInfo">
        <id property="id" column="ID"/>
        <result property="bwLsbh" column="BW_LSBH"/>
        <result property="bwSjly" column="BW_SJLY"/>
        <result property="bwJyjg" column="BW_JYJG"/>
        <result property="bwJyrq" column="BW_JYRQ"/>
        <result property="bwPhoto" column="BW_PHOTO"/>
        <result property="bwFileid" column="BW_FILEID"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createTime" column="CREATE_DATE"/>
        <result property="sbbh" column="SBBH"/>
        <result property="bwBz" column="BW_BZ"/>
        <result property="bwJyry" column="BW_JYRY"/>
        <result property="sbid" column="SBID"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"></association>
        <association property="sbdetail" column="SBBH"
                     select="com.tofly.watermeter.mapper.BwrksbdatailMapper.getSbXq"/>
        <association property="isQualifed" column="BW_JYJG"
                     select="getJyhg"/>
        <collection property="filePaths" column="BW_FILEID" select="getFileByIds"/>

    </resultMap>
    <select id="getZy" resultMap="zysbjddatailMap">
        select * from TF_YWPN_BWZYSBJDDATAIL_W
    </select>
    <select id="getFileByIds" resultType="string">
        select FILE_PATH from TF_YWPN_FILE_W where ID in
        <if test="fileIds != null and fileIds != '' ">
            <foreach collection="fileIds.split(',')" item="id"  open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
    </select>
    <select id="getJyhg" resultType="string">
        select decode(#{jyhg},'1','检验合格','2','检验不合格') from dual
    </select>




    <resultMap id="getSpotMap" type="com.tofly.watermeter.custom.entity.CustomZjSb">
        <id property="id" column="ID"/>
        <result property="bwLsbh" column="BW_LSBH"/>
        <result property="bwSbbh" column="BW_SBBH"/>
        <result property="bwSbcj" column="BW_SBCJ"/>
        <result property="bwSblx" column="BW_SBLX"/>
        <result property="bwSbkj" column="BW_SBKJ"/>
        <result property="bwQ1" column="BW_Q1"/>
        <result property="bwQ2" column="BW_Q2"/>
        <result property="bwQ3" column="BW_Q3"/>
        <result property="bwJyjg" column="BW_JYJG"/>
        <result property="bwPjz" column="BW_PJZ"/>
        <result property="bwJyrq" column="BW_JYRQ"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createDate" column="CREATE_DATE"/>
        <result property="bwBz" column="BW_BZ"/>
        <result property="sbid" column="SBID"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"></association>
                <association property="sbcjName" column="BW_SBCJ" select="com.tofly.watermeter.mapper.BwrksbdatailMapper.getCodeById"/>
                <association property="sbkjName" column="BW_SBKJ" select="com.tofly.watermeter.mapper.BwrksbdatailMapper.getCodeById"/>
                <association property="sblxName" column="BW_SBLX" select="com.tofly.watermeter.mapper.BwrksbdatailMapper.getCodeById"/>
        <!--        <association property="sbztName" column="SBID" select=""/>-->
<!--        <association property="bwrksbdatail" column="SBID"-->
<!--                     select="com.tofly.watermeter.mapper.BwrksbdatailMapper.getSbById"/>-->
        <association property="jyjgName" column="BW_JYJG" select="getJyhg"/>
    </resultMap>
    <select id="getSpot" resultMap="getSpotMap">
        select ID,BW_LSBH,BW_SBBH,BW_Q1,BW_Q2,BW_Q3,BW_JYJG,BW_PJZ,BW_JYRQ,CREATE_USER,CREATE_DATE,BW_BZ,SBID ,
               BW_SBCJ ,BW_SBLX ,BW_SBKJ
        from TF_YWPN_BWZJBCJDATAIL_W
        <where>
            <if test="search.inputContent != null and '' != search.inputContent">
                and BW_SBBH like concat( concat('%',#{search.inputContent}) ,'%')
            </if>
        </where>
    </select>
    <update id="updateFile">
        <foreach collection="list" open="begin" close=";end;" item="l" separator=";">
            update TF_YWPN_FILE_W
            <set>
                TABLE_ID = #{id}
            </set>
            where ID=#{l}
        </foreach>
    </update>
    <resultMap id="bwgzbcjdatailMap" type="com.tofly.watermeter.custom.entity.CustomGzSb">
        <id property="id" column="ID"/>
        <result property="bwLsbh" column="BW_LSBH"/>
        <result property="bwSbbh" column="BW_SBBH"/>
        <result property="bwSbcj" column="BW_SBCJ"/>
        <result property="bwSblx" column="BW_SBLX"/>
        <result property="bwSbkj" column="BW_SBKJ"/>
        <result property="bwCjjl" column="BW_CJJL"/>
        <result property="bwJyjg" column="BW_JYJG"/>
        <result property="bwPhoto" column="BW_PHOTO"/>
        <result property="bwFileid" column="BW_FILEID"/>
        <result property="bwJyrq" column="BW_JYRQ"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createDate" column="CREATE_DATE"/>
        <result property="bwBz" column="BW_BZ"/>
        <result property="sbid" column="SBID"/>
        <result property="bwJyry" column="BW_JYRY"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
<!--        <association property="bwrksbdatail" column="SBID"-->
<!--                     select="com.tofly.watermeter.mapper.BwrksbdatailMapper.getSbById"/>-->
        <association property="sbcjName" column="BW_SBCJ"
                     select="com.tofly.watermeter.mapper.BwrksbdatailMapper.getCodeById"/>
        <association property="sbkjName" column="BW_SBKJ"
                     select="com.tofly.watermeter.mapper.BwrksbdatailMapper.getCodeById"/>
        <association property="sblxName" column="BW_SBLX"
                     select="com.tofly.watermeter.mapper.BwrksbdatailMapper.getCodeById"/>
        <association property="jyjgName" column="BW_JYJG" select="getJyhg"/>
        <collection property="filePaths" column="BW_FILEID" select="getFileByIds"/>
    </resultMap>

    <select id="getExcrete" resultMap="bwgzbcjdatailMap">
        select *
        from TF_YWPN_BWGZBCJDATAIL_W
        <where>
            <if test="search.inputContent != null and '' != search.inputContent">
                and BW_SBBH like concat( concat('%',#{search.inputContent}) ,'%')
            </if>
        </where>
    </select>
</mapper>
