|
|
|
@ -2,6 +2,7 @@ package com.qniao.iot; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.db.Db; |
|
|
|
import cn.hutool.http.HttpUtil; |
|
|
|
import cn.hutool.json.JSONArray; |
|
|
|
@ -168,6 +169,10 @@ public class IotMonitoringDataJob { |
|
|
|
lastWorkingStatState.update(machineWorkingStat); |
|
|
|
lastPwStatState.update(machinePwrStat); |
|
|
|
Long reportTime = receivedEvent.getReportTime(); |
|
|
|
String reportTimeStr = StrUtil.toString(reportTime); |
|
|
|
if(reportTimeStr.length() == 10) { |
|
|
|
reportTime = reportTime * 1000; |
|
|
|
} |
|
|
|
// 1树根 0机智云 |
|
|
|
Integer dataSource = receivedEvent.getDataSource(); |
|
|
|
// 当前数据 |
|
|
|
@ -201,15 +206,21 @@ public class IotMonitoringDataJob { |
|
|
|
if (lastWorkingStat == 1) { |
|
|
|
// 如果上次是工作中,那就进行累加 |
|
|
|
if (lastReportTime != null) { |
|
|
|
nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + workingDuration); |
|
|
|
/*nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + workingDuration); |
|
|
|
nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + workingDuration); |
|
|
|
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration); |
|
|
|
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration);*/ |
|
|
|
if (dataSource == 1) { |
|
|
|
// 树根 |
|
|
|
nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + workingDuration); |
|
|
|
nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + workingDuration); |
|
|
|
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration); |
|
|
|
nowDeviceState.setTheDayJobCount(onData.getTheDayJobCount() + receivedEvent.getCurrJobCount()); |
|
|
|
nowDeviceState.setJobTotal(onData.getJobTotal() + receivedEvent.getCurrJobCount()); |
|
|
|
} else { |
|
|
|
// 机智云 |
|
|
|
nowDeviceState.setTheDayDuration(lastedDeviceState.getTheDayDuration() + receivedEvent.getCurrJobDuration()); |
|
|
|
nowDeviceState.setTheDayJobDuration(lastedDeviceState.getTheDayJobDuration() + receivedEvent.getCurrJobDuration()); |
|
|
|
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + receivedEvent.getCurrJobDuration()); |
|
|
|
nowDeviceState.setTheDayJobCount(lastedDeviceState.getTheDayJobCount() + receivedEvent.getCurrJobCount()); |
|
|
|
nowDeviceState.setJobTotal(lastedDeviceState.getJobTotal() + receivedEvent.getCurrJobCount()); |
|
|
|
} |
|
|
|
@ -226,6 +237,7 @@ public class IotMonitoringDataJob { |
|
|
|
deviceTotalDataStat.update(nowDeviceState); |
|
|
|
} else { |
|
|
|
if (machineWorkingStat.equals(1)) { |
|
|
|
// 工作 |
|
|
|
if (dataSource == 1) { |
|
|
|
// 树根(今日当前数 + 这次信息点距离上次信息点生产的数量) |
|
|
|
nowDeviceState.setTheDayJobCount(onData.getTheDayJobCount() + receivedEvent.getCurrJobCount()); |
|
|
|
@ -241,6 +253,7 @@ public class IotMonitoringDataJob { |
|
|
|
nowDeviceState.setJobDurationTotal(lastedDeviceState.getJobDurationTotal() + workingDuration); |
|
|
|
nowDeviceState.setReportTime(reportTime); |
|
|
|
} else { |
|
|
|
// 待机或开机 |
|
|
|
nowDeviceState = lastedDeviceState; |
|
|
|
} |
|
|
|
deviceTotalDataStat.update(nowDeviceState); |
|
|
|
|