From 66fd957202742202804a614c766b9b973a26d836 Mon Sep 17 00:00:00 2001
From: jinpengyong <jpy123456>
Date: Thu, 07 May 2020 17:15:04 +0800
Subject: [PATCH] update

---
 src/main/resources/mapper/HistoryMinutelyMapper.xml |   44 +++++++++++++++++++++++++++-----------------
 1 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/src/main/resources/mapper/HistoryMinutelyMapper.xml b/src/main/resources/mapper/HistoryMinutelyMapper.xml
index 4ba0029..c202150 100644
--- a/src/main/resources/mapper/HistoryMinutelyMapper.xml
+++ b/src/main/resources/mapper/HistoryMinutelyMapper.xml
@@ -31,6 +31,32 @@
         AND time &lt; #{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 &lt; #{end}
+    </select>
+
     <select id="getMonitorPointOrDeviceAvgData" resultType="java.util.Map">
         SELECT
         DATE_FORMAT(time, #{typeFormat}) time
@@ -78,22 +104,6 @@
         time
     </select>
 
-    <select id="getAreaAvgDataByAreaCode" resultType="java.util.Map">
-    SELECT
-    DATE_FORMAT(time, #{typeFormat}) time,
-    AVG(aqi_json->'$.${sensors1}') AS '${sensors2}'
-    FROM
-    hangzhou_aqi ha
-    WHERE
-    ha.time >= #{start}
-    AND ha.time <![CDATA[<]]> #{end}
-    AND ha.city_code = #{areaCode}
-    GROUP BY
-    DATE_FORMAT(time, #{typeFormat})
-    ORDER BY
-    time
-  </select>
-
     <select id="selectLineChartDateByCrieria" resultType="java.util.Map">
         SELECT
         <choose>
@@ -113,7 +123,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