package com.ruoyi.system.utils;


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


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

/**
 * @Author:
 * @Date: 2023/1/3 15:01
 * @Describe:
 */
public class timingURL {


    /**
     * 获取地上停车数据
     * @param parkSyscode 停车库唯一标识
     * @param entranceSyscode 出入口唯一标识
     * @param startTime 查询开始时间
     * @param endTime 查询结束时间
     * @param pageNo 目标页码
     * @return
     */
    public static String timingURL(String parkSyscode,String entranceSyscode,String startTime,String endTime, int pageNo) {
        /**
         * STEP1：设置平台参数，根据实际情况,设置host appkey appsecret 三个参数.
         */
        ArtemisConfig.host = "114.99.51.58:442"; // 平台的ip端口
        ArtemisConfig.appKey = "26665995";  // 密钥appkey
        ArtemisConfig.appSecret = "P9y9211M5ftH8P1Xrcef";// 密钥appSecret

        /**
         * STEP2：设置OpenAPI接口的上下文
         */
        final String ARTEMIS_PATH = "/artemis";
        /**
         * STEP3：设置接口的URI地址
         */
        final String previewURLsApi = ARTEMIS_PATH + "/api/pms/v1/crossRecords/page";
        //final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/entrance/entranceList";
        Map<String, String> path = new HashMap<String, String>(2) {
            {
                put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
            }
        };

        /**
         * STEP4：设置参数提交方式
         */
        String contentType = "application/json";

        /**
         * STEP5：组装请求参数
         */
        JSONObject jsonBody = new JSONObject();
        //停车库唯一标识
        jsonBody.put("parkSyscode", parkSyscode);
        //出入口唯一标识
        jsonBody.put("entranceSyscode", entranceSyscode);
        //查询开始时间
        //ISO8601格式：
        //yyyy-MM-ddTHH:mm:ss+当前时区，例如北京时间：
        //2018-07-26T15:00:00+08:00
        jsonBody.put("startTime", startTime);
        //查询结束时间
        //ISO8601格式：
        //yyyy-MM-ddTHH:mm:ss+当前时区，例如北京时间：
        //2018-07-26T15:00:00+08:00
        jsonBody.put("endTime", endTime);
        //进出场标识  0-进场   1-出场
        jsonBody.put("vehicleOut", 0);
        //车辆分类  9-黑名单 10-固定车 11-临时车 12-预约车 14-特殊车
        jsonBody.put("carCategory", "10");
        //目标页码
        jsonBody.put("pageNo", pageNo);
        //每页记录数
        jsonBody.put("pageSize", 1000);
        //停车库唯一标识
        String body = jsonBody.toJSONString();
        /**
         * STEP6：调用接口
         */
        String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);// post请求application/json类型参数
        //System.out.println(result);
        /**
         * {
         *     "code": "0",
         *     "msg": "success",
         *     "data": {
         *         "total": 1,
         *         "pageNo": 1,
         *         "pageSize": 15,
         *         "list": [
         *             {
         *                 "crossRecordSyscode": "g45h245gh235g2354g",
         *                 "parkSyscode": "gqwerg354g345g35g",
         *                 "parkName": "停车库1",
         *                 "entranceSyscode": "rggergqw45ghw45gb",
         *                 "entranceName": "出入口1",
         *                 "roadwaySyscode": "a9rvy0y5029waurc92-cu5",
         *                 "roadwayName": "车道1",
         *                 "vehicleOut": 1,
         *                 "releaseMode": 2,
         *                 "releaseResult": 1,
         *                 "releaseWay": 1,
         *                 "releaseReason": 100,
         *                 "plateNo": "浙A12345",
         *                 "cardNo": "54523451",
         *                 "vehicleColor": 1,
         *                 "vehicleType": 1,
         *                 "plateColor": 1,
         *                 "plateType": 2,
         *                 "carCategory": "11",
         *                 "carCategoryName": "临时车",
         *                 "vehiclePicUri": "/pic?=d7ei703i10cd*73a-d5108a--22cd0c9d6592aiid=",
         *                 "plateNoPicUri": "/pic?=d7ei703i10cd*73a-d5108a--22cd0c9d6592aiid=",
         *                 "facePicUri": "/pic?=d7ei703i10cd*73a-d5108a--22cd0c9d6592aiid=",
         *                 "aswSyscode": "h4h45y13ty23hg24h",
         *                 "crossTime": "2018-07-26T15:00:00+08:00",
         *                 "createTime": "2018-07-26T15:00:00+08:00"
         *             }
         *         ]
         *     }
         * }
         */
        return result;
    }



}

