| | |
| | | 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 { |
| | |
| | | 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.setUsername("thhy"); |
| | | emqxConfig.setPassword("Thhy@123"); |
| | | |
| | | 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)); |
| | | } |
| | | } |