TargetFreshJob { @Scheduled(cron = "1 0 0 ? * 1") public void executeTargetFresh() { Date day=new Date(); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); log.info("Fresh Target Job start ："+df.format(day)); ThisLocalizedWeek thisLocalizedWeek = new ThisLocalizedWeek(Locale.CHINA); List<TargetDistance> targetDistances = targetDistanceMapper.selectByTimeRange(thisLocalizedWeek.getPreFirstDay(), thisLocalizedWeek.getPreLastDay()); for (TargetDistance targetDistance : targetDistances) { List<TargetDistance> targetDistanceolds = targetDistanceMapper.selectByUserGroupIdAndTimeRangeReturnList(targetDistance.getUserGroupId(), thisLocalizedWeek.getFirstDay(), thisLocalizedWeek.getLastDay()); if (targetDistanceolds!=null){ for (TargetDistance targetDistanceold : targetDistanceolds) { targetDistanceMapper.deleteByPrimaryKey(targetDistanceold.getTargetDistanceId()); } } targetDistance.setCreationTime(new Date()); targetDistance.setTargetDistanceId(null); log.info("Generate Target"+ targetDistance.toString()); targetDistanceMapper.insert(targetDistance); } day = new Date(); log.info("Fresh Target Job Finished ："+df.format(day)); }  @Scheduled(cron = "1 0 0 ? * 1") void executeTargetFresh();  }
@Test public void executeTargetFresh() { }