<?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.yeejoin.equip.mapper.mysql.EquipmentSpecificIndexMapper">

    <resultMap id="ComplementCode" type="com.yeejoin.equip.entity.EquipmentIndexVO">
        <result property="equipmentId" column="equipment_specific_id"/>
        <result property="id" column="id"/>
        <result property="nameKey" column="name_key"/>
        <result property="value" column="value"/>
        <result property="valueEnum" column="value_enum"/>
        <result property="unitName" column="unit"/>
        <result property="indexAddress" column="index_address"/>
        <result property="gatewayId" column="gateway_id"/>
        <result property="isAlarm" column="is_alarm"/>
        <result property="equipmentIndexName" column="equipment_index_name"/>
        <result property="equipmentSpecificName" column="equipment_specific_name"/>
        <result property="dataType" column="data_type"/>
    </resultMap>

    <select id="getEquipSpecificIndexList" resultMap="ComplementCode">
        SELECT
        si.equipment_specific_id AS equipmentId,
        ei.id,
        ei.name_key,
        si.value,
        si.value_enum,
        ei.is_iot,
        si.index_address,
        si.gateway_id,
        si.data_type,
        si.equipment_specific_name,
        si.equipment_index_name,
        si.is_alarm
        FROM
        wl_equipment_specific_index si
        LEFT JOIN wl_equipment_index ei ON si.equipment_index_id = ei.id
        <where>
            <if test="equipmentId != null and equipmentId !=''">
                si.equipment_specific_id = #{equipmentId}
            </if>
            <if test="isIot != null and isIot !=''">
                AND ei.is_iot = #{isIot}
            </if>
        </where>
    </select>
</mapper>