Java对接海康监控平台
Posted 初见如月
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java对接海康监控平台相关的知识,希望对你有一定的参考价值。
添加海康pom依赖
<dependency>
<groupId>com.hikvision.ga</groupId>
<artifactId>artemis-http-client</artifactId>
<version>1.1.3</version>
</dependency>
private static final String ARTEMIS_PATH = "/artemis";
hutool的JSON格式也行
import cn.hutool.json.JSONObject;
// 传入Json请求参数,以及海康URL
如:
SimpleDateFormat df = new SimpleDateFormat(DatePattern.UTC_MS_WITH_XXX_OFFSET_PATTERN);
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1);
JSONObject jsonBody = new JSONObject();
jsonBody.put("pageSize", "10");
jsonBody.put("pageNo", "1");
jsonBody.put("beginTime", df.format(calendar.getTime()));
jsonBody.put("endTime",df.format(new Date()));
jsonBody.put("order", "DESC");
jsonBody.put("sortby", "collecttime");
JSONObject jsonObject = null ;
String url = "/api/v2/application/istreet/service/rs/v1/alarm/list";
public static String hkLarmList(JSONObject jsonBody, String url) throws Exception
ArtemisConfig.host = "xxxx"; // 平台的ip:30443
ArtemisConfig.appKey = "你的秘钥"; // 密钥appkey
ArtemisConfig.appSecret = "你的秘钥";// 密钥appSecret
final String getCamsApi = ARTEMIS_PATH +url;
Map<String, String> path = new HashMap<String, String>(2);
path.put("https://", getCamsApi);
//设置超时时间
Constants.DEFAULT_TIMEOUT = 60000;
return ArtemisHttpUtil.doPostStringArtemis(path,jsonBody.toJSONString(),null,null,"application/json",null);
以上是关于Java对接海康监控平台的主要内容,如果未能解决你的问题,请参考以下文章