From e25c689888a0dd80d07ffc4e4a45bd290b3d010c Mon Sep 17 00:00:00 2001
From: yuzixiang <yzx123456>
Date: Tue, 19 May 2020 16:50:21 +0800
Subject: [PATCH] 计算臭氧平缓平均值
---
src/main/java/com/moral/service/impl/HistoryServiceImpl.java | 39 +++++++++++++++++++++++++++------------
1 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/moral/service/impl/HistoryServiceImpl.java b/src/main/java/com/moral/service/impl/HistoryServiceImpl.java
index a9f03ea..797a392 100644
--- a/src/main/java/com/moral/service/impl/HistoryServiceImpl.java
+++ b/src/main/java/com/moral/service/impl/HistoryServiceImpl.java
@@ -23,10 +23,6 @@
import javax.annotation.Resource;
-import org.apache.commons.collections.CollectionUtils;
-import org.springframework.stereotype.Service;
-import org.springframework.util.ObjectUtils;
-
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.googlecode.aviator.AviatorEvaluator;
@@ -46,6 +42,10 @@
import com.moral.service.HistoryService;
import com.moral.service.ProfessionService;
import com.moral.util.AQICalculation;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.util.ObjectUtils;
@Service
public class HistoryServiceImpl implements HistoryService {
@@ -378,7 +378,6 @@
startTime = localDate + " " + startHour + ":00:00";
}
Map<String, Object> map = historyMapper.getAVGValueByMacAndTimeslot(mac, startTime, endTime);
- System.out.println(map);
Map<String, Object> returnMap = new HashMap<>();
if (map.isEmpty()) {
returnMap.put("AQI", "N/V");
@@ -465,7 +464,6 @@
startTime = localDate + " " + startHour + ":00:00";
}
Map<String, Object> map = historyMapper.getMonitorPointAVGValueByMonitorPointIdAndTimeslot(monitor_point_id, startTime, endTime);
- System.out.println(map);
Map<String, Object> returnMap = new HashMap<>();
if (map.isEmpty()) {
returnMap.put("AQI", "N/V");
@@ -487,6 +485,8 @@
String startTime = parameters.get("startTime").toString();
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime startTimeLocalDateTime = LocalDateTime.parse(startTime, dateTimeFormatter);
+ LocalDateTime today = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
+ LocalDateTime startTimeDay = startTimeLocalDateTime.truncatedTo(ChronoUnit.DAYS);
int year = startTimeLocalDateTime.getYear();
int month = startTimeLocalDateTime.getMonthValue();
String monthStr = month < 10 ? ("0" + month) : month + "";
@@ -498,13 +498,18 @@
}
parameters.put("sensorKeys", sensorKeys);
List<Map<String, Object>> listMap = null;
- listMap = historyMapper.getCarSensorData(parameters);
+ if (today.compareTo(startTimeDay) == 0) {
+ listMap = historyMapper.listGetSensorData(parameters);
+ }
if (CollectionUtils.isEmpty(listMap)) {
- if (year <= 2019) {
- listMap = historyMinutelyMapper.getSensorData(parameters);
- } else {
- parameters.put("yearAndMonth", yearAndMonth);
- listMap = historyMinutelyMapper.getSensorData2020(parameters);
+ listMap = historyMapper.getCarSensorData(parameters);
+ if (CollectionUtils.isEmpty(listMap)) {
+ if (year <= 2019) {
+ listMap = historyMinutelyMapper.getSensorData(parameters);
+ } else {
+ parameters.put("yearAndMonth", yearAndMonth);
+ listMap = historyMinutelyMapper.getSensorData2020(parameters);
+ }
}
}
List<List<Map<String, Object>>> listMaps = new ArrayList<>();
@@ -543,4 +548,14 @@
}
return listMaps;
}
+
+ @Override
+ public String getO3AVG(Map<String, Object> parameters) {
+ return historyMapper.getO3AVG(parameters);
+ }
+
+ @Override
+ public int getNum(String timef, String timea) {
+ return historyMapper.getNum(timef,timea);
+ }
}
--
Gitblit v1.8.0