2024-02-27 12:53:37 +08:00
|
|
|
|
package com.zhgd.xmgl.util;
|
|
|
|
|
|
|
2024-06-01 18:40:18 +08:00
|
|
|
|
import com.alibaba.fastjson.JSON;
|
2024-03-05 15:16:10 +08:00
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
2024-03-01 15:28:50 +08:00
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
2024-02-27 12:53:37 +08:00
|
|
|
|
import com.hikvision.artemis.sdk.Client;
|
|
|
|
|
|
import com.hikvision.artemis.sdk.Request;
|
|
|
|
|
|
import com.hikvision.artemis.sdk.Response;
|
|
|
|
|
|
import com.hikvision.artemis.sdk.constant.Constants;
|
|
|
|
|
|
import com.hikvision.artemis.sdk.enums.Method;
|
2024-05-21 20:43:59 +08:00
|
|
|
|
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
2024-06-04 20:51:51 +08:00
|
|
|
|
import com.zhgd.jeecg.common.execption.OpenPromptException;
|
2024-06-06 17:21:47 +08:00
|
|
|
|
import com.zhgd.xmgl.base.HikvisionOrganization;
|
2024-06-04 20:51:51 +08:00
|
|
|
|
import com.zhgd.xmgl.base.HikvisionReservationCarInfo;
|
2024-05-31 18:47:42 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.project.entity.Project;
|
2024-02-27 12:53:37 +08:00
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2024-03-01 15:28:50 +08:00
|
|
|
|
import org.springframework.stereotype.Component;
|
2024-02-27 12:53:37 +08:00
|
|
|
|
|
2024-06-06 17:21:47 +08:00
|
|
|
|
import java.util.*;
|
2024-02-27 12:53:37 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 海康接口
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Slf4j
|
2024-03-01 15:28:50 +08:00
|
|
|
|
@Component
|
2024-02-27 12:53:37 +08:00
|
|
|
|
public class HikvisionUtil {
|
2024-03-01 15:28:50 +08:00
|
|
|
|
|
2024-05-31 18:47:42 +08:00
|
|
|
|
public static JSONObject doPostRtObj(String host, String path, String body, Map<String, String> querys, String appKey, String appSecret) throws Exception {
|
|
|
|
|
|
return JSONObject.parseObject(doPost(host, path, body, querys, appKey, appSecret));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-16 21:19:56 +08:00
|
|
|
|
public static String doPost(String host, String path, String body, Map<String, String> querys, String appKey, String appSecret) throws Exception {
|
2024-05-11 01:58:58 +08:00
|
|
|
|
log.info("调用海康接口.url:{}", host + path);
|
|
|
|
|
|
log.info("调用海康接口.body:{}", body);
|
2024-04-16 21:19:56 +08:00
|
|
|
|
Map<String, String> headers = new HashMap();
|
|
|
|
|
|
headers.put("Accept", "*/*");
|
|
|
|
|
|
headers.put("Content-Type", "application/json");
|
2024-04-29 21:14:46 +08:00
|
|
|
|
Request request = new Request(Method.POST_STRING, host, path, appKey, appSecret, Constants.DEFAULT_TIMEOUT * 30);
|
2024-04-16 21:19:56 +08:00
|
|
|
|
request.setHeaders(headers);
|
|
|
|
|
|
request.setQuerys(querys);
|
|
|
|
|
|
request.setStringBody(body);
|
|
|
|
|
|
Response response = Client.execute(request);
|
|
|
|
|
|
String responseStr = getResponseResult(response);
|
2024-05-11 01:58:58 +08:00
|
|
|
|
log.info("调用海康接口.getResponseResult:{}", responseStr);
|
2024-02-27 12:53:37 +08:00
|
|
|
|
return responseStr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static String getResponseResult(Response response) {
|
|
|
|
|
|
String responseStr = null;
|
|
|
|
|
|
int statusCode = response.getStatusCode();
|
|
|
|
|
|
if (!String.valueOf(statusCode).startsWith("2") && !String.valueOf(statusCode).startsWith("3")) {
|
|
|
|
|
|
responseStr = response.getBody();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
responseStr = response.getBody();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return responseStr;
|
|
|
|
|
|
}
|
2024-03-01 15:28:50 +08:00
|
|
|
|
|
2024-04-02 18:26:22 +08:00
|
|
|
|
/**
|
2024-04-16 21:19:56 +08:00
|
|
|
|
* 成功后,获取data结果
|
2024-04-02 18:26:22 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @param rs
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-03-01 15:28:50 +08:00
|
|
|
|
public static JSONObject getJSONObjectData(String rs) {
|
|
|
|
|
|
JSONObject rsJo = JSONObject.parseObject(rs);
|
2024-04-09 17:00:12 +08:00
|
|
|
|
String code = rsJo.getString("code");
|
|
|
|
|
|
if (Objects.equals(code, "0")) {
|
2024-03-01 15:28:50 +08:00
|
|
|
|
return rsJo.getJSONObject("data");
|
|
|
|
|
|
} else {
|
2024-05-31 11:45:33 +08:00
|
|
|
|
log.error("海康返回错误码:{}", rs);
|
|
|
|
|
|
throw new OpenAlertException("海康返回错误码");
|
2024-03-01 15:28:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-03-05 15:16:10 +08:00
|
|
|
|
|
2024-04-16 21:19:56 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 成功后,获取data结果
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param rsJo
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static JSONObject getJSONObjectData(JSONObject rsJo) {
|
|
|
|
|
|
String code = rsJo.getString("code");
|
|
|
|
|
|
if (Objects.equals(code, "0")) {
|
|
|
|
|
|
return rsJo.getJSONObject("data");
|
|
|
|
|
|
} else {
|
2024-05-31 11:45:33 +08:00
|
|
|
|
log.error("海康返回错误码:{}", rsJo.toJSONString());
|
2024-05-31 18:47:42 +08:00
|
|
|
|
throw new OpenAlertException("海康返回错误码");
|
2024-04-16 21:19:56 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-05 15:16:10 +08:00
|
|
|
|
public static JSONArray getJSONArrayData(String rs) {
|
|
|
|
|
|
JSONObject rsJo = JSONArray.parseObject(rs);
|
2024-04-09 17:00:12 +08:00
|
|
|
|
String code = rsJo.getString("code");
|
|
|
|
|
|
if (Objects.equals(code, "0")) {
|
2024-03-05 15:16:10 +08:00
|
|
|
|
return rsJo.getJSONArray("data");
|
|
|
|
|
|
} else {
|
2024-05-31 11:45:33 +08:00
|
|
|
|
log.error("海康返回错误码:{}", rs);
|
2024-05-31 19:28:48 +08:00
|
|
|
|
throw new OpenAlertException("海康返回错误码");
|
2024-03-05 15:16:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-09 17:00:12 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 是否请求成功
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param rs
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static boolean isSuccess(String rs) {
|
|
|
|
|
|
JSONObject rsJo = JSONObject.parseObject(rs);
|
|
|
|
|
|
String code = rsJo.getString("code");
|
|
|
|
|
|
if (Objects.equals(code, "0")) {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-16 21:19:56 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 是否请求成功
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param rsJo
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static boolean isSuccess(JSONObject rsJo) {
|
|
|
|
|
|
String code = rsJo.getString("code");
|
|
|
|
|
|
if (Objects.equals(code, "0")) {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 是否请求成功
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param rsJo
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static boolean isFail(JSONObject rsJo) {
|
|
|
|
|
|
String code = rsJo.getString("code");
|
|
|
|
|
|
if (Objects.equals(code, "0")) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-03-05 15:16:10 +08:00
|
|
|
|
|
2024-05-30 19:52:54 +08:00
|
|
|
|
public static void addPageParamIfAbsent(JSONObject param) {
|
|
|
|
|
|
param.putIfAbsent("pageNo", 1);
|
|
|
|
|
|
param.putIfAbsent("pageSize", 1000);
|
|
|
|
|
|
}
|
2024-05-31 18:47:42 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2024-06-01 21:41:34 +08:00
|
|
|
|
* 查询车辆列表v2-固定车辆
|
2024-05-31 18:47:42 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @param project
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-06-01 21:41:34 +08:00
|
|
|
|
public static JSONObject getFixCarList(Project project, JSONObject param) throws Exception {
|
2024-05-31 18:47:42 +08:00
|
|
|
|
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
final String ARTEMIS_PATH = "/artemis";
|
|
|
|
|
|
final String path = ARTEMIS_PATH + "/api/resource/v2/vehicle/advance/vehicleList";
|
|
|
|
|
|
String host = "https://" + project.getArtemisConfigHost();
|
|
|
|
|
|
return doPostRtObj(host, path, param.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
|
|
|
|
|
}
|
2024-05-31 19:28:48 +08:00
|
|
|
|
|
2024-06-04 20:51:51 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询车辆列表v2-固定车辆
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param carNumber
|
|
|
|
|
|
* @param project
|
|
|
|
|
|
* @param pageNo
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static JSONObject getFixCarListByCarNumber(String carNumber, Project project, Integer pageNo) throws Exception {
|
|
|
|
|
|
final String ARTEMIS_PATH = "/artemis";
|
|
|
|
|
|
final String path = ARTEMIS_PATH + "/api/resource/v2/vehicle/advance/vehicleList";
|
|
|
|
|
|
String host = "https://" + project.getArtemisConfigHost();
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
|
|
//模糊查询
|
|
|
|
|
|
jo.put("plateNo", carNumber);
|
|
|
|
|
|
jo.put("pageNo", pageNo);
|
|
|
|
|
|
jo.put("pageSize", 1000);
|
|
|
|
|
|
return doPostRtObj(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-31 19:28:48 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查询车辆分类
|
|
|
|
|
|
*/
|
2024-06-04 20:51:51 +08:00
|
|
|
|
public static JSONArray getCategoryList(Project project) throws Exception {
|
2024-05-31 19:28:48 +08:00
|
|
|
|
final String ARTEMIS_PATH = "/artemis";
|
|
|
|
|
|
final String path = ARTEMIS_PATH + "/api/pms/v1/car/category/search";
|
|
|
|
|
|
String host = "https://" + project.getArtemisConfigHost();
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
|
|
String rs = doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
|
|
|
|
|
return getJSONArrayData(rs);
|
|
|
|
|
|
}
|
2024-05-31 21:57:30 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 车辆群组绑定
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param project
|
|
|
|
|
|
* @param param
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static JSONObject bindCarCategory(Project project, JSONObject param) throws Exception {
|
|
|
|
|
|
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
final String ARTEMIS_PATH = "/artemis";
|
|
|
|
|
|
final String path = ARTEMIS_PATH + "/api/pms/v1/car/categoryBind";
|
|
|
|
|
|
String host = "https://" + project.getArtemisConfigHost();
|
|
|
|
|
|
return doPostRtObj(host, path, param.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
|
|
|
|
|
}
|
2024-06-01 18:40:18 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除人脸
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param project
|
|
|
|
|
|
* @param workerFaceId
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static JSONObject deleteWorkerFace(Project project, String workerFaceId) throws Exception {
|
|
|
|
|
|
final String ARTEMIS_PATH = "/artemis";
|
|
|
|
|
|
final String path = ARTEMIS_PATH + "/api/resource/v1/face/single/delete";
|
|
|
|
|
|
String host = "https://" + project.getArtemisConfigHost();
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
|
|
jo.put("faceId", workerFaceId);
|
|
|
|
|
|
return JSON.parseObject(doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret()));
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除人员
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param uniqueId
|
|
|
|
|
|
* @param project
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static JSONObject deleteWorkerById(String uniqueId, Project project) throws Exception {
|
|
|
|
|
|
final String ARTEMIS_PATH = "/artemis";
|
|
|
|
|
|
final String path = ARTEMIS_PATH + "/api/resource/v1/person/batch/delete";
|
|
|
|
|
|
String host = "https://" + project.getArtemisConfigHost();
|
|
|
|
|
|
JSONObject jsonBody = new JSONObject();
|
|
|
|
|
|
jsonBody.put("personIds", Arrays.asList(uniqueId));
|
|
|
|
|
|
String body = jsonBody.toJSONString();
|
|
|
|
|
|
return doPostRtObj(host, path, body, null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 根据人员唯一字段获取人员详细信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param project
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static JSONObject queryWorkerByCondition(Project project, JSONObject param) throws Exception {
|
|
|
|
|
|
final String ARTEMIS_PATH = "/artemis";
|
|
|
|
|
|
final String path = ARTEMIS_PATH + "/api/resource/v1/person/condition/personInfo";
|
|
|
|
|
|
String host = "https://" + project.getArtemisConfigHost();
|
|
|
|
|
|
return doPostRtObj(host, path, param.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-04 20:51:51 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取停车库列表
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param project
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static JSONArray getParkList(Project project) throws Exception {
|
|
|
|
|
|
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
final String ARTEMIS_PATH = "/artemis";
|
|
|
|
|
|
final String path = ARTEMIS_PATH + "/api/resource/v1/park/parkList";
|
|
|
|
|
|
String host = "https://" + project.getArtemisConfigHost();
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
|
|
String rs = doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
|
|
|
|
|
return getJSONArrayData(rs);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取项目名称的停车场的parkIndexCode,没有一样名字的就取第一个停车场
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param project
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static String getProjectParkCode(Project project) throws Exception {
|
|
|
|
|
|
JSONArray parkList = getParkList(project);
|
|
|
|
|
|
if (parkList != null && parkList.size() > 0) {
|
|
|
|
|
|
for (int i = 0; i < parkList.size(); i++) {
|
|
|
|
|
|
JSONObject jo = parkList.getJSONObject(i);
|
|
|
|
|
|
if (Objects.equals(jo.getString("parkName"), project.getProjectName())) {
|
|
|
|
|
|
return jo.getString("parkIndexCode");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//没有一样名字的就取第一个停车场
|
|
|
|
|
|
return parkList.getJSONObject(0).getString("parkIndexCode");
|
|
|
|
|
|
} else {
|
|
|
|
|
|
throw new OpenPromptException("未查询到停车场信息");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-06-01 18:40:18 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2024-06-04 20:51:51 +08:00
|
|
|
|
* 查询预约记录v2
|
2024-06-01 18:40:18 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @param carNumber
|
|
|
|
|
|
* @param project
|
|
|
|
|
|
*/
|
2024-06-04 20:51:51 +08:00
|
|
|
|
public static JSONObject getReservationCarInfoList(String carNumber, Project project) throws Exception {
|
2024-06-01 18:40:18 +08:00
|
|
|
|
final String ARTEMIS_PATH = "/artemis";
|
2024-06-04 20:51:51 +08:00
|
|
|
|
final String path = ARTEMIS_PATH + "/api/pms/v2/reserveRecord/page";
|
2024-06-01 18:40:18 +08:00
|
|
|
|
String host = "https://" + project.getArtemisConfigHost();
|
2024-06-04 20:51:51 +08:00
|
|
|
|
HikvisionReservationCarInfo info = getHikvisionReservationCarInfoObj(carNumber, project);
|
|
|
|
|
|
return doPostRtObj(host, path, JSON.toJSONString(info), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询预约记录v2
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param carNumber
|
|
|
|
|
|
* @param project
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static JSONArray getReservationCarInfoDataList(String carNumber, Project project) throws Exception {
|
|
|
|
|
|
JSONObject jo = getReservationCarInfoList(carNumber, project);
|
|
|
|
|
|
return getJSONObjectData(jo).getJSONArray("list");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static HikvisionReservationCarInfo getHikvisionReservationCarInfoObj(String carNumber, Project project) throws Exception {
|
|
|
|
|
|
String projectParkCode = HikvisionUtil.getProjectParkCode(project);
|
|
|
|
|
|
HikvisionReservationCarInfo hikvisionReservationCarInfo = new HikvisionReservationCarInfo();
|
|
|
|
|
|
hikvisionReservationCarInfo.setParkSyscode(projectParkCode);
|
|
|
|
|
|
hikvisionReservationCarInfo.setPlateNo(carNumber);
|
|
|
|
|
|
hikvisionReservationCarInfo.setResvState(0L);
|
|
|
|
|
|
//hikvisionReservationCarInfo.setResvWay();
|
|
|
|
|
|
//hikvisionReservationCarInfo.setAllowTimes();
|
|
|
|
|
|
//hikvisionReservationCarInfo.setIsCharge();
|
|
|
|
|
|
//hikvisionReservationCarInfo.setStartTime();
|
|
|
|
|
|
//hikvisionReservationCarInfo.setEndTime();
|
|
|
|
|
|
hikvisionReservationCarInfo.setPageNo(1L);
|
|
|
|
|
|
hikvisionReservationCarInfo.setPageSize(999L);
|
|
|
|
|
|
return hikvisionReservationCarInfo;
|
2024-06-01 18:40:18 +08:00
|
|
|
|
}
|
2024-06-04 21:23:01 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取组织列表v2
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param project
|
|
|
|
|
|
* @param orgIndex
|
|
|
|
|
|
* @param parentOrgIndexCode
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static String getOrgV2(Project project, String orgIndex, String parentOrgIndexCode) throws Exception {
|
|
|
|
|
|
if (project == null || !Objects.equals(project.getSyncHikvision(), 1)) {
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
final String ARTEMIS_PATH = "/artemis";
|
|
|
|
|
|
final String path = ARTEMIS_PATH + "/api/resource/v2/org/advance/orgList";
|
|
|
|
|
|
String host = "https://" + project.getArtemisConfigHost();
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
|
|
jo.put("pageNo", 1);
|
|
|
|
|
|
jo.put("pageSize", 100);
|
|
|
|
|
|
jo.put("orgIndexCodes", orgIndex);
|
|
|
|
|
|
jo.put("parentOrgIndexCodes", parentOrgIndexCode);
|
|
|
|
|
|
String body = jo.toJSONString();
|
|
|
|
|
|
return doPost(host, path, body, null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
|
|
|
|
|
}
|
2024-06-06 17:21:47 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 批量添加组织
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param project
|
|
|
|
|
|
* @param hikvisionOrganization
|
|
|
|
|
|
* @return
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
*/
|
|
|
|
|
|
public static String addOrgFromHttp(Project project, HikvisionOrganization hikvisionOrganization) throws Exception {
|
|
|
|
|
|
final String ARTEMIS_PATH = "/artemis";
|
|
|
|
|
|
final String path = ARTEMIS_PATH + "/api/resource/v1/org/batch/add";
|
|
|
|
|
|
String host = "https://" + project.getArtemisConfigHost();
|
|
|
|
|
|
ArrayList<HikvisionOrganization> list = new ArrayList<>();
|
|
|
|
|
|
list.add(hikvisionOrganization);
|
|
|
|
|
|
return doPost(host, path, JSON.toJSONString(list), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String deleteOrgByIndexCodes(Project project, List<String> indexCodes) throws Exception {
|
|
|
|
|
|
final String ARTEMIS_PATH = "/artemis";
|
|
|
|
|
|
final String path = ARTEMIS_PATH + "/api/resource/v1/org/batch/delete";
|
|
|
|
|
|
String host = "https://" + project.getArtemisConfigHost();
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
|
|
jo.put("indexCodes", indexCodes);
|
|
|
|
|
|
String rs = doPost(host, path, jo.toJSONString(), null, project.getArtemisConfigAppKey(), project.getArtemisConfigAppSecret());
|
|
|
|
|
|
return rs;
|
|
|
|
|
|
}
|
2024-02-27 12:53:37 +08:00
|
|
|
|
}
|