zhongrj
2023-06-25 30a778548cf99f8f8a17ce63dc09c577d7a5ed16
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/hk/util/GetCameraUtils.java
@@ -2,11 +2,13 @@
import cn.gistack.sm.hk.constant.HkConstant;
import cn.gistack.sm.hk.constant.ProtocolConstant;
import cn.gistack.sm.hk.vo.HkVO;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import org.springblade.core.tool.api.R;
import java.util.ArrayList;
import java.util.HashMap;
@@ -24,12 +26,20 @@
    * @param body
    * @return
    */
   public static String common(String url, String body) {
   public static String common(Integer type,String url, String body) {
      /**
       * STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
       */
      // artemis网关服务器ip端口
      ArtemisConfig.host = HkConstant.HOST;
      if (null==type){
         ArtemisConfig.host = HkConstant.HOST;
      }
      if (type==1) {
         ArtemisConfig.host = HkConstant.HOST;
      }
      if (type==2) {
         ArtemisConfig.host = HkConstant.NEW_HOST;
      }
      // 秘钥appKey
      ArtemisConfig.appKey = HkConstant.AppKey;
      // 秘钥appSecret
@@ -65,11 +75,14 @@
   /**
    * 获取视频预览数据
    *
    * @param url             视频预览url
    * @param type  类型,新/老
    * @param url 视频预览url
    * @param cameraIndexCode 监控点唯一标识
    * @param protocol
    * @param expand
    * @return
    */
   public static String GetCameraPreviewURL(String url, String cameraIndexCode, String protocol) {
   public static String GetCameraPreviewURL(Integer type,String url, String cameraIndexCode, String protocol,String expand) {
      /**
       * 组装请求参数
       */
@@ -78,10 +91,12 @@
      jsonBody.put("streamType", 0);
      jsonBody.put("protocol", protocol);
      jsonBody.put("transmode", 1);
//      jsonBody.put("expand", "streamform=ps");
      if (null!= expand && !expand.equals("")) {
         jsonBody.put("expand", expand);
      }
      String body = jsonBody.toJSONString();
      // 调用公共方法
      return common(url,body);
      return common(type,url,body);
   }
   /**
@@ -91,7 +106,8 @@
    * @param cameraCode 监控点唯一标识
    * @return
    */
   public static String QueryCameraPreviewURL(String url,
   public static String QueryCameraPreviewURL(Integer type,
                                    String url,
                                    String cameraCode,
                                    String resourceType,
                                    String key) {
@@ -113,7 +129,7 @@
      jsonBody.put("expressions", list);
      String body = jsonBody.toJSONString();
      System.out.println(jsonBody);
      return common(url,body);
      return common(type,url,body);
   }
@@ -124,7 +140,7 @@
    * @param cameraIndexCode 监控点唯一标识
    * @return
    */
   public static String GetTalkURLs(String url, String cameraIndexCode) {
   public static String GetTalkURLs(Integer type, String url, String cameraIndexCode) {
      /**
       * 组装请求参数
       */
@@ -138,7 +154,7 @@
      jsonBody.put("talkIndexCode", "ce744c4c67df464f92994185d825b6fa");
      jsonBody.put("protocol", "wss");
      String body = jsonBody.toJSONString();
      return common(url,body);
      return common(type,url,body);
   }
   /**
@@ -150,7 +166,8 @@
    * @param command 命令
    * @return
    */
   public static String controlling(String url,
   public static String controlling(Integer type,
                            String url,
                            String cameraIndexCode,
                            Integer action,
                            String command,
@@ -170,8 +187,29 @@
      /**
       * 调用接口
       */
      return common(url,body);
      return common(type,url,body);
   }
   /**
    * 查询监控点的预置点信息
    *
    * @param url  查询监控点的预置点信息URL
    * @param cameraIndexCode 监控点唯一标识
    * @return
    */
   public static String presetsSearches(Integer type,String url,String cameraIndexCode) {
      /**
       * 组装请求参数
       */
      JSONObject jsonBody = new JSONObject();
      jsonBody.put("cameraIndexCode", cameraIndexCode);
      String body = jsonBody.toJSONString();
      /**
       * 调用接口
       */
      return common(type,url,body);
   }
   /**
    * 云台控制
@@ -184,7 +222,8 @@
    * @param endY 命令
    * @return
    */
   public static String selZoomURLs(String url,
   public static String selZoomURLs(Integer type,
                            String url,
                            String cameraIndexCode,
                            Integer startX,
                            Integer startY,
@@ -204,7 +243,7 @@
      /**
       * 调用接口
       */
      return common(url,body);
      return common(type,url,body);
   }
@@ -214,7 +253,7 @@
    * @param url 监控资源url
    * @return
    */
   public static String GetCameraResourcePage(Integer pageNo, Integer pageSize, String url) {
   public static String GetCameraResourcePage(Integer type,Integer pageNo, Integer pageSize, String url) {
      /**
       * 组装请求参数
       */
@@ -227,7 +266,7 @@
       * 调用接口并返回数据
       * post请求application/json类型参数;
       */
      return common(url, body);
      return common(type,url, body);
   }
   /**
@@ -236,7 +275,7 @@
    * @param url 监控资源url
    * @return
    */
   public static String manualCaptureUrls(String url,String cameraIndexCode) {
   public static String manualCaptureUrls(Integer type,String url,String cameraIndexCode) {
      /**
       * 组装请求参数
       */
@@ -248,18 +287,18 @@
       * 调用接口并返回数据
       * post请求application/json类型参数;
       */
      return common(url, body);
      return common(type,url, body);
   }
//   public static void main(String[] args) {
//
//      String result = GetCameraResourcePage(1, 10, HkConstant.cameras);
//
//      JSONObject jsonObject1 = JSONObject.parseObject(result);
//      JSONObject res1 = (JSONObject) jsonObject1.get("data");
//      JSONArray arr1 = JSON.parseArray(res1.getString("list"));
//      JSONObject data1 = (JSONObject) arr1.get(1);
//      String code1 = data1.get("cameraIndexCode").toString();
////      String result = GetCameraResourcePage(1, 10, HkConstant.cameras);
////
////      JSONObject jsonObject1 = JSONObject.parseObject(result);
////      JSONObject res1 = (JSONObject) jsonObject1.get("data");
////      JSONArray arr1 = JSON.parseArray(res1.getString("list"));
////      JSONObject data1 = (JSONObject) arr1.get(1);
////      String code1 = data1.get("cameraIndexCode").toString();
//
//      // 云台控制
////      String right = controlling(HkConstant.controllingURLs,
@@ -297,10 +336,10 @@
//      //ff1f050afd1c47829dec1ec14575c9e3
//      //e2cb261e14144f53a300769839d54753
//      //根据子节点编号获取设备播放地址
//      String result3 = GetCameraPreviewURL(HkConstant.previewURLs,
//         "0113d3498d2e41caaf9e5355d1575da3", ProtocolConstant.WS);
//      JSONObject jsonObject = JSONObject.parseObject(result3);
//      Map map = (Map) jsonObject.get("data");
////      String result3 = GetCameraPreviewURL(HkConstant.previewURLs,
////         "0113d3498d2e41caaf9e5355d1575da3", ProtocolConstant.WS);
////      JSONObject jsonObject = JSONObject.parseObject(result3);
////      Map map = (Map) jsonObject.get("data");
//      //根据子节点编号获取音频对讲地址
////      String result4 = GetTalkURLs(HkConstant.talkURLs, code1);
//
@@ -308,7 +347,29 @@
////      System.out.println("result1 = " + result1);
////      System.out.println("result2 = " + result2);
////      System.out.println("result3 = " + result3);
//      System.out.println("url = " + map.get("url"));
////      System.out.println("url = " + map.get("url"));
////      System.out.println("result4 = " + result4);
//
//      // 查询回放url
//      HkVO hk = new HkVO();
//      hk.setCameraIndexCode("0c4f30948dde4998a676ec6983119cb5");
//      hk.setBeginTime("2023-05-08T11:52:16.000+08:00");
//      hk.setEndTime("2023-05-11T11:52:15.000+08:00");
//      hk.setProtocol("wss");
//
//      /**
//       * 组装请求参数
//       */
//      JSONObject jsonBody = new JSONObject();
//      jsonBody.put("cameraIndexCode", hk.getCameraIndexCode());
//      jsonBody.put("protocol", hk.getProtocol());
//      jsonBody.put("recordLocation", "1");
//      jsonBody.put("beginTime", hk.getBeginTime());
//      jsonBody.put("endTime", hk.getEndTime());
//      String body = jsonBody.toJSONString();
//
//      String common = common(HkConstant.playbackURLs, body);
//
//      System.out.println("common = " + common);
//   }
}