Kaynağa Gözat

修复 设备添加或修改时候检测设备订阅topic是否相同,相同的topic只允许存在一个设备号

zhaiyifei 1 yıl önce
ebeveyn
işleme
8c9f870045

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

@@ -114,9 +114,6 @@ public class IotDeviceServiceImpl implements IIotDeviceService
             throw new IotBizException(ErrorCode.INVALID_PARAMETER.getCode(),"该设备已存在:"+devCodeExist);
         }
 
-        IotDevice selectIotDevice = new IotDevice();
-        selectIotDevice.setDevtypeBid(devtypeBid);
-
         List<IotDevice> insertIotDeviceList = new ArrayList<>();
         for (String devCode : devCodeList) {
             IotDevice iotDevice = new IotDevice();
@@ -381,7 +378,10 @@ public class IotDeviceServiceImpl implements IIotDeviceService
         Set<String> devTopicSet = new HashSet<>();
         for(IotDevice iotDevice : iotDeviceList){
             devCodeSet.add(iotDevice.getDevtypeBid() + iotDevice.getDevCode());
-            devTopicSet.add(IotMqttConstant.getReportTopicByDevtype(iotDevice.getDevtypeBid()));
+            String topic = IotMqttConstant.getReportTopicByDevtype(iotDevice.getDevtypeBid());
+            if(StringUtils.isNotEmpty(topic)){
+                devTopicSet.add(IotMqttConstant.getReportTopicByDevtype(iotDevice.getDevtypeBid()));
+            }
         }
         String topic = IotMqttConstant.getReportTopicByDevtype(devtypeBid);
         for(String code : devCode){