TRX hace 1 año
padre
commit
6fe9283adf

+ 3 - 3
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/artemis/OperationMessageService.java

@@ -354,10 +354,10 @@ public class OperationMessageService {
             JSONObject requestData = (JSONObject) json.get("data");
             requestData.set("mqttDataId", entity.getDataId());
 
-            String gateWayId = requestData.getStr("gateWayId");
+            String gateWayId = requestData.getStr("gatewayId");
             if (StringUtils.isEmpty(gateWayId)) {
                 gateWayId = entity.getGateWayId();
-                requestData.set("gateWayId", gateWayId);
+                requestData.set("gatewayId", gateWayId);
             }
             String DeviceId = requestData.getStr("deviceId");
             if (StringUtils.isEmpty(DeviceId)) {
@@ -557,7 +557,7 @@ public class OperationMessageService {
                 jsonObject.set("ttl", entity.getTtlTime());
                 jsonObject.set("event", entity.getEvent());
                 jsonObject.set("deviceId", entity.getDeviceId());
-                jsonObject.set("gateWayId", entity.getGateWayId());
+                jsonObject.set("gatewayId", entity.getGateWayId());
                 jsonObject.set("issued", Boolean.TRUE);
 
                 String reTopic = String.format("%s/reply", entity.getTopic());

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

@@ -65,10 +65,10 @@ public class DevicePingInfoService extends SuperService {
 
     public ResultContent<Object> ping(String dataId, String dataStr) {
         PingResult pingResult = new PingResult();
-        GateWayPingInfoParam param = JSONUtil.toBean(dataStr, GateWayPingInfoParam.class);
+        DevicePingInfoParam param = JSONUtil.toBean(dataStr, DevicePingInfoParam.class);
 
-        if (StringUtils.isNotEmpty(param.getDeviceId())) {
-            ResultContent resultContent = devicePing(dataId, dataStr);
+        if (StringUtils.isNotEmpty(param.getDeviceId()) || StringUtils.isNotEmpty(param.getGatewayId())) {
+            ResultContent resultContent = devicePing(dataId, param);
             if (resultContent.isFailed()) {
                 pingResult.setFailed(resultContent.getMsg());
                 return ResultContent.buildSuccess(pingResult);
@@ -86,13 +86,16 @@ public class DevicePingInfoService extends SuperService {
      * 设备ping
      *
      * @param dataId
-     * @param dataStr
+     * @param param
      * @return
      */
-    private ResultContent<Object> devicePing(String dataId, String dataStr) {
-        DevicePingInfoParam param = JSONUtil.toBean(dataStr, DevicePingInfoParam.class);
+    private ResultContent<Object> devicePing(String dataId, DevicePingInfoParam param) {
         String deviceId = param.getDeviceId();
-        ResultContent resultContent = deviceInfoService.deviceCanUse(param.getDeviceId());
+        if (StringUtils.isEmpty(deviceId)) {
+            deviceId = param.getGatewayId();
+        }
+
+        ResultContent resultContent = deviceInfoService.deviceCanUse(deviceId);
         if (resultContent.isFailed()) {
             return ResultContent.buildFail(resultContent.getMsg());
         }
@@ -106,7 +109,7 @@ public class DevicePingInfoService extends SuperService {
             devicePingInfo.setPingType(deviceInfo.getDeviceType().name());
             devicePingInfo.setDeviceId(deviceId);
             devicePingInfo.setDeviceName(deviceInfo.getDeviceName());
-            devicePingInfo.setGateWayId(param.getGateWayId());
+            devicePingInfo.setGateWayId(param.getGatewayId());
             devicePingInfo.setProjectInfoCode(deviceInfo.getProjectInfoCode());
             devicePingInfo.setTTL(new Date(System.currentTimeMillis() + CommonTTLTimeConfig.pingTTl));
             devicePingInfo.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));

+ 2 - 2
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotFreshService.java

@@ -56,7 +56,7 @@ public class IotFreshService {
         JSONObject data = new JSONObject();
         data.set("iotThingId", iotThingId);
         data.set("deviceId", deviceId);
-        data.set("gateWayId", messageResult.getGateWayId());
+        data.set("gatewayId", messageResult.getGateWayId());
         data.set("mqttUserName", messageResult.getMqttUserName());
         IotMain iotMain = messageResult.getIotMain();
         if (iotMain != null) {
@@ -94,7 +94,7 @@ public class IotFreshService {
 //        JSONObject data = new JSONObject();
 //        data.set("iotThingId", iotThingId);
 //        data.set("deviceId", entity.getDeviceId());
-//        data.set("gateWayId", iotMain.getGateWayId());
+//        data.set("gatewayId", iotMain.getGateWayId());
 
         JSONObject jsonObject = new JSONObject();
         jsonObject.set("id", messageId);

+ 1 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotSendMessageService.java

@@ -280,7 +280,7 @@ public class IotSendMessageService extends SuperService {
         jsonObject.set("time", System.currentTimeMillis());
         jsonObject.set("ttl", param.getTtl());
         jsonObject.set("imitate", param.getIsImitate());
-        jsonObject.set("gateWayId", param.getGateWayId());
+        jsonObject.set("gatewayId", param.getGateWayId());
         jsonObject.set("event", "permissionNotice");
 
         String topIc = "/gateway/" + param.getGateWayId() + "/reply";

+ 1 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iotPlatform/impl/OnLineTopic.java

@@ -45,7 +45,7 @@ public class OnLineTopic implements PlatformTopic {
             result.setOperator(param.getOperator());
             result.setSuccess();
             result.setDeviceId(param.getDeviceId());
-            result.setGateWayId(param.getGateWayId());
+            result.setGateWayId(param.getGatewayId());
 
             // 验证设备是否可用
             ResultContent resultContent = deviceInfoService.deviceCanUse(param.getDeviceId());