|
@@ -0,0 +1,61 @@
|
|
|
+package com.xjrsoft.module.hikvision.util;
|
|
|
+
|
|
|
+import com.google.gson.JsonObject;
|
|
|
+import com.hikvision.artemis.sdk.ArtemisHttpUtil;
|
|
|
+import com.hikvision.artemis.sdk.config.ArtemisConfig;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author dzx
|
|
|
+ * @date 2024/4/26
|
|
|
+ */
|
|
|
+public class ApiUtil {
|
|
|
+ public final static String host = "219.153.208.43:30443";// 平台的ip端口
|
|
|
+ public final static String appKey = "21350095";// 密钥appkey
|
|
|
+ public final static String appSecret = "LXi9rE2fm8IfRoLnTA2G";// 密钥appSecret
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 调用海康接口(该方法内部实现了登入认证逻辑)
|
|
|
+ * @param apiPath 接口地址
|
|
|
+ * @param paramJson body参数
|
|
|
+ * @param querys 查询参数
|
|
|
+ * @return 接口调用结果
|
|
|
+ */
|
|
|
+ public String doPost(String apiPath, JsonObject paramJson, Map<String, String> querys){
|
|
|
+ /**
|
|
|
+ * STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
|
|
|
+ */
|
|
|
+ ArtemisConfig.host = ApiUtil.host; // 平台的ip端口
|
|
|
+ ArtemisConfig.appKey = ApiUtil.appKey; // 密钥appkey
|
|
|
+ ArtemisConfig.appSecret = ApiUtil.appSecret;// 密钥appSecret
|
|
|
+
|
|
|
+ /**
|
|
|
+ * STEP2:设置OpenAPI接口的上下文
|
|
|
+ */
|
|
|
+ final String ARTEMIS_PATH = "/artemis";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * STEP3:设置接口的URI地址
|
|
|
+ */
|
|
|
+ final String previewURLsApi = ARTEMIS_PATH + apiPath;
|
|
|
+ Map<String, String> path = new HashMap<String, String>(2) {
|
|
|
+ {
|
|
|
+ put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * STEP4:设置参数提交方式
|
|
|
+ */
|
|
|
+ String contentType = "application/json";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * STEP5:组装请求参数
|
|
|
+ */
|
|
|
+ String body = paramJson.toString();
|
|
|
+
|
|
|
+ return ArtemisHttpUtil.doPostStringArtemis(path, body, querys, null, contentType , null);// post请求application/json类型参数
|
|
|
+ }
|
|
|
+}
|