|
|
|
@ -137,10 +137,16 @@ public class IotMachineEventGeneratorJob { |
|
|
|
|
|
|
|
Long currCount = value.getCurrJobCount(); |
|
|
|
Integer machineWorkingStat = value.getMachineWorkingStat(); |
|
|
|
boolean bool = !(machineWorkingStat == 2 && currCount == 0); |
|
|
|
boolean bool = false; |
|
|
|
if (currCount == null) { |
|
|
|
currCount = 0L; |
|
|
|
} |
|
|
|
if (machineWorkingStat != null) { |
|
|
|
bool = !(machineWorkingStat == 2 && currCount == 0); |
|
|
|
} |
|
|
|
if (bool && value.getMachinePwrStat() != null |
|
|
|
&& value.getMachineIotMac() != null |
|
|
|
&& value.getMachineWorkingStat() != null && value.getReportTime() != null) { |
|
|
|
&& value.getReportTime() != null) { |
|
|
|
long nowTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli(); |
|
|
|
// 晚30分钟的数据就不要了 |
|
|
|
return nowTime - value.getReportTime() <= (30 * 60 * 1000); |
|
|
|
@ -207,7 +213,7 @@ public class IotMachineEventGeneratorJob { |
|
|
|
if (reportTime - lastReportTime <= 30 * 60 * 1000) { |
|
|
|
// 判断是否是机智云还是树根 |
|
|
|
Integer dataSource = event.getDataSource(); |
|
|
|
if(dataSource == 1) { |
|
|
|
if (dataSource == 1) { |
|
|
|
// 树根的需要计算 |
|
|
|
event.setCurrJobCount(accCount - lastAccJobCount); |
|
|
|
// 单位是秒 |
|
|
|
@ -215,10 +221,10 @@ public class IotMachineEventGeneratorJob { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if((event.getCurrJobCount() != 0 && event.getCurrJobDuration() != 0) |
|
|
|
if ((event.getCurrJobCount() != 0 && event.getCurrJobDuration() != 0) |
|
|
|
|| (event.getCurrJobCount() == 0 && event.getCurrJobDuration() == 0)) { |
|
|
|
MachineIotDataReceivedEvent receivedEvent = collDeviceStatusChange(out, deviceState, lastDataReceivedEvent, event); |
|
|
|
if(receivedEvent != null) { |
|
|
|
if (receivedEvent != null) { |
|
|
|
ctx.output(machineIotDataReceivedEventOutput, event); |
|
|
|
} |
|
|
|
lastDataReceivedEventState.update(event); |
|
|
|
@ -332,7 +338,7 @@ public class IotMachineEventGeneratorJob { |
|
|
|
if (command instanceof StartMachineWorkingCommand) { |
|
|
|
// 机器工作 |
|
|
|
return ApolloConfig.getStr(ConfigConstant.SINK_RABBITMQ_START_MACHINE_WORKING_COMMAND_ROUTING_KEY); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
// 机器命令 |
|
|
|
return ApolloConfig.getStr(ConfigConstant.SINK_RABBITMQ_MACHINE_COMMAND_ROUTING_KEY); |
|
|
|
} |
|
|
|
@ -502,9 +508,9 @@ public class IotMachineEventGeneratorJob { |
|
|
|
} |
|
|
|
|
|
|
|
private static MachineIotDataReceivedEvent collDeviceStatusChange(Collector<BaseCommand> out, |
|
|
|
DeviceState deviceState, |
|
|
|
MachineIotDataReceivedEvent lastDataReceivedEvent, |
|
|
|
MachineIotDataReceivedEvent event) { |
|
|
|
DeviceState deviceState, |
|
|
|
MachineIotDataReceivedEvent lastDataReceivedEvent, |
|
|
|
MachineIotDataReceivedEvent event) { |
|
|
|
|
|
|
|
Long machineIotMac = event.getMachineIotMac(); |
|
|
|
Integer dataSource = event.getDataSource(); |
|
|
|
|