TRX 1 рік тому
батько
коміт
63ba830094

+ 2 - 1
src/main/java/com/zswl/dataservice/controller/hardware/OperationMessageController.java

@@ -1,6 +1,7 @@
 package com.zswl.dataservice.controller.hardware;
 
-import com.zswl.dataservice.model.mqtt.*;
+import com.zswl.dataservice.model.artemis.OperationMessageModel;
+import com.zswl.dataservice.model.artemis.OperationMessageSearchParam;
 import com.zswl.dataservice.service.mqtt.DeviceInfoService;
 import com.zswl.dataservice.service.artemis.OperationMessageService;
 import com.zswl.dataservice.utils.result.ResultContent;

+ 1 - 3
src/main/java/com/zswl/dataservice/dao/mqtt/extend/OperationMessageDaoExtend.java

@@ -1,9 +1,7 @@
 package com.zswl.dataservice.dao.mqtt.extend;
 
-import com.zswl.dataservice.domain.mqtt.DeviceInfo;
 import com.zswl.dataservice.domain.mqtt.OperationMessage;
-import com.zswl.dataservice.model.mqtt.DeviceInfoSearchParam;
-import com.zswl.dataservice.model.mqtt.OperationMessageSearchParam;
+import com.zswl.dataservice.model.artemis.OperationMessageSearchParam;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 

+ 1 - 5
src/main/java/com/zswl/dataservice/dao/mqtt/impl/OperationMessageDaoImpl.java

@@ -1,15 +1,11 @@
 package com.zswl.dataservice.dao.mqtt.impl;
 
 import com.zswl.dataservice.dao.base.BaseImpl;
-import com.zswl.dataservice.dao.mqtt.extend.DeviceInfoDaoExtend;
 import com.zswl.dataservice.dao.mqtt.extend.OperationMessageDaoExtend;
-import com.zswl.dataservice.domain.mqtt.DeviceInfo;
 import com.zswl.dataservice.domain.mqtt.OperationMessage;
 import com.zswl.dataservice.helper.DBHelper;
-import com.zswl.dataservice.model.mqtt.DeviceInfoSearchParam;
-import com.zswl.dataservice.model.mqtt.OperationMessageSearchParam;
+import com.zswl.dataservice.model.artemis.OperationMessageSearchParam;
 import com.zswl.dataservice.utils.CommonUtil;
-import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Page;

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

