From 8beab91730f3e3cd6b53e4d498f763ff9dc65ef5 Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Wed, 18 Nov 2020 14:16:55 +0800
Subject: [PATCH] 修改污染溯源接口,从history表中获取改为从history天表获取

---
 src/main/java/com/moral/service/impl/HistoryServiceImpl.java |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/moral/service/impl/HistoryServiceImpl.java b/src/main/java/com/moral/service/impl/HistoryServiceImpl.java
index 42c7456..343cdd3 100644
--- a/src/main/java/com/moral/service/impl/HistoryServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/HistoryServiceImpl.java
@@ -117,7 +117,9 @@
     public String queryValueByMacAndTime(String mac, Date time) {
         return historyMapper.selectValueByMacAndTime(mac, time);
     }
-
+    public String getValueByMacAndTime(String mac, String time,String time1) {
+        return historyMapper.getValueByMacAndTime(mac, time,time1);
+    }
     @Override
     public List<Map<String, Object>> getRegionRankingData(Map<String, Object> parameters) {
         ValidateUtil.notNull(parameters.get("regionCode"), "param.is.null");
@@ -383,7 +385,8 @@
             }
             returnMap = AQICalculation.hourlyAQI(AQIMap);
         }
-
+        long aqi = Math.round(Double.valueOf(returnMap.get("AQI").toString()));
+        returnMap.put("AQI",aqi);
         return returnMap;
     }
 
@@ -520,7 +523,9 @@
                 for (Map.Entry<String, Object> entry : map.entrySet()) {
                     for (Sensor sensor : sensors) {
                         if (sensor.getSensorKey().equals(entry.getKey())) {
-                            mapAvg.put(entry.getKey(), new BigDecimal(entry.getValue().toString().replace("\"", "")).stripTrailingZeros().toPlainString() + sensor.getUnit());
+                            if (entry.getValue() != null) {
+                                mapAvg.put(entry.getKey(), new BigDecimal(entry.getValue().toString().replace("\"", "")).stripTrailingZeros().toPlainString() + sensor.getUnit());
+                            }
                         } else if (("min" + sensor.getSensorKey()).equals(entry.getKey())) {
                             mapMin.put(entry.getKey().substring(3), new BigDecimal(entry.getValue().toString().replace("\"", "")).stripTrailingZeros().toPlainString());
                         } else if (("max" + sensor.getSensorKey()).equals(entry.getKey())) {

--
Gitblit v1.8.0