TRX 1 yıl önce
ebeveyn
işleme
6100742dc3

+ 3 - 0
src/main/java/com/zswl/dataservice/domain/mqtt/DevicePingInfo.java

@@ -29,6 +29,9 @@ public class DevicePingInfo extends SuperEntity {
     @Schema(description = "网关ID")
     private String gateWayId;
 
+    @Schema(description = "ping类型")
+    private String pingType;
+
     @Schema(description = "项目code")
     private String projectInfoCode;
 

+ 4 - 3
src/main/java/com/zswl/dataservice/service/artemis/OperationMessageService.java

@@ -173,11 +173,11 @@ public class OperationMessageService {
             }
             String messageId = message.getJMSMessageID();
             String clientId = message.getStringProperty("__AMQ_CID");
-            log.info("receiveMessage {} 消息监听clientId: {}", messageId, clientId);
+//            log.info("receiveMessage {} 消息监听clientId: {}", messageId, clientId);
             log.info("Topic: {}", topicName);
             if (StringUtils.isNotEmpty(topicName) && topicName.endsWith("reply")) {
                 // 这是响应的数据,不处理
-                log.warn("回复消息不处理");
+//                log.warn("回复消息不处理");
                 return;
             }
             OperationMessage operationMessage = new OperationMessage();
@@ -211,7 +211,8 @@ public class OperationMessageService {
             if (System.currentTimeMillis() > (time + ttl)) {
                 isTimeOut = true;
             }
-            log.info("textMessage: {}", msg);
+//            log.info("textMessage: {}", msg);
+
             String timeStr = DateUtils.paresTime(time, DateUtils.patternyyyySSS);
             jsonObject.set("timeStr", timeStr);
 

+ 6 - 2
src/main/java/com/zswl/dataservice/service/mqtt/DevicePingInfoService.java

@@ -17,6 +17,7 @@ import com.zswl.dataservice.service.base.CommonService;
 import com.zswl.dataservice.service.base.SuperService;
 import com.zswl.dataservice.service.sync.DeviceSyncFullCardService;
 import com.zswl.dataservice.type.DataState;
+import com.zswl.dataservice.type.DeviceType;
 import com.zswl.dataservice.utils.DateUtils;
 import com.zswl.dataservice.utils.bean.BeanUtils;
 import com.zswl.dataservice.utils.mqtt.type.OnLineState;
@@ -70,6 +71,7 @@ public class DevicePingInfoService extends SuperService {
 
             // ping记录
             DevicePingInfo devicePingInfo = new DevicePingInfo();
+            devicePingInfo.setPingType(DeviceType.Consumer.name());
             devicePingInfo.setDeviceId(deviceId);
             devicePingInfo.setDeviceName(deviceInfo.getDeviceName());
             devicePingInfo.setGateWayId(param.getGateWayId());
@@ -77,6 +79,8 @@ public class DevicePingInfoService extends SuperService {
             devicePingInfo.setTTL(new Date(System.currentTimeMillis() + 7 * 24L * 60 * 60 * 1000L));
             devicePingInfo.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
             devicePingInfoDao.save(devicePingInfo);
+
+            // 通知设备
             deviceSyncFullCardService.noticeSyncDeviceOnlineTimeChange(deviceId);
         } else {
             log.info("心跳设备未找到: {}", deviceId);
@@ -84,9 +88,8 @@ public class DevicePingInfoService extends SuperService {
         return ResultContent.buildSuccess();
     }
 
-    @ExecuteAnnotationServiceMethod(value = "ping", remark = "设备心跳")
+    @ExecuteAnnotationServiceMethod(value = "ping", remark = "网关心跳")
     public ResultContent<Object> ping(String dataStr) {
-        log.info("dataStr: {}", dataStr);
         PingResult pingResult = new PingResult();
         GateWayPingInfoParam param = JSONUtil.toBean(dataStr, GateWayPingInfoParam.class);
         GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
@@ -100,6 +103,7 @@ public class DevicePingInfoService extends SuperService {
 
             // ping记录
             DevicePingInfo devicePingInfo = new DevicePingInfo();
+            devicePingInfo.setPingType(DeviceType.GateWay.name());
             devicePingInfo.setGateWayId(param.getGateWayId());
             devicePingInfo.setProjectInfoCode(gateWayInfo.getProjectInfoCode());
             devicePingInfo.setTTL(new Date(System.currentTimeMillis() + 1 * 24L * 60 * 60 * 1000L));

+ 19 - 0
src/main/java/com/zswl/dataservice/type/DeviceType.java

@@ -0,0 +1,19 @@
+package com.zswl.dataservice.type;
+
+import lombok.Getter;
+
+/**
+ * 设备类型
+ */
+public enum DeviceType {
+    Consumer("消费机"),
+    GateWay("网关"),
+    ;
+
+    @Getter
+    private String remark;
+
+    DeviceType(String remark) {
+        this.remark = remark;
+    }
+}