@@ -102,6 +102,9 @@ public class OperationMessage extends SuperEntity {
     @Schema(description = "业务处理的方法")
     private String methodName;
 
+    @Schema(description = "处理时间")
+    private Long handlerTime;
+
     //--------------------返回数据 start ------------------
     @Schema(description = "是否响应成功")
     private Boolean isResult = Boolean.FALSE;

+ 130 - 0
src/main/java/com/zswl/dataservice/model/artemis/OperationMessageModel.java

@@ -0,0 +1,130 @@
+package com.zswl.dataservice.model.artemis;
+
+import com.zswl.dataservice.domain.mqtt.DeviceInfo;
+import com.zswl.dataservice.domain.mqtt.GateWayInfo;
+import com.zswl.dataservice.model.baseParam.SuperModel;
+import com.zswl.dataservice.model.mqtt.DeviceInfoModel;
+import com.zswl.dataservice.model.mqtt.GateWayInfoModel;
+import com.zswl.dataservice.type.OperationType;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import org.springframework.data.mongodb.core.index.Indexed;
+
+import java.util.Date;
+
+/**
+ * @author TRX
+ * @date 2024/5/21
+ */
+@Data
+public class OperationMessageModel extends SuperModel {
+
+    @Schema(description = "mqtt服务器消息ID")
+    private String messageId;
+
+    @Schema(description = "topic")
+    private String topic;
+
+    @Schema(description = "终端ID")
+    private String clientId;
+
+    @Schema(description = "业务生成的ID")
+    private String dataId;
+
+    @Schema(description = "消息内容")
+    private Object data;
+
+    @Schema(description = "ttl时间(毫秒数)")
+    private Long ttlTime;
+
+    @Schema(description = "发送时间")
+    private Long sendTime;
+
+    @Schema(description = "接收的消息是否超时")
+    private Boolean isTimeOut;
+
+    @Schema(description = "处理标记,判断用那个业务方法处理")
+    private String event;
+
+    //------------------------关联的消息
+
+    @Schema(description = "消息的类型")
+    private String messageClass;
+
+    @Schema(description = "关于的设备信息")
+    private DeviceInfoModel deviceInfo;
+
+    @Schema(description = "设备ID")
+    private String deviceId;
+
+    @Schema(description = "关于的网关信息")
+    private GateWayInfoModel gateWayInfo;
+
+    @Schema(description = "网关ID")
+    private String gateWayId;
+
+    @Schema(description = "消息创建时间")
+    private String time;
+
+    @Schema(description = "mqtt消息类型: 发送 接收")
+    OperationType operationType;
+
+    private String operationTypeStr;
+
+    public String getOperationTypeStr() {
+        if (operationType != null) {
+            return operationType.getRemark();
+        }
+        return "";
+    }
+
+    // --------------------- 消息处理结果信息 start -------------------
+    @Schema(description = "是否收到信息")
+    private Boolean isReceive;
+
+    @Schema(description = "接收到的时间")
+    private Long receiveTime;
+
+    @Schema(description = "接收到的时间可阅读的")
+    private String receiveTimeStr;
+
+    //-------------------业务处理结果 start----------------
+
+    @Schema(description = "是否处理成功")
+    private Boolean isHandleSuccess;
+
+    @Schema(description = "业务结果数据")
+    private Object resultData;
+
+    @Schema(description = "处理结果")
+    private String handleMsg;
+
+    @Schema(description = "业务处理的bean")
+    private String beanName;
+
+    @Schema(description = "业务处理的方法")
+    private String methodName;
+
+    @Schema(description = "处理时间")
+    private Long handlerTime;
+
+    //--------------------返回数据 start ------------------
+    @Schema(description = "是否响应成功")
+    private Boolean isResult = Boolean.FALSE;
+
+    @Schema(description = "返回的topic")
+    private String reTopic;
+
+    @Schema(description = "返回-处理时间")
+    private Long reTime;
+
+    @Schema(description = "返回-处理时间可阅读")
+    private String reTimeStr;
+
+    @Schema(description = "响应结果")
+    private String reMsg;
+
+    @Schema(description = "是否响应成功")
+    private Boolean reIsSuccess;
+
+}

+ 113 - 0
src/main/java/com/zswl/dataservice/model/artemis/OperationMessageSearchParam.java

@@ -0,0 +1,113 @@
+package com.zswl.dataservice.model.artemis;
+
+import com.zswl.dataservice.domain.mqtt.DeviceInfo;
+import com.zswl.dataservice.domain.mqtt.GateWayInfo;
+import com.zswl.dataservice.model.baseParam.SuperSearchParam;
+import com.zswl.dataservice.type.OperationType;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import org.springframework.data.mongodb.core.index.Indexed;
+
+import java.util.Date;
+
+/**
+ * @author TRX
+ * @date 2024/5/21
+ */
+@Data
+public class OperationMessageSearchParam extends SuperSearchParam {
+
+    @Schema(description = "mqtt服务器消息ID")
+    private String messageId;
+
+    @Schema(description = "topic")
+    private String topic;
+
+    @Schema(description = "终端ID")
+    private String clientId;
+
+    @Schema(description = "业务生成的ID")
+    private String dataId;
+
+    @Schema(description = "消息内容")
+    private Object data;
+
+    @Schema(description = "ttl时间(毫秒数)")
+    private Long ttlTime;
+
+    @Schema(description = "发送时间")
+    private Long sendTime;
+
+    @Schema(description = "接收的消息是否超时")
+    private Boolean isTimeOut;
+
+    @Schema(description = "处理标记,判断用那个业务方法处理")
+    private String event;
+
+    //------------------------关联的消息
+
+    @Schema(description = "消息的类型")
+    private String messageClass;
+
+    @Schema(description = "设备ID")
+    private String deviceId;
+
+    @Schema(description = "网关ID")
+    private String gateWayId;
+
+    @Schema(description = "消息创建时间")
+    private String time;
+
+    @Schema(description = "mqtt消息类型: 发送 接收")
+    OperationType operationType;
+
+    // --------------------- 消息处理结果信息 start -------------------
+    @Schema(description = "是否收到信息")
+    private Boolean isReceive;
+
+    @Schema(description = "接收到的时间")
+    private Long receiveTime;
+
+    @Schema(description = "接收到的时间可阅读的")
+    private String receiveTimeStr;
+
+    //-------------------业务处理结果 start----------------
+
+    @Schema(description = "是否处理成功")
+    private Boolean isHandleSuccess;
+
+    @Schema(description = "业务结果数据")
+    private Object resultData;
+
+    @Schema(description = "处理结果")
+    private String handleMsg;
+
+    @Schema(description = "业务处理的bean")
+    private String beanName;
+
+    @Schema(description = "业务处理的方法")
+    private String methodName;
+
+    @Schema(description = "处理时间")
+    private Long handlerTime;
+
+    //--------------------返回数据 start ------------------
+    @Schema(description = "是否响应成功")
+    private Boolean isResult;
+
+    @Schema(description = "返回的topic")
+    private String reTopic;
+
+    @Schema(description = "返回-处理时间")
+    private Long reTime;
+
+    @Schema(description = "返回-处理时间可阅读")
+    private String reTimeStr;
+
+    @Schema(description = "响应结果")
+    private String reMsg;
+
+    @Schema(description = "是否响应成功")
+    private Boolean reIsSuccess;
+
+}

+ 0 - 60
src/main/java/com/zswl/dataservice/model/mqtt/OperationMessageModel.java

@@ -1,60 +0,0 @@
-package com.zswl.dataservice.model.mqtt;
-
-import com.zswl.dataservice.model.baseParam.SuperModel;
-import com.zswl.dataservice.type.OperationType;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-/**
- * @author TRX
- * @date 2024/5/21
- */
-@Data
-public class OperationMessageModel extends SuperModel {
-
-    @Schema(description = "消息ID")
-    private String messageId;
-
-    @Schema(description = "topic")
-    private String topic;
-
-    @Schema(description = "消息内容")
-    private Object data;
-
-    @Schema(description = "ttl时间(毫秒数)")
-    private Long ttlTime;
-
-    @Schema(description = "关于的设备信息")
-    private DeviceInfoModel deviceInfo;
-
-    @Schema(description = "设备ID")
-    private String deviceId;
-
-    @Schema(description = "关于的网关信息")
-    private GateWayInfoModel gateWayInfo;
-
-    @Schema(description = "网关ID")
-    private String gateWayId;
-
-    @Schema(description = "是否收到信息")
-    private Boolean isReceive;
-
-    @Schema(description = "接收到的时间")
-    private Long receiveTime;
-
-    @Schema(description = "接收到的时间可阅读的")
-    private String receiveTimeStr;
-
-    @Schema(description = "mqtt消息类型: 发送 接收")
-    OperationType operationType;
-
-    private String operationTypeStr;
-
-    public String getOperationTypeStr() {
-        if (operationType != null) {
-            return operationType.getRemark();
-        }
-        return "";
-    }
-
-}

+ 0 - 37
src/main/java/com/zswl/dataservice/model/mqtt/OperationMessageSearchParam.java

@@ -1,37 +0,0 @@
-package com.zswl.dataservice.model.mqtt;
-
-import com.zswl.dataservice.model.baseParam.SuperSearchParam;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
-
-import java.util.List;
-
-/**
- * @author TRX
- * @date 2024/5/21
- */
-@Data
-public class OperationMessageSearchParam extends SuperSearchParam {
-
-    @Schema(description = "消息ID")
-    private String messageId;
-
-    @Schema(description = "topic")
-    private String topic;
-
-    @Schema(description = "消息内容")
-    private Object data;
-
-    @Schema(description = "ttl时间(毫秒数)")
-    private Long ttlTime;
-
-    @Schema(description = "设备ID")
-    private String deviceId;
-
-    @Schema(description = "网关ID")
-    private String gateWayId;
-
-    @Schema(description = "是否收到信息")
-    private Boolean isReceive;
-
-}

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

@@ -1,5 +1,6 @@
 package com.zswl.dataservice.service.artemis;
 
+import cn.hutool.core.date.StopWatch;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.google.gson.JsonObject;
@@ -9,9 +10,8 @@ import com.zswl.dataservice.dao.other.ExecuteMethodInfoDao;
 import com.zswl.dataservice.domain.mqtt.DeviceInfo;
 import com.zswl.dataservice.domain.mqtt.OperationMessage;
 import com.zswl.dataservice.domain.other.ExecuteMethodInfo;
-import com.zswl.dataservice.helper.ApplicationContextHolder;
-import com.zswl.dataservice.model.hxz.ConsumTransactionsModel;
-import com.zswl.dataservice.model.mqtt.*;
+import com.zswl.dataservice.model.artemis.OperationMessageModel;
+import com.zswl.dataservice.model.artemis.OperationMessageSearchParam;
 import com.zswl.dataservice.service.base.SuperService;
 import com.zswl.dataservice.service.mqtt.DeviceInfoService;
 import com.zswl.dataservice.service.mqtt.GateWayInfoService;
@@ -157,7 +157,8 @@ public class OperationMessageService {
         JSONObject json = (JSONObject) entity.getData();
         if (json.containsKey("data")) {
             Object result = null;
-
+            StopWatch stopWatch = new StopWatch();
+            stopWatch.start();
             boolean isHandleSuccess = true;
             String handleMsg = "处理成功";
             try {
@@ -188,6 +189,8 @@ public class OperationMessageService {
                 isHandleSuccess = false;
                 handleMsg = String.format("业务处理出错:%S", e.getMessage());
             }
+            stopWatch.stop();
+            entity.setHandlerTime(stopWatch.getLastTaskTimeMillis());
             // 返回结果
             entity.setResultData(result);
             // 业务处理失败