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

    <resultMap id="leakRecordMap" type="com.tofly.pojo.plan.LeakRecord">
        <id property="id" column="ID"/>
        <result property="leakSourceCode" column="LEAK_SOURCE_CODE"/>
        <result property="x" column="X"/>
        <result property="y" column="Y"/>
        <result property="address" column="ADDRESS"/>
        <result property="pipe" column="PIPE"/>
        <result property="pipeDiameter" column="PIPE_DIAMETER"/>
        <result property="pipelineBurialAge" column="PIPELINE_BURIAL_AGE"/>
        <result property="pipelineBuriedDepth" column="PIPELINE_BURIED_DEPTH"/>
        <result property="pipelineDamageCondition" column="PIPELINE_DAMAGE_CONDITION"/>
        <result property="groundMedium" column="GROUND_MEDIUM"/>
        <result property="detectionNode" column="DETECTION_NODE"/>
        <result property="leakSourceNode" column="LEAK_SOURCE_NODE"/>
        <result property="leakSourceFileId" column="LEAK_SOURCE_FILE_ID"/>
        <result property="handlingInformation" column="HANDLING_INFORMATION"/>
        <result property="excavationNode" column="EXCAVATION_NODE"/>
        <result property="inspectUser" column="INSPECT_USER"/>
        <result property="inspectTime" column="INSPECT_TIME"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="planChildId" column="PLAN_CHILD_ID"/>
        <result property="excavationFileId" column="EXCAVATION_FILE_ID"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"></association>
        <association property="leakSourceFilePathList" column="LEAK_SOURCE_FILE_ID" select="getLeakSourceFilePathList"/>
        <association property="excavationFilePathList" column="EXCAVATION_FILE_ID" select="getExcavationFilePathList"/>
    </resultMap>

    <select id="getLeakSourceFilePathList" resultType="string" databaseId="oracle">
        select FILE_PATH as filePath
        from TF_YWPN_FILE_W
        <if test="leakSourceFileId != null and leakSourceFileId != ''  ">where id in
            <foreach item="nodeCodestr" collection="leakSourceFileId.split(',')" open="(" separator="," close=")">
                #{nodeCodestr}
            </foreach>
        </if>
        <if test="fileIds == null ">
            where id = ''
        </if>

    </select>

    <select id="getExcavationFilePathList" resultType="string" databaseId="oracle">
        select FILE_PATH as filePath
        from TF_YWPN_FILE_W
        <if test="excavationFileId != null and excavationFileId != ''  ">where id in
            <foreach item="nodeCodestr" collection="excavationFileId.split(',')" open="(" separator="," close=")">
                #{nodeCodestr}
            </foreach>
        </if>
        <if test="fileIds == null ">
            where id = ''
        </if>

    </select>

</mapper>
