From e7eb9aff4f348f2b6c245be5215f571c2789fb8e Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Wed, 29 Apr 2020 15:42:58 +0800 Subject: [PATCH] update --- src/main/resources/mapper/HistoryMinutelyMapper.xml | 26 ++++++++++++++++++++++++++ 1 files changed, 26 insertions(+), 0 deletions(-) diff --git a/src/main/resources/mapper/HistoryMinutelyMapper.xml b/src/main/resources/mapper/HistoryMinutelyMapper.xml index 4ba0029..bf83a38 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 -- Gitblit v1.8.0