From e8f0b3422d307c686b3a81269f9e9e4fb34a846e Mon Sep 17 00:00:00 2001
From: wjli <591616088@qq.com>
Date: 星期五, 12 四月 2024 10:49:46 +0800
Subject: [PATCH] 指纹登陆返回客户端加密信息
---
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/HaiKangPost.java | 135 +++++++++++++++++++++++++++++++++++---------
1 files changed, 106 insertions(+), 29 deletions(-)
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/HaiKangPost.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/HaiKangPost.java
index 4dee7b7..dc903ee 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/HaiKangPost.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/util/HaiKangPost.java
@@ -1,36 +1,38 @@
package cn.exrick.xboot.your.util;
-import java.util.HashMap;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.util.*;
-import cn.exrick.xboot.your.vo.FindHistoryGpsRequest;
-import cn.exrick.xboot.your.vo.PlaybackURLsVo;
-import cn.exrick.xboot.your.vo.PreviewURLsVo;
-import cn.exrick.xboot.your.vo.TalkURLsVo;
+import cn.exrick.xboot.your.vo.*;
+import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
-import com.hikvision.artemis.sdk.ArtemisHttpUtil;
-import com.hikvision.artemis.sdk.config.ArtemisConfig;
+import com.hikvision.artemis.sdk.Client;
+import com.hikvision.artemis.sdk.Request;
+import com.hikvision.artemis.sdk.Response;
+import com.hikvision.artemis.sdk.constant.Constants;
+import com.hikvision.artemis.sdk.enums.Method;
+import org.springframework.stereotype.Component;
/**
* 娴峰悍杞︽満鎺ュ彛
*/
+@Component
public class HaiKangPost {
/**
* STEP1锛氳缃钩鍙板弬鏁帮紝鏍规嵁瀹為檯鎯呭喌,璁剧疆host appkey appsecret 涓変釜鍙傛暟.
*/
- static {
- ArtemisConfig.host = "111.63.178.115:1443";// 骞冲彴闂ㄦ埛/nginx鐨処P鍜岀鍙o紙蹇呴』浣跨敤https鍗忚锛宧ttps绔彛榛樿涓�443锛�
- ArtemisConfig.appKey = "28156526"; // 绉橀挜appkey
- ArtemisConfig.appSecret = "MNkyjHuids4XxFONSOaL";// 绉橀挜appSecret
- }
/**
* STEP2锛氳缃甇penAPI鎺ュ彛鐨勪笂涓嬫枃
*/
private static final String ARTEMIS_PATH = "/artemis";
+ //private static final String HOST = "111.63.178.115:1443";
+ private static final String HOST = "10.10.101.1:1443";
+ private static final String APP_KEY = "28156526";
+ private static final String APP_SECRET = "MNkyjHuids4XxFONSOaL";
//鏍规嵁杞﹁締缂栧彿鍙婃椂娈佃幏鍙栧巻鍙插畾浣嶄俊鎭�
- public static String findHistoryGps(FindHistoryGpsRequest findHistoryGpsRequest){
+ public String findHistoryGps(FindHistoryGpsRequest findHistoryGpsRequest){
String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/rtsm/v1/gps/findHistoryGps";
Map<String,String> path = new HashMap<String,String>(2){
{
@@ -38,12 +40,12 @@
}
};
String body= JSONUtil.toJsonStr(findHistoryGpsRequest);
- String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
+ String result = doPostStringArtemis(path,body,null,null,"application/json");
return result;
}
//鏌ヨ鎸囧畾杞﹁締缂栧彿鐨勬渶鏂板畾浣�
- public static String findLatestGps(String[] code){
+ public String findLatestGps(String[] code){
String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/rtsm/v1/gps/findLatestGps";
Map<String,String> path = new HashMap<String,String>(2){
{
@@ -51,12 +53,12 @@
}
};
String body= JSONUtil.toJsonStr(code);
- String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
+ String result = doPostStringArtemis(path,body,null,null,"application/json");
return result;
}
//鑾峰彇鐩戞帶鐐归瑙堝彇娴乁RL
- public static String previewURLs(PreviewURLsVo previewURLsVo){
+ public String previewURLs(PreviewURLsVo previewURLsVo){
String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/video/v1/cameras/previewURLs";
Map<String,String> path = new HashMap<String,String>(2){
{
@@ -64,12 +66,13 @@
}
};
String body= JSONUtil.toJsonStr(previewURLsVo);
- String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
+ String result = doPostStringArtemis(path,body,null,null,"application/json");
+ System.out.println(result);
return result;
}
//鑾峰彇鐩戞帶鐐瑰洖鏀惧彇娴乁RL
- public static String playbackURLs(PlaybackURLsVo playbackURLsVo){
+ public String playbackURLs(PlaybackURLsVo playbackURLsVo){
String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/video/v1/cameras/playbackURLs";
Map<String,String> path = new HashMap<String,String>(2){
{
@@ -77,12 +80,25 @@
}
};
String body= JSONUtil.toJsonStr(playbackURLsVo);
- String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
+ String result = doPostStringArtemis(path,body,null,null,"application/json");
+ return result;
+ }
+
+ //鏍规嵁鎶ヨID鑾峰彇鍏宠仈鍥剧墖淇℃伅
+ public String findPicturesByAlarmId(AlarmVo alarmVo){
+ String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/rtsm/v1/multimedia/findPicturesByAlarmId";
+ Map<String,String> path = new HashMap<String,String>(2){
+ {
+ put("https://",findHistoryGpsDataApi);
+ }
+ };
+ String body= JSONUtil.toJsonStr(alarmVo);
+ String result = doPostStringArtemis(path,body,null,null,"application/json");
return result;
}
//璇煶瀵硅
- public static String talkURLs(TalkURLsVo talkURLsVo){
+ public String talkURLs(TalkURLsVo talkURLsVo){
String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/video/v1/cameras/talkURLs";
Map<String,String> path = new HashMap<String,String>(2){
{
@@ -90,34 +106,95 @@
}
};
String body= JSONUtil.toJsonStr(talkURLsVo);
- String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
+ String result = doPostStringArtemis(path,body,null,null,"application/json");
return result;
}
//鎸変簨浠剁被鍨嬭幏鍙栦簨浠惰闃呬俊鎭�
- public static String getTopicInfo(){
+ public String getTopicInfo(){
String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/common/v1/event/getTopicInfo";
Map<String,String> path = new HashMap<String,String>(2){
{
put("https://",findHistoryGpsDataApi);
}
};
- String eventTypes[] = {"5201154049"};
- String body= JSONUtil.toJsonStr(eventTypes);
- String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
+ BigDecimal eventTypes[] = {new BigDecimal(new String("5201154049"))};
+ Map<String,Object> map = new HashMap<>();
+ map.put("eventTypes",eventTypes);
+ String body= JSONUtil.toJsonStr(map);
+ System.out.println(body);
+ String result = doPostStringArtemis(path,body,null,null,"application/json");
return result;
}
+ public String doPostStringArtemis(Map<String, String> path, String body, Map<String, String> querys, String accept, String contentType) {
+ String httpSchema = (String)path.keySet().toArray()[0];
+ if (httpSchema != null && !StrUtil.isEmpty(httpSchema)) {
+ String responseStr = null;
+
+ try {
+ Map<String, String> headers = new HashMap();
+ if (StrUtil.isNotBlank(accept)) {
+ headers.put("Accept", accept);
+ } else {
+ headers.put("Accept", "*/*");
+ }
+
+ if (StrUtil.isNotBlank(contentType)) {
+ headers.put("Content-Type", contentType);
+ } else {
+ headers.put("Content-Type", "application/text;charset=UTF-8");
+ }
+
+ Request request = new Request(Method.POST_STRING, httpSchema + HOST, (String)path.get(httpSchema), APP_KEY, APP_SECRET, Constants.DEFAULT_TIMEOUT);
+ request.setHeaders(headers);
+ request.setQuerys(querys);
+ request.setStringBody(body);
+ Response response = Client.execute(request);
+ responseStr = getResponseResult2(response);
+ } catch (Exception var10) {
+ }
+
+ return responseStr;
+ } else {
+ throw new RuntimeException("http鍜宧ttps鍙傛暟閿欒httpSchema: " + httpSchema);
+ }
+ }
+
+ private String getResponseResult2(Response response) {
+ String responseStr = null;
+ int statusCode = response.getStatusCode();
+ if (!String.valueOf(statusCode).startsWith("2") && !String.valueOf(statusCode).startsWith("3")) {
+ String msg = response.getErrorMessage();
+ responseStr = response.getBody();
+ } else {
+ responseStr = response.getBody();
+ }
+
+ return responseStr;
+ }
+
+
public static void main(String[] args) {
+ HaiKangPost haiKangPost = new HaiKangPost();
+// haiKangPost.getTopicInfo();
+
// FindHistoryGpsRequest findHistoryGpsRequest = new FindHistoryGpsRequest();
// findHistoryGpsRequest.setVehicleIndexCode("b279d865eabe497db465eb2f4d2cc87d");
// findHistoryGpsRequest.setPageNo(1);
// findHistoryGpsRequest.setPageSize(20);
// findHistoryGpsRequest.setBeginTime("2021-11-25T03:10:01.000+08:00");
// findHistoryGpsRequest.setEndTime("2021-11-25T12:10:01.000+08:00");
-// System.out.println(findHistoryGps(findHistoryGpsRequest));
+// HaiKangPost haiKangPost = new HaiKangPost();
+// System.out.println(haiKangPost.findHistoryGps(findHistoryGpsRequest));
// String code[] = {"b279d865eabe497db465eb2f4d2cc87d"};
-// System.out.println(findLatestGps(code));
+// System.out.println(haiKangPost.findLatestGps(code));
+
+ PreviewURLsVo previewURLsVo = new PreviewURLsVo();
+ previewURLsVo.setCameraIndexCode("27760424aa8b486e84db8d6720b2a9bf");
+ previewURLsVo.setProtocol("rtsp");
+ haiKangPost.previewURLs(previewURLsVo);
+
}
}
--
Gitblit v1.9.1