|
|
@@ -1387,4 +1387,24 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
|
|
|
return object;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void deletedDeviceAndSyncToHost(Long id) {
|
|
|
+ final IotDeviceInfo deviceInfo = getById(id);
|
|
|
+ if (deviceInfo == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ final BaseDeviceTypeEnum deviceTypeEnum = BaseDeviceTypeEnum.getEnumByCode(deviceInfo.getDeviceType());
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("deviceType", deviceTypeEnum.name());
|
|
|
+ param.put("deviceCode", deviceInfo.getDeviceCode());
|
|
|
+ param.put("deviceProduct", deviceInfo.getDeviceProduct());
|
|
|
+
|
|
|
+ final String topic = TopicTypeEnums.formatUrl(TopicTypeEnums.PRODUCT_SERVICE_INVOKE.getUrl(), WebSocketConstants.DETECTION_HOST, WebSocketConstants.DETECTION_HOST_DEVICE);
|
|
|
+ final WebsocketResult result = WebsocketResult.invokeHostServer(topic, new JSONObject(), WebSocketConstants.DELETED_DEVICES_SERVICES, param);
|
|
|
+ websocketService.sendMsgByTokens(result, deviceInfo.getIotToken());
|
|
|
+ monitorSyncStatus(deviceInfo);
|
|
|
+ LogUtils.SYNC_DEVICE.info("设备[ {} ]已被删除,同步至主机 [ {} ],设备类型:{}", deviceInfo.getDeviceName(), deviceInfo.getIotToken(), deviceTypeEnum.getDesc());
|
|
|
+ }
|
|
|
}
|