From 68e22957db996437fa20a9a4aa5ff37c54d4056f Mon Sep 17 00:00:00 2001 From: jinpengyong <jpy123456> Date: Wed, 27 Sep 2023 15:22:25 +0800 Subject: [PATCH] chore:补充提交 --- screen-api/src/main/java/com/moral/api/service/impl/DeviceServiceImpl.java | 26 +++++++++++++++++++++----- 1 files changed, 21 insertions(+), 5 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 f49fa12..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 @@ -71,6 +71,15 @@ } @Override + public List<Device> getDevicesByMonitorPointId(List<Integer> monitorPointId) { + QueryWrapper<Device> wrapper = new QueryWrapper(); + wrapper.in("monitor_point_id", monitorPointId); + wrapper.eq("is_delete", Constants.NOT_DELETE); + wrapper.orderByAsc("dev_num"); + return deviceMapper.selectList(wrapper); + } + + @Override public Map<String, Object> getSensorsByMac(Map<String, Object> params) { List<String> sensorCodes = Arrays.asList(Constants.SENSOR_CODE_PM25 , Constants.SENSOR_CODE_PM10 @@ -196,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) { @@ -237,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); @@ -295,7 +305,7 @@ } middleDate = DateUtils.addDays(middleDate,1); } - } else if ("monthly".equals(type)){ + } else if ("month".equals(type)){ end = DateUtils.getDateAddMonth(endTime, 1); timeUnits = "monthly"; dateFormat = "%Y-%m"; @@ -349,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