|
|
|
@ -48,7 +48,6 @@ import org.thingsboard.server.common.data.id.EntityId; |
|
|
|
import org.thingsboard.server.common.data.id.EntityViewId; |
|
|
|
import org.thingsboard.server.common.data.id.RuleChainId; |
|
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
|
import org.thingsboard.server.common.data.id.UserId; |
|
|
|
import org.thingsboard.server.common.data.kv.AttributeKey; |
|
|
|
import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
|
|
|
import org.thingsboard.server.common.msg.TbMsg; |
|
|
|
@ -75,7 +74,6 @@ import java.util.ArrayList; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
@Component |
|
|
|
@Slf4j |
|
|
|
@ -94,7 +92,7 @@ public class TelemetryEdgeProcessor extends BaseEdgeProcessor { |
|
|
|
public List<ListenableFuture<Void>> processTelemetryFromEdge(TenantId tenantId, EntityDataProto entityData) { |
|
|
|
log.trace("[{}] processTelemetryFromEdge [{}]", tenantId, entityData); |
|
|
|
List<ListenableFuture<Void>> result = new ArrayList<>(); |
|
|
|
EntityId entityId = constructEntityId(entityData); |
|
|
|
EntityId entityId = constructEntityId(entityData.getEntityType(), entityData.getEntityIdMSB(), entityData.getEntityIdLSB()); |
|
|
|
if ((entityData.hasPostAttributesMsg() || entityData.hasPostTelemetryMsg() || entityData.hasAttributesUpdatedMsg()) && entityId != null) { |
|
|
|
Pair<TbMsgMetaData, CustomerId> pair = getBaseMsgMetadataAndCustomerId(tenantId, entityId); |
|
|
|
TbMsgMetaData metaData = pair.getKey(); |
|
|
|
@ -310,31 +308,6 @@ public class TelemetryEdgeProcessor extends BaseEdgeProcessor { |
|
|
|
return futureToSet; |
|
|
|
} |
|
|
|
|
|
|
|
private EntityId constructEntityId(EntityDataProto entityData) { |
|
|
|
EntityType entityType = EntityType.valueOf(entityData.getEntityType()); |
|
|
|
switch (entityType) { |
|
|
|
case DEVICE: |
|
|
|
return new DeviceId(new UUID(entityData.getEntityIdMSB(), entityData.getEntityIdLSB())); |
|
|
|
case ASSET: |
|
|
|
return new AssetId(new UUID(entityData.getEntityIdMSB(), entityData.getEntityIdLSB())); |
|
|
|
case ENTITY_VIEW: |
|
|
|
return new EntityViewId(new UUID(entityData.getEntityIdMSB(), entityData.getEntityIdLSB())); |
|
|
|
case DASHBOARD: |
|
|
|
return new DashboardId(new UUID(entityData.getEntityIdMSB(), entityData.getEntityIdLSB())); |
|
|
|
case TENANT: |
|
|
|
return TenantId.fromUUID(new UUID(entityData.getEntityIdMSB(), entityData.getEntityIdLSB())); |
|
|
|
case CUSTOMER: |
|
|
|
return new CustomerId(new UUID(entityData.getEntityIdMSB(), entityData.getEntityIdLSB())); |
|
|
|
case USER: |
|
|
|
return new UserId(new UUID(entityData.getEntityIdMSB(), entityData.getEntityIdLSB())); |
|
|
|
case EDGE: |
|
|
|
return new EdgeId(new UUID(entityData.getEntityIdMSB(), entityData.getEntityIdLSB())); |
|
|
|
default: |
|
|
|
log.warn("Unsupported entity type [{}] during construct of entity id. EntityDataProto [{}]", entityData.getEntityType(), entityData); |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public DownlinkMsg convertTelemetryEventToDownlink(EdgeEvent edgeEvent) throws JsonProcessingException { |
|
|
|
EntityId entityId; |
|
|
|
switch (edgeEvent.getType()) { |
|
|
|
|