<?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.tdengine.ESEquipmentsMapper">
    <insert id="batchInsert" parameterType="java.util.List" >
        insert into indicator_data
        (ts,
         id,
         address,
         gateway_id,
         data_type,
         is_alarm,
         unit,
         equipment_index_name,
         equipment_specific_name,
         `value`,
         `value_f` ,
         value_label,
         equipment_number,
         display_name,
         created_time)
        values
        <foreach separator=" " collection="list" item="equip" index="index" >
            (now + #{index}a,
             #{equip.id},
             #{equip.address},
             #{equip.gatewayId},
             #{equip.dataType},
             #{equip.isAlarm},
             #{equip.unit},
             #{equip.equipmentIndexName},
             #{equip.equipmentSpecificName},
             #{equip.value},
             #{equip.valueF},
             #{equip.valueLabel},
             #{equip.equipmentNumber},
             #{equip.displayName},
             #{time})
        </foreach>
    </insert>

    <insert id="insert" parameterType="com.yeejoin.equip.entity.ESEquipments" >
        insert into indicator_data
        (createdTime,
        id,
        address,
        gateway_id,
        data_type,
        is_alarm,
        unit,
        equipment_index_name,
        equipment_specific_name,
        `value`,
        `value_f` ,
        value_label,
        equipment_number,
        display_name)
        values
            (NOW,
            #{id},
            #{address},
            #{gatewayId},
            #{dataType},
            #{isAlarm},
            #{unit},
            #{equipmentIndexName},
            #{equipmentSpecificName},
            #{value},
            #{valueF},
            #{valueLabel},
            #{equipmentNumber},
            #{displayName})
    </insert>

    <!--创建表-->
    <update id="createTable" >
        create table if not exists indicator_data
        (ts TIMESTAMP,
        id binary(64),
        address binary(64),
        gateway_id binary(64),
        data_type NCHAR(12),
        is_alarm BIGINT,
        unit NCHAR(24),
        equipment_index_name VARCHAR(255) ,
        equipment_specific_name VARCHAR(255),
        `value` VARCHAR(12),
        `value_f` FLOAT,
        value_label VARCHAR(64),
        equipment_number BINARY(64),
        display_name VARCHAR(200),
        created_time VARCHAR(64));
    </update>
</mapper>