UserStatisticsTask.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package cn.com.lzt.userstats.timetask;
  2. import java.util.Date;
  3. import org.jeecgframework.core.util.ApplicationContextUtil;
  4. import org.quartz.Job;
  5. import org.quartz.JobExecutionContext;
  6. import org.quartz.JobExecutionException;
  7. import org.springframework.stereotype.Service;
  8. import cn.com.lzt.userstats.service.UserStatsServiceI;
  9. /**
  10. *
  11. * @ClassName:SmsSendTask 人员统计定时任务类
  12. * @Description: TODO
  13. * @author zhijia.wang
  14. * @date 2017-11-16 20:11:35
  15. *
  16. */
  17. @Service("userStatisticsTask")
  18. public class UserStatisticsTask implements Job{
  19. /*@Scheduled(cron="0 0/1 * * * ?")*/
  20. public void userStatistics() {
  21. long start = System.currentTimeMillis();
  22. org.jeecgframework.core.util.LogUtil.info("===================人员统计定时任务开始===================");
  23. try {
  24. System.out.println("===================人员统计定时任务开始"+new Date());
  25. UserStatsServiceI userStatsServiceI = ApplicationContextUtil
  26. .getContext().getBean(UserStatsServiceI.class);
  27. userStatsServiceI.userStatsTaskData();
  28. System.out.println("===================人员统计定时任务结束"+new Date());
  29. } catch (Exception e) {
  30. e.printStackTrace();
  31. }
  32. org.jeecgframework.core.util.LogUtil.info("===================人员统计定时任务结束===================");
  33. long end = System.currentTimeMillis();
  34. long times = end - start;
  35. org.jeecgframework.core.util.LogUtil.info("总耗时"+times+"毫秒");
  36. }
  37. @Override
  38. public void execute(JobExecutionContext arg0) throws JobExecutionException {
  39. userStatistics();
  40. }
  41. }