|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package com.xxl.job.admin.controller; |
|
|
|
|
|
|
|
|
|
import com.xxl.job.admin.core.cron.CronExpression; |
|
|
|
|
import com.xxl.job.admin.core.exception.XxlJobException; |
|
|
|
|
import com.xxl.job.admin.core.model.XxlJobGroup; |
|
|
|
|
import com.xxl.job.admin.core.model.XxlJobInfo; |
|
|
|
@ -14,6 +15,7 @@ import com.xxl.job.admin.service.XxlJobService; |
|
|
|
|
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.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.ui.Model; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
@ -22,10 +24,8 @@ import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Arrays; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.text.ParseException; |
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* index controller |
|
|
|
@ -141,5 +141,30 @@ public class JobInfoController { |
|
|
|
|
JobTriggerPoolHelper.trigger(id, TriggerTypeEnum.MANUAL, -1, null, executorParam); |
|
|
|
|
return ReturnT.SUCCESS; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping("/nextTriggerTime") |
|
|
|
|
@ResponseBody |
|
|
|
|
public ReturnT<List<String>> nextTriggerTime(String cron) { |
|
|
|
|
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); |
|
|
|
|
if (lastTime != null) { |
|
|
|
|
result.add(DateUtil.formatDateTime(lastTime)); |
|
|
|
|
} else { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
//
|
|
|
|
|
} |
|
|
|
|
if (result!=null && result.size()>0) { |
|
|
|
|
return new ReturnT<List<String>>(result); |
|
|
|
|
} else { |
|
|
|
|
return new ReturnT<List<String>>(ReturnT.FAIL_CODE, I18nUtil.getString("jobinfo_field_cron_unvalid")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|