package cn.updev.Message.Task;

import org.apache.commons.lang.time.DateUtils;

import javax.servlet.ServletContextEvent;
import java.util.Timer;

/**
 * Created by hypo on 15-11-27.
 */
public class EventCheckMaster implements ServletContextListener {
    /**
     * 每天的毫秒数
     */
    public static final long PERIOD_DAY = DateUtils.MILLIS_IN_DAY;
    /**
     * 一周内的毫秒数
     */
    public static final long PERIOD_WEEK = PERIOD_DAY * 7;
    /**
     * 无延迟
     */
    public static final long NO_DELAY = 0;
    /**
     * 定时器
     */
    private Timer timer;
    /**
     * 在Web应用启动时初始化任务
     */
    public void contextInitialized(ServletContextEvent event) {
        //定义定时器
        timer = new Timer("数据库表备份",true);
        //启动备份任务,每月(4个星期)执行一次
        timer.schedule(new BackUpTableTask(),NO_DELAY, PERIOD_WEEK * 4);
    }
    /**
     * 在Web应用结束时停止任务
     */
    public void contextDestroyed(ServletContextEvent event) {
        timer.cancel(); // 定时器销毁
    }
}
@@ -115,16 +115,181 @@
 tEvent;%0A
+import javax.servlet.ServletContextListener;%0Aimport java.text.DateFormat;%0Aimport java.text.ParseException;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.Date;%0A
 import j
@@ -304,16 +304,16 @@
 .Timer;%0A
-
 %0A/**%0A * 
@@ -520,98 +520,8 @@
 /**%0A
-     * %E4%B8%80%E5%91%A8%E5%86%85%E7%9A%84%E6%AF%AB%E7%A7%92%E6%95%B0%0A     */%0A    public static final long PERIOD_WEEK = PERIOD_DAY * 7;%0A    /**%0A
     
@@ -779,52 +779,560 @@
 er(%22
-%E6%95%B0%E6%8D%AE%E5%BA%93%E8%A1%A8%E5%A4%87%E4%BB%BD%22,true);%0A        //%E5%90%AF%E5%8A%A8%E5%A4%87%E4%BB%BD%E4%BB%BB%E5%8A%A1,%E6%AF%8F%E6%9C%88(4%E4%B8%AA%E6%98%9F%E6%9C%9F)%E6%89%A7%E8%A1%8C%E4%B8%80%E6%AC%A1
+EventNeedToDoCheck%22,true);%0A%0A        Date now = new Date();%0A        DateFormat dateFormat1 = new SimpleDateFormat(%22yyyy-MM-dd%22);%0A        DateFormat dateFormat2 = new SimpleDateFormat(%22yyyy-MM-dd HH:mm:ss%22);%0A        String ft = dateFormat1.format(now);%0A        Date firstTime = null;%0A        try %7B%0A            firstTime = dateFormat2.parse(ft + %22 %22 + %2206:00:00%22);%0A        %7D catch (ParseException e) %7B%0A            e.printStackTrace();%0A            firstTime = now;%0A        %7D%0A        System.out.println(%22%E9%A6%96%E6%AC%A1%E6%89%A7%E8%A1%8C%E4%BB%BB%E5%8A%A1%E6%97%B6%E9%97%B4%E4%B8%BA%EF%BC%9A%22 + firstTime);%0A        //%E5%90%AF%E5%8A%A8%E4%BA%8B%E4%BB%B6%E6%A3%80%E6%9F%A5%E4%BB%BB%E5%8A%A1%EF%BC%8C%E6%AF%8F%E5%A4%A96%E7%82%B9%E5%BC%80%E5%A7%8B%E6%89%A7%E8%A1%8C
 %0A   
@@ -1359,34 +1359,30 @@
 new 
-BackUpTableTask(),NO_DELAY
+EventCheck(),firstTime
 , PE
@@ -1390,16 +1390,11 @@
 IOD_
-WEEK * 4
+DAY
 );%0A 

update EventCheckMaster