|
@ -110,6 +110,7 @@ public class JobService {
|
|
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
|
params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
|
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
|
for (int j = 1; j <= 2; j++) {
|
|
|
if (breakPoint(wlyyJobConfigVO, j)) continue;
|
|
@ -129,6 +130,7 @@ public class JobService {
|
|
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
|
params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
|
|
|
for (int i = 1; i <= 2; i++) {
|
|
|
if (breakPoint(wlyyJobConfigVO, i)) continue;
|
|
|
params.put("timeLevel", i + "");
|
|
@ -141,6 +143,10 @@ public class JobService {
|
|
|
}
|
|
|
|
|
|
private boolean breakPoint(WlyyJobConfigVO wlyyJobConfigVO, int i) {
|
|
|
//该方法使用于每日统计
|
|
|
if(wlyyJobConfigVO.getIncrementInterval()!=1){
|
|
|
return true;
|
|
|
}
|
|
|
//如果为空或者等3说明纪要生成到达量也要生成增量
|
|
|
if (StringUtils.isEmpty(wlyyJobConfigVO.getTimeLevel()) || Integer.valueOf(wlyyJobConfigVO.getTimeLevel()) == 3) {
|
|
|
return false;
|
|
@ -149,13 +155,14 @@ public class JobService {
|
|
|
if (!(StringUtils.isEmpty(wlyyJobConfigVO.getTimeLevel())) && Integer.valueOf(wlyyJobConfigVO.getTimeLevel()) == i) {
|
|
|
return false;
|
|
|
}
|
|
|
if(wlyyJobConfigVO.getIncrementInterval()!=1){
|
|
|
return true;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
private boolean breakPoint(QuartzJobConfig wlyyJobConfigVO, int i) {
|
|
|
//该方法使用于每日统计
|
|
|
if(wlyyJobConfigVO.getIncrementInterval()!=1){
|
|
|
return true;
|
|
|
}
|
|
|
//如果为空或者等3说明纪要生成到达量也要生成增量
|
|
|
if (StringUtils.isEmpty(wlyyJobConfigVO.getTimeLevel()) || Integer.valueOf(wlyyJobConfigVO.getTimeLevel()) == 3) {
|
|
|
return false;
|
|
@ -176,6 +183,7 @@ public class JobService {
|
|
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
|
params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
|
|
|
for (int i = 1; i <= day; i++) {
|
|
|
for (int j = 1; j <= 2; j++) {
|
|
|
if (breakPoint(wlyyJobConfigVO, j)) continue;
|
|
@ -220,6 +228,7 @@ public class JobService {
|
|
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
|
params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
|
|
|
//往quartz框架添加任务
|
|
|
params.put("startTime", daybefore);
|
|
|
params.put("endTime", yesterday);
|
|
@ -266,7 +275,7 @@ public class JobService {
|
|
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
|
|
|
|
params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
|
|
|
//往quartz框架添加任务
|
|
|
params.put("startTime", daybefore);
|
|
|
params.put("endTime", yesterday);
|
|
@ -292,6 +301,7 @@ public class JobService {
|
|
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
|
params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
|
|
|
for (int i = 1; i <= day; i++) {
|
|
|
//往quartz框架添加任务
|
|
|
params.put("startTime", getYesterday(0 - i - 1));
|
|
@ -400,7 +410,7 @@ public class JobService {
|
|
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
|
|
|
|
params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
|
|
|
//往quartz框架添加任务
|
|
|
params.put("startTime", daybefore);
|
|
|
params.put("endTime", yesterday);
|
|
@ -436,6 +446,7 @@ public class JobService {
|
|
|
|
|
|
Map<String, String> params = new HashMap<String, String>();
|
|
|
params.put("jobConfig", wlyyJobConfigVO.getId());
|
|
|
params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
|
|
|
//往quartz框架添加任务
|
|
|
params.put("startTime", daybefore);
|
|
|
params.put("endTime", yesterday);
|
|
@ -467,4 +478,121 @@ public class JobService {
|
|
|
throw new Exception("已经停止");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**************************************按周或按月****************************************/
|
|
|
public void productWeekByDayToDay(String start, String end,String id) 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("日期参数错误");
|
|
|
}
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(startDate);
|
|
|
int a = calendar.get(Calendar.YEAR);
|
|
|
calendar.clear();
|
|
|
calendar.setTime(endDate);
|
|
|
int b = calendar.get(Calendar.YEAR);
|
|
|
|
|
|
int startWeek = DateUtil.week(startDate);
|
|
|
if(a!=b){
|
|
|
Date lastDate = DateUtil.getYearLast(a);
|
|
|
int lastWeek = DateUtil.week(lastDate);
|
|
|
for(int i=startWeek;i<=lastWeek;i++){
|
|
|
start = getDate(startDate ,i,2);
|
|
|
end = getDate(startDate ,i+1,1);
|
|
|
productDataByOneDay2(start,end,2,id);
|
|
|
}
|
|
|
startDate =lastDate;
|
|
|
}
|
|
|
startWeek = DateUtil.week(startDate);
|
|
|
int endWeek = DateUtil.week(endDate);
|
|
|
|
|
|
for(int i=startWeek;i<=endWeek;i++){
|
|
|
start = getDate(startDate ,i,2);
|
|
|
end = getDate(startDate ,i+1,1);
|
|
|
productDataByOneDay2(start,end,2,id);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void productMonthByDayToDay(String start, String end,String id) 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("日期参数错误");
|
|
|
}
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(startDate);
|
|
|
int a = calendar.get(Calendar.YEAR);
|
|
|
int a1 = calendar.get(Calendar.MONTH);
|
|
|
calendar.clear();
|
|
|
calendar.setTime(endDate);
|
|
|
int b = calendar.get(Calendar.YEAR);
|
|
|
int b1 = calendar.get(Calendar.MONTH);
|
|
|
|
|
|
if(a!=b){
|
|
|
for(int i=a1;i<=12;i++){
|
|
|
// start = getDate(startDate ,i,1)+" 00:00:00";
|
|
|
// end = getDate(startDate ,i,7)+" 59:59:59";
|
|
|
start = DateUtil.getFristDayOfMonth(startDate);
|
|
|
end = DateUtil.getLastDayOfMonth(startDate);
|
|
|
productDataByOneDay2(start,end,3,id);
|
|
|
}
|
|
|
a1=1;
|
|
|
calendar.clear();
|
|
|
calendar.set(Calendar.YEAR, b);
|
|
|
startDate = calendar.getTime();
|
|
|
}
|
|
|
for(int i=a1;i<=b1;i++){
|
|
|
start = DateUtil.getFristDayOfMonth(startDate);
|
|
|
end = DateUtil.getLastDayOfMonth(startDate);
|
|
|
productDataByOneDay2(start,end,3,id);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public void productDataByOneDay2(String start, String end,Integer incrementInterval,String id) throws Exception {
|
|
|
String condition = "";
|
|
|
if(!StringUtils.isEmpty(id)){
|
|
|
condition+=" and a.id in ("+id+") ";
|
|
|
}
|
|
|
if(incrementInterval!=null){
|
|
|
condition +=" and a.increment_interval ="+incrementInterval.intValue();
|
|
|
}
|
|
|
String sql = "select * from wlyy_job_config_new a where a.del='1' and a.id !=11 "+condition+" order by a.id asc";
|
|
|
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());
|
|
|
params.put("incrementInterval", wlyyJobConfigVO.getIncrementInterval()!=null?String.valueOf(wlyyJobConfigVO.getIncrementInterval()):"1");
|
|
|
//往quartz框架添加任务
|
|
|
params.put("startTime", start);
|
|
|
params.put("endTime", end);
|
|
|
|
|
|
for (int j = 1; j <= 2; j++) {
|
|
|
// if (Integer.valueOf(wlyyJobConfigVO.getId()) > 86 && j == 2) continue;
|
|
|
params.put("timeLevel", j + "");
|
|
|
if (!StringUtils.isEmpty(quartzJobConfig.getJobClass())) {
|
|
|
quartzHelper.startNow(getRightClass(quartzJobConfig), quartzJobConfig.getId() + UUID.randomUUID().toString().replace("-", ""), params);
|
|
|
Thread.sleep(sleepTime);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public String getDate(Date date ,int weekNum,int day){
|
|
|
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
cal.setTime(date);
|
|
|
cal.set(Calendar.WEEK_OF_YEAR, weekNum); // 设置为2016年的第10周
|
|
|
cal.set(Calendar.DAY_OF_WEEK, day); // 1表示周日,2表示周一,7表示周六
|
|
|
return sf.format(cal.getTime());
|
|
|
}
|
|
|
}
|