|
@ -45,8 +45,10 @@ public class JobService {
|
|
QuartzJobConfig quartzJobConfig = wlyyJobConfigDao.findById(id, "1");
|
|
QuartzJobConfig quartzJobConfig = wlyyJobConfigDao.findById(id, "1");
|
|
if (quartzJobConfig != null) {
|
|
if (quartzJobConfig != null) {
|
|
for (int j = 1; j <= 2; j++) {
|
|
for (int j = 1; j <= 2; j++) {
|
|
|
|
if (breakPoint(quartzJobConfig, j)) continue;
|
|
quartzHelper.removeJob(quartzJobConfig.getId() + "-" + j);
|
|
quartzHelper.removeJob(quartzJobConfig.getId() + "-" + j);
|
|
wlyyJobConfigDao.updateStatus(quartzJobConfig.getId(),"0") ;;
|
|
|
|
|
|
wlyyJobConfigDao.updateStatus(quartzJobConfig.getId(), "0");
|
|
|
|
;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
throw new Exception("任务已经停止");
|
|
throw new Exception("任务已经停止");
|
|
@ -70,9 +72,11 @@ public class JobService {
|
|
if (quartzJobConfigs != null && quartzJobConfigs.size() > 0) {
|
|
if (quartzJobConfigs != null && quartzJobConfigs.size() > 0) {
|
|
for (QuartzJobConfig quartzJobConfig : quartzJobConfigs) {
|
|
for (QuartzJobConfig quartzJobConfig : quartzJobConfigs) {
|
|
for (int j = 1; j <= 2; j++) {
|
|
for (int j = 1; j <= 2; j++) {
|
|
|
|
if (breakPoint(quartzJobConfig, j)) continue;
|
|
quartzHelper.removeJob(quartzJobConfig.getId() + "-" + j);
|
|
quartzHelper.removeJob(quartzJobConfig.getId() + "-" + j);
|
|
|
|
|
|
wlyyJobConfigDao.updateStatus(quartzJobConfig.getId(),"0") ;;
|
|
|
|
|
|
wlyyJobConfigDao.updateStatus(quartzJobConfig.getId(), "0");
|
|
|
|
;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@ -108,10 +112,11 @@ public class JobService {
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
for (int j = 1; j <= 2; j++) {
|
|
for (int j = 1; j <= 2; j++) {
|
|
|
|
if (breakPoint(wlyyJobConfigVO, j)) continue;
|
|
params.put("timeLevel", j + "");
|
|
params.put("timeLevel", j + "");
|
|
//往quartz框架添加任务
|
|
//往quartz框架添加任务
|
|
quartzHelper.addJob(getRightClass(quartzJobConfig), quartzJobConfig.getQuartzCron(), quartzJobConfig.getId() + "-" + j, params);
|
|
quartzHelper.addJob(getRightClass(quartzJobConfig), quartzJobConfig.getQuartzCron(), quartzJobConfig.getId() + "-" + j, params);
|
|
wlyyJobConfigDao.updateStatus(quartzJobConfig.getId(),"1") ;//设置任务状态是启动 }
|
|
|
|
|
|
wlyyJobConfigDao.updateStatus(quartzJobConfig.getId(), "1");//设置任务状态是启动 }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -125,6 +130,7 @@ public class JobService {
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
for (int i = 1; i <= 2; i++) {
|
|
for (int i = 1; i <= 2; i++) {
|
|
|
|
if (breakPoint(wlyyJobConfigVO, i)) continue;
|
|
params.put("timeLevel", i + "");
|
|
params.put("timeLevel", i + "");
|
|
//往quartz框架添加任务
|
|
//往quartz框架添加任务
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
@ -134,6 +140,19 @@ public class JobService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private boolean breakPoint(WlyyJobConfigVO wlyyJobConfigVO, int i) {
|
|
|
|
if (Integer.valueOf(wlyyJobConfigVO.getId()) > 86 && i == 2) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean breakPoint(QuartzJobConfig wlyyJobConfigVO, int i) {
|
|
|
|
if (Integer.valueOf(wlyyJobConfigVO.getId()) > 86 && i == 2) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
public void productDataByDay(Integer day) throws Exception {
|
|
public void productDataByDay(Integer day) throws Exception {
|
|
List<QuartzJobConfig> quartzJobConfigs = wlyyJobConfigDao.findByIds();
|
|
List<QuartzJobConfig> quartzJobConfigs = wlyyJobConfigDao.findByIds();
|
|
@ -146,6 +165,7 @@ public class JobService {
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
for (int i = 1; i <= day; i++) {
|
|
for (int i = 1; i <= day; i++) {
|
|
for (int j = 1; j <= 2; j++) {
|
|
for (int j = 1; j <= 2; j++) {
|
|
|
|
if (breakPoint(wlyyJobConfigVO, j)) continue;
|
|
params.put("timeLevel", j + "");
|
|
params.put("timeLevel", j + "");
|
|
//往quartz框架添加任务
|
|
//往quartz框架添加任务
|
|
params.put("startTime", getYesterday(0 - i - 1));
|
|
params.put("startTime", getYesterday(0 - i - 1));
|
|
@ -167,7 +187,7 @@ public class JobService {
|
|
}
|
|
}
|
|
|
|
|
|
public void productDataByOneDay(String yesterday) throws Exception {
|
|
public void productDataByOneDay(String yesterday) throws Exception {
|
|
String sql="select * from wlyy_job_config_new a where a.del='1' and a.id !=11 order by a.id asc";
|
|
|
|
|
|
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");
|
|
SimpleDateFormat dataSimple = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
Date date = dataSimple.parse(yesterday);
|
|
Date date = dataSimple.parse(yesterday);
|
|
@ -179,7 +199,7 @@ public class JobService {
|
|
calendar.add(calendar.DATE, -1);//把日期往后增加一天.整数往后推,负数往前移动
|
|
calendar.add(calendar.DATE, -1);//把日期往后增加一天.整数往后推,负数往前移动
|
|
Date nowDate = calendar.getTime(); //这个时间就是日期往后推一天的结果
|
|
Date nowDate = calendar.getTime(); //这个时间就是日期往后推一天的结果
|
|
String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
|
|
String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
|
|
List<QuartzJobConfig> quartzJobConfigs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(QuartzJobConfig.class));
|
|
|
|
|
|
List<QuartzJobConfig> quartzJobConfigs = jdbcTemplate.query(sql, new BeanPropertyRowMapper(QuartzJobConfig.class));
|
|
for (QuartzJobConfig quartzJobConfig : quartzJobConfigs) {
|
|
for (QuartzJobConfig quartzJobConfig : quartzJobConfigs) {
|
|
|
|
|
|
WlyyJobConfigVO wlyyJobConfigVO = new WlyyJobConfigVO();
|
|
WlyyJobConfigVO wlyyJobConfigVO = new WlyyJobConfigVO();
|
|
@ -192,6 +212,7 @@ public class JobService {
|
|
params.put("endTime", yesterday);
|
|
params.put("endTime", yesterday);
|
|
|
|
|
|
for (int j = 1; j <= 2; j++) {
|
|
for (int j = 1; j <= 2; j++) {
|
|
|
|
if (breakPoint(wlyyJobConfigVO, j)) continue;
|
|
params.put("timeLevel", j + "");
|
|
params.put("timeLevel", j + "");
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
@ -238,6 +259,7 @@ public class JobService {
|
|
params.put("endTime", yesterday);
|
|
params.put("endTime", yesterday);
|
|
|
|
|
|
for (int j = 1; j <= 2; j++) {
|
|
for (int j = 1; j <= 2; j++) {
|
|
|
|
if (breakPoint(wlyyJobConfigVO, j)) continue;
|
|
params.put("timeLevel", j + "");
|
|
params.put("timeLevel", j + "");
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
@ -262,6 +284,7 @@ public class JobService {
|
|
params.put("startTime", getYesterday(0 - i - 1));
|
|
params.put("startTime", getYesterday(0 - i - 1));
|
|
params.put("endTime", getYesterday(0 - i));
|
|
params.put("endTime", getYesterday(0 - i));
|
|
for (int j = 1; j <= 2; j++) {
|
|
for (int j = 1; j <= 2; j++) {
|
|
|
|
if (breakPoint(wlyyJobConfigVO, j)) continue;
|
|
params.put("timeLevel", j + "");
|
|
params.put("timeLevel", j + "");
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
@ -270,6 +293,7 @@ public class JobService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public void productDataByDayToDay(String start, String end) throws Exception {
|
|
public void productDataByDayToDay(String start, String end) throws Exception {
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
Date startDate = sdf.parse(start);
|
|
Date startDate = sdf.parse(start);
|
|
@ -280,7 +304,7 @@ public class JobService {
|
|
int day = daysBetween(startDate, endDate);
|
|
int day = daysBetween(startDate, endDate);
|
|
for (int i = 0; i < day; i++) {
|
|
for (int i = 0; i < day; i++) {
|
|
Cache.cleanCache();//清空缓存
|
|
Cache.cleanCache();//清空缓存
|
|
// Thread.sleep(60000L);//休息60秒
|
|
|
|
|
|
// Thread.sleep(60000L);//休息60秒
|
|
productDataByOneDay(getYesterday(i, startDate));
|
|
productDataByOneDay(getYesterday(i, startDate));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -316,10 +340,10 @@ public class JobService {
|
|
throw new Exception("日期参数错误");
|
|
throw new Exception("日期参数错误");
|
|
}
|
|
}
|
|
int day = daysBetween(startDate, endDate);
|
|
int day = daysBetween(startDate, endDate);
|
|
String [] idStr=ids.split(",");
|
|
|
|
|
|
String[] idStr = ids.split(",");
|
|
for (int i = 0; i < day; i++) {
|
|
for (int i = 0; i < day; i++) {
|
|
Cache.cleanCache();//清空缓存
|
|
Cache.cleanCache();//清空缓存
|
|
for(String id:idStr){
|
|
|
|
|
|
for (String id : idStr) {
|
|
productDataByOneDayWithId(getYesterday(i, startDate), id);
|
|
productDataByOneDayWithId(getYesterday(i, startDate), id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -327,7 +351,7 @@ public class JobService {
|
|
|
|
|
|
//================================================没有休眠时间=============================================================
|
|
//================================================没有休眠时间=============================================================
|
|
|
|
|
|
public void productDataByDayToDayAndIdNoSleep(String start, String end, String id,Long sleepTime) throws Exception {
|
|
|
|
|
|
public void productDataByDayToDayAndIdNoSleep(String start, String end, String id, Long sleepTime) throws Exception {
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
Date startDate = sdf.parse(start);
|
|
Date startDate = sdf.parse(start);
|
|
Date endDate = sdf.parse(end);
|
|
Date endDate = sdf.parse(end);
|
|
@ -337,12 +361,12 @@ public class JobService {
|
|
int day = daysBetween(startDate, endDate);
|
|
int day = daysBetween(startDate, endDate);
|
|
for (int i = 0; i < day; i++) {
|
|
for (int i = 0; i < day; i++) {
|
|
Cache.cleanCache();//清空缓存
|
|
Cache.cleanCache();//清空缓存
|
|
productDataByOneDayWithIdNoSleep(getYesterday(i, startDate), id,sleepTime);
|
|
|
|
|
|
productDataByOneDayWithIdNoSleep(getYesterday(i, startDate), id, sleepTime);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public void productDataByOneDayWithIdNoSleep(String yesterday, String id,Long sleepTime) throws Exception {
|
|
|
|
|
|
public void productDataByOneDayWithIdNoSleep(String yesterday, String id, Long sleepTime) throws Exception {
|
|
SimpleDateFormat dataSimple = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat dataSimple = new SimpleDateFormat("yyyy-MM-dd");
|
|
Date date = dataSimple.parse(yesterday);
|
|
Date date = dataSimple.parse(yesterday);
|
|
if (date == null) {
|
|
if (date == null) {
|
|
@ -373,13 +397,13 @@ public class JobService {
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
}
|
|
}
|
|
Thread.sleep(sleepTime*1000L);
|
|
|
|
|
|
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";
|
|
|
|
|
|
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");
|
|
SimpleDateFormat dataSimple = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
Date date = dataSimple.parse(yesterday);
|
|
Date date = dataSimple.parse(yesterday);
|
|
@ -391,7 +415,7 @@ public class JobService {
|
|
calendar.add(calendar.DATE, -1);//把日期往后增加一天.整数往后推,负数往前移动
|
|
calendar.add(calendar.DATE, -1);//把日期往后增加一天.整数往后推,负数往前移动
|
|
Date nowDate = calendar.getTime(); //这个时间就是日期往后推一天的结果
|
|
Date nowDate = calendar.getTime(); //这个时间就是日期往后推一天的结果
|
|
String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
|
|
String daybefore = new SimpleDateFormat("yyyy-MM-dd").format(nowDate.getTime());
|
|
List<QuartzJobConfig> quartzJobConfigs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(QuartzJobConfig.class));
|
|
|
|
|
|
List<QuartzJobConfig> quartzJobConfigs = jdbcTemplate.query(sql, new BeanPropertyRowMapper(QuartzJobConfig.class));
|
|
for (QuartzJobConfig quartzJobConfig : quartzJobConfigs) {
|
|
for (QuartzJobConfig quartzJobConfig : quartzJobConfigs) {
|
|
|
|
|
|
WlyyJobConfigVO wlyyJobConfigVO = new WlyyJobConfigVO();
|
|
WlyyJobConfigVO wlyyJobConfigVO = new WlyyJobConfigVO();
|
|
@ -408,7 +432,7 @@ public class JobService {
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
}
|
|
}
|
|
Thread.sleep(sleepTime*1000L);
|
|
|
|
|
|
Thread.sleep(sleepTime * 1000L);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|