From da6410b1823f95a447869d9b4fdaed32a62b4518 Mon Sep 17 00:00:00 2001
From: 叶松 <2217086471@qq.com>
Date: 星期一, 30 十月 2023 16:05:30 +0800
Subject: [PATCH] 模具修改
---
hd/pipe/StaffManage/src/main/java/com/thhy/staff/utils/MqUtils.java | 42 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 41 insertions(+), 1 deletions(-)
diff --git a/hd/pipe/StaffManage/src/main/java/com/thhy/staff/utils/MqUtils.java b/hd/pipe/StaffManage/src/main/java/com/thhy/staff/utils/MqUtils.java
index f975e44..0bc6aee 100644
--- a/hd/pipe/StaffManage/src/main/java/com/thhy/staff/utils/MqUtils.java
+++ b/hd/pipe/StaffManage/src/main/java/com/thhy/staff/utils/MqUtils.java
@@ -1,13 +1,17 @@
package com.thhy.staff.utils;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
import com.thhy.general.utils.UUIDUtils;
import com.thhy.staff.config.EmqxConfig;
+import com.thhy.staff.modules.biz.face.entity.MqContent;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
+import java.util.ArrayList;
import java.util.List;
public class MqUtils {
@@ -21,7 +25,7 @@
// MQTT 连接选项
MqttConnectOptions connOpts = new MqttConnectOptions();
- connOpts.setUserName(emqxConfig.getUsername());
+ connOpts.setUserName(emqxConfig.getLogin());
connOpts.setPassword(emqxConfig.getPassword().toCharArray());
// 保留会话
connOpts.setCleanSession(true);
@@ -51,4 +55,40 @@
throw new RuntimeException(e);
}
}
+
+ public static void main(String[] args) {
+ EmqxConfig emqxConfig = new EmqxConfig();
+ emqxConfig.setHost("111.30.93.215");
+ emqxConfig.setPort("1883");
+ emqxConfig.setQos(1);
+ emqxConfig.setLogin("thhy");
+ emqxConfig.setPassword("Thhy@123");
+
+ System.out.println(JSON.toJSONString(emqxConfig));
+ System.out.println(emqxConfig.toString());
+
+ List<String> list = new ArrayList<>();
+ list.add("0A:0C:E1:25:75:2C");
+
+ String prefix = "http://111.30.93.212:15002/staff/face/";
+ String notify = "/sp/notify";
+
+ MqContent mqContent = new MqContent("sync_person", prefix+notify);
+
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("path",prefix+"syncPersonSingle");
+ JSONObject pathParamJson = new JSONObject();
+ pathParamJson.put("dev_sno","");
+ pathParamJson.put("limit",10);
+ pathParamJson.put("offset",0);
+ pathParamJson.put("total",1);
+ List<String> userIds = new ArrayList<>();
+ userIds.add("02e6d1c4ded41512d0ca3622");
+ pathParamJson.put("person_list",userIds);
+ pathParamJson.put("person_type","4");
+ jsonObject.put("path_params",pathParamJson);
+ mqContent.setData(jsonObject);
+
+ System.out.println(JSON.toJSONString(mqContent));
+ }
}
--
Gitblit v1.9.3