package com.ruoyi.common.utils.hkws;

import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.alibaba.fastjson2.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class GetCameraPreviewURL {

    public static String GetCameraPreviewURL(String url,String body) {

        /**
         * STEP1：设置平台参数，根据实际情况,设置host appkey appsecret 三个参数.
         */
        ArtemisConfig.host = "60.171.161.56:1443"; // 平台的ip端口
        ArtemisConfig.appKey = "25679504";  // 密钥appkey
        ArtemisConfig.appSecret = "9F3cOy6JnpHeOeDOYcgP";// 密钥appSecret

        /**
         * STEP2：设置OpenAPI接口的上下文
         */
        final String ARTEMIS_PATH = "/artemis";

        /**
         * STEP3：设置接口的URI地址
         */
        //final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/cameras";
        final String previewURLsApi = ARTEMIS_PATH + url;
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
            }
        };

        /**
         * STEP4：设置参数提交方式
         */
        String contentType = "application/json";
        /**
         * STEP6：调用接口
         */
        String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);// post请求application/json类型参数
        return result;
    }

   /* public static void main(String[] args) {

        *//**
         * STEP3：设置接口的URI地址
         *//*
        String url = "/api/resource/v2/door/search";

        *//**
         * STEP5：组装请求参数
         *//*
        JSONObject jsonBody = new JSONObject();
        jsonBody.put("pageNo", 1);
        jsonBody.put("pageSize", 60);
        *//*jsonBody.put("receptionistId", "123v453673dsferf12312");
        JSONObject jsonBody2 = new JSONObject();
        jsonBody2.put("defaultPrivilegeGroupFlag","1");
        String[] privilegeGroupIds = {"793d155-3cc3-4b2a-bb23-8507552863"};
        jsonBody2.put("privilegeGroupIds",privilegeGroupIds);
        jsonBody.put("visitorPermissionSet",jsonBody2);

        jsonBody.put("visitStartTime", "2024-06-28T15:00:00+08:00");
        jsonBody.put("visitEndTime", "2024-06-28T19:00:00+08:00");
        jsonBody.put("visitPurpose",  "参观");
        List<JSONObject> jSONObjectList = new ArrayList<>();
        JSONObject jsonBody3 = new JSONObject();
        jsonBody3.put("visitorName","张三");
        jsonBody3.put("gender",1);
        jsonBody3.put("phoneNo","18297543143");
        jsonBody3.put("plateNo","浙A12345");
        jsonBody3.put("certificateType",111);
        jsonBody3.put("certificateNo","312488198704015698");
        jsonBody3.put("certAddr","江苏南京");
        jsonBody3.put("certIssuer","南京市政府");
        jsonBody3.put("nation",1);
        jsonBody3.put("birthplace","江苏南京");
        jsonBody3.put("visitorPhoto","cMc8yMjIfE87ujdq0nvyPcKodJ3XPpvt//2Q==");
        jsonBody3.put("visitorWorkUnit","海康威视");
        jsonBody3.put("visitorAddress","人民路一号");
        jSONObjectList.add(jsonBody3);

        jsonBody.put("visitorInfoList", jSONObjectList);*//*




        String result = GetCameraPreviewURL(url,jsonBody.toString());
        System.out.println("result结果示例: " + result);
    }*/
}
