From 4f879df01e855d436c65e1fbdc74f64ce47c901b Mon Sep 17 00:00:00 2001 From: ZhuDongming <773644075@qq.com> Date: Thu, 30 Apr 2020 16:49:15 +0800 Subject: [PATCH] update小时查询表时判断 --- src/main/resources/mapper/HistoryMinutelyMapper.xml | 28 +++++++++++++++++++++++++++- 1 files changed, 27 insertions(+), 1 deletions(-) diff --git a/src/main/resources/mapper/HistoryMinutelyMapper.xml b/src/main/resources/mapper/HistoryMinutelyMapper.xml index 4ba0029..3f4c176 100644 --- a/src/main/resources/mapper/HistoryMinutelyMapper.xml +++ b/src/main/resources/mapper/HistoryMinutelyMapper.xml @@ -31,6 +31,32 @@ AND time < #{end} </select> + <select id="getAvgByDevice" resultType="java.util.Map"> + SELECT + <foreach collection="sensorKeys" separator="," item="sensorKey"> + AVG(json->'$.${sensorKey}[0]') AS '${sensorKey}' + </foreach> + FROM + history_daily + WHERE + mac IN + (SELECT + d.mac + FROM + device d + WHERE + d.is_delete = 0 + <if test="monitorPointId != null"> + AND d.monitor_point_id = #{monitorPointId} + </if> + <if test="mac != null"> + AND d.mac = #{mac} + </if> + ) + AND time >= #{start} + AND time < #{end} + </select> + <select id="getMonitorPointOrDeviceAvgData" resultType="java.util.Map"> SELECT DATE_FORMAT(time, #{typeFormat}) time @@ -113,7 +139,7 @@ DATE_FORMAT(time,'${@com.moral.common.util.ReportTimeFormat@toMySqlTimeFormat(timePeriod.timeUnits)}') as format_time FROM - `history_minutely` hmi + history_${timeUnits} hmi <where> and hmi.time >= #{timePeriod.startTime} and hmi.time <![CDATA[<=]]> #{timePeriod.endTime} -- Gitblit v1.8.0