From 55d668118cc044e0f96d6876cf40dfe2cbaae53a Mon Sep 17 00:00:00 2001 From: "hupenghui@qniao.cn" <1049970895> Date: Fri, 16 Sep 2022 20:14:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/qniao/iot/IotMonitoringDataJob.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/qniao/iot/IotMonitoringDataJob.java b/src/main/java/com/qniao/iot/IotMonitoringDataJob.java index b172fd8..e6da999 100644 --- a/src/main/java/com/qniao/iot/IotMonitoringDataJob.java +++ b/src/main/java/com/qniao/iot/IotMonitoringDataJob.java @@ -137,14 +137,21 @@ public class IotMonitoringDataJob { // 上次启动时间 Long lastBootTime = lastDeviceState.getLastBootTime(); Long lastTheDayDuration = lastDeviceState.getTheDayDuration(); + lastTheDayDuration = lastTheDayDuration == null ? 0L : lastTheDayDuration; Long lastTheDayJobDuration = lastDeviceState.getTheDayJobDuration(); + lastTheDayJobDuration = lastTheDayJobDuration == null ? 0L : lastTheDayJobDuration; Long lastJobDurationTotal = lastDeviceState.getJobDurationTotal(); + lastJobDurationTotal = lastJobDurationTotal == null ? 0L : lastJobDurationTotal; Long lastTheDayJobCount = lastDeviceState.getTheDayJobCount(); + lastTheDayJobCount = lastTheDayJobCount == null ? 0L : lastTheDayJobCount; Long lastJobTotal = lastDeviceState.getJobTotal(); + lastJobTotal = lastJobTotal == null ? 0L : lastJobTotal; Integer machinePwrStat = command.getMachinePwrStat(); Integer machineWorkingStat = command.getMachineWorkingStat(); Long currJobDuration = command.getCurrJobDuration(); + currJobDuration = currJobDuration == null ? 0L : currJobDuration; Long currJobCount = command.getCurrJobCount(); + currJobCount = currJobCount == null ? 0L : currJobCount; // 当前数据 DeviceTotalData nowDeviceState = new DeviceTotalData(); nowDeviceState.setMachinePwrStat(machinePwrStat); @@ -299,9 +306,17 @@ public class IotMonitoringDataJob { if (iotMac.equals(machineIotMac)) { deviceTotalData = new DeviceTotalData(); Object productionTotal = JSONUtil.getByPath(JSONUtil.parse(o), "productionTotal"); - deviceTotalData.setJobTotal(Integer.toUnsignedLong(Integer.parseInt(String.valueOf(productionTotal)))); + if(productionTotal == null) { + deviceTotalData.setJobTotal(0L); + }else { + deviceTotalData.setJobTotal(Integer.toUnsignedLong(Integer.parseInt(String.valueOf(productionTotal)))); + } Object workTotalTotal = JSONUtil.getByPath(JSONUtil.parse(o), "workTotalTotal"); - deviceTotalData.setJobDurationTotal(Integer.toUnsignedLong(Integer.parseInt(String.valueOf(workTotalTotal))) * 3600); + if(workTotalTotal == null) { + deviceTotalData.setJobDurationTotal(0L); + }else { + deviceTotalData.setJobDurationTotal(Integer.toUnsignedLong(Integer.parseInt(String.valueOf(workTotalTotal))) * 3600); + } Object startingUpTime = JSONUtil.getByPath(JSONUtil.parse(o), "startingUpTime"); LocalDateTime lastBootTime = LocalDateTime .parse((String) startingUpTime, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));