wang-hao-jie
2021-12-08 1b4c59f5f3a0e332ad1cc27c836d98c6d2bdf22c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package cn.exrick.xboot.your.util;
 
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
 
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.hutool.json.JSONUtil;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
 
 
/**
 * 海康车机接口
 */
public class HaiKangPost {
    /**
     * STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
     */
    static {
        ArtemisConfig.host = "111.63.178.115:1443";// 平台门户/nginx的IP和端口(必须使用https协议,https端口默认为443)
        ArtemisConfig.appKey = "28156526"; // 秘钥appkey
        ArtemisConfig.appSecret = "MNkyjHuids4XxFONSOaL";// 秘钥appSecret
    }
    /**
     * STEP2:设置OpenAPI接口的上下文
     */
    private static final String ARTEMIS_PATH = "/artemis";
 
    //根据车辆编号及时段获取历史定位信息
    public static String findHistoryGps(FindHistoryGpsRequest findHistoryGpsRequest){
        String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/rtsm/v1/gps/findHistoryGps";
        Map<String,String> path = new HashMap<String,String>(2){
            {
                put("https://",findHistoryGpsDataApi);
            }
        };
        String body= JSONUtil.toJsonStr(findHistoryGpsRequest);
        String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
 
    //查询指定车辆编号的最新定位
    public static String findLatestGps(String[] code){
        String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/rtsm/v1/gps/findLatestGps";
        Map<String,String> path = new HashMap<String,String>(2){
            {
                put("https://",findHistoryGpsDataApi);
            }
        };
        String body= JSONUtil.toJsonStr(code);
        String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
 
    //获取监控点预览取流URL
    public static String previewURLs(PreviewURLsVo previewURLsVo){
        String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/video/v1/cameras/previewURLs";
        Map<String,String> path = new HashMap<String,String>(2){
            {
                put("https://",findHistoryGpsDataApi);
            }
        };
        String body= JSONUtil.toJsonStr(previewURLsVo);
        String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
 
    //获取监控点回放取流URL
    public static String playbackURLs(PlaybackURLsVo playbackURLsVo){
        String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/video/v1/cameras/playbackURLs";
        Map<String,String> path = new HashMap<String,String>(2){
            {
                put("https://",findHistoryGpsDataApi);
            }
        };
        String body= JSONUtil.toJsonStr(playbackURLsVo);
        String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
 
    //语音对讲
    public static String talkURLs(TalkURLsVo talkURLsVo){
        String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/video/v1/cameras/talkURLs";
        Map<String,String> path = new HashMap<String,String>(2){
            {
                put("https://",findHistoryGpsDataApi);
            }
        };
        String body= JSONUtil.toJsonStr(talkURLsVo);
        String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
 
    //按事件类型获取事件订阅信息
    public static String getTopicInfo(){
        String findHistoryGpsDataApi = ARTEMIS_PATH +"/api/common/v1/event/getTopicInfo";
        Map<String,String> path = new HashMap<String,String>(2){
            {
                put("https://",findHistoryGpsDataApi);
            }
        };
        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 = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json");
        return result;
    }
 
    public static void main(String[] args) {
        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));
 
//        String code[] = {"b279d865eabe497db465eb2f4d2cc87d"};
//        System.out.println(findLatestGps(code));
 
//        PreviewURLsVo previewURLsVo = new PreviewURLsVo();
//        previewURLsVo.setCameraIndexCode("b279d865eabe497db465eb2f4d2cc87d");
//        previewURLs(previewURLsVo);
    }
}