Browse Source

sparkplug: connection3

pull/7763/head
nickAS21 4 years ago
parent
commit
09e5060bef
  1. 8
      application/src/main/java/org/thingsboard/server/service/transport/DefaultTransportApiService.java

8
application/src/main/java/org/thingsboard/server/service/transport/DefaultTransportApiService.java

@ -365,13 +365,13 @@ public class DefaultTransportApiService implements TransportApiService {
DeviceProfile deviceProfile = deviceProfileCache.findOrCreateDeviceProfile(sparkplugNode.getTenantId(), requestMsg.getDeviceType());
device.setDeviceProfileId(deviceProfile.getId());
ObjectNode additionalInfo = JacksonUtil.newObjectNode();
additionalInfo.put(DataConstants.LAST_CONNECTED_GATEWAY, sparkplugNodeId.toString());
additionalInfo.put(DataConstants.LAST_CONNECTED_SPARKPLUG, sparkplugNodeId.toString());
device.setAdditionalInfo(additionalInfo);
Device savedDevice = deviceService.saveDevice(device);
tbClusterService.onDeviceUpdated(savedDevice, null);
device = savedDevice;
relationService.saveRelation(TenantId.SYS_TENANT_ID, new EntityRelation(sparkplugNode.getId(), device.getId(), "Created"));
relationService.saveRelation(TenantId.SYS_TENANT_ID, new EntityRelation(device.getId(), sparkplugNode.getId(), "Created"));
TbMsgMetaData metaData = new TbMsgMetaData();
CustomerId customerId = sparkplugNode.getCustomerId();
@ -395,8 +395,12 @@ public class DefaultTransportApiService implements TransportApiService {
ObjectNode newDeviceAdditionalInfo = (ObjectNode) deviceAdditionalInfo;
newDeviceAdditionalInfo.put(DataConstants.LAST_CONNECTED_SPARKPLUG, sparkplugNodeId.toString());
Device savedDevice = deviceService.saveDevice(device);
relationService.saveRelation(TenantId.SYS_TENANT_ID, new EntityRelation(device.getId(), sparkplugNode.getId(), "Created"));
tbClusterService.onDeviceUpdated(savedDevice, device);
}
}
TransportProtos.GetOrCreateDeviceFromSparkplugResponseMsg.Builder builder =
TransportProtos.GetOrCreateDeviceFromSparkplugResponseMsg.newBuilder()

Loading…
Cancel
Save