package com.steering.jobface.ydm;

import java.util.Timer;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.text.ParseException;

public class CoreStatisticsServlet extends HttpServlet {
    private static final long serialVersionUID = 7740196299095638854L;

    public void init() throws ServletException {
        try {
//            SimpleDateFormat fTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//            Date strDate = fTime.parse("2019-09-01 00:00:00");
//            Date strDate1 = fTime.parse("2019-09-01 00:00:00");
//            Date strDate2 = fTime.parse("2019-09-01 00:00:00");
            SimpleDateFormat fTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            String strDay = df.format(new Date());
            Date strDate = fTime.parse(strDay+" 18:00:00");
            Date strDate1 = fTime.parse(strDay+" 20:00:00");
            Date strDate2 = fTime.parse(strDay+" 21:00:00");
            System.out.println("--------------后台线程初始化中--------------------");
            // 领导报表库存综合信息
            new Timer().scheduleAtFixedRate(new CoreSlmYdmStatisticsTask(), strDate,
                    24*60*60*1000);
            // 领导报表收发存信息
            new Timer().scheduleAtFixedRate(new CoreYdmStockTask(), strDate1,
                    24*60*60*1000);
         // 领导报表结算
            new Timer().scheduleAtFixedRate(new CoreBalanceTask(), strDate2,
                    24*60*60*1000);
            System.out.println("--------------后台线程初始化成功--------------------");
        }
        catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }    
}
