From ed2a9d376c3846bb8d6cf838bfff9bd3ae07bc3b Mon Sep 17 00:00:00 2001
From: ZhuDongming <773644075@qq.com>
Date: Mon, 12 Aug 2019 15:52:05 +0800
Subject: [PATCH] 修改多点重合下拉时第一个时间位置不变问题
---
src/main/java/com/moral/service/impl/HistoryServiceImpl.java | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/moral/service/impl/HistoryServiceImpl.java b/src/main/java/com/moral/service/impl/HistoryServiceImpl.java
index da7fdbd..6628fe1 100644
--- a/src/main/java/com/moral/service/impl/HistoryServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/HistoryServiceImpl.java
@@ -38,6 +38,7 @@
import com.moral.service.AccountService;
import com.moral.service.HistoryService;
import com.moral.service.ProfessionService;
+import com.moral.util.AQICalculation;
@Service
public class HistoryServiceImpl implements HistoryService {
@@ -286,7 +287,7 @@
if (sensorUnits.containsKey(sensorKey)) {
Map<String, Object> sensorUnit = (Map<String, Object>) sensorUnits.get(sensorKey);
String rules = sensorUnit.get("rules").toString();
- rules = rules.replace("d", "").replace("{0}", "sensorKeyValue");
+ rules = rules.replace("d", "").replace("{0}", "value");
Expression expression = AviatorEvaluator.compile(rules);
Map<String, Object> env = new HashMap<String, Object>();
env.put("value", Double.valueOf(sensorKeyValue.toString()));
@@ -359,6 +360,20 @@
startTime = localDate+" "+startHour+":00:00";
}
Map<String, Object> map = historyMapper.getAVGValueByMacAndTimeslot(mac, startTime, endTime);
- return map;
+ System.out.println(map);
+ Map<String, Object> returnMap = new HashMap<>();
+ if (map.isEmpty()) {
+ returnMap.put("AQI", "N/V");
+ } else {
+ Map<String, Double> AQIMap = new HashMap<>();
+ for (Map.Entry<String, Object> entry : map.entrySet()) {
+ String key = entry.getKey();
+ Double value = Double.parseDouble(entry.getValue().toString());
+ AQIMap.put(key, value);
+ }
+ returnMap = AQICalculation.hourlyAQI(AQIMap);
+ }
+
+ return returnMap;
}
}
--
Gitblit v1.8.0