于紫祥_1901
2020-11-18 d0fe2eb9cefc7e3bfdddc5fa66633057c42697fc
src/main/resources/mapper/HistoryHourlyMapper.xml
@@ -26,7 +26,7 @@
        </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
@@ -44,7 +44,7 @@
        </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
@@ -100,7 +100,12 @@
    </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`&gt;=#{startTime} and `time`&lt;#{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`&gt;=#{startTime}
        and `time`&lt;#{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`&gt;=#{startTime} and `time`<![CDATA[<]]>#{endTime}