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

    <resultMap id="repairuserMap" type="com.tofly.pojo.maintain.Repairuser">
        <id property="id" column="ID"/>
        <result property="respUser" column="RESP_USER"/>
        <result property="repairId" column="REPAIR_ID"/>
        <result property="teamUser" column="TEAM_USER"/>
        <result property="isread" column="ISREAD"/>
        <result property="isrepeat" column="ISREPEAT"/>
        <result property="repeatNum" column="REPEAT_NUM"/>
        <result property="state" column="STATE"/>
        <result property="ratifyTime" column="RATIFY_TIME"/>
        <result property="realTime" column="REAL_TIME"/>
        <result property="regionCode" column="REGION_CODE"/>
        <result property="regionName" column="REGION_NAME"/>
        <result property="address" column="ADDRESS"/>
        <result property="lgtd" column="LGTD"/>
        <result property="lttd" column="LTTD"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="confirmTime" column="CONFIRM_TIME"/>
        <result property="overTime" column="OVER_TIME"/>
        <result property="planNum" column="PLAN_NUM"/>
        <result property="overNum" column="OVER_NUM"/>
        <result property="lngLats" column="LNG_LATS"/>
        <result property="phone" column="PHONE"/>
    </resultMap>


    <resultMap id="repairuserVoMap" type="com.tofly.pojo.maintain.vo.RepairuserVo">
        <id property="id" column="ID"/>
        <result property="respUser" column="RESP_USER"/>
        <result property="repairId" column="REPAIR_ID"/>
        <result property="teamUser" column="TEAM_USER"/>
        <result property="isread" column="ISREAD"/>
        <result property="isrepeat" column="ISREPEAT"/>
        <result property="repeatNum" column="REPEAT_NUM"/>
        <result property="state" column="STATE"/>
        <result property="ratifyTime" column="RATIFY_TIME"/>
        <result property="realTime" column="REAL_TIME"/>
        <result property="regionCode" column="REGION_CODE"/>
        <result property="regionName" column="REGION_NAME"/>
        <result property="address" column="ADDRESS"/>
        <result property="lgtd" column="LGTD"/>
        <result property="lttd" column="LTTD"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="confirmTime" column="CONFIRM_TIME"/>
        <result property="overTime" column="OVER_TIME"/>
        <result property="planNum" column="PLAN_NUM"/>
        <result property="overNum" column="OVER_NUM"/>
        <result property="lngLats" column="LNG_LATS"/>
        <result property="phone" column="PHONE"/>
        <association property="respUserName" column="RESP_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
        <association property="teamUserName" column="TEAM_USER" select="getTeamUserName"/>
        <association property="isreadName" column="ISREAD" select="getIsreadName"/>
        <association property="isrepeatName" column="ISREPEAT" select="getIsrepeatName"/>
        <association property="stateName" column="STATE" select="getState"/>
        <association property="createUserName" column="CREATE_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
    </resultMap>

    <select id="getIsreadName" resultType="string">
        select decode(#{isread},'0','未查看','1','已查看') as isreadName from dual
    </select>

    <select id="getIsrepeatName" resultType="string">
        select decode(#{isrepeat},'0','未返工','1','已返工') as isrepeatName from dual
    </select>


    <select id="getState" resultType="string">
        select decode(#{state},'0','未派工','1','未审核','2','未开始','3','正在执行','4','处理完成','5','已开始未执行','6','驳回','7','转移申请','8','已转移') as stateName from dual
    </select>

    <select id="getTeamUserName" resultType="string" databaseId="oracle">
        select
        LISTAGG(real_name,',') within group(order by real_name)
        from TF_SMPN_USER_X
        <if test="teamUser != null and teamUser != ''  ">where id in
            <foreach item="nodeCodestr" collection="teamUser.split(',')" open="(" separator="," close=")">
                #{nodeCodestr}
            </foreach>
        </if>
        <if test="fileIds == null ">
            where id = ''
        </if>

    </select>

    <select id="getrepairuserVoList" resultMap="repairuserVoMap">
        select * from TF_YWPN_REPAIRUSER_W where repair_Id = #{repairId}
    </select>
</mapper>
