<?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.trouble.TroubleMapper">

    <resultMap id="troubleMap" type="com.tofly.pojo.trouble.Trouble">
        <id property="id" column="ID"/>
        <result property="isread" column="ISREAD"/>
        <result property="isSubmit" column="IS_SUBMIT"/>
        <result property="submitTime" column="SUBMIT_TIME"/>
        <result property="submitUser" column="SUBMIT_USER"/>
        <result property="auditResult" column="AUDIT_RESULT"/>
        <result property="auditTime" column="AUDIT_TIME"/>
        <result property="auditUser" column="AUDIT_USER"/>
        <result property="auditNotes" column="AUDIT_NOTES"/>
        <result property="pipeName" column="PIPE_NAME"/>
        <result property="location" column="LOCATION"/>
        <result property="padId" column="PAD_ID"/>
        <result property="typeId" column="TYPE_ID"/>
        <result property="lgtd" column="LGTD"/>
        <result property="lttd" column="LTTD"/>
        <result property="address" column="ADDRESS"/>
        <result property="notes" column="NOTES"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="isbuild" column="ISBUILD"/>
        <result property="buildId" column="BUILD_ID"/>
        <result property="suggest" column="SUGGEST"/>
        <result property="uploadType" column="UPLOAD_TYPE"/>
        <result property="uploadFileids" column="UPLOAD_FILEIDS"/>
        <result property="isrespect" column="ISRESPECT"/>
        <result property="state" column="STATE"/>
        <result property="regionId" column="REGION_ID"/>
        <result property="regionName" column="REGION_NAME"/>
        <result property="toubleRangeId" column="TOUBLE_RANGE_ID"/>
        <result property="deviceId" column="DEVIICE_ID"/>
        <result property="deptId" column="DEPT_ID"/>
        <association property="device" column="DEVICE_Id" select="com.tofly.gpsboot.mapper.plan.PlanFactoryMapper.getDeviceInfo"/>
        <association property="locationName" column="LOCATION" select="getLocationName"/>
        <association property="deptName" column="DEPT_ID" select="getDeptName"/>
    </resultMap>

    <select id="getLocationName" resultType="java.lang.String">
        select cname locationName
        from tf_ywpn_syschildcode_d
        where id = #{location}
    </select>

    <select id="getDeptName"  resultType="java.lang.String">
        select NAME deptName
        from tf_smpn_department_x
        where ID = #{id}
    </select>
</mapper>
