|
|
@ -1,6 +1,8 @@ |
|
|
package com.qniao.iot.machine.event.generator.job; |
|
|
package com.qniao.iot.machine.event.generator.job; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
|
import cn.hutool.core.map.MapUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.db.Db; |
|
|
import cn.hutool.db.Db; |
|
|
import cn.hutool.json.JSON; |
|
|
import cn.hutool.json.JSON; |
|
|
@ -13,18 +15,19 @@ import com.qniao.iot.machine.command.StopMachineWorkingCommand; |
|
|
import com.qniao.iot.machine.event.MachineIotDataReceivedEvent; |
|
|
import com.qniao.iot.machine.event.MachineIotDataReceivedEvent; |
|
|
import com.qniao.iot.machine.event.MachineIotDataReceivedEventKafkaDeserializationSchema; |
|
|
import com.qniao.iot.machine.event.MachineIotDataReceivedEventKafkaDeserializationSchema; |
|
|
import com.qniao.iot.machine.event.MachineIotDataReceivedEventRabbitMqSerializationSchema; |
|
|
import com.qniao.iot.machine.event.MachineIotDataReceivedEventRabbitMqSerializationSchema; |
|
|
|
|
|
import com.qniao.iot.machine.event.generator.config.ApolloConfig; |
|
|
|
|
|
import com.qniao.iot.machine.event.generator.constant.ConfigConstant; |
|
|
import com.rabbitmq.client.AMQP; |
|
|
import com.rabbitmq.client.AMQP; |
|
|
import org.apache.flink.api.common.eventtime.WatermarkStrategy; |
|
|
import org.apache.flink.api.common.eventtime.WatermarkStrategy; |
|
|
import org.apache.flink.api.common.functions.FilterFunction; |
|
|
|
|
|
import org.apache.flink.api.common.state.ValueState; |
|
|
import org.apache.flink.api.common.state.ValueState; |
|
|
import org.apache.flink.api.common.state.ValueStateDescriptor; |
|
|
import org.apache.flink.api.common.state.ValueStateDescriptor; |
|
|
import org.apache.flink.api.common.typeinfo.TypeInformation; |
|
|
import org.apache.flink.api.common.typeinfo.TypeInformation; |
|
|
import org.apache.flink.api.java.utils.ParameterTool; |
|
|
|
|
|
import org.apache.flink.configuration.Configuration; |
|
|
import org.apache.flink.configuration.Configuration; |
|
|
import org.apache.flink.connector.kafka.source.KafkaSource; |
|
|
import org.apache.flink.connector.kafka.source.KafkaSource; |
|
|
import org.apache.flink.connector.kafka.source.enumerator.initializer.OffsetsInitializer; |
|
|
import org.apache.flink.connector.kafka.source.enumerator.initializer.OffsetsInitializer; |
|
|
import org.apache.flink.streaming.api.CheckpointingMode; |
|
|
import org.apache.flink.streaming.api.CheckpointingMode; |
|
|
import org.apache.flink.streaming.api.datastream.DataStream; |
|
|
import org.apache.flink.streaming.api.datastream.DataStream; |
|
|
|
|
|
import org.apache.flink.streaming.api.datastream.DataStreamSource; |
|
|
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; |
|
|
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; |
|
|
import org.apache.flink.streaming.api.functions.KeyedProcessFunction; |
|
|
import org.apache.flink.streaming.api.functions.KeyedProcessFunction; |
|
|
import org.apache.flink.streaming.connectors.elasticsearch.ElasticsearchSinkFunction; |
|
|
import org.apache.flink.streaming.connectors.elasticsearch.ElasticsearchSinkFunction; |
|
|
@ -41,8 +44,6 @@ import org.apache.http.impl.client.BasicCredentialsProvider; |
|
|
import org.elasticsearch.action.index.IndexRequest; |
|
|
import org.elasticsearch.action.index.IndexRequest; |
|
|
import org.elasticsearch.client.Requests; |
|
|
import org.elasticsearch.client.Requests; |
|
|
|
|
|
|
|
|
import javax.sql.DataSource; |
|
|
|
|
|
import java.io.IOException; |
|
|
|
|
|
import java.sql.SQLException; |
|
|
import java.sql.SQLException; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
@ -59,23 +60,22 @@ public class IotMachineEventGeneratorJob { |
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception { |
|
|
public static void main(String[] args) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final ParameterTool params = ParameterTool.fromArgs(args); |
|
|
|
|
|
|
|
|
|
|
|
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); |
|
|
final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); |
|
|
env.enableCheckpointing(60000L, CheckpointingMode.EXACTLY_ONCE); |
|
|
env.enableCheckpointing(60000L, CheckpointingMode.EXACTLY_ONCE); |
|
|
KafkaSource<MachineIotDataReceivedEvent> source = KafkaSource.<MachineIotDataReceivedEvent>builder() |
|
|
KafkaSource<MachineIotDataReceivedEvent> source = KafkaSource.<MachineIotDataReceivedEvent>builder() |
|
|
.setBootstrapServers(params.get("source.bootstrap.servers")) |
|
|
|
|
|
.setTopics("machine_iot_data_received_event") |
|
|
|
|
|
.setGroupId("root_cloud_iot_data_etl") |
|
|
|
|
|
|
|
|
.setBootstrapServers(ApolloConfig.get(ConfigConstant.SOURCE_KAFKA_BOOTSTRAP_SERVERS)) |
|
|
|
|
|
.setTopics(ApolloConfig.get(ConfigConstant.SOURCE_KAFKA_TOPICS)) |
|
|
|
|
|
.setGroupId(ApolloConfig.get(ConfigConstant.SOURCE_KAFKA_GROUP_ID)) |
|
|
.setStartingOffsets(OffsetsInitializer.earliest()) |
|
|
.setStartingOffsets(OffsetsInitializer.earliest()) |
|
|
.setValueOnlyDeserializer(new MachineIotDataReceivedEventKafkaDeserializationSchema()) |
|
|
.setValueOnlyDeserializer(new MachineIotDataReceivedEventKafkaDeserializationSchema()) |
|
|
.build(); |
|
|
.build(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设备数据分组 |
|
|
// 设备数据分组 |
|
|
DataStream<BaseCommand> commandDataStream = env.fromSource(source, WatermarkStrategy.noWatermarks(), "machineIotDataReceivedEvent Kafka Source") |
|
|
|
|
|
.keyBy(MachineIotDataReceivedEvent::getMachineIotMac) |
|
|
|
|
|
|
|
|
DataStreamSource<MachineIotDataReceivedEvent> dataStreamSource = env |
|
|
|
|
|
.fromSource(source, WatermarkStrategy.noWatermarks(), "machineIotDataReceivedEvent Kafka Source"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DataStream<BaseCommand> commandDataStream = dataStreamSource.keyBy(MachineIotDataReceivedEvent::getMachineIotMac) |
|
|
.process(new KeyedProcessFunction<Long, MachineIotDataReceivedEvent, BaseCommand>() { |
|
|
.process(new KeyedProcessFunction<Long, MachineIotDataReceivedEvent, BaseCommand>() { |
|
|
|
|
|
|
|
|
private ValueState<JSON> deviceState; |
|
|
private ValueState<JSON> deviceState; |
|
|
@ -93,7 +93,8 @@ public class IotMachineEventGeneratorJob { |
|
|
deviceState -> deviceState, (deviceState1, deviceState2) -> deviceState1)); |
|
|
deviceState -> deviceState, (deviceState1, deviceState2) -> deviceState1)); |
|
|
} |
|
|
} |
|
|
deviceState = getRuntimeContext() |
|
|
deviceState = getRuntimeContext() |
|
|
.getState(new ValueStateDescriptor<>("deviceState", TypeInformation.of(JSON.class), JSONUtil.parse(allMachineMap))); |
|
|
|
|
|
|
|
|
.getState(new ValueStateDescriptor<>("deviceState", |
|
|
|
|
|
TypeInformation.of(JSON.class), JSONUtil.parse(allMachineMap))); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@ -102,13 +103,15 @@ public class IotMachineEventGeneratorJob { |
|
|
|
|
|
|
|
|
// 获取最新设备状态 |
|
|
// 获取最新设备状态 |
|
|
JSON deviceStateListJson = deviceState.value(); |
|
|
JSON deviceStateListJson = deviceState.value(); |
|
|
DeviceState lastedDeviceState = deviceStateListJson.getByPath(StrUtil.toString(event.getMachineIotMac()), DeviceState.class); |
|
|
|
|
|
|
|
|
DeviceState lastedDeviceState = deviceStateListJson |
|
|
|
|
|
.getByPath(StrUtil.toString(event.getMachineIotMac()), DeviceState.class); |
|
|
Integer deviceStatus = getDeviceStatus(event); |
|
|
Integer deviceStatus = getDeviceStatus(event); |
|
|
if (deviceStatus != null) { |
|
|
if (deviceStatus != null) { |
|
|
deviceStateListJson.putByPath(StrUtil.toString(event.getMachineIotMac()), |
|
|
deviceStateListJson.putByPath(StrUtil.toString(event.getMachineIotMac()), |
|
|
new DeviceState(event.getId(), event.getMachineIotMac(), deviceStatus, event.getReportTime())); |
|
|
new DeviceState(event.getId(), event.getMachineIotMac(), deviceStatus, event.getReportTime())); |
|
|
if (lastedDeviceState != null) { |
|
|
if (lastedDeviceState != null) { |
|
|
DeviceState newState = new DeviceState(lastedDeviceState.getMachineId(), event.getMachineIotMac(), deviceStatus, event.getReportTime()); |
|
|
|
|
|
|
|
|
DeviceState newState = new DeviceState(lastedDeviceState.getMachineId(), event.getMachineIotMac(), |
|
|
|
|
|
deviceStatus, event.getReportTime()); |
|
|
collDeviceStatusChange(out, newState, lastedDeviceState, event); |
|
|
collDeviceStatusChange(out, newState, lastedDeviceState, event); |
|
|
} |
|
|
} |
|
|
deviceState.update(deviceStateListJson); |
|
|
deviceState.update(deviceStateListJson); |
|
|
@ -121,7 +124,7 @@ public class IotMachineEventGeneratorJob { |
|
|
sinkRabbitMq(commandDataStream); |
|
|
sinkRabbitMq(commandDataStream); |
|
|
|
|
|
|
|
|
// 写入es |
|
|
// 写入es |
|
|
sinkEs(commandDataStream); |
|
|
|
|
|
|
|
|
sinkEs(dataStreamSource); |
|
|
|
|
|
|
|
|
env.execute("Kafka Job"); |
|
|
env.execute("Kafka Job"); |
|
|
} |
|
|
} |
|
|
@ -131,72 +134,48 @@ public class IotMachineEventGeneratorJob { |
|
|
|
|
|
|
|
|
// rabbitmq配置(测试环境) |
|
|
// rabbitmq配置(测试环境) |
|
|
RMQConnectionConfig connectionConfig = new RMQConnectionConfig.Builder() |
|
|
RMQConnectionConfig connectionConfig = new RMQConnectionConfig.Builder() |
|
|
.setHost("8.135.8.221") |
|
|
|
|
|
.setVirtualHost("/") |
|
|
|
|
|
.setUserName("qniao") |
|
|
|
|
|
.setPassword("Qianniao2020") |
|
|
|
|
|
.setPort(5672).build(); |
|
|
|
|
|
|
|
|
.setHost(ApolloConfig.get(ConfigConstant.SINK_RABBITMQ_HOST)) |
|
|
|
|
|
.setVirtualHost(ApolloConfig.get(ConfigConstant.SINK_RABBITMQ_VIRTUAL_HOST)) |
|
|
|
|
|
.setUserName(ApolloConfig.get(ConfigConstant.SINK_RABBITMQ_USER_NAME)) |
|
|
|
|
|
.setPassword(ApolloConfig.get(ConfigConstant.SINK_RABBITMQ_PASSWORD)) |
|
|
|
|
|
.setPort(ApolloConfig.getInt(ConfigConstant.SINK_RABBITMQ_PORT)).build(); |
|
|
|
|
|
|
|
|
// 发送相应的指令到rabbitmq的交换机 |
|
|
// 发送相应的指令到rabbitmq的交换机 |
|
|
commandDataStream.addSink(new RMQSink<>(connectionConfig, new MachineIotDataReceivedEventRabbitMqSerializationSchema(), |
|
|
commandDataStream.addSink(new RMQSink<>(connectionConfig, new MachineIotDataReceivedEventRabbitMqSerializationSchema(), |
|
|
new RMQSinkPublishOptions<BaseCommand>() { |
|
|
new RMQSinkPublishOptions<BaseCommand>() { |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public String computeRoutingKey(BaseCommand command) { |
|
|
|
|
|
return "machine-iot-data-received-event"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public AMQP.BasicProperties computeProperties(BaseCommand command) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public String computeRoutingKey(BaseCommand command) { |
|
|
|
|
|
return ApolloConfig.get(ConfigConstant.SINK_RABBITMQ_ROUTING_KEY); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public String computeExchange(BaseCommand command) { |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public AMQP.BasicProperties computeProperties(BaseCommand command) { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 交换机名称 |
|
|
|
|
|
return "flink_test_exchange"; |
|
|
|
|
|
} |
|
|
|
|
|
})).name("commandDataStream to rabbitmq Sink"); |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public String computeExchange(BaseCommand command) { |
|
|
|
|
|
|
|
|
// 直接发队列 |
|
|
|
|
|
// commandDataStream.addSink(new RMQSink<>(connectionConfig, "flink_test_queue", new BaseCommandSerializationSchema())).name("12"); |
|
|
|
|
|
|
|
|
// 交换机名称 |
|
|
|
|
|
return ApolloConfig.get(ConfigConstant.SINK_RABBITMQ_EXCHANGE); |
|
|
|
|
|
} |
|
|
|
|
|
})).name("commandDataStream to rabbitmq Sink"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static void sinkEs(DataStream<BaseCommand> commandDataStream) { |
|
|
|
|
|
|
|
|
private static void sinkEs(DataStreamSource<MachineIotDataReceivedEvent> dataStream) { |
|
|
|
|
|
|
|
|
List<HttpHost> httpHosts = new ArrayList<>(); |
|
|
List<HttpHost> httpHosts = new ArrayList<>(); |
|
|
httpHosts.add(new HttpHost("119.23.41.137", 9200, "http")); |
|
|
|
|
|
ElasticsearchSink.Builder<BaseCommand> esSinkBuilder = new ElasticsearchSink.Builder<>(httpHosts, |
|
|
|
|
|
(ElasticsearchSinkFunction<BaseCommand>) (command, runtimeContext, requestIndexer) -> { |
|
|
|
|
|
|
|
|
|
|
|
HashMap<String, String> map = new HashMap<>(); |
|
|
|
|
|
if (command instanceof PowerOnMachineCommand) { |
|
|
|
|
|
// 设备开机数据 |
|
|
|
|
|
PowerOnMachineCommand powerOnMachineCommand = (PowerOnMachineCommand) command; |
|
|
|
|
|
map.put("id", powerOnMachineCommand.getId().toString()); |
|
|
|
|
|
map.put("currTotalOutput", powerOnMachineCommand.getCurrTotalOutput().toString()); |
|
|
|
|
|
} |
|
|
|
|
|
if (command instanceof PowerOffMachineCommand) { |
|
|
|
|
|
// 设备关机数据 |
|
|
|
|
|
PowerOffMachineCommand powerOffMachineCommand = (PowerOffMachineCommand) command; |
|
|
|
|
|
map.put("id", powerOffMachineCommand.getId().toString()); |
|
|
|
|
|
map.put("currTotalOutput", powerOffMachineCommand.getCurrTotalOutput().toString()); |
|
|
|
|
|
} |
|
|
|
|
|
if (command instanceof StopMachineWorkingCommand) { |
|
|
|
|
|
// 设备待机数据 |
|
|
|
|
|
StopMachineWorkingCommand stopMachineWorkingCommand = (StopMachineWorkingCommand) command; |
|
|
|
|
|
map.put("id", stopMachineWorkingCommand.getId().toString()); |
|
|
|
|
|
map.put("currTotalOutput", stopMachineWorkingCommand.getCurrTotalOutput().toString()); |
|
|
|
|
|
} |
|
|
|
|
|
if (command instanceof StartMachineWorkingCommand) { |
|
|
|
|
|
// 设备工作数据 |
|
|
|
|
|
StartMachineWorkingCommand startMachineWorkingCommand = (StartMachineWorkingCommand) command; |
|
|
|
|
|
map.put("id", startMachineWorkingCommand.getId().toString()); |
|
|
|
|
|
map.put("currTotalOutput", startMachineWorkingCommand.getCurrTotalOutput().toString()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
httpHosts.add(new HttpHost(ApolloConfig.get(ConfigConstant.SINK_ELASTICSEARCH_HOST), |
|
|
|
|
|
ApolloConfig.getInt(ConfigConstant.SINK_ELASTICSEARCH_POST), |
|
|
|
|
|
ApolloConfig.get(ConfigConstant.SINK_ELASTICSEARCH_SCHEME))); |
|
|
|
|
|
ElasticsearchSink.Builder<MachineIotDataReceivedEvent> esSinkBuilder = new ElasticsearchSink.Builder<>(httpHosts, |
|
|
|
|
|
(ElasticsearchSinkFunction<MachineIotDataReceivedEvent>) (machineIotDataReceivedEvent, runtimeContext, requestIndexer) -> { |
|
|
|
|
|
|
|
|
//创建es 请求 |
|
|
//创建es 请求 |
|
|
IndexRequest indexRequest = Requests.indexRequest().index("machine-iot-data-received-event").source(map); |
|
|
|
|
|
|
|
|
IndexRequest indexRequest = Requests.indexRequest() |
|
|
|
|
|
.index(ApolloConfig.get(ConfigConstant.SINK_ELASTICSEARCH_INDEX)) |
|
|
|
|
|
.source(BeanUtil.beanToMap(machineIotDataReceivedEvent)); |
|
|
requestIndexer.add(indexRequest); |
|
|
requestIndexer.add(indexRequest); |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
@ -204,25 +183,27 @@ public class IotMachineEventGeneratorJob { |
|
|
esSinkBuilder.setBulkFlushMaxActions(10); |
|
|
esSinkBuilder.setBulkFlushMaxActions(10); |
|
|
//刷新前缓冲区的最大数据大小(以MB为单位) |
|
|
//刷新前缓冲区的最大数据大小(以MB为单位) |
|
|
esSinkBuilder.setBulkFlushMaxSizeMb(5); |
|
|
esSinkBuilder.setBulkFlushMaxSizeMb(5); |
|
|
//论缓冲操作的数量或大小如何都要刷新的时间间隔 |
|
|
|
|
|
|
|
|
//无论缓冲操作的数量或大小如何,都要刷新的时间间隔 |
|
|
esSinkBuilder.setBulkFlushInterval(5000L); |
|
|
esSinkBuilder.setBulkFlushInterval(5000L); |
|
|
// 客户端创建配置回调,配置账号密码 |
|
|
// 客户端创建配置回调,配置账号密码 |
|
|
esSinkBuilder.setRestClientFactory( |
|
|
esSinkBuilder.setRestClientFactory( |
|
|
restClientBuilder -> { |
|
|
restClientBuilder -> { |
|
|
restClientBuilder.setHttpClientConfigCallback(httpAsyncClientBuilder -> { |
|
|
restClientBuilder.setHttpClientConfigCallback(httpAsyncClientBuilder -> { |
|
|
CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); |
|
|
CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); |
|
|
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("elastic", "qn56521")); |
|
|
|
|
|
|
|
|
credentialsProvider.setCredentials(AuthScope.ANY, |
|
|
|
|
|
new UsernamePasswordCredentials(ApolloConfig.get(ConfigConstant.SINK_ELASTICSEARCH_USER_NAME), |
|
|
|
|
|
ApolloConfig.get(ConfigConstant.SINK_ELASTICSEARCH_PASSWORD))); |
|
|
return httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider); |
|
|
return httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider); |
|
|
}); |
|
|
}); |
|
|
restClientBuilder.setRequestConfigCallback(requestConfigBuilder -> { |
|
|
restClientBuilder.setRequestConfigCallback(requestConfigBuilder -> { |
|
|
// 设置es连接超时时间 |
|
|
// 设置es连接超时时间 |
|
|
requestConfigBuilder.setConnectTimeout(3000); |
|
|
|
|
|
|
|
|
requestConfigBuilder.setConnectTimeout(ApolloConfig.getInt(ConfigConstant.SINK_ELASTICSEARCH_CONNECT_TIMEOUT)); |
|
|
return requestConfigBuilder; |
|
|
return requestConfigBuilder; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
//数据流添加sink |
|
|
//数据流添加sink |
|
|
commandDataStream.addSink(esSinkBuilder.build()).name("commandDataStream to es sink"); |
|
|
|
|
|
|
|
|
dataStream.addSink(esSinkBuilder.build()).name("commandDataStream to es sink"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -235,7 +216,7 @@ public class IotMachineEventGeneratorJob { |
|
|
&& Integer.valueOf("1").equals(event.getMachineWorkingStat())) { |
|
|
&& Integer.valueOf("1").equals(event.getMachineWorkingStat())) { |
|
|
return 1; |
|
|
return 1; |
|
|
} else if (Integer.valueOf("1").equals(event.getMachinePwrStat()) |
|
|
} else if (Integer.valueOf("1").equals(event.getMachinePwrStat()) |
|
|
&& Integer.valueOf("0").equals(event.getMachineWorkingStat())) { |
|
|
|
|
|
|
|
|
&& Integer.valueOf("2").equals(event.getMachineWorkingStat())) { |
|
|
return 2; |
|
|
return 2; |
|
|
} |
|
|
} |
|
|
return null; |
|
|
return null; |
|
|
@ -256,14 +237,5 @@ public class IotMachineEventGeneratorJob { |
|
|
// 设备开始工作 |
|
|
// 设备开始工作 |
|
|
out.collect(new StartMachineWorkingCommand(newState.getMachineIotMac(), event.getCurrJobCount())); |
|
|
out.collect(new StartMachineWorkingCommand(newState.getMachineIotMac(), event.getCurrJobCount())); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*if (newState.getStatus() == 1 || newState.getStatus() == 2) { |
|
|
|
|
|
System.out.println("设备开机。相关事件:" + event.toString()); |
|
|
|
|
|
out.collect(new PowerOnMachineCommand(newState.getMachineIotMac(), event.getCurrJobCount())); |
|
|
|
|
|
} else if (newState.getStatus() == 0) { |
|
|
|
|
|
System.out.println("设备关机。相关事件:" + event.toString()); |
|
|
|
|
|
out.collect(new PowerOffMachineCommand(newState.getMachineIotMac(), event.getCurrJobCount())); |
|
|
|
|
|
}*/ |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |