|
@@ -2,17 +2,13 @@ package com.ozs.service.utils;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.alibaba.fastjson2.filter.Filter;
|
|
|
+import com.alibaba.fastjson2.filter.SimplePropertyPreFilter;
|
|
|
import com.ozs.common.utils.sign.Md5Utils;
|
|
|
import com.ozs.common.utils.stateSecrets.SM4Utils;
|
|
|
import com.ozs.common.utils.uuid.IdUtils;
|
|
|
-import com.ozs.service.entity.vo.BaseCameraVersionVo;
|
|
|
-import com.ozs.service.entity.vo.Codec;
|
|
|
-import com.ozs.service.entity.vo.Data;
|
|
|
-import com.ozs.service.entity.vo.Heartbeat;
|
|
|
-import com.ozs.service.entity.vo.Param;
|
|
|
-import com.ozs.service.entity.vo.Svp;
|
|
|
-import com.ozs.service.entity.vo.UpdateDeviceSn;
|
|
|
-import com.ozs.service.entity.vo.Venc0;
|
|
|
+import com.ozs.service.entity.BaseCameraManagement;
|
|
|
+import com.ozs.service.entity.vo.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.eclipse.paho.client.mqttv3.MqttClient;
|
|
|
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
|
|
@@ -110,6 +106,26 @@ public class PublishClient {
|
|
|
publish(getMqttTopic("heart_" + deviceSn), message);
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ JSONObject res = new JSONObject();
|
|
|
+ res.put("Name", "ConfigRequest");
|
|
|
+ Codec codec = new Codec();
|
|
|
+ Venc venc = new Venc();
|
|
|
+ venc.setFps(Double.valueOf(11));
|
|
|
+ ArrayList<Venc> vencList = new ArrayList<>();
|
|
|
+ vencList.add(venc);
|
|
|
+ codec.setVenc(vencList);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ res.put("device_sn", "11");
|
|
|
+ res.put("sign", "rate" + IdUtils.fastSimpleUUID());
|
|
|
+ map.put("codec",codec);
|
|
|
+ res.put("data", map);
|
|
|
+ String s = JSONObject.toJSONString(res);
|
|
|
+
|
|
|
+ System.out.println(s);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
public static void updateDeviceSn(BaseCameraVersionVo baseCameraVersionVo) {
|
|
|
/**
|
|
|
* 发布客户端
|
|
@@ -149,20 +165,23 @@ public class PublishClient {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public static void confidenceCoefficient(BaseCameraVersionVo baseCameraVersionVo, String value) {
|
|
|
+ public static void confidenceCoefficient(BaseCameraManagement baseCameraManagement, String value) {
|
|
|
/**
|
|
|
* 发布客户端
|
|
|
*/
|
|
|
- for (String code : baseCameraVersionVo.getCameraCodeList()) {
|
|
|
try {
|
|
|
JSONObject res = new JSONObject();
|
|
|
- res.put("Name", "ConfigRequest");
|
|
|
- Svp svp = new Svp();
|
|
|
- Param param = new Param();
|
|
|
- param.setThreshold(Double.valueOf(value));
|
|
|
- svp.setParam(param);
|
|
|
+ res.put("Name", "HeartRequest");
|
|
|
+ Codec codec = new Codec();
|
|
|
+ Venc venc = new Venc();
|
|
|
+ venc.setFps(Double.valueOf(value));
|
|
|
+ ArrayList<Venc> vencList = new ArrayList<>();
|
|
|
+ vencList.add(venc);
|
|
|
+ codec.setVenc(vencList);
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("svp", svp);
|
|
|
+ res.put("device_sn", baseCameraManagement.getCameraSn());
|
|
|
+ res.put("sign", "rate" + IdUtils.fastSimpleUUID());
|
|
|
+ map.put("codec",codec);
|
|
|
res.put("data", map);
|
|
|
res.put("sign", "cien" + IdUtils.fastSimpleUUID());
|
|
|
String s = JSONObject.toJSONString(res);
|
|
@@ -175,7 +194,7 @@ public class PublishClient {
|
|
|
/**
|
|
|
* 消息保留
|
|
|
*/
|
|
|
-// message.setRetained(false);
|
|
|
+// message.setRetained(false);
|
|
|
/**
|
|
|
* 消息内容
|
|
|
*/
|
|
@@ -183,31 +202,29 @@ public class PublishClient {
|
|
|
/**
|
|
|
* 发布
|
|
|
*/
|
|
|
- publish(getMqttTopic("config_" + code), message);
|
|
|
+ publish(getMqttTopic("config_" + baseCameraManagement.getCameraCode()), message);
|
|
|
} catch (MqttException e) {
|
|
|
System.out.println(e.getMessage());
|
|
|
}
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
- public static void configFrameRate(BaseCameraVersionVo baseCameraVersionVo, String value) {
|
|
|
+ public static void configFrameRate(BaseCameraManagement baseCameraManagement,Integer mode) {
|
|
|
/**
|
|
|
* 发布客户端
|
|
|
*/
|
|
|
- for (String code : baseCameraVersionVo.getCameraCodeList()) {
|
|
|
try {
|
|
|
JSONObject res = new JSONObject();
|
|
|
- res.put("Name", "ConfigRequest");
|
|
|
+ res.put("Name", "HeartRequest");
|
|
|
Codec codec = new Codec();
|
|
|
- Venc0 venc0 = new Venc0();
|
|
|
- venc0.setFps(Double.valueOf(value));
|
|
|
- codec.setVenc0(venc0);
|
|
|
+ Day2night day2night = new Day2night();
|
|
|
+ day2night.setMode(mode);
|
|
|
+ codec.setDay2night(day2night);
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("codec", codec);
|
|
|
- res.put("data", map);
|
|
|
+ res.put("device_sn", baseCameraManagement.getCameraSn());
|
|
|
res.put("sign", "rate" + IdUtils.fastSimpleUUID());
|
|
|
+ map.put("codec",codec);
|
|
|
+ res.put("data", map);
|
|
|
String s = JSONObject.toJSONString(res);
|
|
|
-
|
|
|
MqttMessage message = new MqttMessage();
|
|
|
/**
|
|
|
* 保证消息能到达一次
|
|
@@ -224,11 +241,10 @@ public class PublishClient {
|
|
|
/**
|
|
|
* 发布
|
|
|
*/
|
|
|
- publish(getMqttTopic("config_" + code), message);
|
|
|
+ publish(getMqttTopic("config_" + baseCameraManagement.getCameraCode()), message);
|
|
|
} catch (MqttException e) {
|
|
|
System.out.println(e.getMessage());
|
|
|
}
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
@PostConstruct
|