<?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.scada.mapper.ScadaIoserverHisMapper">

    <resultMap id="scadaIoserverHisMap" type="com.tofly.scada.entity.ScadaIoserverHis">
        <id property="id" column="ID"/>
        <result property="code" column="CODE"/>
        <result property="value" column="VALUE"/>
        <result property="operationTime" column="OPERATION_TIME"/>
        <result property="operationUser" column="OPERATION_USER"/>
        <association property="codeName" column="CODE" select="getCodeName"/>
        <association property="operationUserName" column="OPERATION_USER" select="getUserName"/>
    </resultMap>

    <select id="getUserName" resultType="java.lang.String" >
        select real_name from tf_smpn_user_x where id=#{operationUser}
    </select>
    <select id="getCodeName" resultType="java.lang.String" >
        select VARIABLE_NAME from TF_INDEX_ALLOCATION where VARIABLE_CODE=#{code}
    </select>
</mapper>
