<?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.build.BuildMapper">

    <resultMap id="buildMap" type="com.tofly.pojo.build.Build">
        <id property="id" column="ID"/>
        <result property="submitTime" column="SUBMIT_TIME"/>
        <result property="submitUser" column="SUBMIT_USER"/>
        <result property="auditResult" column="AUDIT_RESULT"/>
        <result property="auditTime" column="AUDIT_TIME"/>
        <result property="auditUser" column="AUDIT_USER"/>
        <result property="auditNotes" column="AUDIT_NOTES"/>
        <result property="isread" column="ISREAD"/>
        <result property="typeId" column="TYPE_ID"/>
        <result property="uploadType" column="UPLOAD_TYPE"/>
        <result property="lgtd" column="LGTD"/>
        <result property="lttd" column="LTTD"/>
        <result property="address" column="ADDRESS"/>
        <result property="sgdw" column="SGDW"/>
        <result property="gdfzr" column="GDFZR"/>
        <result property="phone" column="PHONE"/>
        <result property="notes" column="NOTES"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="uploadFileids" column="UPLOAD_FILEIDS"/>
        <result property="ischeackRead" column="ISCHEACK_READ"/>
        <result property="isrespect" column="ISRESPECT"/>
        <result property="state" column="STATE"/>
        <result property="isSubmit" column="IS_SUBMIT"/>
        <result property="regionId" column="REGION_ID"/>
        <result property="regionName" column="REGION_NAME"/>
        <result property="ownerUnitName" column="OWNER_UNIT_NAME"/>
        <result property="ownerUnitUser" column="OWNER_UNIT_USER"/>
        <result property="ownerUnitPhone" column="OWNER_UNIT_PHONE"/>
        <result property="siteName" column="SITE_NAME"/>
        <association property="submitUserName" column="SUBMIT_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
        <association property="auditUserName" column="AUDIT_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
        <association property="auditResultName" column="AUDIT_RESULT" select="getAuditResultName"/>
        <association property="isreadName" column="ISREAD" select="getIsreadName"/>
        <association property="typeIdName" column="TYPE_ID" select="getTypeIdName"/>
        <association property="uploadTypeName" column="UPLOAD_TYPE" select="getUploadTypeName"/>
        <association property="createUserName" column="CREATE_USER" select="com.tofly.gpsboot.mapper.plan.HydrantrecordMapper.getRealName"/>
        <association property="filePathList" column="UPLOAD_FILEIDS" select="getFilePathList"/>
        <association property="isrespectName" column="ISRESPECT" select="getIsrespectName"/>
        <association property="stateName" column="STATE" select="getStateName"/>
        <association property="isSubmitName" column="IS_SUBMIT" select="getIsSubmitName"/>
    </resultMap>
    <select id="getFilePathList" resultType="string" databaseId="oracle">
        select FILE_PATH as filePath
        from TF_YWPN_FILE_W
        <if test="uploadFileids != null and uploadFileids != ''  ">where id in
            <foreach item="nodeCodestr" collection="uploadFileids.split(',')" open="(" separator="," close=")">
                #{nodeCodestr}
            </foreach>
        </if>
        <if test="uploadFileids == null ">
            where id = ''
        </if>

    </select>
    <select id="getIsreadName" resultType="string">
        select decode(#{isread},'0','未查看','1','已查看') as isreadName from dual
    </select>
    <select id="getAuditResultName" resultType="string">
        select decode(#{isread},'0','未审核','1','同意','2','不同意') as auditResultName from dual
    </select>
    <select id="getTypeIdName" resultType="string">
        select name typeIdName
        from TF_YWPN_BUILDTYPE_D
        where id = #{typeId}
    </select>
    <select id="getUploadTypeName" resultType="string">
        select decode(#{uploadType},'0','手机端现场上报','1','内业上报') as uploadTypeName from dual
    </select>

    <select id="getIscheackReadName" resultType="string">
        select decode(#{ischeackRead},'0','未查询','1','已查收') as ischeackReadName from dual
    </select>
    <select id="getIsrespectName" resultType="string">
        select decode(#{isrespect},'0','否','1','是') as isrespectName from dual
    </select>
    <select id="getStateName" resultType="string">
        select decode(#{state},'0','无需监护','1','监护巡查','2','已结束','3','监护结束申请','4','已上报') as stateName from dual
    </select>
    <select id="getIsSubmitName" resultType="string">
        select decode(#{isSubmit},'0','未提交','1','已提交') as isSubmitName from dual
    </select>

</mapper>
