From c38942417e15141f9a03d11bb518195ecca44b42 Mon Sep 17 00:00:00 2001
From: cjl <276999030@qq.com>
Date: Sat, 26 Aug 2023 13:39:44 +0800
Subject: [PATCH] fix:小时数据丢失问题修复

---
 screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java b/screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
index 005d4ca..74d4260 100644
--- a/screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
+++ b/screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java
@@ -205,6 +205,7 @@
 
         QueryWrapper<Device> queryWrapper = new QueryWrapper<>();
         queryWrapper.select("mac", "name").in("mac", macs);
+        queryWrapper.orderByAsc("dev_num","name","id");
         List<Device> devices = deviceMapper.selectList(queryWrapper);
         Map<String,Object> devicesInfo = new HashMap<>();
         for (Device device:devices) {
@@ -246,8 +247,8 @@
                 for (HistoryHourly historyHourly:distinctHistoryHourlies) {
                     Map<String,Object> historyHourlyMap = new HashMap<>();
                     historyHourlyMap.put("mac",mac);
-                    JSONObject value = JSONObject.parseObject(historyHourly.getValue());
-                    Double sensorValue = Double.parseDouble(value.get(sensorCode).toString());
+                    JSONObject  value= JSONObject.parseObject(historyHourly.getValue());
+                    Double sensorValue = Objects.nonNull(value)&&Objects.nonNull(value.get(sensorCode))?Double.parseDouble(value.get(sensorCode).toString()):0d;
                     historyHourlyMap.put(sensorCode,sensorValue);
                     Date time = historyHourly.getTime();
                     String timeStr = DateUtils.dateToDateString(time, DateUtils.yyyy_MM_dd_HH_EN);

--
Gitblit v1.8.0