419 lines
14 KiB
Plaintext
419 lines
14 KiB
Plaintext
package com.jysoft.visitor.util;
|
||
|
||
|
||
|
||
import java.util.HashMap;
|
||
import java.util.Map;
|
||
|
||
import org.json.JSONException;
|
||
import org.json.JSONObject;
|
||
|
||
//import com.alibaba.fastjson.JSONObject;
|
||
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
|
||
import com.hikvision.artemis.sdk.config.ArtemisConfig;
|
||
|
||
public class ArtemisPost {
|
||
/**
|
||
* 请根据自己的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.8.59:81";// 代理API网关nginx服务器ip端口
|
||
ArtemisConfig.appKey = "24000016";// 秘钥appkey
|
||
ArtemisConfig.appSecret = "Kiy0rqovJg6ykU8tjkTF";// 秘钥appSecret
|
||
}
|
||
/**
|
||
* 能力开放平台的网站路径
|
||
* TODO 路径不用修改,就是/artemis
|
||
*/
|
||
private static final String ARTEMIS_PATH = "/artemis";
|
||
|
||
private static final boolean POST_B = true;
|
||
|
||
|
||
/**
|
||
* 调用POST请求类型(application/json)接口,这里以入侵报警事件日志为例
|
||
* https://open.hikvision.com/docs/918519baf9904844a2b608e558b21bb6#e6798840
|
||
*
|
||
* @return
|
||
* @throws JSONException
|
||
*/
|
||
public static String callPostStringApi() throws JSONException{
|
||
/**
|
||
* http://10.33.47.50/artemis/api/scpms/v1/eventLogs/searches
|
||
* 根据API文档可以看出来,这是一个POST请求的Rest接口,而且传入的参数值为一个json
|
||
* ArtemisHttpUtil工具类提供了doPostStringArtemis这个函数,一共六个参数在文档里写明其中的意思,因为接口是https,
|
||
* 所以第一个参数path是一个hashmap类型,请put一个key-value,query为传入的参数,body为传入的json数据
|
||
* 传入的contentType为application/json,accept不指定为null
|
||
* header没有额外参数可不传,指定为null
|
||
*
|
||
*/
|
||
final String getCamsApi = ARTEMIS_PATH +"/api/irds/v2/region/nodesByParams";
|
||
Map<String, String> path = new HashMap<String, String>(2) {
|
||
{
|
||
put("https://", getCamsApi);//根据现场环境部署确认是http还是https
|
||
}
|
||
};
|
||
|
||
JSONObject jsonBody = new JSONObject();
|
||
|
||
jsonBody.put("pageNo", 1);
|
||
jsonBody.put("pageSize", 3);
|
||
jsonBody.put("resourceType", "region");
|
||
String body = jsonBody.toString();
|
||
String result = "";
|
||
if(POST_B){
|
||
result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);// post请求application/json类型参数
|
||
}
|
||
return result;
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* 调用POST请求批量获取设备列表
|
||
*
|
||
* @return
|
||
* @throws JSONException
|
||
*/
|
||
public static String getDeviceInfo() throws JSONException{
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/irds/v2/deviceResource/resources";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("https://",VechicleDataApi);
|
||
}
|
||
};
|
||
JSONObject jsonBody = new JSONObject();
|
||
jsonBody.put("pageNo", 1);
|
||
jsonBody.put("pageSize", 10);
|
||
jsonBody.put("resourceType", "door");
|
||
|
||
String body = jsonBody.toString();
|
||
//System.out.println("body: "+body);
|
||
String result = "";
|
||
if(POST_B){
|
||
result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//批量增加人员
|
||
public static String syncStaffBatch(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/resource/v1/person/batch/add";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
String result = "";
|
||
if(POST_B){
|
||
result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//批量删除人员
|
||
public static String deleteStaffBatch(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/resource/v1/person/batch/delete";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//批量发卡
|
||
public static String syncCardBatch(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/cis/v1/card/bindings";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
String result = "";
|
||
if(POST_B){
|
||
result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//批量退卡
|
||
public static String deletionCardBatch(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/cis/v1/card/deletion";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
String result = "";
|
||
if(POST_B){
|
||
result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//批量挂失
|
||
public static String syncCardLossBatch(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/cis/v1/card/batch/loss";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
String result = "";
|
||
if(POST_B){
|
||
result =ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//批量解挂
|
||
public static String syncCardUnLossBatch(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/cis/v1/card/batch/unLoss";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//设备信息初始化
|
||
public static String syncDeviceBatch(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/irds/v2/deviceResource/resources";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//权限下发
|
||
public static String syncRole(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/acps/v1/authDownload/task/simpleDownload";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//添加人脸
|
||
public static String addFace(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/resource/v1/face/single/add";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//修改人脸
|
||
public static String updateFace(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/resource/v1/face/single/update";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//根据人员唯一字段获取人员详细信息
|
||
public static String conditionPersonInfo(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/resource/v1/person/condition/personInfo";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//修改人员信息
|
||
public static String updatePerson(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/resource/v1/person/single/update";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//事件订阅
|
||
public static String eventSubscriptionByEventTypes(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/eventService/v1/eventSubscriptionByEventTypes";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//取消事件订阅
|
||
public static String unsubscribe(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/eventService/v1/eventUnSubscriptionByEventTypes";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
//批量添加组织
|
||
public static String addOrg(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/resource/v1/org/batch/add";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
//批量删除组织
|
||
public static String deleteOrg(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/resource/v1/org/batch/delete";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
//修改组织
|
||
public static String updateOrg(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/resource/v1/org/single/update";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
//通过人员id查询人员信息
|
||
public static String queryPersonInfoById(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/resource/v1/person/personId/personInfo";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
public static String queryPersonListById(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/resource/v2/person/advance/personList";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
//多条件查询人员卡信息
|
||
public static String advanceCardList(String body){
|
||
final String VechicleDataApi = ARTEMIS_PATH +"/api/irds/v1/card/advance/cardList";
|
||
Map<String,String> path = new HashMap<String,String>(2){
|
||
{
|
||
put("http://",VechicleDataApi);
|
||
}
|
||
};
|
||
//System.out.println("body: "+body);
|
||
|
||
String result = "";
|
||
if(POST_B){
|
||
result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
public static void main(String[] args) {
|
||
String s = "3ac70823e3e245c39aa09b5fd30a60a7,a02204c067ae488b990af92e8af0cdad,b90b7251c8d64a8bafc7d0750e90f97a,87fc1cba2db743f58066b29a2d2474f4,cb87082b5d074444808aa7146784b75a,8a0623c451f642648e640dc7c6e271d7,735f927b617f4f8fa28fc883450402fc,10fc69129d774ae38e41fe713621af5f,320ea193b7fa47e6ab18a183565c911b,f9f7159760d34680b0ca7f8828f34b36,fb68aec1d24545029b82993fe004103e,b2f1adf07ebf430ea94ba3ad4b087d1e,be3be4f31daf422faa0e0da0e731f048,5a56992bddc74393bf215e752e16d3a1,16ff4e0fca6542c7b1434f2ab697d397,687f2536cf4b4c2f8e0584deae53c9c5,79e970b3752e45cb89669ff42a3ebe79,301a72dbe75c455cbaff0f4d962d68b5,9fbeca997b8e4cfbba0c6b7c28395899,75f179e0d1ef461c9505ed04667907b1,51aa86129731413393c0605b1903f666,5f9d695efb134bba915c767ae0cbf851,5d955fb8f2bb49d0b7765d147b8c9d1c,e2f92168a04f415ea9717763cc9319f8,ccd8f989e69a4744aa10eba3577530a0,630f6a9f219249ed85211a1e0a2a16dc,499a02cbc49e40cbb36bfed5ef966b70,768ecd63e5d7437d86ff714750c23b16,3b7763c45d0a4cb9a4d93f788027ae04,44580c69a64b4a49bbeb3b786ace8017,9f582eddb965492d8a3c9406073092da,ff479fef8ae7498fbdddebd945bf6814,2b629858ef1d43c49dcf4915c1da25b3,10020238ad7648b4ae1206215038e9c9,7e8087827c194037b1456b8e2d7e7ab0,faee6e4ded024ef3befe5bd5d72084e1,5660f99348e243e4b7339e65b0c7e7cf,6c18e10f0b21415a83bb1212ca9dcf64,0527747ad2ac45be9696108090b48795,fd1e5ee8306d4b8bb2b5fec41a8e8c47,2c61eb003b3b4f18b4ae74451cd90fcb,f570e5e700774f33aec95fe4f2b2b797,437b6a6255e54c91980cd47d12bbd611,fec41a495eb74692843c9f903126e4cc,";
|
||
System.out.println(s.indexOf("0527747ad2ac45be9696108090b48795"));
|
||
}
|
||
}
|