|
|
@ -6,18 +6,17 @@ import com.xxl.job.admin.core.util.I18nUtil;
|
|
|
|
import com.xxl.job.admin.service.XxlJobService;
|
|
|
|
import com.xxl.job.admin.service.XxlJobService;
|
|
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
|
|
import com.xxl.job.core.biz.model.ReturnT;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import org.quartz.CronExpression;
|
|
|
|
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
|
|
|
import org.springframework.beans.propertyeditors.CustomDateEditor;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
import org.springframework.web.bind.WebDataBinder;
|
|
|
|
import org.springframework.web.bind.WebDataBinder;
|
|
|
|
import org.springframework.web.bind.annotation.InitBinder;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
@ -100,6 +99,29 @@ public class IndexController {
|
|
|
|
return "help";
|
|
|
|
return "help";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
|
|
|
|
@RequestMapping("/cron-preview")
|
|
|
|
|
|
|
|
@PermessionLimit(limit=false)
|
|
|
|
|
|
|
|
public ReturnT<String[]> cronPreview(HttpServletResponse response, String expression, @RequestParam(defaultValue = "5")int times){
|
|
|
|
|
|
|
|
if (times <= 0) times = 5;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
CronExpression exp = new CronExpression(expression);
|
|
|
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
Date d = new Date();
|
|
|
|
|
|
|
|
// 循环得到接下来n此的触发时间点,供验证
|
|
|
|
|
|
|
|
String[] arr = new String[times];
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while (i < times) {
|
|
|
|
|
|
|
|
d = exp.getNextValidTimeAfter(d);
|
|
|
|
|
|
|
|
arr[i] = df.format(d);
|
|
|
|
|
|
|
|
i ++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return new ReturnT<String[]>(arr);
|
|
|
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
|
|
|
return new ReturnT<String[]>(500, I18nUtil.getString("jobinfo_field_cron_unvalid"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@InitBinder
|
|
|
|
@InitBinder
|
|
|
|
public void initBinder(WebDataBinder binder) {
|
|
|
|
public void initBinder(WebDataBinder binder) {
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|