//package com.huimv.admin.timer;
//
//import cn.hutool.core.codec.Base64;
//import cn.hutool.core.util.ObjectUtil;
//import cn.hutool.json.JSONUtil;
//import com.alibaba.fastjson.JSON;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.toolkit.StringUtils;
//import com.huimv.admin.common.utils.Digests;
//import com.huimv.admin.common.utils.HttpClientSSLUtils;
//import com.huimv.admin.entity.EnvData;
//import com.huimv.admin.entity.EnvDevice;
//import com.huimv.admin.entity.EnvWarningInfo;
//import com.huimv.admin.entity.EnvWarningThreshold;
//import com.huimv.admin.entity.hkwsdto.CameraDto1;
//import com.huimv.admin.entity.hkwsdto.HkvsCameraDto;
//import com.huimv.admin.entity.zengxindto.*;
//import com.huimv.admin.service.*;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.*;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.transaction.annotation.Transactional;
//import org.springframework.web.client.RestTemplate;
//
//import java.lang.invoke.MethodHandleProxies;
//import java.time.LocalDate;
//import java.time.LocalDateTime;
//import java.time.LocalTime;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.List;
//import java.util.Map;
//
//@Configuration
//@EnableScheduling
//public class CarmeraTimer {
//    private static final String APPKEY = "1c9ee657";
//    private static final String SECRET = "a5d723941c804a429447e71db2707ce8";
//    private static final String OPENAPI_IP_PORT_HTTP = "http://61.153.248.106:100";
//    private static final String OPENAPI_IP_PORT_HTTPS = "https://61.153.248.106:4430";
//    private static final String ITF_ADDRESS_GET_CAMERAS = "/openapi/service/vss/res/getCameras";
//    private static final String OP_USER_UUID = "5b2eb534696b11e89c2e438f92627767";
//
//    @Autowired
//    private ICameraBaseService cameraBaseService;
//        //数据库账号密码加密
//    //更新摄像头状态
//    @Scheduled(cron = "0 0/10 * * * ? ")
//    private void updateCameraOnlin() throws Exception {
//        String cameras = testGetCameras();
//        HkvsCameraDto hkvsCameraDto = JSONUtil.toBean(cameras, HkvsCameraDto.class);
//        if (ObjectUtil.isNotEmpty(hkvsCameraDto) && hkvsCameraDto.getErrorCode() ==0 ){
//            List<CameraDto1> list = hkvsCameraDto.getData().getList();
//            if (ObjectUtil.isNotEmpty(list)){
//                cameraBaseService.updateCameraOnlin(list);
//            }
//            System.out.println("更新成功");
//        }else {
//            System.out.println("摄像头信息为空");
//        }
//    }
//    /**
//     * HTTP方式
//     * 分页获取监控点信息 测试
//     * @return
//     * @throws Exception
//     */
//    private static String testGetCameras() throws Exception{
//        String url = OPENAPI_IP_PORT_HTTP + ITF_ADDRESS_GET_CAMERAS;
//        Map<String, Object> map = new HashMap<String, Object>();
//        map.put("appkey", APPKEY);//设置APPKEY
//        map.put("time", System.currentTimeMillis());//设置时间参数
//        map.put("pageNo", 1);//设置分页参数
//        map.put("pageSize", 1000);//设置分页参数
//        map.put("opUserUuid", OP_USER_UUID);//设置操作用户UUID
//        String params = JSON.toJSONString(map);
//        System.out.println(" ====== getCameras请求参数：【" + params + "】");
//        String data = HttpClientSSLUtils.doPost(url + "?token=" + Digests.buildToken(url + "?" + params, null, SECRET), params);
//        System.out.println(" ====== getCameras请求返回结果：【{" + data + "}】");
//        return data;
//    }
//
//
//    public static void main(String[] args) {
//        RestTemplate restTemplate = new RestTemplate();
//        String envUrl = "https://dnqyt.envchina.com/api/public/station-data";
//        LocalDate previousDay = LocalDate.now().minusDays(1);
//        LocalDateTime previousDayStart = LocalDateTime.of(previousDay, LocalTime.MIN);
//
//        String sgToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJkYW9ub25nIiwidWlkIjozLCJ1biI6IlpYUUxZWktKMjMwN0EyIiwiZXhwIjoxNjg5MDcwNTYxLCJqdGkiOiIzIn0.BEFESZrKOwBej4rxOfoj7qPcHGomh6KN7xbXdjOB__w";
//        HttpHeaders headers = new HttpHeaders();
//        headers.add("token",sgToken);
//        headers.setContentType(MediaType.APPLICATION_JSON);
//        HttpEntity<Map<String, Object>> formEntity = new HttpEntity<Map<String, Object>>(headers);
//
//        String urlWithParams = envUrl + "?type=D&mn=33330424001391" + "&startTime=" + "2023-07-10 00:00:00" + "&endTime=" + "2023-07-10 00:00:00";
//        ResponseEntity<String> result = restTemplate.exchange(urlWithParams, HttpMethod.GET,formEntity,String.class);
//        System.out.println(result);
//    }
//
//}
