public class TvbGiftOnOverSpendTimeTaskImpl implements
TvbGiftOnOverSpendTimeTask {
private static final Log log = LogFactory.getLog("timeTaskLog");
private Date excuteDate = null;
private int executeTimes = 0;
public void giftOnOverSpend() {
String configExecuteTimes = MiniCms.getConfig("tvb", "executeTimes", "1");
int times = 1;
try{
times = Integer.parseInt(configExecuteTimes);
}catch(Exception e){
log.error("获取executeTimes配置失败");
}
if(excuteDate != null){
SimpleDateFormat nowSdf = new SimpleDateFormat("yyyyMMdd");
Date now = new Date();
String nowStr = nowSdf.format(now);
String executeDateStr = nowSdf.format(excuteDate);
if(nowStr.equals(executeDateStr)){
if(executeTimes >= times){
log.error("该程序当天只能执行"+configExecuteTimes+"次");
return;
}
}else{
executeTimes = 0;
}
}
//执行程序
}
}
程序每天只执行一次
最新推荐文章于 2024-03-06 11:15:55 发布