From 4b0551504e9bb3ea66292bfbf85d7937a7af8946 Mon Sep 17 00:00:00 2001
From: vince <757871790@qq.com>
Date: 星期四, 09 十一月 2023 12:09:19 +0800
Subject: [PATCH] 手动测试
---
src/main/java/com/fzzy/gateway/service/GatewayDeviceService2.java | 64 ++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/fzzy/gateway/service/GatewayDeviceService2.java b/src/main/java/com/fzzy/gateway/service/GatewayDeviceService2.java
index 42f0067..f30ac51 100644
--- a/src/main/java/com/fzzy/gateway/service/GatewayDeviceService2.java
+++ b/src/main/java/com/fzzy/gateway/service/GatewayDeviceService2.java
@@ -1,10 +1,21 @@
package com.fzzy.gateway.service;
import com.bstek.dorado.annotation.DataResolver;
+import com.bstek.dorado.annotation.Expose;
+import com.fzzy.api.data.GatewayDeviceType;
import com.fzzy.api.utils.ContextUtil;
import com.fzzy.gateway.GatewayUtils;
+import com.fzzy.gateway.api.GatewayRemoteManager;
+import com.fzzy.gateway.data.BaseResp;
import com.fzzy.gateway.entity.GatewayDevice;
+import com.fzzy.gateway.hx2023.ScConstant;
+import com.fzzy.gateway.hx2023.data.SyncReqData;
import com.fzzy.gateway.service.repository.GatewayDeviceRep;
+import com.fzzy.mqtt.MqttGatewayService;
+import com.fzzy.mqtt.MqttProviderConfig;
+import com.fzzy.mqtt.MqttPublishService;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;
@@ -12,11 +23,17 @@
import javax.annotation.Resource;
import java.util.List;
+@Slf4j
@Component
public class GatewayDeviceService2 {
@Resource
private GatewayDeviceRep gatewayDeviceRep;
+
+ @Resource
+ private GatewayRemoteManager gatewayRemoteManager;
+ @Resource
+ private MqttGatewayService publishService;
public List<GatewayDevice> listAll() {
Sort sort = new Sort(Sort.Direction.ASC, "deviceId");
@@ -59,4 +76,51 @@
}
}
+
+ /**
+ * 娴嬭瘯MQTT绮儏妫�娴�
+ * gatewayDeviceService#ajaxTestGrain2
+ * 绮儏鎺ㄩ�佹祴璇�
+ *
+ * @param data
+ * @return
+ */
+ @Expose
+ public String ajaxTestGrain2(GatewayDevice data) {
+
+
+ SyncReqData reqData = new SyncReqData();
+ reqData.setDevice(data);
+ reqData.setAutoReplay(true);
+ reqData.setMessageType(ScConstant.MESSAGE_TYPE_INVOKE_FUNCTION);
+ reqData.setMessageId(ScConstant.getMessageId());
+ reqData.setFunctionId(ScConstant.FUNCTION_getTAndRHInfo);
+
+
+ if (!GatewayDeviceType.TYPE_07.getCode().equals(data.getType())) {
+ return "ERROR锛氬綋鍓嶈澶囬潪绮儏璁惧涓嶆敮鎸佸綋鍓嶆搷浣�";
+ }
+
+ if(StringUtils.isEmpty(data.getCableRule())){
+ return "ERROR锛氬綋鍓嶈澶囨病鏈夐厤缃竷绾胯鍒欙紝鏃犳硶鎵ц";
+ }
+
+ BaseResp resp = gatewayRemoteManager.getSyncGrainService(data.getSyncProtocol()).syncGrain2(reqData);
+
+ //鑷姩鎺ㄩ��
+ if (200 == resp.getCode() && reqData.isAutoReplay()) {
+ String topic = ScConstant.TOPIC_REPORT;
+ topic = topic.replace("${productId}", data.getProductId()).replace("${deviceId}", data.getDeviceId());
+
+ publishService.publishMqttWithTopic(resp.getData(),topic);
+
+ log.info("----------------------------鎵嬪姩鎺ㄩ�丮QTT绮儏淇℃伅---------------------------");
+ log.info("-----TOPIC-----{}",topic);
+ log.info("-----Message-----{}",resp.getData());
+
+ }
+
+ return "SUCCESS锛氭墽琛屽畬鎴�";
+ }
+
}
--
Gitblit v1.9.3