package com.doumee.core.utils.haikang;
|
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
|
import com.hikvision.artemis.sdk.config.ArtemisConfig;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
|
import java.text.DateFormat;
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
|
|
public class HKUtil {
|
|
private static final Logger logger = LoggerFactory.getLogger(HKUtil.class);
|
|
/**
|
* 请根据自己的appKey和appSecret更换static静态块中的三个参数. [1 host]
|
* 如果你选择的是和现场环境对接,host要修改为现场环境的ip,https端口默认为443,http端口默认为80.例如10.33.25.22:443
|
* 或者10.33.25.22:80 appKey和appSecret请按照或得到的appKey和appSecret更改. TODO
|
* 调用前先要清楚接口传入的是什么,是传入json就用doPostStringArtemis方法,下载图片doPostStringImgArtemis方法
|
*/
|
static {
|
// ArtemisConfig.host = "192.168.200.254:1443";// 代理API网关nginx服务器ip端口
|
|
// 滁州
|
// ArtemisConfig.host = "192.168.200.254:1443";// 代理API网关nginx服务器ip端口
|
ArtemisConfig.host = "223.244.234.186:1443";// 代理API网关nginx服务器ip端口
|
ArtemisConfig.appKey = "28641717";// 秘钥appkey
|
ArtemisConfig.appSecret = "GFGG5TnXPOv0yDfhHHDm";// 秘钥appSecret
|
|
// 天津
|
// ArtemisConfig.host = "192.168.14.200:1443";// 代理API网关nginx服务器ip端口
|
// ArtemisConfig.appKey = "22374094";// 秘钥appkey
|
// ArtemisConfig.appSecret = "2efhkRsHy5E32hzWtlAQ";// 秘钥appSecret
|
|
// 肇庆
|
// ArtemisConfig.host = "218.15.229.246:1443";// 代理API网关nginx服务器ip端口
|
// ArtemisConfig.appKey = "27380292";// 秘钥appkey
|
// ArtemisConfig.appSecret = "sPilPIypjdwU7t4FSJHm";// 秘钥appSecret
|
|
// 咸宁
|
// ArtemisConfig.host = "10.51.224.50:443";// 代理API网关nginx服务器ip端口
|
// ArtemisConfig.appKey = "21994050";// 秘钥appkey
|
// ArtemisConfig.appSecret = "Yb3DBafVm2MlUFxr6KwP";// 秘钥appSecret
|
|
// 四川
|
// ArtemisConfig.host = "10.50.224.101:443";// 代理API网关nginx服务器ip端口
|
// ArtemisConfig.appKey = "22454983";// 秘钥appkey
|
// ArtemisConfig.appSecret = "ukC82RcT6HDLGgH8HWCa";// 秘钥appSecret
|
}
|
|
|
public static void main(String[] args) throws ParseException {
|
|
// HKUtil.event(197151, "https://yqslah.yuanqisenlin.com/zq_yqsl_interface/eventRev");
|
//197151,196893,1644171265
|
// HKUtil.eventCancle(196893);
|
// HKUtil.eventCancle(1644171265);
|
// HKUtil.eventCancle(197151);
|
// HKUtil.eventQuery();
|
// JSONObject jsonObject = HKUtil.previewURLs("599548f5fa2a4ebfa9b3b2bf1ebd3c8c",0,null,null,null,null);
|
// System.out.println(111);
|
// System.out.println(jsonObject);
|
|
// JSONObject jsonBody = new JSONObject();
|
//
|
// int page = 2;
|
// int rows = 1000;
|
// jsonBody.put("pageSize",rows);
|
// jsonBody.put("pageNo",page);
|
// JSONObject ret = getPersonList(jsonBody);
|
// System.out.println(ret);
|
}
|
|
|
/**
|
* 能力开放平台的网站路径 TODO 路径不用修改,就是/artemis
|
*/
|
private static final String ARTEMIS_PATH = "/artemis";
|
|
public static JSONObject loginData(int page, int rows, String start, String end) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/acs/v2/door/events";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
jsonBody.put("startTime", start);
|
jsonBody.put("endTime", end);
|
jsonBody.put("receiveStartTime", start);
|
jsonBody.put("receiveEndTime", end);
|
jsonBody.put("pageNo", page);
|
jsonBody.put("pageSize", rows);
|
jsonBody.put("sort", "eventTime");
|
jsonBody.put("order", "desc");
|
String body = jsonBody.toJSONString();
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 访客查询
|
* @param page
|
* @param rows
|
* @return
|
*/
|
public static JSONObject fkData(int page, int rows, String visitorId) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/visitor/v1/event/turnover/search";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
jsonBody.put("pageNo", page);
|
jsonBody.put("pageSize", rows);
|
jsonBody.put("visitorName", visitorId);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 访客记录列表
|
* @param page
|
* @param rows
|
* @return
|
*/
|
public static JSONObject fkList(int page, int rows) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/visitor/v2/visiting/records";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
jsonBody.put("pageNo", page);
|
jsonBody.put("pageSize", rows);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendPost(path, body);
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
private static String sendPost(Map<String, String> path, String body) {
|
return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);
|
}
|
|
/**
|
* 事件订阅
|
* 正常开门--198913
|
* @param code
|
* @param url
|
* @return
|
*/
|
public static JSONObject event(int code, String url) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/eventService/v1/eventSubscriptionByEventTypes";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
jsonBody.put("eventTypes", Arrays.asList(code));
|
jsonBody.put("eventDest", url);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendPost(path, body);// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 取消事件订阅
|
* @param code
|
* @return
|
*/
|
public static JSONObject eventCancle(int code) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/eventService/v1/eventUnSubscriptionByEventTypes";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
jsonBody.put("eventTypes", Arrays.asList(code));
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendPost(path, body);// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 查询订阅事件
|
* @return
|
*/
|
public static JSONObject eventQuery() {
|
final String getCamsApi = ARTEMIS_PATH + "/api/eventService/v1/eventSubscriptionView";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendPost(path, body);// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 获取组织列表
|
* @param page
|
* @param rows
|
* @return
|
*/
|
public static JSONObject orgList(int page, int rows) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/orgList";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
jsonBody.put("pageNo", page);
|
jsonBody.put("pageSize", rows);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","获取组织列表","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
System.out.println(result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 添加组织
|
* @param jsonArray
|
* @return
|
*/
|
public static JSONObject addOrg(JSONArray jsonArray) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/batch/add";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
|
String body = jsonArray.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","添加组织","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 修改组织
|
* @param jsonBody
|
* @return
|
*/
|
public static JSONObject updateOrg(JSONObject jsonBody) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/single/update";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
|
String body = jsonBody.toJSONString();
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","修改组织","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 删除组织
|
* @param jsonBody
|
* @return
|
*/
|
public static JSONObject delOrg(JSONObject jsonBody) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/batch/delete";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
|
String body = jsonBody.toJSONString();
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","删除组织","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 门禁设备列表
|
* @param page
|
* @param rows
|
* @return
|
*/
|
public static JSONObject deviceList(int page, int rows) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v2/acsDevice/search";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
jsonBody.put("pageNo", page);
|
jsonBody.put("pageSize", rows);
|
// jsonBody.put("resourceType", "acsDevice");
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","获取门禁设备列表","0");
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 门禁点列表
|
* @param page
|
* @param rows
|
* @return
|
*/
|
public static JSONObject doorList(int page, int rows) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v2/door/search";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
jsonBody.put("pageNo", page);
|
jsonBody.put("pageSize", rows);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","门禁点列表","0");
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 分页获取监控点资源列表
|
* @param page
|
* @param rows
|
* @return
|
*/
|
public static JSONObject camerasList(int page, int rows) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/cameras";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
jsonBody.put("pageNo", page);
|
jsonBody.put("pageSize", rows);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","分页获取监控点资源","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 获取监控点预览取流URL
|
* @param code
|
* @param streamType
|
* @return
|
*/
|
public static JSONObject previewURLs(String code, int streamType, String protocol, Integer transmode, String expand, String streamform) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/video/v2/cameras/previewURLs";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
// 监控点唯一标识
|
jsonBody.put("cameraIndexCode", code);
|
// 码流类型,0:主码流,1:子码流,2:第三码流,参数不填,默认为主码流
|
/* jsonBody.put("streamType", streamType);
|
*//* 取流协议(应用层协议),“hik”:HIK私有协议,使用视频SDK进行播放时,传入此类型;“rtsp”,“rtmp”,“hls”,“ws”。参数不填,默认为HIK协议 *//*
|
jsonBody.put("protocol", protocol);
|
//传输协议(传输层协议),0:UDP,1:TCP。默认是TCP
|
jsonBody.put("transmode", transmode);
|
// 转码标志,不携带此字段或传0表示不转码,传1或2表示转码。
|
jsonBody.put("expand", expand);
|
// 输出码流转封装格式,“ps”:PS封装格式、“rtp”:RTP封装协议。当protocol=rtsp时生效,且不传值时默认为RTP封装协议。
|
jsonBody.put("streamform", streamform);*/
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","获取监控点预览流","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 添加人员
|
* @param jsonBody
|
* @return
|
*/
|
public static JSONObject addPerson(JSONObject jsonBody) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v2/person/single/add";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","添加人员","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 批量添加人员
|
* @param jsonBody
|
* @return
|
*/
|
public static JSONObject batchSave(JSONArray jsonBody) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/batch/add";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","批量添加人员","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 删除人员
|
* @param jsonBody
|
* @return
|
*/
|
public static JSONObject delPerson(JSONObject jsonBody) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/batch/delete";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","删除人员","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 获取人员卡号
|
* @param jsonBody
|
* @return
|
*/
|
public static JSONObject getPersonCard(JSONObject jsonBody) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/irds/v1/card/advance/cardList";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","获取人员卡号","1");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 同步人员
|
* @param jsonBody
|
* @return
|
*/
|
public static JSONObject getPersonList(JSONObject jsonBody) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v2/person/advance/personList";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","获取人员列表","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 修改人员信息,不含人脸
|
* @param jsonBody
|
* @return
|
*/
|
public static JSONObject updatePerson(JSONObject jsonBody) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/single/update";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","修改人员信息","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 添加人脸数据
|
* @param jsonBody
|
* @return
|
*/
|
public static JSONObject addPersonFace(JSONObject jsonBody) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/face/single/add";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","添加人脸数据","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 修改人脸数据
|
* @param jsonBody
|
* @return
|
*/
|
public static JSONObject updatePersonFace(JSONObject jsonBody) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/face/single/update";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","修改人脸数据","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 创建下载任务
|
* @param taskType(下载任务类型 1:卡片 4:人脸)
|
*
|
* @return
|
*/
|
public static JSONObject newTask(String taskType) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/acps/v1/authDownload/task/addition";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
jsonBody.put("taskType",taskType);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","创建下载任务","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 向下载任务中添加数据
|
* @param jsonBody
|
* @return
|
*/
|
public static JSONObject addTaskData(JSONObject jsonBody) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/acps/v1/authDownload/data/addition";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","下载任务添加数据","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 开始下载任务
|
* @param taskId
|
* @return
|
*/
|
public static JSONObject startTask(String taskId) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/acps/v1/authDownload/task/start";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
jsonBody.put("taskId",taskId);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","开始下载任务","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 删除未开始的下载任务
|
* @param taskId
|
* @return
|
*/
|
public static JSONObject deleteTask(String taskId) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/acps/v1/authDownload/task/deletion";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
jsonBody.put("taskId",taskId);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","删除未开始下载任务","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 查询下载任务进度
|
* @param taskId
|
* @return
|
*/
|
public static JSONObject queryTask(String taskId) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/acps/v1/authDownload/task/progress";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
jsonBody.put("taskId",taskId);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","查询下载任务进度","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
|
/**
|
* 查询人员下载结果
|
* @param jsonBody
|
* @return
|
*/
|
public static JSONObject queryPersonResult(JSONObject jsonBody) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/acps/v1/auth_item/list/search";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = sendpost(path, body,"0","查询人员下载结果","0");// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/*public static JSONArray getResourceInfos(List<LhDeviceDO> deviceList){
|
JSONArray resourceInfos = new JSONArray();
|
deviceList.forEach(v->{
|
JSONObject deviceObject = new JSONObject();
|
deviceObject.put("resourceIndexCode",v.getId());
|
deviceObject.put("resourceType",v.getResourceType());
|
String channelNo = v.getChannelNo();
|
String[] c = channelNo.split(",");
|
int[] array = Arrays.asList(c).stream().mapToInt(Integer::parseInt).toArray();
|
JSONArray ca = new JSONArray();
|
for (int i =0 ; i<array.length;i++) {
|
ca.add(array[i]);
|
}
|
deviceObject.put("channelNos",ca);
|
resourceInfos.add(deviceObject);
|
});
|
return resourceInfos;
|
}*/
|
/**
|
* 分页获取监控点资源
|
* @param page
|
* @param rows
|
* @return
|
*/
|
public static JSONObject monitoryList(int page, int rows) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/cameras";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
jsonBody.put("pageNo", page);
|
jsonBody.put("pageSize", rows);
|
// jsonBody.put("resourceType", "acsDevice");
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = null;
|
try {
|
result = sendpost(path, body,"0","分页获取监控点资源","1");
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
/**
|
* 分页获取监控点在线状态
|
* @param page
|
* @param rows
|
* @return
|
*/
|
public static JSONObject monitoryStatus(int page, int rows) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/nms/v1/online/camera/get";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
jsonBody.put("pageNo", page);
|
jsonBody.put("pageSize", rows);
|
|
// List<String>list=new ArrayList<>();
|
// list.add("1a3cb6e19fbc44d8b31ae74e29fb438d");
|
// jsonBody.put("indexCodes", list);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = null;
|
try {
|
result = sendpost(path, body,"0","分页获取监控点在线状态","1");
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 获取监控点预览取流URLv2
|
* @param cameraIndexCode
|
* @return
|
*/
|
public static JSONObject monitoryPreview(String cameraIndexCode) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/video/v2/cameras/previewURLs";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
jsonBody.put("cameraIndexCode", cameraIndexCode);
|
jsonBody.put("streamType", "");
|
jsonBody.put("protocol", "");
|
jsonBody.put("transmode", "");
|
jsonBody.put("expand", "");
|
jsonBody.put("streamform", "");
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = null;
|
try {
|
result = sendpost(path, body,"0","获取监控点预览取流URLv2","0");
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 获取监控点回放
|
* @param cameraIndexCode
|
* @return
|
*/
|
public static JSONObject monitoryBackview(String cameraIndexCode,String beginTime,String endTime) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/video/v2/cameras/playbackURLs";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
Date startDate=null;
|
Date endDate=null;
|
try {
|
startDate = sdf.parse(beginTime);
|
endDate = sdf.parse(endTime);
|
} catch (ParseException e) {
|
e.printStackTrace();
|
}
|
|
jsonBody.put("cameraIndexCode", cameraIndexCode);
|
jsonBody.put("recordLocation", "");
|
jsonBody.put("protocol", "");
|
jsonBody.put("transmode", "");
|
jsonBody.put("uuid", "");
|
jsonBody.put("expand", "");
|
jsonBody.put("streamform", "");
|
jsonBody.put("lockType", "");
|
jsonBody.put("beginTime", getISO8601Timestamp(startDate));
|
jsonBody.put("endTime", getISO8601Timestamp(endDate));
|
// jsonBody.put("beginTime", "2021-12-15T00:00:00.000+08:00");
|
// jsonBody.put("endTime", "2021-12-16T00:00:00.000+08:00");
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = null;
|
try {
|
// result = sendPost(path, body);
|
result = sendpost(path, body,"0","获取监控点回放","0");
|
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* 云台操作
|
* @param cameraIndexCode
|
* @return
|
*/
|
public static JSONObject yuntaiOperation(String cameraIndexCode,String action,String command,String speed) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/video/v1/ptzs/controlling";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
|
jsonBody.put("cameraIndexCode", cameraIndexCode);
|
jsonBody.put("action", action);
|
jsonBody.put("command", command);
|
jsonBody.put("speed", speed);
|
jsonBody.put("presetIndex", "");
|
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = null;
|
try {
|
result = sendpost(path, body,"0","云台操作","0");
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
}
|
|
/**
|
* type 0内部调用1外部调用
|
* msg 方法名
|
* flage 0走log日志 1不走
|
* @param path
|
* @param body
|
* @param type
|
* @return
|
*/
|
private static String sendpost(Map<String, String> path, String body,String type,String msg,String flage) {
|
String result = null;
|
try {
|
result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);
|
} catch (Exception e) {
|
e.printStackTrace();
|
} finally {
|
try {
|
if("0".equals(flage)){
|
// HkMonitoryLogDO hkMonitoryLogDO=new HkMonitoryLogDO();
|
// hkMonitoryLogDO.setId(UUID.randomUUID().toString());
|
// hkMonitoryLogDO.setMethodName(msg);
|
// hkMonitoryLogDO.setType(type);
|
// hkMonitoryLogDO.setCreateDate(new Date());
|
//
|
// hkMonitoryLogDO.setCreator("内部请求");
|
// hkMonitoryLogDO.setIsDeleted("0");
|
// hkMonitoryLogDO.setRequestData(body);
|
// hkMonitoryLogDO.setResponseData(result);
|
// hkMonitoryLogDO.setUrl(path.get("https://"));
|
// HkMonitoryLogService bean = SpringContextUtil.getBean(HkMonitoryLogService.class);
|
// int save = bean.save(hkMonitoryLogDO);
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
return result;
|
}
|
|
}
|
|
|
/**
|
* 获取增量人员数据列表(删除,修改,新增)
|
* @param page
|
* @param rows
|
* @param startTime
|
* @param endTime
|
* @return
|
*/
|
public static JSONObject userChange(int page, int rows, String startTime, String endTime) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/person/personList/timeRange";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
jsonBody.put("pageNo", page);
|
jsonBody.put("pageSize", rows);
|
jsonBody.put("startTime", startTime);
|
jsonBody.put("endTime", endTime);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
// return JSONObject.parseObject("{\"code\":\"1\",\"msg\":\"HKUtil代码注释,功能关闭\"}");
|
}
|
|
/**
|
* 获取增量人员数据列表(删除,修改,新增)
|
* @param page
|
* @param rows
|
* @param startTime
|
* @param endTime
|
* @return
|
*/
|
public static JSONObject orgChange(int page, int rows, String startTime, String endTime) {
|
final String getCamsApi = ARTEMIS_PATH + "/api/resource/v1/org/timeRange";
|
Map<String, String> path = new HashMap<String, String>(2) {
|
{
|
put("https://", getCamsApi);// 根据现场环境部署确认是http还是https
|
}
|
};
|
JSONObject jsonBody = new JSONObject();
|
|
jsonBody.put("pageNo", page);
|
jsonBody.put("pageSize", rows);
|
jsonBody.put("startTime", startTime);
|
jsonBody.put("endTime", endTime);
|
String body = jsonBody.toJSONString();
|
|
logger.info(getCamsApi+"--->body参数:"+body);
|
String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, "application/json", null);// post请求application/json类型参数
|
logger.info(getCamsApi+"--->result参数:"+result);
|
return JSONObject.parseObject(result);
|
// return JSONObject.parseObject("{\"code\":\"1\",\"msg\":\"HKUtil代码注释,功能关闭\"}");
|
}
|
|
|
/**
|
* 传入Data类型日期,返回字符串类型时间(ISO8601标准时间)
|
* @param date
|
* @return
|
*/
|
public static String getISO8601Timestamp(Date date){
|
TimeZone tz = TimeZone.getTimeZone("Asia/Shanghai");
|
//TimeZone tz = TimeZone.getTimeZone("GMT-01");
|
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
df.setTimeZone(tz);
|
String nowAsISO = df.format(date);
|
return nowAsISO;
|
}
|
|
}
|