From 94d4a4e7600665f6b40b6d791b798b498196191b Mon Sep 17 00:00:00 2001 From: 于紫祥_1901 <email@yuzixiang_1910> Date: Wed, 23 Dec 2020 13:54:23 +0800 Subject: [PATCH] 公式更改 --- src/main/java/com/moral/service/impl/HistoryServiceImpl.java | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/moral/service/impl/HistoryServiceImpl.java b/src/main/java/com/moral/service/impl/HistoryServiceImpl.java index 8007e0a..08137c7 100644 --- a/src/main/java/com/moral/service/impl/HistoryServiceImpl.java +++ b/src/main/java/com/moral/service/impl/HistoryServiceImpl.java @@ -406,14 +406,17 @@ String timeUnits = startTime.substring(0, 10).replace("-", ""); Map<String, Object> map = historyMapper.getAVGValueByMacAndTimeslot(mac, startTime, endTime, timeUnits); Map<String, Object> returnMap = new HashMap<>(); - if (map.isEmpty()) { - returnMap.put("AQI", "N/V"); + if (ObjectUtils.isEmpty(map) || map.isEmpty()) { + returnMap.put("AQI", "N/V"); + return returnMap; } 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); + if (entry.getValue() != null) { + Double value = Double.parseDouble(entry.getValue().toString()); + AQIMap.put(key, value); + } } returnMap = AQICalculation.hourlyAQI(AQIMap); } -- Gitblit v1.8.0