|
@ -245,6 +245,7 @@ public class JobService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public void productDataByDayAndId(Integer day, String id) throws Exception {
|
|
|
QuartzJobConfig quartzJobConfig = wlyyJobConfigDao.findById(id);
|
|
|
if (quartzJobConfig == null) {
|
|
@ -320,4 +321,92 @@ public class JobService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//================================================没有休眠时间=============================================================
|
|
|
|
|
|
public void productDataByDayToDayAndIdNoSleep(String start, String end, String id,Long sleepTime) throws Exception {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
Date startDate = sdf.parse(start);
|
|
|
Date endDate = sdf.parse(end);
|
|
|
if (startDate.after(endDate)) {
|
|
|
throw new Exception("日期参数错误");
|
|
|
}
|
|
|
int day = daysBetween(startDate, endDate);
|
|
|
for (int i = 0; i < day; i++) {
|
|
|
Cache.cleanCache();//清空缓存
|
|
|
productDataByOneDayWithIdNoSleep(getYesterday(i, startDate), id,sleepTime);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public void productDataByOneDayWithIdNoSleep(String yesterday, String id,Long sleepTime) throws Exception {
|
|
|
SimpleDateFormat dataSimple = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
Date date = dataSimple.parse(yesterday);
|
|
|
if (date == null) {
|
|
|
throw new Exception("时间格式错误");
|
|
|
}
|
|
|
Calendar calendar = new GregorianCalendar();
|
|
|
calendar.setTime(date);
|
|
|
calendar.add(calendar.DATE, -1);//把日期往后增加一天.整数往后推,负数往前移动
|
|
|
Date nowDate = calendar.getTime(); //这个时间就是日期往后推一天的结果
|
|
|
String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
|
|
|
|
|
|
QuartzJobConfig quartzJobConfig = wlyyJobConfigDao.findById(id);
|
|
|
if (quartzJobConfig == null) {
|
|
|
throw new Exception("id不存在");
|
|
|
}
|
|
|
WlyyJobConfigVO wlyyJobConfigVO = new WlyyJobConfigVO();
|
|
|
BeanUtils.copyProperties(quartzJobConfig, wlyyJobConfigVO);
|
|
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
|
|
|
|
//往quartz框架添加任务
|
|
|
params.put("startTime", daybefore);
|
|
|
params.put("endTime", yesterday);
|
|
|
|
|
|
for (int j = 1; j <= 2; j++) {
|
|
|
params.put("timeLevel", j + "");
|
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
|
}
|
|
|
Thread.sleep(sleepTime*1000L);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public void productDataByOneDayNoSleep(String yesterday,Long sleepTime) throws Exception {
|
|
|
String sql="select * from wlyy_job_config_new a where a.del='1' and a.id !=11 order by a.id asc";
|
|
|
SimpleDateFormat dataSimple = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
Date date = dataSimple.parse(yesterday);
|
|
|
if (date == null) {
|
|
|
throw new Exception("时间格式错误");
|
|
|
}
|
|
|
Calendar calendar = new GregorianCalendar();
|
|
|
calendar.setTime(date);
|
|
|
calendar.add(calendar.DATE, -1);//把日期往后增加一天.整数往后推,负数往前移动
|
|
|
Date nowDate = calendar.getTime(); //这个时间就是日期往后推一天的结果
|
|
|
String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
|
|
|
List<QuartzJobConfig> quartzJobConfigs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(QuartzJobConfig.class));
|
|
|
for (QuartzJobConfig quartzJobConfig : quartzJobConfigs) {
|
|
|
|
|
|
WlyyJobConfigVO wlyyJobConfigVO = new WlyyJobConfigVO();
|
|
|
BeanUtils.copyProperties(quartzJobConfig, wlyyJobConfigVO);
|
|
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
|
//往quartz框架添加任务
|
|
|
params.put("startTime", daybefore);
|
|
|
params.put("endTime", yesterday);
|
|
|
|
|
|
for (int j = 1; j <= 2; j++) {
|
|
|
params.put("timeLevel", j + "");
|
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
|
}
|
|
|
Thread.sleep(sleepTime*1000L);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|