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

    <resultMap id="planchildMap" type="com.tofly.pojo.plan.Planchild">
        <id property="id" column="ID"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="respUser" column="RESP_USER"/>
        <result property="planId" column="PLAN_ID"/>
        <result property="planState" column="PLAN_STATE"/>
        <result property="percent" column="PERCENT"/>
        <result property="overLen" column="OVER_LEN"/>
        <result property="overCount" column="OVER_COUNT"/>
        <result property="overIds" column="OVER_IDS"/>
        <association property="createUserName" column="CREATE_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
        <association property="respUserName" column="RESP_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
        <association property="planStateName" column="PLAN_STATE" select="getPlanStateName"/>
        <association property="planBegindate" column="PLAN_ID" select="getPlanBegindate"/>
        <association property="planEnddate" column="PLAN_ID" select="getPlanBegindate"/>
    </resultMap>


    <select id="getPlanStateName" resultType="string">
        SELECT CNAME
        FROM
            TF_YWPN_SYSCHILDCODE_D
        WHERE
            PCID =51500
          AND
            CCODE = #{planType}
    </select>

    <select id="getPlanBegindate" resultType="java.lang.Object">
        select PLAN_BEGINDATE as planBegindate
        from TF_YWPN_PLAN_W
        where ID =  #{planId}
    </select>

    <select id="getPlanBegindate" resultType="java.lang.Object">
        select PLAN_ENDDATE as planEnddate
        from TF_YWPN_PLAN_W
        where ID =  #{planId}
    </select>

</mapper>
