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

  <resultMap id="tfIndexAllocationMap" type="com.tofly.xrtygis.entity.TfIndexAllocation">
                      <id property="id" column="ID"/>
                      <result property="describe" column="DESCRIBE"/>
                      <result property="createUser" column="CREATE_USER"/>
                      <result property="createTime" column="CREATE_TIME"/>
                      <result property="deviceId" column="DEVICE_ID"/>
                      <result property="model" column="MODEL"/>
                      <result property="variableCode" column="VARIABLE_CODE"/>
                      <result property="variableName" column="VARIABLE_NAME"/>
                      <result property="displayName" column="DISPLAY_NAME"/>
                      <result property="unit" column="UNIT"/>
                      <result property="alarmUpperLimit" column="ALARM_UPPER_LIMIT"/>
                      <result property="alarmLowerLimit" column="ALARM_LOWER_LIMIT"/>
                      <result property="isAlarm" column="IS_ALARM"/>
                      <result property="sortNumber" column="SORT_NUMBER"/>
                      <result property="accuracy" column="ACCURACY"/>
                      <result property="archivesCode" column="ARCHIVES_CODE"/>
                      <result property="type" column="TYPE"/>
                      <result property="isDisplay" column="IS_DISPLAY"/>
                      <association property="createUserName" column="CREATE_USER"
                                   select="com.tofly.xrtygis.mapper.IFileMapper.getUserName"></association>
                      <association property="deviceName" column="DEVICE_ID"
                                   select="com.tofly.xrtygis.mapper.TfDeviceArchiveManageMapper.getDeviceName"></association>
                      <association property="modelName" column="MODEL"
                                   select="getModelName"></association>
                      <association property="isAlarmName" column="IS_ALARM"
                                   select="getIsAlarmName"></association>
                      <association property="typeName" column="TYPE"
                                   select="getTypeName"></association>
                      <association property="isDisplayName" column="IS_DISPLAY"
                                   select="getIsDisplayName"></association>
  </resultMap>

    <select id="getModelName" resultType="string">
        SELECT decode(#{model},'1','出口','2','入口','3','加药') as modelName FROM dual
    </select>

    <select id="getIsAlarmName" resultType="string">
        SELECT decode(#{isAlarm},'0','未报警','1','已报警') as isAlarmName FROM dual
    </select>

    <select id="getIsDisplayName" resultType="string">
        SELECT decode(#{isDisplay},'0','否','1','是') as isDisplayName FROM dual
    </select>

    <select id="getTypeName" resultType="string">
        SELECT CNAME
        FROM
            TF_YWPN_SYSCHILDCODE_D
        WHERE
            PCID =60000
          AND
            CCODE = #{type}
    </select>

    <select id="getReportLevel" resultType="string">
        SELECT REPORT_LEVEL
        FROM TF_SCADA_REPORT
        WHERE ID = #{reportId}
    </select>
                                                                                            
</mapper>
