<?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.amos.boot.module.das.mapper.analysis.IndicatorDataMapper">


    <!--创建超级表-->
    <update id="createTable">
        create STABLE if not exists indicator_data
               (created_time timestamp,
               das_time  VARCHAR(100),
               data_type NCHAR(12),
               point_seq VARCHAR(100) ,
               point_address VARCHAR(100) ,
               point_location VARCHAR(500) ,
               point_name VARCHAR(200),
               point_type VARCHAR(50),
               `value` VARCHAR(50),
               `value_f` float)
        TAGS  (gateway_id binary(64));
    </update>

    <insert id="insertBatch" parameterType="java.util.List">
        insert into
        <foreach separator=" " collection="list" item="item" index="index">
            indicator_data_#{gatewayId,jdbcType=VARCHAR} USING indicator_data
            TAGS (#{gatewayId,jdbcType=VARCHAR})
            VALUES (NOW + #{index}a,
            #{dasTime,jdbcType=VARCHAR},
            #{item.dataType,jdbcType=VARCHAR},
            #{item.pointSeq,jdbcType=VARCHAR},
            #{item.pointAddress,jdbcType=VARCHAR},
            #{item.pointLocation,jdbcType=VARCHAR},
            #{item.pointName,jdbcType=VARCHAR},
            #{item.pointType,jdbcType=VARCHAR},
            #{item.value,jdbcType=VARCHAR},
            #{item.valueF,jdbcType=FLOAT})
        </foreach>
    </insert>
</mapper>