package com.ruoyi.web.controller.chenyanlogin.timer;

import com.ruoyi.web.controller.chenyanlogin.dto.QiXiangDto;
import com.ruoyi.web.controller.chenyanlogin.entity.QiXiang;
import com.ruoyi.web.controller.chenyanlogin.service.IQiXiangService;
import com.ruoyi.web.domain.entity.LotVideo;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.ResponseEntity;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.client.RestTemplate;

import java.util.List;


@Configuration
@EnableScheduling
@CrossOrigin
public class QiXiangTimer {
    @Autowired
    private IQiXiangService qiXiangService;
    @Autowired
    private RestTemplate restTemplate;

    //获取气象数据
    @Scheduled(cron = "0 0/10 * * * ? ")
//    @Scheduled(cron = "0 * * * * ? ")
    public  void statusCamerList() throws Exception {
        ResponseEntity<QiXiangDto> forEntity = restTemplate.getForEntity("https://yun-api.bigdata5s.com/open-api/open/weather/getCurrentDeviceData?username=18802880368&password=123456&deviceId=1965660599109943299", QiXiangDto.class);
        if (forEntity.getBody().getCode() == 200){
            qiXiangService.save(forEntity.getBody().getData());
        }
    }


}
