| | |
| | | package com.doumee.core.haikang.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alibaba.fastjson.TypeReference; |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.core.haikang.model.HKConstants; |
| | | import com.doumee.core.haikang.model.HKTools; |
| | | import com.doumee.core.haikang.model.param.BaseListPageResponse; |
| | | import com.doumee.core.haikang.model.param.BaseRequst; |
| | | import com.doumee.core.haikang.model.param.BaseResponse; |
| | | import com.doumee.core.haikang.model.param.BaseListPageRequest; |
| | | 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.utils.HttpsUtil; |
| | | import com.hikvision.artemis.sdk.config.ArtemisConfig; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | @Slf4j |
| | | public class HKService { |
| | |
| | | return null; |
| | | } |
| | | /** |
| | | *分页获取区域列表(分页) |
| | | * @return |
| | | */ |
| | | public static BaseResponse<BaseListPageResponse<PageRegionInfoResponse>> pageRegions(BaseListPageRequest param){ |
| | | log.info("【海康分页获取区域列表】================开始===="+JSONObject.toJSONString(param)); |
| | | try { |
| | | Map<String ,String> header = new HashMap<>(); |
| | | // header.put("userId",param.getUserId()); |
| | | String res = HKTools.pageRegions(header,JSONObject.toJSONString(param)); |
| | | TypeReference typeReference = |
| | | new TypeReference< BaseResponse<BaseListPageResponse<PageRegionInfoResponse>> >(){}; |
| | | BaseResponse<BaseListPageResponse<PageRegionInfoResponse>> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康分页获取区域列表"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【海康分页获取区域列表】================失败====:\n"+ e.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | *获取监控点预览取流URL |
| | | * @return |
| | | */ |
| | | public static BaseResponse<CamerasPreviewURLsResponse> cameraPreviewURLs(CameraPreviewURLsRequest param){ |
| | | log.info("【海康获取监控点预览取流URL】================开始===="+JSONObject.toJSONString(param)); |
| | | try { |
| | | Map<String ,String> header = new HashMap<>(); |
| | | // header.put("userId",param.getUserId()); |
| | | // header.put("domainId ",param.getDomainId()); |
| | | String res = HKTools.cameraPreviewURLs(header,JSONObject.toJSONString(param)); |
| | | TypeReference typeReference = |
| | | new TypeReference< BaseResponse<CamerasPreviewURLsResponse> >(){}; |
| | | BaseResponse<CamerasPreviewURLsResponse> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康获取监控点预览取流URL"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【海康获取监控点预览取流URL】================失败====:\n"+ e.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | *分页获取监控点资源(分页) |
| | | * @return |
| | | */ |
| | | public static BaseResponse<BaseListPageResponse<PageCameraInfoResponse>> pageCameras(BaseListPageRequest param){ |
| | | log.info("【海康分页获取监控点资源】================开始===="+JSONObject.toJSONString(param)); |
| | | try { |
| | | Map<String ,String> header = new HashMap<>(); |
| | | header.put("userId",param.getUserId()); |
| | | String res = HKTools.pageCameras(header,JSONObject.toJSONString(param)); |
| | | TypeReference typeReference = |
| | | new TypeReference< BaseResponse<BaseListPageResponse<PageCameraInfoResponse>> >(){}; |
| | | BaseResponse<BaseListPageResponse<PageCameraInfoResponse>> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | // logResult(result,"海康分页获取监控点资源"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【海康分页获取监控点资源】================失败====:\n"+ e.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | *获取消防传感器列表(分页) |
| | | * @return |
| | | */ |
| | | public static BaseResponse<BaseListPageResponse<PageFireChannelInfoResponse>> pageFireChannel(BaseListPageRequest param){ |
| | | log.info("【海康分页获取消防传感器列表】================开始===="+JSONObject.toJSONString(param)); |
| | | try { |
| | | String res = HKTools.pageFireChannel(JSONObject.toJSONString(param)); |
| | | TypeReference typeReference = |
| | | new TypeReference< BaseResponse<BaseListPageResponse<PageFireChannelInfoResponse>> >(){}; |
| | | BaseResponse<BaseListPageResponse<PageFireChannelInfoResponse>> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康分页获取消防传感器列表"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【海康分页获取消防传感器列表】================失败====:\n"+ e.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | *查询消防传感器部件状态v2(分页) |
| | | * @return |
| | | */ |
| | | public static BaseResponse<BaseListPageResponse<PageSensorStatusResponse>> pageSensorStatus(SensorStatusListRequest param){ |
| | | log.info("【海康分页查询消防传感器部件状态v2】================开始===="+JSONObject.toJSONString(param)); |
| | | try { |
| | | String res = HKTools.pageSensorStatus(JSONObject.toJSONString(param)); |
| | | TypeReference typeReference = |
| | | new TypeReference< BaseResponse<BaseListPageResponse<PageSensorStatusResponse>> >(){}; |
| | | BaseResponse<BaseListPageResponse<PageSensorStatusResponse>> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康分页查询消防传感器部件状态v2"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【海康分页查询消防传感器部件状态v2】================失败====:\n"+ e.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | *安防看板-今日告警事件-根据eventType字段3 |
| | | * @return |
| | | */ |
| | | public static BaseResponse<BaseListPageResponse<RuleEventSearchDataResponse>> ruleEventSearch(RuleEventSearchRequest param){ |
| | | log.info("【海康安防看板-今日告警事件-根据eventType字段3】================开始===="+JSONObject.toJSONString(param)); |
| | | try { |
| | | String res = HKTools.ruleEventSearch(JSONObject.toJSONString(param)); |
| | | TypeReference typeReference = |
| | | new TypeReference< BaseResponse<BaseListPageResponse<RuleEventSearchDataResponse>> >(){}; |
| | | BaseResponse<BaseListPageResponse<RuleEventSearchDataResponse>> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康安防看板-今日告警事件-根据eventType字段3"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【海康安防看板-今日告警事件-根据eventType字段3】================失败====:\n"+ e.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | *统计统安防看板--园区实时车数量4 |
| | | * @return |
| | | */ |
| | | public static BaseResponse<ParkingStatisticResponse> getParkingStatistics(){ |
| | | log.info("【海康安防看板--园区实时车数量4】================开始===="); |
| | | try { |
| | | String res = HKTools.getParkingStatistics(); |
| | | TypeReference typeReference = |
| | | new TypeReference< BaseResponse<ParkingStatisticResponse>>(){}; |
| | | BaseResponse<ParkingStatisticResponse> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康安防看板--园区实时车数量4"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【海康安防看板--园区实时车数量4】================失败====:\n"+ e.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | *统计园区总体的安防设备数量,在线数、在线率、离线数、离线率 |
| | | * @return |
| | | */ |
| | | public static BaseResponse<List<SecureDevStatusTotalResponse>> getSecureDevStatusTotal(SecureDevStatusTotalRequest param){ |
| | | log.info("【海康统计园区总体的安防设备数量,在线数、在线率、离线数、离线率】================开始===="+JSONObject.toJSONString(param)); |
| | | try { |
| | | String res = HKTools.getSecureDevStatusTotal(JSONObject.toJSONString(param)); |
| | | TypeReference typeReference = |
| | | new TypeReference< BaseResponse<List<SecureDevStatusTotalResponse>> >(){}; |
| | | BaseResponse<List<SecureDevStatusTotalResponse>> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康统计园区总体的安防设备数量,在线数、在线率、离线数、离线率"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【海康统计园区总体的安防设备数量,在线数、在线率、离线数、离线率】================失败====:\n"+ e.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | *安防看板-园区安防设备-各类型设备状态数据列表 |
| | | * @return |
| | | */ |
| | | public static BaseResponse<List<SecureDevStatusListResponse>> getSecureDevStatusList(SecureDevStatusTotalRequest param){ |
| | | log.info("【海康安防看板-园区安防设备-各类型设备状态数据列表】================开始===="+JSONObject.toJSONString(param)); |
| | | try { |
| | | String res = HKTools.getSecureDevStatusList(JSONObject.toJSONString(param)); |
| | | TypeReference typeReference = |
| | | new TypeReference< BaseResponse<List<SecureDevStatusListResponse>> >(){}; |
| | | BaseResponse<List<SecureDevStatusListResponse>> result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康安防看板-园区安防设备-各类型设备状态数据列表"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【海康安防看板-园区安防设备-各类型设备状态数据列表】================失败====:\n"+ e.getMessage()); |
| | | } |
| | | return null; |
| | | } |
| | | /** |
| | | *根据用户标识获取客户端TGC接口 |
| | | * @return |
| | | */ |
| | |
| | | return null; |
| | | } |
| | | |
| | | public static BaseResponse sendSmsByHk(Map<String,Object> param,String url){ |
| | | log.info("【海康发送短信】================开始===="+JSONObject.toJSONString(param)); |
| | | try { |
| | | TypeReference typeReference = |
| | | new TypeReference<BaseResponse>(){}; |
| | | String res = HttpsUtil.postJson(url, JSONObject.toJSONString(param)); |
| | | BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"海康发送短信"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【海康发送短信】================失败====:\n"+ e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public static BaseResponse sendSms(Map<String,Object> param){ |
| | | log.info("【发送短信信息】================开始===="+ JSONObject.toJSONString(param)); |
| | | try { |
| | | String res = HKTools.sendSms(JSONObject.toJSONString(param)); |
| | | TypeReference typeReference = |
| | | new TypeReference<BaseResponse>(){}; |
| | | BaseResponse result = JSONObject.parseObject(res, typeReference.getType()); |
| | | logResult(result,"发送短信信息"); |
| | | return result; |
| | | }catch (Exception e){ |
| | | log.error("【发送短信信息】================失败====:\n"+ e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | private static void logResult(BaseResponse res,String name) { |
| | | if(StringUtils.equals(res.getCode(),HKConstants.RESPONSE_SUCCEE)){ |
| | | log.info("【"+name+"】================成功====\n"+res); |