| | |
| | | </foreach> |
| | | FROM |
| | | <if test="mac!=null and time!=null"> |
| | | (select mac,value,time,version from history |
| | | (select mac,value,time,version from history_${yearAndDay} |
| | | where mac = #{mac} and time BETWEEN DATE_SUB(#{time}, INTERVAL 1 HOUR) and #{time}) h |
| | | </if> |
| | | GROUP BY |
| | |
| | | </foreach> |
| | | FROM |
| | | <if test="mac!=null"> |
| | | (select mac,value,time,version from history |
| | | (select mac,value,time,version from history_${yearAndDay} |
| | | where mac = #{mac} and time BETWEEN DATE_SUB(#{time}, INTERVAL 1 DAY) and #{time}) h |
| | | </if> |
| | | GROUP BY |
| | |
| | | </select> |
| | | |
| | | <select id="getDataByMacAndTime" resultType="java.util.Map"> |
| | | SELECT DATE_FORMAT(`time`,'%Y-%m-%d %H:%i:%s') as `time`,json->'$.${sensor}[0]' as ${sensor} FROM `history_hourly` where `mac`=#{mac} and `time`>=#{startTime} and `time`<#{endTime} |
| | | SELECT DATE_FORMAT(`time`,'%Y-%m-%d %H:%i:%s') as `time`, |
| | | json->'$.${sensor}[0]' as ${sensor} |
| | | FROM `history_hourly` |
| | | where `mac`=#{mac} |
| | | and `time`>=#{startTime} |
| | | and `time`<#{endTime} |
| | | </select> |
| | | <select id="getDataByMacAndTime1" resultType="java.util.Map"> |
| | | SELECT DATE_FORMAT(`time`,'%Y-%m-%d %H:%i:%s') as `time`,json->'$.${sensor}[0]' as ${sensor} FROM `history_hourly` where `mac`=#{mac} and `time`>=#{startTime} and `time`<![CDATA[<]]>#{endTime} |