<?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.car.TfCarApplyMapper">

  <resultMap id="tfCarApplyMap" type="com.tofly.pojo.car.TfCarApply">
                <id property="id" column="ID"/>
                      <result property="carNumber" column="CAR_NUMBER"/>
                      <result property="startMileage" column="START_MILEAGE"/>
                      <result property="endMileage" column="END_MILEAGE"/>
                      <result property="startTime" column="START_TIME"/>
                      <result property="endTime" column="END_TIME"/>
                      <result property="auditUser" column="AUDIT_USER"/>
                      <result property="auditDept" column="AUDIT_DEPT"/>
                      <result property="auditTime" column="AUDIT_TIME"/>
                      <result property="auditView" column="AUDIT_VIEW"/>
                      <result property="auditStatus" column="AUDIT_STATUS"/>
                      <result property="applyUser" column="APPLY_USER"/>
                      <result property="applyDept" column="APPLY_DEPT"/>
                      <result property="applyTime" column="APPLY_TIME"/>
                      <result property="annex" column="ANNEX"/>
                      <result property="remark" column="REMARK"/>
                      <result property="createTime" column="CREATE_TIME"/>
                      <result property="createUser" column="CREATE_USER"/>
                  <association property="auditUserName"  column="AUDIT_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName" ></association>
                  <association property="applyUserName"  column="APPLY_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName" ></association>
                  <association property="createUserName"  column="CREATE_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName" ></association>
                  <association property="auditDeptName"  column="AUDIT_DEPT" select="getDeptName" ></association>
                  <association property="applyDeptName"  column="APPLY_DEPT" select="getDeptName" ></association>
                  <collection property="annexList"  column="ANNEX" select="getAnnexList" ></collection>
  </resultMap>

    <select id="getDeptName" resultType="string">
        SELECT NAME
        FROM TF_SMPN_DEPARTMENT_X
        WHERE ID = #{deptId}
    </select>

    <select id="getRealNameAll" resultType="map">
        SELECT ID, REAL_NAME
        FROM TF_SMPN_USER_X
        WHERE STATUS_FLAG = '1'
    </select>

    <select id="getAnnexList" resultType="com.tofly.pojo.comm.File">
        SELECT *
        FROM TF_YWPN_FILE_W
        WHERE
            to_char(ID) IN
        <foreach item="nodeCodestr" collection="annex.split(',')" open="(" separator="," close=")">
            #{nodeCodestr}
        </foreach>
    </select>


                                                                                            
</mapper>
