创建定时任务生产工厂import java.text.SimpleDateFormat;
import java.util.Date;
import bingo.modules.bussiness.task.QuartzManager;
/**
*
* {@link QuartzFactory}
*
* TODO : document me
*
* @author shenlu
*/
public class QuartzFactory {
/**
* 个性化菜单定时上架
* @param jobTime 任务调度时间
* @param jobName 任务名称
* {@link}UpShelvesJob 上架任务类
*/
public static void createUpShelvesJob(Date jobDate,String jobName,String id){
String jobTime = convertTime(jobDate);
QuartzManager.addJob(jobName, MenuUpShelvesJob.class, jobTime, id);
}
/**
* 个性化菜单定时下架
* @param jobTime 任务调度时间
* @param jobName 任务名称
* {@link}UpShelvesJob 上架任务类
*/
public static void createDownShelvesJob(Date jobDate,String jobName,String id){
String jobTime = convertTime(jobDate);
QuartzManager.addJob(jobName, MenuDownShelvesJob.class, jobTime, id);
}
/**
* 全网菜单上下架
* @param jobDate 任务调度时间
* @param jobName 任务名称
* {@link}WholeMenuUpOrDownShelvesJob 全网上下架任务类
*/
public static void createWholeUpOrDownShelvesJob(Date jobDate,String jobName,String id){
String jobTime = convertTime(jobDate);
QuartzManager.addJob(jobName, WholeMenuUpOrDownShelvesJob.class, jobTime, id);
}
private static String convertTime(Date jobDate){
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = format.format(jobDate);
String[] times = time.split(" ");
String[] timesF = times[1].split(":");
String[] timesT = times[0].split("-");
String jobTime = timesF[2]+" "+timesF[1]+" "+time