From b63dccee424ee9dfb8944ead15ff084ff62d63fa Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Fri, 10 May 2024 18:22:37 +0800
Subject: [PATCH] 对接及事件查询订阅调整
---
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/hk/util/GetCameraUtils.java | 264 +++++++++++++++++++++++++++++++++++-----------------
1 files changed, 175 insertions(+), 89 deletions(-)
diff --git a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/hk/util/GetCameraUtils.java b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/hk/util/GetCameraUtils.java
index 317afb8..d2d286a 100644
--- a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/hk/util/GetCameraUtils.java
+++ b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/hk/util/GetCameraUtils.java
@@ -2,21 +2,17 @@
import cn.gistack.sm.hk.constant.HkConstant;
import cn.gistack.sm.hk.constant.ProtocolConstant;
+import cn.gistack.sm.hk.vo.EventVO;
import cn.gistack.sm.hk.vo.HkVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
-import org.springblade.core.tool.api.R;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import static cn.gistack.sm.hk.constant.HkConstant.ARTEMIS_PATH;
-
public class GetCameraUtils {
/**
@@ -44,6 +40,15 @@
ArtemisConfig.appKey = HkConstant.AppKey;
// 秘钥appSecret
ArtemisConfig.appSecret = HkConstant.AppSecret;
+
+ if (type==3) {
+ // 秘钥appKey
+ ArtemisConfig.appKey = HkConstant.EventAppKey;
+ // 秘钥appSecret
+ ArtemisConfig.appSecret = HkConstant.EventAppSecret;
+ // host
+ ArtemisConfig.host = HkConstant.Event_NEW_HOST;
+ }
/**
@@ -79,18 +84,25 @@
* @param url 视频预览url
* @param cameraIndexCode 监控点唯一标识
* @param protocol
+ * @param transmode
* @param expand
* @return
*/
- public static String GetCameraPreviewURL(Integer type,String url, String cameraIndexCode, String protocol,String expand) {
+ public static String GetCameraPreviewURL(Integer type,
+ String url,
+ String cameraIndexCode,
+ String protocol,
+ Integer transmode,
+ String expand,
+ Integer streamType) {
/**
* 组装请求参数
*/
JSONObject jsonBody = new JSONObject();
jsonBody.put("cameraIndexCode", cameraIndexCode);
- jsonBody.put("streamType", 0);
+ jsonBody.put("streamType",streamType);
jsonBody.put("protocol", protocol);
- jsonBody.put("transmode", 1);
+ jsonBody.put("transmode", transmode);
if (null!= expand && !expand.equals("")) {
jsonBody.put("expand", expand);
}
@@ -246,29 +258,6 @@
return common(type,url,body);
}
-
- /**
- * 获取监控点资源分页数据
- *
- * @param url 监控资源url
- * @return
- */
- public static String GetCameraResourcePage(Integer type,Integer pageNo, Integer pageSize, String url) {
- /**
- * 组装请求参数
- */
- JSONObject jsonBody = new JSONObject();
- jsonBody.put("pageNo", pageNo);
- jsonBody.put("pageSize", pageSize);
- String body = jsonBody.toJSONString();
-
- /**
- * 调用接口并返回数据
- * post请求application/json类型参数;
- */
- return common(type,url, body);
- }
-
/**
* 抓图
*
@@ -290,67 +279,164 @@
return common(type,url, body);
}
+ /**
+ * 获取监控点资源分页数据
+ * @param url 监控资源url
+ * @return
+ */
+ public static String GetCameraResourcePage(Integer type,Integer pageNo, Integer pageSize, String url) {
+ /**
+ * 组装请求参数
+ */
+ JSONObject jsonBody = new JSONObject();
+ jsonBody.put("pageNo", pageNo);
+ jsonBody.put("pageSize", pageSize);
+ String body = jsonBody.toJSONString();
+
+ /**
+ * 调用接口并返回数据
+ * post请求application/json类型参数;
+ */
+ return common(type,url, body);
+ }
+
+ /**
+ * 海康视频事件订阅
+ * @param eventVO
+ * @param url
+ * @return
+ */
+ public static String addEventSubscriptionByEventTypes(EventVO eventVO, String url) {
+ /**
+ * 组装请求参数
+ */
+ JSONObject jsonBody = new JSONObject();
+ jsonBody.put("eventTypes", Arrays.stream(eventVO.getEventTypes().split(",")).mapToLong(Long::parseLong).toArray());
+ jsonBody.put("eventDest", eventVO.getEventDest());
+ if (null!=eventVO.getSubType()){
+ jsonBody.put("subType", eventVO.getSubType());
+ }
+ if (null!=eventVO.getEventLvl()){
+ jsonBody.put("eventLvl", Arrays.stream(eventVO.getEventLvl().split(",")).mapToInt(Integer::parseInt).toArray());
+ }
+ String body = jsonBody.toJSONString();
+
+ /**
+ * 调用接口并返回数据
+ * post请求application/json类型参数;
+ */
+ return common(null==eventVO.getType()?1:eventVO.getType(),url, body);
+ }
+
+ /**
+ * 海康视频事件取消订阅
+ * @param eventVO
+ * @param url
+ * @return
+ */
+ public static String removeEventSubscriptionByEventTypes(EventVO eventVO, String url) {
+ long[] eventTypes = Arrays.stream(eventVO.getEventTypes().split(",")).mapToLong(Long::parseLong).toArray();
+ /**
+ * 组装请求参数
+ */
+ JSONObject jsonBody = new JSONObject();
+ jsonBody.put("eventTypes", eventTypes);
+ String body = jsonBody.toJSONString();
+
+ /**
+ * 调用接口并返回数据
+ * post请求application/json类型参数;
+ */
+ return common(null==eventVO.getType()?1:eventVO.getType(),url, body);
+ }
+
+ /**
+ * 查询事件订阅信息
+ * @param eventVO
+ * @param url
+ * @return
+ */
+ public static String getEventSubscriptionView(EventVO eventVO, String url) {
+ /**
+ * 组装请求参数
+ */
+ JSONObject jsonBody = new JSONObject();
+ String body = jsonBody.toJSONString();
+
+ /**
+ * 调用接口并返回数据
+ * post请求application/json类型参数;
+ */
+ return common(null==eventVO.getType()?1:eventVO.getType(),url, body);
+ }
+
// public static void main(String[] args) {
//
-//// String result = GetCameraResourcePage(1, 10, HkConstant.cameras);
-////
-//// JSONObject jsonObject1 = JSONObject.parseObject(result);
-//// JSONObject res1 = (JSONObject) jsonObject1.get("data");
-//// JSONArray arr1 = JSON.parseArray(res1.getString("list"));
-//// JSONObject data1 = (JSONObject) arr1.get(1);
-//// String code1 = data1.get("cameraIndexCode").toString();
+// String previewURL = GetCameraPreviewURL(1, HkConstant.previewURLs,
+// "0c4f30948dde4998a676ec6983119cb5",
+// "rtsp",
+// "transcode=1&videotype=h264");
+// System.out.println("previewURL = " + previewURL);
+
+// String result = GetCameraResourcePage(1, 10, HkConstant.cameras);
//
-// // 云台控制
-//// String right = controlling(HkConstant.controllingURLs,
-//// "ff1f050afd1c47829dec1ec14575c9e3",
-//// 0,
-//// "ZOOM_OUT",
-//// null,
-//// null
-//// );
-//// System.out.println("right = " + right);
+// JSONObject jsonObject1 = JSONObject.parseObject(result);
+// JSONObject res1 = (JSONObject) jsonObject1.get("data");
+// JSONArray arr1 = JSON.parseArray(res1.getString("list"));
+// JSONObject data1 = (JSONObject) arr1.get(1);
+// String code1 = data1.get("cameraIndexCode").toString();
+
+ // 云台控制
+// String right = controlling(HkConstant.controllingURLs,
+// "ff1f050afd1c47829dec1ec14575c9e3",
+// 0,
+// "ZOOM_OUT",
+// null,
+// null
+// );
+// System.out.println("right = " + right);
+
+// // 放大
+// String big = selZoomURLs(HkConstant.selZoomURLs,
+// "ff1f050afd1c47829dec1ec14575c9e3",
+// 55,
+// 58,
+// 22,
+// 23
+// );
+// System.out.println("big = " + big);
+
+ // 抓图
+// String manualCapture = manualCaptureUrls(HkConstant.manualCaptureUrls,
+// "ff1f050afd1c47829dec1ec14575c9e3");
+// System.out.println("manualCapture = " + manualCapture);
+
+ //根据设备编号获取子节点编号
+// String result2 = QueryCameraPreviewURL(HkConstant.camerasID, code1, "camera", "parentIndexCode");
//
-//// // 放大
-//// String big = selZoomURLs(HkConstant.selZoomURLs,
-//// "ff1f050afd1c47829dec1ec14575c9e3",
-//// 55,
-//// 58,
-//// 22,
-//// 23
-//// );
-//// System.out.println("big = " + big);
-//
-// // 抓图
-//// String manualCapture = manualCaptureUrls(HkConstant.manualCaptureUrls,
-//// "ff1f050afd1c47829dec1ec14575c9e3");
-//// System.out.println("manualCapture = " + manualCapture);
-//
-// //根据设备编号获取子节点编号
-//// String result2 = QueryCameraPreviewURL(HkConstant.camerasID, code1, "camera", "parentIndexCode");
-////
-//// JSONObject jsonObject2 = JSONObject.parseObject(result2);
-//// JSONObject res2 = (JSONObject) jsonObject2.get("data");
-//// JSONArray arr2 = JSON.parseArray(res2.getString("list"));
-//// JSONObject data2 = (JSONObject) arr2.get(0);
-//// String code2 = data2.get("indexCode").toString();
-// //ff1f050afd1c47829dec1ec14575c9e3
-// //e2cb261e14144f53a300769839d54753
-// //根据子节点编号获取设备播放地址
-//// String result3 = GetCameraPreviewURL(HkConstant.previewURLs,
-//// "0113d3498d2e41caaf9e5355d1575da3", ProtocolConstant.WS);
-//// JSONObject jsonObject = JSONObject.parseObject(result3);
-//// Map map = (Map) jsonObject.get("data");
-// //根据子节点编号获取音频对讲地址
-//// String result4 = GetTalkURLs(HkConstant.talkURLs, code1);
-//
-//// System.out.println("result结果示例: " + result);
-//// System.out.println("result1 = " + result1);
-//// System.out.println("result2 = " + result2);
-//// System.out.println("result3 = " + result3);
-//// System.out.println("url = " + map.get("url"));
-//// System.out.println("result4 = " + result4);
-//
-// // 查询回放url
+// JSONObject jsonObject2 = JSONObject.parseObject(result2);
+// JSONObject res2 = (JSONObject) jsonObject2.get("data");
+// JSONArray arr2 = JSON.parseArray(res2.getString("list"));
+// JSONObject data2 = (JSONObject) arr2.get(0);
+// String code2 = data2.get("indexCode").toString();
+ //ff1f050afd1c47829dec1ec14575c9e3
+ //e2cb261e14144f53a300769839d54753
+ //根据子节点编号获取设备播放地址
+// String result3 = GetCameraPreviewURL(HkConstant.previewURLs,
+// "0113d3498d2e41caaf9e5355d1575da3", ProtocolConstant.WS);
+// JSONObject jsonObject = JSONObject.parseObject(result3);
+// Map map = (Map) jsonObject.get("data");
+ //根据子节点编号获取音频对讲地址
+// String result4 = GetTalkURLs(HkConstant.talkURLs, code1);
+
+// System.out.println("result结果示例: " + result);
+// System.out.println("result1 = " + result1);
+// System.out.println("result2 = " + result2);
+// System.out.println("result3 = " + result3);
+// System.out.println("url = " + map.get("url"));
+// System.out.println("result4 = " + result4);
+
+ // 查询回放url
// HkVO hk = new HkVO();
// hk.setCameraIndexCode("0c4f30948dde4998a676ec6983119cb5");
// hk.setBeginTime("2023-05-08T11:52:16.000+08:00");
--
Gitblit v1.9.3