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);
}