<?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.xrtygis.mapper.RxyjfwMapper">

    <resultMap id="rxyjfwMap" type="com.tofly.xrtygis.entity.Rxyjfw">
        <id property="id" column="ID"/>
        <result property="yjbh" column="YJBH"/>
        <result property="ywlx" column="YWLX"/>
        <result property="yjbt" column="YJBT"/>
        <result property="yjly" column="YJLY"/>
        <result property="yjms" column="YJMS"/>
        <result property="fileid" column="FILEID"/>
        <result property="shbz" column="SHBZ"/>
        <result property="shry" column="SHRY"/>
        <result property="shsj" column="SHSJ"/>
        <result property="shyj" column="SHYJ"/>
        <result property="createUser" column="CREATE_USER"/>
        <result property="createDate" column="CREATE_DATE"/>
        <result property="isSms" column="IS_SMS"/>
        <result property="smsObject" column="SMS_OBJECT"/>
        <result property="shjg" column="SHJG"/>
        <result property="shbm" column="SHBM"/>
        <result property="remarks" column="REMARKS"/>
        <result property="isReview" column="IS_REVIEW"/>
        <result property="isRead" column="IS_READ"/>
        <result property="voice" column="VOICE"/>
        <association property="yjlyName" column="YJLY"
                     select="getYjlyName"/>
        <association property="voiceName" column="ID"
                     select="getVoiceName"/>
        <association property="shbmName" column="SHBM" select="bmName"/>
        <association property="createUserName" column="CREATE_USER"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>
        <association property="shryName" column="SHRY"
                     select="com.tofly.baseapi.mapper.ToflyCodeCommonMapper.getUserName"/>

        <association property="shbzName" column="SHBZ" select="shbzName"/>
        <association property="isSmsName" column="IS_SMS" select="isSmsName"/>
        <association property="smsObjectName" column="SMS_OBJECT" select="smsObjectName"/>
        <association property="shjgName" column="SHJG" select="shjgName"/>
        <association property="isReviewName" column="IS_REVIEW" select="isReviewName"/>

    </resultMap>

    <select id="getVoiceName" resultType="string">
        select decode(VOICE, 0, '播报', 1, '不播报')
        from TF_YWPN_RXYJFW_W
        where ID = ${id}
    </select>

    <select id="isReviewName" resultType="string">
        select decode(#{id}, '0', '不需要审核', '1', '需要审核')
        from dual
    </select>
    <select id="shjgName" resultType="string">
        select decode(#{sms}, '0', '不同意', '1', '同意')
        from dual
    </select>

    <select id="smsObjectName" resultType="string">
        select decode(#{sms}, '0', '客户', '1', '员工')
        from dual
    </select>

    <select id="isSmsName" resultType="string">
        select decode(#{sms}, '0', '否', '1', '是')
        from dual
    </select>

    <select id="shbzName" resultType="string">
        select decode(#{shbz}, '0', '未审核', '1', '审核')
        from dual
    </select>

    <select id="getYjlyName" resultType="string">
        select decode(#{yjly}, '0', '人工', '1', '系统')
        from dual
    </select>

    <select id="bmName" resultType="string">
        select NAME
        FROM "TF_XRTY_NEW_UDB"."TF_SMPN_DEPARTMENT_X"
        WHERE ID = #{id}
    </select>

    <select id="getStopWater" resultType="string">
        SELECT YJMS
        FROM TF_YWPN_RXYJFW_W
        WHERE YJBT = '停水通知'
          AND TO_CHAR(CREATE_DATE, 'yyyyMMdd') = #{currentDate}
        ORDER BY CREATE_DATE DESC
    </select>

</mapper>
