`
lp54459622
  • 浏览: 11861 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

程序每天只执行一次

 
阅读更多
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;
			}			
		}
                //执行程序
        }
}
 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics