소스 검색

更新!

TRX 1 년 전
부모
커밋
ad6b64fc14
1개의 변경된 파일11개의 추가작업 그리고 6개의 파일을 삭제
  1. 11 6
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotServiceImpl.java

+ 11 - 6
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotServiceImpl.java

@@ -525,16 +525,21 @@ public class IotServiceImpl extends SuperService {
             realIotTopic = realIotTopic.replaceAll(Pattern.quote("${deviceId}"), deviceId);
             replyRealIotTopic = replyRealIotTopic.replaceAll(Pattern.quote("${deviceId}"), deviceId);
 
+            String gateWayId = "";
             DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
             if (ObjectUtils.isNotEmpty(deviceInfo)) {
-                GateWay2Device gateWay2Device = gateWay2DeviceDao.findTopByDeviceInfoOrderByUpdateTimeDesc(deviceInfo);
-                if (ObjectUtils.isNotEmpty(gateWay2Device) && gateWay2Device.getGateWayInfo() != null) {
-                    String gateWayId = gateWay2Device.getGateWayInfo().getDeviceId();
-                    realIotTopic = realIotTopic.replaceAll(Pattern.quote("${gateWayId}"), gateWayId);
-                    replyRealIotTopic = replyRealIotTopic.replaceAll(Pattern.quote("${gateWayId}"), gateWayId);
-                    iotMain.setGateWayId(gateWayId);
+                if (deviceInfo.getDeviceCategory() == DeviceCategory.GW) {
+                    gateWayId = deviceInfo.getDeviceId();
+                } else {
+                    GateWay2Device gateWay2Device = gateWay2DeviceDao.findTopByDeviceInfoOrderByUpdateTimeDesc(deviceInfo);
+                    if (ObjectUtils.isNotEmpty(gateWay2Device) && gateWay2Device.getGateWayInfo() != null) {
+                        gateWayId = gateWay2Device.getGateWayInfo().getDeviceId();
+                    }
                 }
             }
+            realIotTopic = realIotTopic.replaceAll(Pattern.quote("${gateWayId}"), gateWayId);
+            replyRealIotTopic = replyRealIotTopic.replaceAll(Pattern.quote("${gateWayId}"), gateWayId);
+            iotMain.setGateWayId(gateWayId);
 
             if (deviceInfo.getDeviceCategory() == DeviceCategory.GW) {
                 realIotTopic = realIotTopic.replaceAll(Pattern.quote("${gateWayId}"), deviceInfo.getDeviceId());