| | |
| | | rList.add(null); |
| | | }else { |
| | | for (int j = 0; j < lists.get(0).size(); j++) { |
| | | Map<String,Object> listMap = new HashMap(); |
| | | List<Map> mapList=new ArrayList<>(); |
| | | if (lists.get(0).size()==1){ |
| | | Map<String, Object> listMap = new HashMap(); |
| | | List<Map> mapList = new ArrayList<>(); |
| | | if (lists.get(0).size() == 1) { |
| | | mapList.add(null); |
| | | }else { |
| | | } else { |
| | | mapList.add((Map) lists.get(0).get(j).get("data")); |
| | | } |
| | | for (int i = 1; i < lists.size(); i++) { |
| | | if (lists.get(i).size()==1){ |
| | | mapList.add(null); |
| | | listMap.put("data",mapList); |
| | | }else { |
| | | if (lists.get(0).get(j).get("time").equals(lists.get(i).get(j).get("time"))){ |
| | | mapList.add((Map) lists.get(i).get(j).get("data")); |
| | | } |
| | | listMap.put("time",lists.get(0).get(j).get("time")); |
| | | listMap.put("data",mapList); |
| | | for (int i = 1; i < lists.size(); i++) { |
| | | if (lists.get(i).size() == 1) { |
| | | mapList.add(null); |
| | | listMap.put("data", mapList); |
| | | } else { |
| | | if (lists.get(0).get(j).get("time").equals(lists.get(i).get(j).get("time"))) { |
| | | mapList.add((Map) lists.get(i).get(j).get("data")); |
| | | } |
| | | listMap.put("time", lists.get(0).get(j).get("time")); |
| | | listMap.put("data", mapList); |
| | | } |
| | | } |
| | | rList.add(listMap); |
| | | } |
| | | } |
| | |
| | | Map maxMap = new HashMap(); |
| | | for (Map.Entry<String, Object> entry : map.entrySet()) { |
| | | String key = entry.getKey(); |
| | | if (entry.getValue() instanceof Double){ |
| | | Double value = Double.parseDouble(entry.getValue().toString()); |
| | | if (key!="O3_8h"){ |
| | | maxMap.put(key,value); |
| | | } |
| | | Double PM2_5AQI; |
| | | Double PM10AQI; |
| | | Double SO2AQI; |
| | | Double NO2AQI; |
| | | Double COAQI; |
| | | Double O3AQI; |
| | | if (entry.getValue().toString().equals("")){ |
| | | continue; |
| | | } |
| | | Double value = Double.parseDouble(entry.getValue().toString()); |
| | | |
| | | if (key!="O3_8h"){ |
| | | maxMap.put(key,value); |
| | | }else { |
| | | continue; |
| | | } |
| | | Double PM2_5AQI; |
| | | Double PM10AQI; |
| | | Double SO2AQI; |
| | | Double NO2AQI; |
| | | Double COAQI; |
| | | Double O3AQI; |
| | | |
| | | switch (key) { |
| | | case "PM2_5":PM2_5AQI = PM2_5AQI(value); |
| | | AQIList.add(PM2_5AQI); |
| | |
| | | case "maxO3_8h":O3AQI = O3AQI(value); |
| | | AQIList.add(O3AQI); |
| | | break; |
| | | |
| | | default: |
| | | break; |
| | | } |
| | | }else { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | Double AQIMAX = Collections.max(AQIList); |
| | | Map<String, Object> returnMap = new HashMap<>(); |
| | | |
| | | Optional<Map.Entry<String, Integer>> max0 = maxMap.entrySet() |
| | | .stream() |
| | | .max(Map.Entry.comparingByValue()); |
| | | |
| | | returnMap.put("maxSensor",max0.get().getKey()); |
| | | returnMap.put("AQI", AQIMAX); |
| | | Double AQIMAX = Collections.max(AQIList); |
| | | Optional<Map.Entry<String, Integer>> max0 = maxMap.entrySet() |
| | | .stream() |
| | | .max(Map.Entry.comparingByValue()); |
| | | returnMap.put("maxSensor", max0.get().getKey()); |
| | | returnMap.put("AQI", AQIMAX); |
| | | return returnMap; |
| | | } |
| | | public static Map<String, Object> dayAQI(Map<String, Object> map){ |
| | |
| | | </select> |
| | | <select id="getDataAvbByMIdAndTime" resultType="java.util.Map"> |
| | | select hh.time as `time`, |
| | | ROUND(AVG(hh.json->"$.e1[0]")) as `PM2_5`,ROUND(AVG(hh.json->"$.e2[0]")) as 'PM10',CAST(AVG(hh.json->"$.e10[0]") as DECIMAL(10,1)) as 'CO', |
| | | ROUND(AVG(hh.json->"$.e11[0]")) as 'SO2',ROUND(AVG(hh.json->"$.e16[0]")) as 'NO2',ROUND(AVG(hh.json->"$.e15[0]")) as 'O3' |
| | | IFNULL(ROUND(AVG(hh.json->"$.e1[0]")),"") as `PM2_5`,IFNULL(ROUND(AVG(hh.json->"$.e2[0]")),"") as 'PM10',IFNULL(ROUND(AVG(hh.json->"$.e10[0]"),1),"") as 'CO', |
| | | IFNULL(ROUND(AVG(hh.json->"$.e11[0]")),"") as 'SO2',IFNULL(ROUND(AVG(hh.json->"$.e16[0]")),"") as 'NO2',IFNULL(ROUND(AVG(hh.json->"$.e15[0]")),"") as 'O3' |
| | | from monitor_point mt,device d,history_hourly hh |
| | | where mt.id=d.monitor_point_id and d.mac=hh.mac and mt.id=#{mId} and hh.time>#{startTime} and hh.time<![CDATA[<=]]>#{endTime} GROUP BY hh.time; |
| | | </select> |
| | | <select id="getDataByMonitorPoints" resultType="java.util.Map"> |
| | | select hh.time as `time`, |
| | | ROUND(AVG(hh.json->"$.e1[0]")) as `PM2_5`,ROUND(AVG(hh.json->"$.e2[0]")) as 'PM10',CAST(AVG(hh.json->"$.e10[0]") as DECIMAL(10,1)) as 'CO', |
| | | ROUND(AVG(hh.json->"$.e11[0]")) as 'SO2',ROUND(AVG(hh.json->"$.e16[0]")) as 'NO2',ROUND(AVG(hh.json->"$.e15[0]")) as 'O3' |
| | | IFNULL(ROUND(AVG(hh.json->"$.e1[0]")),"") as `PM2_5`,IFNULL(ROUND(AVG(hh.json->"$.e2[0]")),"") as 'PM10',IFNULL(ROUND(AVG(hh.json->"$.e10[0]"),1),"") as 'CO', |
| | | IFNULL(ROUND(AVG(hh.json->"$.e11[0]")),"") as 'SO2',IFNULL(ROUND(AVG(hh.json->"$.e16[0]")),"") as 'NO2',IFNULL(ROUND(AVG(hh.json->"$.e15[0]")),"") as 'O3' |
| | | from monitor_point mt,device d,history_hourly hh |
| | | where mt.id=d.monitor_point_id and d.mac=hh.mac and mt.id in |
| | | <foreach collection="mIds" item="id" index="index" open="(" close=")" separator=","> |
| | |
| | | </select> |
| | | <select id="getAvgDataByMId" resultType="java.util.Map"> |
| | | SELECT |
| | | ROUND(AVG(hh.json->"$.e1[0]")) as `PM2_5`,ROUND(AVG(hh.json->"$.e2[0]")) as 'PM10',CAST(AVG(hh.json->"$.e10[0]") as DECIMAL(10,1)) as 'CO', |
| | | ROUND(AVG(hh.json->"$.e11[0]")) as 'SO2',ROUND(AVG(hh.json->"$.e16[0]")) as 'NO2',ROUND(AVG(hh.json->"$.e15[0]")) as 'O3_day' |
| | | IFNULL(ROUND(AVG(hh.json->"$.e1[0]")),"") as `PM2_5`,IFNULL(ROUND(AVG(hh.json->"$.e2[0]")),"") as 'PM10',IFNULL(ROUND(AVG(hh.json->"$.e10[0]"),1),"") as 'CO', |
| | | IFNULL(ROUND(AVG(hh.json->"$.e11[0]")),"") as 'SO2',IFNULL(ROUND(AVG(hh.json->"$.e16[0]")),"") as 'NO2',IFNULL(ROUND(AVG(hh.json->"$.e15[0]")),"") as 'O3_day' |
| | | from monitor_point mt,device d,history_hourly hh where mt.id=d.monitor_point_id |
| | | and d.mac=hh.mac and mt.id =#{mId} and hh.time<![CDATA[<=]]>#{endTime} and hh.time>#{startTime} |
| | | </select> |
| | | <select id="getAvgDataByMIds" resultType="java.util.Map"> |
| | | SELECT ROUND(AVG(hh.json->"$.e1[0]")) as `PM2_5`,ROUND(AVG(hh.json->"$.e2[0]")) as 'PM10',CAST(AVG(hh.json->"$.e10[0]") as DECIMAL(10,1)) as 'CO', |
| | | ROUND(AVG(hh.json->"$.e11[0]")) as 'SO2',ROUND(AVG(hh.json->"$.e16[0]")) as 'NO2',ROUND(AVG(hh.json->"$.e15[0]")) as 'O3_day' |
| | | SELECT |
| | | IFNULL(ROUND(AVG(hh.json->"$.e1[0]")),"") as `PM2_5`,IFNULL(ROUND(AVG(hh.json->"$.e2[0]")),"") as 'PM10',IFNULL(ROUND(AVG(hh.json->"$.e10[0]"),1),"") as 'CO', |
| | | IFNULL(ROUND(AVG(hh.json->"$.e11[0]")),"") as 'SO2',IFNULL(ROUND(AVG(hh.json->"$.e16[0]")),"") as 'NO2',IFNULL(ROUND(AVG(hh.json->"$.e15[0]")),"") as 'O3_day' |
| | | from monitor_point mt,device d,history_hourly hh where mt.id=d.monitor_point_id |
| | | and d.mac=hh.mac and mt.id in |
| | | <foreach collection="mIds" item="id" index="index" open="(" close=")" separator=","> |
| | |
| | | limit 0,1
|
| | | </select>
|
| | | <select id="getDailyAvgData" resultType="java.util.Map">
|
| | | SELECT ROUND(AVG(hd.json->"$.e1[0]")) as `PM2_5`,ROUND(AVG(hd.json->"$.e2[0]")) as 'PM10',CAST(AVG(hd.json->"$.e10[0]") as DECIMAL(10,1)) as 'CO',
|
| | | ROUND(AVG(hd.json->"$.e11[0]")) as 'SO2',ROUND(AVG(hd.json->"$.e16[0]")) as 'NO2',ROUND(AVG(hd.json->"$.e15[0]")) as 'O3_day'
|
| | | FROM `history_daily` hd,monitor_point mt,device d where mt.id=d.monitor_point_id
|
| | | SELECT
|
| | | IFNULL(ROUND(AVG(hd.json->"$.e1[0]")),"") as `PM2_5`,IFNULL(ROUND(AVG(hd.json->"$.e2[0]")),"") as 'PM10',IFNULL(ROUND(AVG(hd.json->"$.e10[0]"),1),"") as 'CO',
|
| | | IFNULL(ROUND(AVG(hd.json->"$.e11[0]")),"") as 'SO2',IFNULL(ROUND(AVG(hd.json->"$.e16[0]")),"") as 'NO2',IFNULL(ROUND(AVG(hd.json->"$.e15[0]")),"") as 'O3_day'
|
| | | FROM `history_daily` hd,monitor_point mt,device d where mt.id=d.monitor_point_id
|
| | | and d.mac=hd.mac and mt.id=#{mId} and time=#{time}
|
| | | </select>
|
| | | <select id="getDailyAvgDataByMIds" resultType="java.util.Map">
|
| | | SELECT ROUND(AVG(hd.json->"$.e1[0]")) as `PM2_5`,ROUND(AVG(hd.json->"$.e2[0]")) as 'PM10',CAST(AVG(hd.json->"$.e10[0]") as DECIMAL(10,1)) as 'CO',
|
| | | ROUND(AVG(hd.json->"$.e11[0]")) as 'SO2',ROUND(AVG(hd.json->"$.e16[0]")) as 'NO2',ROUND(AVG(hd.json->"$.e15[0]")) as 'O3_day'
|
| | | SELECT
|
| | | IFNULL(ROUND(AVG(hd.json->"$.e1[0]")),"") as `PM2_5`,IFNULL(ROUND(AVG(hd.json->"$.e2[0]")),"") as 'PM10',IFNULL(ROUND(AVG(hd.json->"$.e10[0]"),1),"") as 'CO',
|
| | | IFNULL(ROUND(AVG(hd.json->"$.e11[0]")),"") as 'SO2',IFNULL(ROUND(AVG(hd.json->"$.e16[0]")),"") as 'NO2',IFNULL(ROUND(AVG(hd.json->"$.e15[0]")),"") as 'O3_day'
|
| | | FROM `history_daily` hd,monitor_point mt,device d where mt.id=d.monitor_point_id
|
| | | and d.mac=hd.mac and mt.id in
|
| | | <foreach collection="mIds" item="id" index="index" open="(" close=")" separator=",">
|