浏览代码

更新!

TRX 1 年之前
父节点
当前提交
fed24f471b

+ 9 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/DevicePingInfoService.java

@@ -98,6 +98,7 @@ public class DevicePingInfoService extends SuperService {
             updateDeviceOnLine(deviceInfo.getDeviceId(), deviceInfo.getDeviceName(), OnLineDeviceType.Device);
         } else {
             log.info("心跳设备未找到: {}", deviceId);
+            return ResultContent.buildFail(String.format("设备不存在:%s", deviceId));
         }
         return ResultContent.buildSuccess();
     }
@@ -107,7 +108,11 @@ public class DevicePingInfoService extends SuperService {
         GateWayPingInfoParam param = JSONUtil.toBean(dataStr, GateWayPingInfoParam.class);
 
         if (StringUtils.isNotEmpty(param.getDeviceId())) {
-            devicePing(dataId, dataStr);
+            ResultContent resultContent = devicePing(dataId, dataStr);
+            if (resultContent.isFailed()) {
+                pingResult.setFailed(resultContent.getMsg());
+                return ResultContent.buildSuccess(pingResult);
+            }
         } else if (StringUtils.isNotEmpty(param.getGateWayId())) {
             log.info("ping 网关在线处理:{}", param.getGateWayId());
             GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
@@ -131,6 +136,9 @@ public class DevicePingInfoService extends SuperService {
 
                 // 网关在线状态
                 updateDeviceOnLine(gateWayInfo.getGateWayId(), gateWayInfo.getGateWayName(), OnLineDeviceType.GateWay);
+            } else {
+                pingResult.setFailed(String.format("网关不存在:%s", param.getGateWayId()));
+                return ResultContent.buildSuccess(pingResult);
             }
         } else {
             pingResult.setFailed("ping设备不存在");