|
|
@ -243,7 +243,7 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS |
|
|
try { |
|
|
try { |
|
|
if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && |
|
|
if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && |
|
|
!relation.getTo().getEntityType().equals(EntityType.EDGE)) { |
|
|
!relation.getTo().getEntityType().equals(EntityType.EDGE)) { |
|
|
sendNotificationMsgToEdgeService(tenantId, null, null, json.writeValueAsString(relation), |
|
|
sendNotificationMsgToEdge(tenantId, null, null, json.writeValueAsString(relation), |
|
|
EdgeEventType.RELATION, edgeTypeByActionType(actionType)); |
|
|
EdgeEventType.RELATION, edgeTypeByActionType(actionType)); |
|
|
} |
|
|
} |
|
|
} catch (Exception e1) { |
|
|
} catch (Exception e1) { |
|
|
@ -267,18 +267,18 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void sendEntityNotificationMsg(TenantId tenantId, EntityId entityId, EdgeEventActionType action) { |
|
|
private void sendEntityNotificationMsg(TenantId tenantId, EntityId entityId, EdgeEventActionType action) { |
|
|
sendNotificationMsgToEdgeService(tenantId, null, entityId, null, null, action); |
|
|
sendNotificationMsgToEdge(tenantId, null, entityId, null, null, action); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void sendEntityAssignToCustomerNotificationMsg(TenantId tenantId, EntityId entityId, CustomerId customerId, EdgeEventActionType action) { |
|
|
private void sendEntityAssignToCustomerNotificationMsg(TenantId tenantId, EntityId entityId, CustomerId customerId, EdgeEventActionType action) { |
|
|
try { |
|
|
try { |
|
|
sendNotificationMsgToEdgeService(tenantId, null, entityId, json.writeValueAsString(customerId), null, action); |
|
|
sendNotificationMsgToEdge(tenantId, null, entityId, json.writeValueAsString(customerId), null, action); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.warn("Failed to push assign/unassign to/from customer to core: {}", customerId, e); |
|
|
log.warn("Failed to push assign/unassign to/from customer to core: {}", customerId, e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected void sendAlarmDeleteNotificationMsg(TenantId tenantId, Alarm alarm, List<EdgeId> edgeIds, String body) { |
|
|
private void sendAlarmDeleteNotificationMsg(TenantId tenantId, Alarm alarm, List<EdgeId> edgeIds, String body) { |
|
|
try { |
|
|
try { |
|
|
sendDeleteNotificationMsg(tenantId, alarm.getId(), edgeIds, body); |
|
|
sendDeleteNotificationMsg(tenantId, alarm.getId(), edgeIds, body); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
@ -286,8 +286,7 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected <E extends HasName, I extends EntityId> void sendDeleteNotificationMsg(TenantId tenantId, I entityId, E entity, |
|
|
private <E extends HasName, I extends EntityId> void sendDeleteNotificationMsg(TenantId tenantId, I entityId, E entity, List<EdgeId> edgeIds) { |
|
|
List<EdgeId> edgeIds) { |
|
|
|
|
|
try { |
|
|
try { |
|
|
sendDeleteNotificationMsg(tenantId, entityId, edgeIds, null); |
|
|
sendDeleteNotificationMsg(tenantId, entityId, edgeIds, null); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
@ -298,17 +297,17 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS |
|
|
private void sendDeleteNotificationMsg(TenantId tenantId, EntityId entityId, List<EdgeId> edgeIds, String body) { |
|
|
private void sendDeleteNotificationMsg(TenantId tenantId, EntityId entityId, List<EdgeId> edgeIds, String body) { |
|
|
if (edgeIds != null && !edgeIds.isEmpty()) { |
|
|
if (edgeIds != null && !edgeIds.isEmpty()) { |
|
|
for (EdgeId edgeId : edgeIds) { |
|
|
for (EdgeId edgeId : edgeIds) { |
|
|
sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, body, null, EdgeEventActionType.DELETED); |
|
|
sendNotificationMsgToEdge(tenantId, edgeId, entityId, body, null, EdgeEventActionType.DELETED); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void sendEntityAssignToEdgeNotificationMsg(TenantId tenantId, EdgeId edgeId, EntityId entityId, EdgeEventActionType action) { |
|
|
private void sendEntityAssignToEdgeNotificationMsg(TenantId tenantId, EdgeId edgeId, EntityId entityId, EdgeEventActionType action) { |
|
|
sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, null, null, action); |
|
|
sendNotificationMsgToEdge(tenantId, edgeId, entityId, null, null, action); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void sendNotificationMsgToEdgeService(TenantId tenantId, EdgeId edgeId, EntityId entityId, String body, EdgeEventType type, EdgeEventActionType action) { |
|
|
private void sendNotificationMsgToEdge(TenantId tenantId, EdgeId edgeId, EntityId entityId, String body, EdgeEventType type, EdgeEventActionType action) { |
|
|
tbClusterService.sendNotificationMsgToEdgeService(tenantId, edgeId, entityId, body, type, action); |
|
|
tbClusterService.sendNotificationMsgToEdge(tenantId, edgeId, entityId, body, type, action); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void pushAssignedFromNotification(Tenant currentTenant, TenantId newTenantId, Device assignedDevice) { |
|
|
private void pushAssignedFromNotification(Tenant currentTenant, TenantId newTenantId, Device assignedDevice) { |
|
|
|