Преглед на файлове

增加设备以及连接修改同步到TOS平台功能

zhaiyifei преди 1 година
родител
ревизия
c398ec93d7

+ 0 - 8
src/main/java/com/yunfeiyun/agmp/iotm/web/service/IIotDeviceService.java

@@ -48,14 +48,6 @@ public interface IIotDeviceService {
     public List<IotDevice> selectIotDeviceList(IotDevice iotDevice);
 
     /**
-     * 新增设备基础
-     *
-     * @param iotDevice 设备基础
-     * @return 结果
-     */
-    public int insertIotDevice(IotDevice iotDevice);
-
-    /**
      * 批量新增设备基础
      *
      * @param iotDeviceList 设备基础列表

+ 11 - 25
src/main/java/com/yunfeiyun/agmp/iotm/web/service/impl/IotDeviceServiceImpl.java

@@ -253,23 +253,6 @@ public class IotDeviceServiceImpl implements IIotDeviceService
         return iotDeviceMapper.selectIotDeviceList(iotDevice);
     }
 
-
-    /**
-     * 新增设备基础
-     *
-     * @param iotDevice 设备基础
-     * @return 结果
-     */
-    @Override
-    public int insertIotDevice(IotDevice iotDevice) {
-        iotDevice.setDevBid(iotDevice.getUUId());
-        iotDevice.setTid(SecurityUtils.getTid());
-        int result =  iotDeviceMapper.insertIotDevice(iotDevice);
-        sendToTosMsgService.sendIotDeviceInsertMsg(iotDevice);
-        sendToIotsMsgService.sendIotDeviceInsertMsg(iotDevice);
-        return result;
-    }
-
     /**
      * 批量新增设备基础
      *
@@ -282,9 +265,12 @@ public class IotDeviceServiceImpl implements IIotDeviceService
             iotDevice.setTid(SecurityUtils.getTid());
         }
         int status = iotDeviceMapper.insertIotDeviceByBatch(iotDeviceList);
-        // TODO 发送消息
-        // 获取连接 订阅设备
         // 同步新增设备到TOS
+        // 获取连接 订阅设备
+        for(IotDevice iotDevice : iotDeviceList){
+            sendToTosMsgService.sendIotDeviceInsertMsg(iotDevice);
+            sendToIotsMsgService.sendIotDeviceInsertMsg(iotDevice);
+        }
         return status;
     }
 
@@ -297,12 +283,13 @@ public class IotDeviceServiceImpl implements IIotDeviceService
     @Override
     public int updateIotDevice(IotDevice iotDevice, IotDeviceconn oldDeviceconn, IotDeviceconn newDeviceconn){
         int result = iotDeviceMapper.updateIotDevice(iotDevice);
-        // TODO 发送消息
-        // 解除旧连接订阅
-        // 订阅新连接
         // 同步修改设备到TOS
         sendToTosMsgService.sendIotDeviceUpdateMsg(iotDevice);
-        sendToIotsMsgService.sendIotDeviceUpdateMsg(iotDevice);
+        if(oldDeviceconn != null && newDeviceconn != null){
+            // 解除旧连接订阅 串行
+            // 订阅新连接 串行
+            sendToIotsMsgService.sendIotDeviceUpdateMsg(iotDevice);
+        }
         return result;
     }
 
@@ -318,10 +305,9 @@ public class IotDeviceServiceImpl implements IIotDeviceService
     public int deleteIotDeviceByDevBid(IotDevice iotDevice) {
         String devBid = iotDevice.getDevBid();
         int result = iotDeviceMapper.deleteIotDeviceByDevBid(devBid);
-        // TODO
-        // 解除连接订阅
         // 同步删除设备到TOS
         sendToTosMsgService.sendIotDeviceDeleteMsg(iotDevice);
+        // 解除连接订阅
         sendToIotsMsgService.sendIotDeviceDeleteMsg(iotDevice);
         return result;
     }