TRX 1 år sedan
förälder
incheckning
cef974e279

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

@@ -105,13 +105,9 @@ public class DevicePingInfoService extends SuperService {
     public ResultContent<Object> ping(String dataId, String dataStr) {
         PingResult pingResult = new PingResult();
         GateWayPingInfoParam param = JSONUtil.toBean(dataStr, GateWayPingInfoParam.class);
-        if (StringUtils.isEmpty(param.getGateWayId())) {
-            pingResult.setFailed("");
-            return ResultContent.buildFail("GateWayId为空");
-        }
         if (StringUtils.isNotEmpty(param.getDeviceId())) {
             devicePing(dataId, dataStr);
-        } else {
+        } else if (StringUtils.isNotEmpty(param.getGateWayId())) {
             log.info("ping 网关在线处理:{}", param.getGateWayId());
             GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
             if (ObjectUtils.isNotEmpty(gateWayInfo)) {
@@ -135,6 +131,9 @@ public class DevicePingInfoService extends SuperService {
                 // 网关在线状态
                 updateDeviceOnLine(gateWayInfo.getGateWayId(), gateWayInfo.getGateWayName(), OnLineDeviceType.GateWay);
             }
+        } else {
+            pingResult.setFailed("");
+            return ResultContent.buildFail("ping设备不存在");
         }
         pingResult.setSuccess();
         pingResult.setTime(System.currentTimeMillis());