|
|
|
@ -171,6 +171,7 @@ public class IotMonitoringDataJob { |
|
|
|
Long reportTime = receivedEvent.getReportTime(); |
|
|
|
String reportTimeStr = StrUtil.toString(reportTime); |
|
|
|
if(reportTimeStr.length() == 10) { |
|
|
|
// 机智云那边的设备可能是秒或毫秒 |
|
|
|
reportTime = reportTime * 1000; |
|
|
|
} |
|
|
|
// 1树根 0机智云 |
|
|
|
@ -178,12 +179,12 @@ public class IotMonitoringDataJob { |
|
|
|
// 当前数据 |
|
|
|
DeviceTotalData nowDeviceState = new DeviceTotalData(); |
|
|
|
if (lastedDeviceState.getReportTime() <= receivedEvent.getReportTime()) { |
|
|
|
if (lastWorkingStat == null) { |
|
|
|
DeviceState deviceState = getDeviceStateListJson(receivedEvent.getMachineIotMac()); |
|
|
|
Integer status = deviceState == null ? null : deviceState.getStatus(); |
|
|
|
lastWorkingStat = status == null ? 0 : status; |
|
|
|
lastPwStat = lastWorkingStat == 0 ? 0 : 1; |
|
|
|
if (lastWorkingStat == null || lastPwStat == null) { |
|
|
|
lastWorkingStat = lastedDeviceState.getMachineWorkingStat(); |
|
|
|
lastPwStat = lastedDeviceState.getMachinePwrStat(); |
|
|
|
} |
|
|
|
nowDeviceState.setMachinePwrStat(machinePwrStat); |
|
|
|
nowDeviceState.setMachineWorkingStat(machineWorkingStat); |
|
|
|
if (onData == null) { |
|
|
|
onData = lastedDeviceState; |
|
|
|
onDataState.update(onData); |
|
|
|
@ -206,9 +207,6 @@ public class IotMonitoringDataJob { |
|
|
|
if (lastWorkingStat == 1) { |
|
|
|
// 如果上次是工作中,那就进行累加 |
|
|
|
if (lastReportTime != null) { |
|
|
|
/*nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + workingDuration); |
|
|
|
nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + workingDuration); |
|
|
|
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration);*/ |
|
|
|
if (dataSource == 1) { |
|
|
|
// 树根 |
|
|
|
nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + workingDuration); |
|
|
|
@ -253,8 +251,6 @@ public class IotMonitoringDataJob { |
|
|
|
} |
|
|
|
nowDeviceState.setCurrLocalDate(localDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
|
nowDeviceState.setLastBootTime(onData.getReportTime()); |
|
|
|
/*nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + workingDuration); |
|
|
|
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration);*/ |
|
|
|
nowDeviceState.setReportTime(reportTime); |
|
|
|
} else { |
|
|
|
// 待机或开机 |
|
|
|
@ -333,6 +329,8 @@ public class IotMonitoringDataJob { |
|
|
|
value.setTheDayJobDuration(deviceMonitoringData.getCurrJobDuration()); |
|
|
|
value.setTheDayJobCount(deviceMonitoringData.getCurrJobCount()); |
|
|
|
value.setLastBootTime(deviceMonitoringData.getLastBootTime()); |
|
|
|
value.setMachinePwrStat(deviceMonitoringData.getMachinePwrStat()); |
|
|
|
value.setMachineWorkingStat(deviceMonitoringData.getMachineWorkingStat()); |
|
|
|
value.setTheDayDuration(deviceMonitoringData.getCurrDuration()); |
|
|
|
value.setReportTime(deviceMonitoringData.getReportTime()); |
|
|
|
} else { |
|
|
|
@ -393,6 +391,23 @@ public class IotMonitoringDataJob { |
|
|
|
deviceTotalData.setTheDayJobDuration(0L); |
|
|
|
deviceTotalData.setTheDayJobCount(0L); |
|
|
|
deviceTotalData.setCurrLocalDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
|
// 是否在线 |
|
|
|
Object isOnlineObj = JSONUtil.getByPath(JSONUtil.parse(o), "isOnline"); |
|
|
|
if(isOnlineObj != null) { |
|
|
|
int isOnline = Integer.parseInt(String.valueOf(isOnlineObj)); |
|
|
|
if(isOnline == 0) { |
|
|
|
// 开机 |
|
|
|
deviceTotalData.setMachinePwrStat(1); |
|
|
|
deviceTotalData.setMachineWorkingStat(2); |
|
|
|
}else { |
|
|
|
// 关机 |
|
|
|
deviceTotalData.setMachinePwrStat(0); |
|
|
|
deviceTotalData.setMachineWorkingStat(0); |
|
|
|
} |
|
|
|
}else { |
|
|
|
deviceTotalData.setMachinePwrStat(0); |
|
|
|
deviceTotalData.setMachineWorkingStat(0); |
|
|
|
} |
|
|
|
deviceTotalData.setReportTime(reportTime); |
|
|
|
stop = true; |
|
|
|
break; |
|
|
|
@ -406,6 +421,8 @@ public class IotMonitoringDataJob { |
|
|
|
deviceTotalData.setLastBootTime(reportTime); |
|
|
|
deviceTotalData.setTheDayJobDuration(0L); |
|
|
|
deviceTotalData.setTheDayJobCount(0L); |
|
|
|
deviceTotalData.setMachinePwrStat(0); |
|
|
|
deviceTotalData.setMachineWorkingStat(0); |
|
|
|
deviceTotalData.setCurrLocalDate(LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
|
deviceTotalData.setReportTime(reportTime); |
|
|
|
} |
|
|
|
|