|
|
|
@ -8,6 +8,7 @@ import com.xxl.job.admin.core.model.XxlJobUser; |
|
|
|
|
import com.xxl.job.admin.core.route.ExecutorRouteStrategyEnum; |
|
|
|
|
import com.xxl.job.admin.core.scheduler.MisfireStrategyEnum; |
|
|
|
|
import com.xxl.job.admin.core.scheduler.ScheduleTypeEnum; |
|
|
|
|
import com.xxl.job.admin.core.thread.JobScheduleHelper; |
|
|
|
|
import com.xxl.job.admin.core.thread.JobTriggerPoolHelper; |
|
|
|
|
import com.xxl.job.admin.core.trigger.TriggerTypeEnum; |
|
|
|
|
import com.xxl.job.admin.core.util.I18nUtil; |
|
|
|
@ -18,6 +19,8 @@ import com.xxl.job.core.biz.model.ReturnT; |
|
|
|
|
import com.xxl.job.core.enums.ExecutorBlockStrategyEnum; |
|
|
|
|
import com.xxl.job.core.glue.GlueTypeEnum; |
|
|
|
|
import com.xxl.job.core.util.DateUtil; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.ui.Model; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
@ -36,6 +39,7 @@ import java.util.*; |
|
|
|
|
@Controller |
|
|
|
|
@RequestMapping("/jobinfo") |
|
|
|
|
public class JobInfoController { |
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(JobInfoController.class); |
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
|
private XxlJobGroupDao xxlJobGroupDao; |
|
|
|
@ -148,23 +152,29 @@ public class JobInfoController { |
|
|
|
|
|
|
|
|
|
@RequestMapping("/nextTriggerTime") |
|
|
|
|
@ResponseBody |
|
|
|
|
public ReturnT<List<String>> nextTriggerTime(String cron) { |
|
|
|
|
public ReturnT<List<String>> nextTriggerTime(String scheduleType, String scheduleConf) { |
|
|
|
|
|
|
|
|
|
XxlJobInfo paramXxlJobInfo = new XxlJobInfo(); |
|
|
|
|
paramXxlJobInfo.setScheduleType(scheduleType); |
|
|
|
|
paramXxlJobInfo.setScheduleConf(scheduleConf); |
|
|
|
|
|
|
|
|
|
List<String> result = new ArrayList<>(); |
|
|
|
|
try { |
|
|
|
|
CronExpression cronExpression = new CronExpression(cron); |
|
|
|
|
Date lastTime = new Date(); |
|
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
|
|
lastTime = cronExpression.getNextValidTimeAfter(lastTime); |
|
|
|
|
lastTime = JobScheduleHelper.generateNextValidTime(paramXxlJobInfo, lastTime); |
|
|
|
|
if (lastTime != null) { |
|
|
|
|
result.add(DateUtil.formatDateTime(lastTime)); |
|
|
|
|
} else { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
return new ReturnT<List<String>>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid")); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
logger.error(e.getMessage(), e); |
|
|
|
|
return new ReturnT<List<String>>(ReturnT.FAIL_CODE, (I18nUtil.getString("schedule_type")+I18nUtil.getString("system_unvalid")) + e.getMessage()); |
|
|
|
|
} |
|
|
|
|
return new ReturnT<List<String>>(result); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|