From e51e2d053b498e236097bcb4012c8446d672be86 Mon Sep 17 00:00:00 2001 From: ZhuDongming <773644075@qq.com> Date: Tue, 19 May 2020 16:35:46 +0800 Subject: [PATCH] 设备版本添加大屏界面控制 --- src/main/java/com/moral/service/impl/HistoryServiceImpl.java | 27 +++++++++++++++++---------- 1 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/moral/service/impl/HistoryServiceImpl.java b/src/main/java/com/moral/service/impl/HistoryServiceImpl.java index 9008efe..0de5639 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 { @@ -485,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 + ""; @@ -496,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<>(); -- Gitblit v1.8.0