<?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.gpsboot.mapper.plan.HydrantrecordMapper">

    <resultMap id="hydrantrecordMap" type="com.tofly.pojo.plan.Hydrantrecord">
        <id property="id" column="ID"/>
        <result property="planChildid" column="PLAN_CHILDID"/>
        <result property="xAddr" column="X_ADDR"/>
        <result property="yAddr" column="Y_ADDR"/>
        <result property="network" column="NETWORK"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="stDischarge" column="ST_DISCHARGE"/>
        <result property="stTime" column="ST_TIME"/>
        <result property="notes" column="NOTES"/>
        <result property="fileIds" column="FILE_IDS"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="sbCode" column="SB_CODE"/>
        <result property="stCaliber" column="ST_CALIBER"/>
        <result property="address" column="ADDRESS"/>
        <result property="regionCode" column="REGION_CODE"/>
        <association property="createUserName" javaType="java.lang.String" column="CREATE_USER" select="getRealName" />
        <association property="filePathList" column="FILE_IDS" select="getFilePathList"/>
    </resultMap>

    <select id="getRealName" resultType="java.lang.String" databaseId="oracle">
        select REAL_NAME createUserName
        from TF_SMPN_USER_X
        where id=#{createUser}
    </select>
    <select id="getFilePathList" resultType="java.lang.String" databaseId="oracle">
        select FILE_PATH as filePath
        from TF_YWPN_FILE_W
        <if test="fileIds != null and fileIds != ''  ">where id in
            <foreach item="nodeCodestr" collection="fileIds.split(',')" open="(" separator="," close=")">
                #{nodeCodestr}
            </foreach>
        </if>
        <if test="fileIds == null ">
            where id = ''
        </if>

    </select>
</mapper>
