<?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.mapper.HistoryMinutelyMapper">
|
|
<insert id="insertHistoryMinutely">
|
insert into
|
history_minutely_${yearAndMonth}
|
values
|
<foreach collection="list" item="map" separator=",">
|
(#{map.mac},#{map.time},#{map.json})
|
</foreach>
|
</insert>
|
|
<select id="getMinutelySensorData" resultType="java.util.LinkedHashMap">
|
SELECT
|
h.mac,
|
<foreach collection="sensorKeys" separator="," item="sensorKey">
|
AVG(json->'$.${sensorKey}[0]') AS '${sensorKey}',
|
MIN(json->'$.${sensorKey}[1]') AS 'MIN${sensorKey}',
|
MAX(json->'$.${sensorKey}[2]') AS 'MAX${sensorKey}'
|
</foreach>
|
FROM
|
history_minutely_${yearAndMonth} h
|
WHERE
|
h.time >= #{start}
|
AND h.time <![CDATA[<]]> #{end}
|
AND h.mac in
|
<foreach collection="macs" open="(" separator="," close=")"
|
item="mac">
|
#{mac}
|
</foreach>
|
group by
|
h.mac
|
</select>
|
|
</mapper>
|