jinpengyong
2021-12-23 3d593b39648ff583a255765f76760768d6ba5f55
screen-job/src/main/resources/mapper/HistoryHourlyMapper.xml
@@ -12,6 +12,15 @@
            ) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT '小时数据表'
    </update>
    <update id="createTableComplete" parameterType="String">
        CREATE TABLE IF NOT EXISTS `history_hourly_${timeUnits}_complete` (
            `mac` VARCHAR (20) 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 '包含最大值,最小值,平局值的小时数据表'
    </update>
    <insert id="insertHistoryHourly">
        INSERT INTO history_hourly_${timeUnits} VALUES
        <foreach collection="list" item="item" separator=",">
@@ -32,4 +41,13 @@
        WHERE `time` <![CDATA[>=]]> #{start}
        AND `time` <![CDATA[<]]> #{end}
    </select>
    <insert id="insertHistoryHourlyComplete">
        INSERT INTO
        history_hourly_${timeUnits}_complete
        VALUES
        <foreach collection="list" item="item" separator=",">
            (#{item.mac}, #{item.time}, #{item.value})
        </foreach>
    </insert>
</mapper>