| | |
| | | and h.time <![CDATA[<]]> #{end} |
| | | ORDER BY |
| | | h.time |
| | | </select> |
| | | |
| | | <select id="getMultiDeviceSensorData" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT(time, #{typeFormat}) time, |
| | | <foreach collection="macs" separator="," item="mac" index="index"> |
| | | AVG(json->'$.${sensorKey}[0]') AS '${index}${sensorKey}' |
| | | </foreach> |
| | | FROM |
| | | history_${timeUnits} |
| | | WHERE |
| | | <foreach collection="macs" separator="," item="mac" index="index"> |
| | | mac = #{mac} |
| | | </foreach> |
| | | AND time >= #{start} |
| | | AND h.time <![CDATA[<]]> #{end} |
| | | GROUP BY |
| | | DATE_FORMAT(time, #{typeFormat}) |
| | | ORDER BY |
| | | time |
| | | </select> |
| | | |
| | | <select id="getMultiDeviceSensorData1" resultType="java.util.Map"> |
| | | SELECT * |
| | | from |
| | | <foreach collection="macs" separator="," item="mac" index="index"> |
| | | (SELECT |
| | | AVG(json->'$.${sensorKey}[0]') AS '${index}${sensorKey}', |
| | | DATE_FORMAT(time,'%Y-%m') as time |
| | | FROM history_${timeUnits} |
| | | WHERE mac=#{mac} |
| | | AND time >= #{start} |
| | | AND time <![CDATA[<]]> #{end} |
| | | GROUP BY DATE_FORMAT(time,#{typeFormat}) |
| | | ORDER BY |
| | | time) as t${index} |
| | | </foreach> |
| | | WHERE t1.time=t2.time |
| | | </select> |
| | | </mapper> |