|
|
@ -77,9 +77,9 @@ public abstract class AbstractTbMsgPushNode<T extends BaseTbMsgPushNodeConfigura |
|
|
EdgeEventActionType actionType = getAlarmActionType(msg); |
|
|
EdgeEventActionType actionType = getAlarmActionType(msg); |
|
|
return buildEvent(ctx.getTenantId(), actionType, getUUIDFromMsgData(msg), getAlarmEventType(), null); |
|
|
return buildEvent(ctx.getTenantId(), actionType, getUUIDFromMsgData(msg), getAlarmEventType(), null); |
|
|
} else { |
|
|
} else { |
|
|
EdgeEventActionType actionType = getEdgeEventActionTypeByMsgType(msgType); |
|
|
|
|
|
Map<String, Object> entityBody = new HashMap<>(); |
|
|
|
|
|
Map<String, String> metadata = msg.getMetaData().getData(); |
|
|
Map<String, String> metadata = msg.getMetaData().getData(); |
|
|
|
|
|
EdgeEventActionType actionType = getEdgeEventActionTypeByMsgType(msgType, metadata); |
|
|
|
|
|
Map<String, Object> entityBody = new HashMap<>(); |
|
|
JsonNode dataJson = JacksonUtil.toJsonNode(msg.getData()); |
|
|
JsonNode dataJson = JacksonUtil.toJsonNode(msg.getData()); |
|
|
switch (actionType) { |
|
|
switch (actionType) { |
|
|
case ATTRIBUTES_UPDATED: |
|
|
case ATTRIBUTES_UPDATED: |
|
|
@ -148,21 +148,27 @@ public abstract class AbstractTbMsgPushNode<T extends BaseTbMsgPushNodeConfigura |
|
|
return scope; |
|
|
return scope; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected EdgeEventActionType getEdgeEventActionTypeByMsgType(String msgType) { |
|
|
protected EdgeEventActionType getEdgeEventActionTypeByMsgType(String msgType, Map<String, String> metadata) { |
|
|
EdgeEventActionType actionType; |
|
|
EdgeEventActionType actionType; |
|
|
if (SessionMsgType.POST_TELEMETRY_REQUEST.name().equals(msgType) |
|
|
if (SessionMsgType.POST_TELEMETRY_REQUEST.name().equals(msgType) |
|
|
|| DataConstants.TIMESERIES_UPDATED.equals(msgType)) { |
|
|
|| DataConstants.TIMESERIES_UPDATED.equals(msgType)) { |
|
|
actionType = EdgeEventActionType.TIMESERIES_UPDATED; |
|
|
actionType = EdgeEventActionType.TIMESERIES_UPDATED; |
|
|
} else if (DataConstants.ATTRIBUTES_UPDATED.equals(msgType) |
|
|
} else if (DataConstants.ATTRIBUTES_UPDATED.equals(msgType)) { |
|
|
|| DataConstants.CONNECT_EVENT.equals(msgType) |
|
|
|
|
|
|| DataConstants.DISCONNECT_EVENT.equals(msgType) |
|
|
|
|
|
|| DataConstants.ACTIVITY_EVENT.equals(msgType) |
|
|
|
|
|
|| DataConstants.INACTIVITY_EVENT.equals(msgType)) { |
|
|
|
|
|
actionType = EdgeEventActionType.ATTRIBUTES_UPDATED; |
|
|
actionType = EdgeEventActionType.ATTRIBUTES_UPDATED; |
|
|
} else if (SessionMsgType.POST_ATTRIBUTES_REQUEST.name().equals(msgType)) { |
|
|
} else if (SessionMsgType.POST_ATTRIBUTES_REQUEST.name().equals(msgType)) { |
|
|
actionType = EdgeEventActionType.POST_ATTRIBUTES; |
|
|
actionType = EdgeEventActionType.POST_ATTRIBUTES; |
|
|
} else if (DataConstants.ATTRIBUTES_DELETED.equals(msgType)) { |
|
|
} else if (DataConstants.ATTRIBUTES_DELETED.equals(msgType)) { |
|
|
actionType = EdgeEventActionType.ATTRIBUTES_DELETED; |
|
|
actionType = EdgeEventActionType.ATTRIBUTES_DELETED; |
|
|
|
|
|
} else if (DataConstants.CONNECT_EVENT.equals(msgType) |
|
|
|
|
|
|| DataConstants.DISCONNECT_EVENT.equals(msgType) |
|
|
|
|
|
|| DataConstants.ACTIVITY_EVENT.equals(msgType) |
|
|
|
|
|
|| DataConstants.INACTIVITY_EVENT.equals(msgType)) { |
|
|
|
|
|
String scope = metadata.get(SCOPE); |
|
|
|
|
|
if ( StringUtils.isEmpty(scope)) { |
|
|
|
|
|
actionType = EdgeEventActionType.TIMESERIES_UPDATED; |
|
|
|
|
|
} else { |
|
|
|
|
|
actionType = EdgeEventActionType.ATTRIBUTES_UPDATED; |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
log.warn("Unsupported msg type [{}]", msgType); |
|
|
log.warn("Unsupported msg type [{}]", msgType); |
|
|
throw new IllegalArgumentException("Unsupported msg type: " + msgType); |
|
|
throw new IllegalArgumentException("Unsupported msg type: " + msgType); |
|
|
|