hz-zhhq-app-service/greenH5modul/.svn/pristine/a3/a392c2f086514c8d14ecb1c9dd8...

127 lines
3.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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端口默认为443http端口默认为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:443";// 代理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;
/**
* 访客预约v2
*/
private static final String APPOINTMENT = "/api/visitor/v2/appointment";
/**
* 预约免登记
*/
private static final String REGISTRATION = "/api/visitor/v1/appointment/registration";
/**
* 未预约登记
*/
private static final String REGISTER = "/api/visitor/v1/orderless/register";
/**
* 设置请求地址
*
* @param api
* @return
*/
private static Map<String, String> setPath(String api) {
Map<String, String> path = new HashMap<String, String>() {
{
put("https://", api);// 根据现场环境部署确认是http还是https
}
};
return path;
}
public static String syncRole(String body){
return body;
}
/**
* post 请求
*
* @param body
* @return
* @throws JSONException
*/
public static String post(String body, String api) throws JSONException {
/*
* JSONObject jsonBody = new JSONObject(); jsonBody.put("pageNo", 1);
* jsonBody.put("pageSize", 20); String body = jsonBody.toString();
*/
String result = "";
if (POST_B) {
result = ArtemisHttpUtil.doPostStringArtemis(setPath(ARTEMIS_PATH + api), body, null, null,
"application/json", null);// post请求application/json类型参数
}
return result;
}
/**
* get 请求
*
* @param body
* @return
* @throws JSONException
*/
public static String get(Map<String, String> body, String api) throws JSONException {
String result = "";
if (POST_B) {
result = ArtemisHttpUtil.doGetArtemis(setPath(ARTEMIS_PATH + api), body, null, "application/json");// post请求application/json类型参数
}
return result;
}
/**
* 事件订阅
*
* @param body
* @return
*/
public static String eventSubscriptionByEventTypes(String body) {
final String api ="/api/eventService/v1/eventSubscriptionByEventTypes";
Map<String, String> path = new HashMap<String, String>(2) {
{
put("http://", api);
}
};
String result = "";
if (POST_B) {
result = ArtemisHttpUtil.doPostStringArtemis(setPath(ARTEMIS_PATH + api), body, null, null,"application/json", null);
}
System.err.println(result);
return result;
}
}