cjl
2023-07-10 3226649df5365fe731d8f66bc768cb8518e42e2e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?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.moral.api.mapper.HistoryFiveMinutelyMapper">
 
    <update id="createTable" parameterType="String">
        CREATE TABLE  IF NOT EXISTS `history_five_minutely_${timeUnits}` (
            `mac` VARCHAR (30) DEFAULT NULL COMMENT '设备mac',
            `time` datetime DEFAULT NULL COMMENT '数据时间',
            `value` json DEFAULT NULL COMMENT '数据',
            KEY `idx_mac_time` (`mac`,`time`)
            ) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT '5分钟数据表'
    </update>
 
    <insert id="insertHistoryFiveMinutely">
        INSERT INTO
        history_five_minutely_${timeUnits}
        VALUES
        <foreach collection="list" item="item" separator=",">
            (#{item.mac}, #{item.time}, #{item.value})
        </foreach>
    </insert>
 
</mapper>