zhanghua
2025-04-14 1cad14bca191807e18705c3a5526eda8151be439
ycl-platform/src/main/java/com/ycl/util/VideoUtil.java
@@ -135,12 +135,12 @@
    private final String APP_SECRET = "LElVf9Ct3ykStZHCmFNZ";
    public PageResult<Camera> callPostCameras(Integer pageNo, Integer pageSize, String treeCode) throws Exception {
        System.out.println("海康视频-callPostCameras");
        ArtemisConfig config = new ArtemisConfig();
        config.setHost(HOST); // 代理API网关nginx服务器ip端口
        config.setAppKey(APP_KEY);  // 秘钥appkey
        config.setAppSecret(APP_SECRET);// 秘钥appSecret
        System.out.println("海康视频-初始化config");
        final String getSecurityApi = ARTEMIS_PATH + "/api/resource/v1/cameras"; // 接口路径
        Map<String, String> path = new HashMap<String, String>(2) {
            {
@@ -157,13 +157,13 @@
        jsonBody.put("pageSize", pageSize);
        jsonBody.put("treeCode", treeCode);
        String body = jsonBody.toString();
        System.out.println("海康视频开始请求:");
//        System.out.println("海康视频开始请求:");
        //参数根据接口实际情况设置
        HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, body, null, null, "application/json", head);
        try {
            String strResult = EntityUtils.toString(result.getEntity());
            HttpResponseResult responseResult = com.alibaba.fastjson.JSONObject.parseObject(strResult, HttpResponseResult.class);
            System.out.println("海康视频结果:" + responseResult.toString());
//            System.out.println("海康视频结果:" + responseResult.toString());
            if ("0".equals(responseResult.getCode())) {
                com.alibaba.fastjson.JSONObject jsonObject = responseResult.getData();
                String strList = jsonObject.getString("list");
@@ -186,7 +186,7 @@
        config.setHost(HOST); // 代理API网关nginx服务器ip端口
        config.setAppKey(APP_KEY);  // 秘钥appkey
        config.setAppSecret(APP_SECRET);// 秘钥appSecret
        final String getSecurityApi = ARTEMIS_PATH + "/api/resource/v1/cameras/previewURLs"; // 接口路径
        final String getSecurityApi = ARTEMIS_PATH + "/api/video/v1/cameras/previewURLs"; // 接口路径
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getSecurityApi);
@@ -207,11 +207,57 @@
        jsonBody.put("streamType", 0);
        jsonBody.put("protocol", "hls");
        jsonBody.put("transmode", 0);
        jsonBody.put("expand","transcode=1&videotype=h264");
        String body = jsonBody.toString();
        //参数根据接口实际情况设置
        HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, body, null, null, "application/json", null);
//        System.out.println("海康完成请求");
        try {
            String strResult = EntityUtils.toString(result.getEntity());
//            System.out.println("海康返回结果:" + strResult);
            HttpResponseResult responseResult = com.alibaba.fastjson.JSONObject.parseObject(strResult, HttpResponseResult.class);
            if ("0".equals(responseResult.getCode())) {
                com.alibaba.fastjson.JSONObject jsonObject = responseResult.getData();
                String url = jsonObject.getString("url");
                return url;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
    public String getKHPresets(String code) throws Exception {
        ArtemisConfig config = new ArtemisConfig();
        config.setHost(HOST); // 代理API网关nginx服务器ip端口
        config.setAppKey(APP_KEY);  // 秘钥appkey
        config.setAppSecret(APP_SECRET);// 秘钥appSecret
        final String getSecurityApi = ARTEMIS_PATH + "/api/video/v1/presets/searches"; // 接口路径
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", getSecurityApi);
            }
        };
        Map<String, String> head = new HashMap<String, String>(2) {  //get请求的head参数
            {
                put("headpost", "sky-test");
            }
        };
        Map<String, String> query = new HashMap<String, String>(2) {  //get请求的head参数
            {
                put("domainId", "0");
            }
        };
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("cameraIndexCode", code);
        String body = jsonBody.toString();
        //参数根据接口实际情况设置
        HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(config, path, body, query, null, "application/json", head);
//        System.out.println("海康完成请求-getKHPresets");
        try {
            String strResult = EntityUtils.toString(result.getEntity());
//            System.out.println("海康返回结果-getKHPresets:" + strResult);
            HttpResponseResult responseResult = com.alibaba.fastjson.JSONObject.parseObject(strResult, HttpResponseResult.class);
            if ("0".equals(responseResult.getCode())) {
                com.alibaba.fastjson.JSONObject jsonObject = responseResult.getData();