优化数据推送
This commit is contained in:
parent
a2a41fc449
commit
577fb3d00d
@ -64,6 +64,9 @@ public class IPCDataUploadSyncThread implements Runnable {
|
||||
for (IpcMonitorField part : partList) {
|
||||
// 筛选当前部位参数
|
||||
List<IpcMonitorField> plcList = plcListRead.stream().filter(field -> part.getFieldCode().equals(field.getParentCode())).collect(Collectors.toList());
|
||||
if(plcList.isEmpty()){
|
||||
continue;
|
||||
}
|
||||
// // 遍历生成振动数据 开始
|
||||
// Map<String,String> tags = new HashMap<>();
|
||||
// tags.put("part",part.getFieldValue());
|
||||
@ -119,22 +122,20 @@ public class IPCDataUploadSyncThread implements Runnable {
|
||||
}
|
||||
msgMap.put("d", dataList);
|
||||
// 进行数据推送
|
||||
// System.out.println(msgMap.toString());
|
||||
// System.out.println(host + "----------" + clientId + "----------" + topicu);
|
||||
// MqttClient sampleClient = new MqttClient(host, clientId, new MemoryPersistence());
|
||||
// MqttConnectOptions connOpts = new MqttConnectOptions();
|
||||
// connOpts.setUserName(userName);
|
||||
// connOpts.setPassword(password.toCharArray());
|
||||
// sampleClient.connect(connOpts);
|
||||
// MqttMessage message = new MqttMessage(changeMapToByte(msgMap));
|
||||
// sampleClient.publish(topicu, message);
|
||||
// sampleClient.disconnect();
|
||||
// // 显式关闭MqttClient以释放资源
|
||||
// sampleClient.close();
|
||||
//// System.exit(0);
|
||||
// } catch (MqttException me) {
|
||||
// logger.info("数据推送失败,时间{},reason{},msg{},loc{},cause{},excep{}", new Date(), me.getReasonCode(), me.getMessage(), me.getLocalizedMessage(), me.getCause(), me);
|
||||
// me.printStackTrace();
|
||||
MqttClient sampleClient = new MqttClient(host, clientId, new MemoryPersistence());
|
||||
MqttConnectOptions connOpts = new MqttConnectOptions();
|
||||
connOpts.setUserName(userName);
|
||||
connOpts.setPassword(password.toCharArray());
|
||||
sampleClient.connect(connOpts);
|
||||
MqttMessage message = new MqttMessage(changeMapToByte(msgMap));
|
||||
sampleClient.publish(topicu, message);
|
||||
sampleClient.disconnect();
|
||||
// 显式关闭MqttClient以释放资源
|
||||
sampleClient.close();
|
||||
logger.info("数据推送成功,时间{},数据{}", new Date(), msgMap.toString());
|
||||
} catch (MqttException me) {
|
||||
logger.info("数据推送失败,时间{},reason{},msg{},loc{},cause{},excep{}", new Date(), me.getReasonCode(), me.getMessage(), me.getLocalizedMessage(), me.getCause(), me);
|
||||
me.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
logger.info("数据推送失败,时间{},{}", new Date(), e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
Loading…
Reference in New Issue
Block a user