ZhuDongming
2020-03-27 b267036e505d752accca9aea0cc29fec48e1da25
src/main/resources/mapper/HistoryMapper.xml
@@ -99,6 +99,27 @@
        h.mac
    </select>
    <select id="getSensorDataByMac" resultType="java.util.LinkedHashMap">
        SELECT
        h.mac,
        <foreach  collection="sensorKeys" separator="," item="sensorKey">
            AVG(value->'$.${sensorKey}') AS '${sensorKey}',
            MAX(cast(h.value ->'$.${sensorKey}' as decimal(11,3))) AS 'MAX${sensorKey}',
            MIN(cast(h.value ->'$.${sensorKey}' as decimal(11,3))) AS 'MIN${sensorKey}'
        </foreach>
        FROM
        history h
        WHERE
        h.time >= #{start}
        AND h.time <![CDATA[<]]> #{end}
        and h.mac in
        <foreach collection="macList" index="index" item="mac" open="(" separator="," close=")">
            #{mac}
        </foreach>
        group by
        h.mac
    </select>
    <select id="getSensorDataOnce" resultType="java.util.LinkedHashMap">
        SELECT
        h.mac,DATE_FORMAT(time,'%Y-%m-%dT%H:%i') time,