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

    <resultMap id="gpscalculateMap" type="com.tofly.pojo.plan.Gpscalculate">
        <id property="id" column="ID"/>
        <result property="pathinplan" column="PATHINPLAN"/>
        <result property="pathpatroled" column="PATHPATROLED"/>
        <result property="buildingsitefinded" column="BUILDINGSITEFINDED"/>
        <result property="buildingsitemonitor" column="BUILDINGSITEMONITOR"/>
        <result property="buildingpatroled" column="BUILDINGPATROLED"/>
        <result property="troubleinplan" column="TROUBLEINPLAN"/>
        <result property="troubleipatroled" column="TROUBLEIPATROLED"/>
        <result property="vaildTotalTime" column="VAILD_TOTAL_TIME"/>
        <result property="vaildTotalDistance" column="VAILD_TOTAL_DISTANCE"/>
        <result property="vaildSpeed" column="VAILD_SPEED"/>
        <result property="findTroubleNum" column="FIND_TROUBLE_NUM"/>
        <result property="gpsDate" column="GPS_DATE"/>
        <result property="userId" column="USER_ID"/>
        <result property="signRange" column="SIGN_RANGE"/>
        <result property="planTotalTime" column="PLAN_TOTAL_TIME"/>
        <result property="planTotalDistance" column="PLAN_TOTAL_DISTANCE"/>
        <result property="planTotalAverage" column="PLAN_TOTAL_AVERAGE"/>
        <result property="carTotalDistance" column="CAR_TOTAL_DISTANCE"/>
        <result property="carTotalTime" column="CAR_TOTAL_TIME"/>
        <result property="carTotalAverage" column="CAR_TOTAL_AVERAGE"/>
        <result property="pointinplan" column="POINTINPLAN"/>
        <result property="pointpatroled" column="POINTPATROLED"/>
        <result property="repairOrderNum" column="REPAIR_ORDER_NUM"/>
        <result property="completeOrderNum" column="COMPLETE_ORDER_NUM"/>
        <result property="repairOrderNum" column="REPAIR_ORDER_NUM"/>
        <result property="completeOrderNum" column="COMPLETE_ORDER_NUM"/>
        <result property="overCount" column="OVER_COUNT"/>
        <result property="overLen" column="OVER_LEN"/>
        <association property="userName" column="USER_ID" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
        <association property="deptName" column="USER_ID" select="com.tofly.gpsboot.mapper.maintain.RepairuserMapper.getDeptName"/>
    </resultMap>
    <select id="getRealName" resultType="string" databaseId="oracle">
        select REAL_NAME userName
        from TF_SMPN_USER_X
        where id=#{userId}
    </select>

    <select id="getDeptName" resultType="string">
        select NAME as deptName
        from TF_SMPN_DEPARTMENT_X
        where id =
              (select DEPARTMENT_ID
               from TF_SMPN_USER_X
               where id = #{userId})
    </select>

</mapper>
