From 995a527d6e7d2d0cb141f6853b2b7a2a67b8a1c2 Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Fri, 20 Nov 2020 18:00:22 +0800
Subject: [PATCH] Merge branch 'master' of http://blit.7drlb.com:8888/r/screen_job
---
src/main/resources/mapper/HistoryHourlyMapper.xml | 73 ++++++++++++++++++++++++++++++++++--
1 files changed, 68 insertions(+), 5 deletions(-)
diff --git a/src/main/resources/mapper/HistoryHourlyMapper.xml b/src/main/resources/mapper/HistoryHourlyMapper.xml
index 0c12c40..f9a4473 100644
--- a/src/main/resources/mapper/HistoryHourlyMapper.xml
+++ b/src/main/resources/mapper/HistoryHourlyMapper.xml
@@ -14,7 +14,45 @@
<select id="getHourlySensorData" resultType="java.util.LinkedHashMap">
SELECT
h.mac,
- <foreach collection="sensorKeys" separator="," item="sensorKey">
+ <foreach collection="sensorKeys" separator="," item="sensorKey">
+ <choose >
+ <when test="sensorKey=='e23'">
+ ROUND((CASE WHEN AVG(json->'$.e18[0]'*SIN((json->'$.e23[0]'/180)*PI()))<![CDATA[>]]>0 AND AVG(json->'$.e18[0]'*COS((json->'$.e23[0]'/180)*PI()))<![CDATA[>]]>0
+ THEN ATAN(AVG(json->'$.e18[0]'*SIN((json->'$.e23[0]'/180)*PI()))/AVG(json->'$.e18[0]'*COS((json->'$.e23[0]'/180)*PI())))*180/PI()
+ WHEN AVG(json->'$.e18[0]'*SIN((json->'$.e23[0]'/180)*PI()))>0 AND AVG(json->'$.e18[0]'*COS((json->'$.e23[0]'/180)*PI()))<![CDATA[<]]>0
+ THEN (ATAN(AVG(json->'$.e18[0]'*SIN((json->'$.e23[0]'/180)*PI()))/AVG(json->'$.e18[0]'*COS((json->'$.e23[0]'/180)*PI())))*180/PI())+180
+ WHEN AVG(json->'$.e18[0]'*SIN((json->'$.e23[0]'/180)*PI()))<![CDATA[<]]>0 AND AVG(json->'$.e18[0]'*COS((json->'$.e23[0]'/180)*PI()))<![CDATA[<]]>0
+ THEN (ATAN(AVG(json->'$.e18[0]'*SIN((json->'$.e23[0]'/180)*PI()))/AVG(json->'$.e18[0]'*COS((json->'$.e23[0]'/180)*PI())))*180/PI())+180
+ ELSE (ATAN(AVG(json->'$.e18[0]'*SIN((json->'$.e23[0]'/180)*PI()))/AVG(json->'$.e18[0]'*COS((json->'$.e23[0]'/180)*PI())))*180/PI())+360
+ END),3) AS '${sensorKey}',
+ MIN(json->'$.${sensorKey}[1]') AS 'MIN${sensorKey}',
+ MAX(json->'$.${sensorKey}[2]') AS 'MAX${sensorKey}'
+ </when>
+ <otherwise>
+ AVG(json->'$.${sensorKey}[0]') AS '${sensorKey}',
+ MIN(json->'$.${sensorKey}[1]') AS 'MIN${sensorKey}',
+ MAX(json->'$.${sensorKey}[2]') AS 'MAX${sensorKey}'
+ </otherwise>
+ </choose>
+ </foreach>
+ FROM
+ history_hourly h
+ WHERE
+ h.time >= #{start}
+ AND h.time <![CDATA[<]]> #{end}
+ AND h.mac in
+ <foreach collection="macs" open="(" separator="," close=")"
+ item="mac">
+ #{mac}
+ </foreach>
+ group by
+ h.mac
+ </select>
+
+ <select id="getHourlySensorDataToCalculateO3" resultType="java.util.LinkedHashMap">
+ SELECT
+ h.mac,
+ <foreach collection="sensorKeys" separator="," item="sensorKey">
AVG(json->'$.${sensorKey}[0]') AS '${sensorKey}',
MIN(json->'$.${sensorKey}[1]') AS 'MIN${sensorKey}',
MAX(json->'$.${sensorKey}[2]') AS 'MAX${sensorKey}'
@@ -22,10 +60,9 @@
FROM
history_hourly h
WHERE
- h.time >= #{start}
- AND h.time <![CDATA[<]]> #{end}
- AND h.mac in
- <foreach collection="macs" open="(" separator="," close=")"
+ h.time = #{time}
+ AND h.mac in
+ <foreach collection="macList" open="(" separator="," close=")"
item="mac">
#{mac}
</foreach>
@@ -33,4 +70,30 @@
h.mac
</select>
+ <insert id="insertHistoryO3Hourly">
+ insert into
+ history_hourly_o3
+ values
+ <foreach collection="list" item="map" separator=",">
+ (#{map.mac},#{map.time},#{map.json})
+ </foreach>
+ </insert>
+
+ <select id="getBeamByMacs" resultType="java.util.Map">
+ SELECT
+ DATE_FORMAT(h.time,#{typeFormat}) time,
+ avg(h.json->'$.e12[0]') 'beam'
+ FROM history_hourly h
+ WHERE h.json->'$.e12[0]' is not null
+ and h.mac in
+ <foreach collection="macs" open="(" separator="," close=")" item="mac">
+ #{mac}
+ </foreach>
+ and h.time in
+ <foreach collection="times" open="(" separator="," close=")" item="time">
+ #{time}
+ </foreach>
+ group by h.time
+ </select>
+
</mapper>
\ No newline at end of file
--
Gitblit v1.8.0