package com.gyee.frame.common.quartz.task;

import com.gyee.frame.netty.websocket.secureecho.EchoClient;
import com.gyee.frame.service.WeatherfdService;
import com.gyee.frame.service.WeatherfhService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 *
 * @CLASSNAME   WeatherfdPushTask
 * @Description 气象推送数据
 */
@Component("weatherfdpushtask")
public class weatherfdpushtask {
	@Resource
	private  WeatherfhService weatherfhService;
	@Resource
    private WeatherfdService weatherfdService;
    /**
     * 无参的任务
     * @throws Exception 
     */
    public void runweatherfdpushtask() throws Exception {

        System.out.println("气象数据采集开始！");
        Calendar c = Calendar.getInstance();
        weatherfdService.deleteDays();

        for(int i=0;i<90;i++) {


            StringBuilder dateValue=new StringBuilder("Weatherfd|");
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String data =  sdf.format(c.getTime());
            dateValue.append(data);

            EchoClient.runclient(dateValue.toString());

            c.add(Calendar.DAY_OF_MONTH,1);

        }
        c = Calendar.getInstance();
        weatherfhService.deleteHours();
        for(int i=0;i<40;i++) {


            StringBuilder dateValue=new StringBuilder("Weatherfh|");
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH");
            String data =  sdf.format(c.getTime());
            dateValue.append(data);

            EchoClient.runclient(dateValue.toString());

            c.add(Calendar.HOUR_OF_DAY,1);

        }
        System.out.println("气象数据采集完成！");
    }   

}
