<?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.maintain.RepairplanMapper">

    <resultMap id="repairplanMap" type="com.tofly.pojo.maintain.Repairplan">
        <id property="id" column="ID"/>
        <result property="year" column="YEAR"/>
        <result property="submitTime" column="SUBMIT_TIME"/>
        <result property="issubmit" column="ISSUBMIT"/>
        <result property="submitUser" column="SUBMIT_USER"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="planState" column="PLAN_STATE"/>
        <result property="yearId" column="YEAR_ID"/>
        <result property="month" column="MONTH"/>
    </resultMap>


    <resultMap id="repairplanVoMap" type="com.tofly.pojo.maintain.vo.RepairplanVo">
        <id property="id" column="ID"/>
        <result property="year" column="YEAR"/>
        <result property="submitTime" column="SUBMIT_TIME"/>
        <result property="issubmit" column="ISSUBMIT"/>
        <result property="submitUser" column="SUBMIT_USER"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="planState" column="PLAN_STATE"/>
        <result property="yearId" column="YEAR_ID"/>
        <result property="month" column="MONTH"/>
        <association property="issubmitName" column="ISSUBMIT" select="getIssubmitName"/>
        <association property="submitUserName" column="SUBMIT_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
        <association property="createUserName" column="CREATE_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
        <association property="planStateName" column="PLAN_STATE" select="getPlanStateName"/>
        <collection property="repairplandetailVoList" column="ID" select="com.tofly.gpsboot.mapper.maintain.RepairplandetailMapper.getRepairPlanDetailVoList"/>
        <collection property="auditVoList" column="ID" select="com.tofly.gpsboot.mapper.comm.AuditMapper.getRepairPlanAuditVoList"/>
    </resultMap>

    <select id="getIssubmitName" resultType="java.lang.String">
        select decode(#{issubmit},'0','未上报','1','已上报') as issubmitName from dual
    </select>

    <select id="getPlanStateName" resultType="java.lang.String">
        select decode(#{planState},'0','待审核','1','审批拒绝','2','审批通过') as planStateName from dual
    </select>

    <select id="getRepairPlanVoList" resultMap="repairplanVoMap">
        select * from TF_YWPN_REPAIRPLAN_W where id = #{id}
    </select>

</mapper>
