jiangping
2024-11-05 c9ef2687d3460da668d08d58dee6af468ed6693e
server/visits/dmvisit_service/src/main/java/com/doumee/core/haikang/service/HKService.java
@@ -1,19 +1,16 @@
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;
@@ -25,7 +22,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Slf4j
public class HKService {
@@ -1431,6 +1427,103 @@
        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;
    }
    /**
     *根据用户标识获取客户端TGC接口
     * @return
     */
@@ -1467,21 +1560,6 @@
        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;
    }
@@ -1502,6 +1580,23 @@
    }
    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);