package com.doumee.core.haikang.service; import com.alibaba.fastjson.JSONObject; import com.doumee.biz.system.SystemDictDataBiz; import com.doumee.core.haikang.model.param.request.*; import com.doumee.core.haikang.model.param.respose.*; import com.doumee.core.utils.Constants; import com.doumee.core.haikang.model.HKConstants; import com.doumee.core.haikang.model.HKTools; import com.doumee.core.haikang.model.param.BaseRequst; import com.doumee.core.haikang.model.param.BaseResponse; import com.hikvision.artemis.sdk.config.ArtemisConfig; import lombok.extern.slf4j.Slf4j; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; import com.alibaba.fastjson.TypeReference; import java.io.InputStream; import java.util.List; @Service @Slf4j public class HKService { private Logger logger = LoggerFactory.getLogger(HKService.class); @Autowired private SystemDictDataBiz systemDictDataBiz; @PostConstruct public int initHkConfig(){ ArtemisConfig.host = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_HOST).getCode(); ArtemisConfig.appKey = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_APPKEY).getCode(); ArtemisConfig.appSecret = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_APPSECRET).getCode(); HKConstants.https = systemDictDataBiz.queryByCode(Constants.HK_PARAM, Constants.HK_HTTPS).getCode(); return 0; } /** * 获取根组织数据 * @return */ public BaseResponse getRootOrg(BaseRequst param){ log.error("【海康获取根组织】================开始===="); try { String res = HKTools.getRootOrg (); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康获取根组织】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康获取根组织】================失败====:\n"+ e.getMessage()); } return null; } /** * 修改组织数据 * @return */ public BaseResponse editOrg(OrgEditRequest param){ log.error("【海康修改组织】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.editOrg(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康修改组织】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康修改组织】================失败====:\n"+ e.getMessage()); } return null; } /** *批量新增组织数据 * @return */ public BaseResponse addBatchOrg(List param){ log.error("【海康新增组织】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.addBatchOrg(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康新增组织】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康新增组织】================失败====:\n"+ e.getMessage()); } return null; } /** *批量删除组织数据 * @return */ public BaseResponse delBatchOrg(OrgDelRequest param){ log.error("【海康删除组织】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.delOrg(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse >(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康删除组织】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康删除组织】================失败====:\n"+ e.getMessage()); } return null; } /** *新增人员信息(支持人脸数据) * @return */ public BaseResponse addUser(UserAddRequest param){ log.error("【海康新增人员】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.addUser(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康新增人员】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康新增人员】================失败====:\n"+ e.getMessage()); } return null; } /** *修改人员信息(不支持人脸数据) * @return */ public BaseResponse editUser(UserAddRequest param){ log.error("【海康修改人员】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.editUser(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康修改人员】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康修改人员】================失败====:\n"+ e.getMessage()); } return null; } /** *批量新增人员信息(无人脸) * @return */ public BaseResponse addBatchUser(List param){ log.error("【海康批量新增人员】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.addBatchUser(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康批量新增人员】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康批量新增人员】================失败====:\n"+ e.getMessage()); } return null; } /** *批量删除人员信息 * @return */ public BaseResponse delBatchUser(List param){ log.error("【海康批量新增人员】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.delBatchUser(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康批量新增人员】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康批量新增人员】================失败====:\n"+ e.getMessage()); } return null; } /** *添加人脸信息 * @return */ public BaseResponse addFace(List param){ log.error("【海康添加人脸信息】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.addFace(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康添加人脸信息】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康添加人脸信息】================失败====:\n"+ e.getMessage()); } return null; } /** *编辑人脸信息 * @return */ public BaseResponse editFace(List param){ log.error("【海康编辑人脸信息】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.editFace(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康编辑人脸信息】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康编辑人脸信息】================失败====:\n"+ e.getMessage()); } return null; } /** *删除人脸信息 * @return */ public BaseResponse delFace(List param){ log.error("【海康删除人脸信息】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.editFace(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康删除人脸信息】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康删除人脸信息】================失败====:\n"+ e.getMessage()); } return null; } /** * 获取海康人脸访问地址 * @return */ public static InputStream getFaceInputStream(FacePictureRequest param) { log.error("【海康人脸访问图片流】================开始===="+JSONObject.toJSONString(param)); try { InputStream res = HKTools.getFaceInputStream(JSONObject.toJSONString(param)); log.error("【海康人脸访问图片流】================成功====\n"); return res; }catch (Exception e){ log.error("【海康人脸访问图片流】================失败====:\n"+ e.getMessage()); } return null; } /** *获取车库列表数据(全量) * @return */ public BaseResponse> parkList(ParkListRequest param){ log.error("【海获取车库列表数据】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.parkList(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康获取车库列表数据】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康获取车库列表数据】================失败====:\n"+ e.getMessage()); } return null; } /** *获取车库列表数据(全量) * @return */ public BaseResponse> entranceList(EntranceListRequest param){ log.error("【海获取车库列表数据】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.entranceList(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康获取车库列表数据】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康获取车库列表数据】================失败====:\n"+ e.getMessage()); } return null; } /** *固定车辆充值(包期) * @return */ public BaseResponse carChargeAddtion(CarChargeAddRequest param){ log.error("【海康固定车辆充值】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.carChargeAddtion(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康固定车辆充值】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康固定车辆充值】================失败====:\n"+ e.getMessage()); } return null; } /** *固定车辆取消包期 * @return */ public BaseResponse carChargeDeletion(CarChargeDelRequest param){ log.error("【海康固定车辆取消包期】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.carChargeDeletion(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康固定车辆取消包期】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康固定车辆取消包期】================失败====:\n"+ e.getMessage()); } return null; } /** *车位预约 * @return */ public BaseResponse parkReservationAddition(ParkReservationAddRequest param){ log.error("【海康车位预约】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.parkAddition(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康车位预约】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康车位预约】================失败====:\n"+ e.getMessage()); } return null; } /** *车位取消预约 * @return */ public BaseResponse parkReservationDeletion(ParkReservationDelRequest param){ log.error("【海康车位取消预约】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.carChargeDeletion(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康车位取消预约】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康车位取消预约】================失败====:\n"+ e.getMessage()); } return null; } /** *访客预约 * @return */ public BaseResponse visitAppiontment(VisitAppointmentRequest param){ log.error("【海康访客预约】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.visitAppiontment(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse>(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康访客预约】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康访客预约】================失败====:\n"+ e.getMessage()); } return null; } /** *访客免登记预约 * @return */ public BaseResponse visitAppiontmentMDJ(VisitAppointmentMDJRequest param){ log.error("【海康访客免登记预约】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.visitAppiontmentMDJ(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse >(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康访客免登记预约】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康访客免登记预约】================失败====:\n"+ e.getMessage()); } return null; } /** *访客权限组列表查询(分页) * @return */ public BaseResponse privilegeGroup(PrivilegeGroupRequest param){ log.error("【海康访客权限组列表查询】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.privilegeGroup(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse >(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康访客权限组列表查询】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康访客权限组列表查询】================失败====:\n"+ e.getMessage()); } return null; } /** *门禁设备查询(分页) * @return */ public BaseResponse acsDeviceList(AcsDeviceListRequest param){ log.error("【海康门禁设备查询】================开始===="+JSONObject.toJSONString(param)); try { String res = HKTools.acsDeviceList(JSONObject.toJSONString(param)); TypeReference typeReference = new TypeReference< BaseResponse >(){}; BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); log.error("【海康门禁设备查询】================成功====\n"+res); return result; }catch (Exception e){ log.error("【海康门禁设备查询】================失败====:\n"+ e.getMessage()); } return null; } }