From 39dc3d6f7168eae8fda1b0fe6671be819d35c732 Mon Sep 17 00:00:00 2001 From: cjl <276999030@qq.com> Date: Thu, 28 Sep 2023 11:10:37 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/wb' into wb --- screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 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..bd62813 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); @@ -358,8 +359,14 @@ Map<String,Object> historyHourlyMap = new HashMap<>(); historyHourlyMap.put("mac",mac); JSONObject value = JSONObject.parseObject(historyFiveMinutely.getValue()); - Double sensorValue = Double.parseDouble(value.get(sensorCode).toString()); - historyHourlyMap.put(sensorCode,sensorValue); + if (value.get(sensorCode)==null){ + historyHourlyMap.put(sensorCode,0.0); + }else { + Double sensorValue = Double.parseDouble(value.get(sensorCode).toString()); + historyHourlyMap.put(sensorCode,sensorValue); + } +// Double sensorValue = Double.parseDouble(value.get(sensorCode).toString()); +// historyHourlyMap.put(sensorCode,sensorValue); Date time = historyFiveMinutely.getTime(); String timeStr = DateUtils.dateToDateString(time, DateUtils.yyyy_MM_dd_HH_mm_ss_EN); historyHourlyMap.put("time",timeStr); -- Gitblit v1.8.0