|
|
|
@ -1,7 +1,6 @@ |
|
|
|
|
package com.xxl.job.controller; |
|
|
|
|
|
|
|
|
|
import java.text.ParseException; |
|
|
|
|
import java.util.Calendar; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.List; |
|
|
|
@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
|
|
|
|
|
import com.xxl.job.core.constant.Constants.JobGroupEnum; |
|
|
|
|
import com.xxl.job.core.model.ReturnT; |
|
|
|
|
import com.xxl.job.core.model.XxlJobLog; |
|
|
|
|
import com.xxl.job.dao.IXxlJobLogDao; |
|
|
|
@ -32,33 +32,9 @@ public class JobLogController { |
|
|
|
|
@Resource |
|
|
|
|
public IXxlJobLogDao xxlJobLogDao; |
|
|
|
|
|
|
|
|
|
@RequestMapping("/save") |
|
|
|
|
@ResponseBody |
|
|
|
|
public ReturnT<String> triggerLog(int triggerLogId, String status, String msg) { |
|
|
|
|
XxlJobLog log = xxlJobLogDao.load(triggerLogId); |
|
|
|
|
if (log!=null) { |
|
|
|
|
log.setHandleTime(new Date()); |
|
|
|
|
log.setHandleStatus(status); |
|
|
|
|
log.setHandleMsg(msg); |
|
|
|
|
xxlJobLogDao.updateHandleInfo(log); |
|
|
|
|
return ReturnT.SUCCESS; |
|
|
|
|
} |
|
|
|
|
return ReturnT.FAIL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping |
|
|
|
|
public String index(Model model, String jobName, String filterTime) { |
|
|
|
|
|
|
|
|
|
// 默认filterTime
|
|
|
|
|
Calendar todayz = Calendar.getInstance(); |
|
|
|
|
todayz.set(Calendar.HOUR_OF_DAY, 0); |
|
|
|
|
todayz.set(Calendar.MINUTE, 0); |
|
|
|
|
todayz.set(Calendar.SECOND, 0); |
|
|
|
|
model.addAttribute("triggerTimeStart", todayz.getTime()); |
|
|
|
|
model.addAttribute("triggerTimeEnd", Calendar.getInstance().getTime()); |
|
|
|
|
|
|
|
|
|
model.addAttribute("jobName", jobName); |
|
|
|
|
model.addAttribute("filterTime", filterTime); |
|
|
|
|
public String index(Model model) { |
|
|
|
|
model.addAttribute("JobGroupList", JobGroupEnum.values()); |
|
|
|
|
return "joblog/index"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -66,7 +42,8 @@ public class JobLogController { |
|
|
|
|
@ResponseBody |
|
|
|
|
public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int start, |
|
|
|
|
@RequestParam(required = false, defaultValue = "10") int length, |
|
|
|
|
String jobName, String filterTime) { |
|
|
|
|
String jobGroup, String jobName, String filterTime) { |
|
|
|
|
|
|
|
|
|
// parse param
|
|
|
|
|
Date triggerTimeStart = null; |
|
|
|
|
Date triggerTimeEnd = null; |
|
|
|
@ -74,24 +51,36 @@ public class JobLogController { |
|
|
|
|
String[] temp = filterTime.split(" - "); |
|
|
|
|
if (temp!=null && temp.length == 2) { |
|
|
|
|
try { |
|
|
|
|
triggerTimeEnd = DateUtils.parseDate(temp[0], new String[]{"yyyy-MM-dd HH:mm:ss"}); |
|
|
|
|
triggerTimeStart = DateUtils.parseDate(temp[0], new String[]{"yyyy-MM-dd HH:mm:ss"}); |
|
|
|
|
triggerTimeEnd = DateUtils.parseDate(temp[1], new String[]{"yyyy-MM-dd HH:mm:ss"}); |
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} catch (ParseException e) { } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// page query
|
|
|
|
|
List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobName, triggerTimeStart, triggerTimeEnd); |
|
|
|
|
int list_count = xxlJobLogDao.pageListCount(start, length, jobName, triggerTimeStart, triggerTimeEnd); |
|
|
|
|
List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobGroup, jobName, triggerTimeStart, triggerTimeEnd); |
|
|
|
|
int list_count = xxlJobLogDao.pageListCount(start, length, jobGroup, jobName, triggerTimeStart, triggerTimeEnd); |
|
|
|
|
|
|
|
|
|
// package result
|
|
|
|
|
Map<String, Object> maps = new HashMap<String, Object>(); |
|
|
|
|
maps.put("recordsTotal", list_count); // 总记录数
|
|
|
|
|
maps.put("recordsFiltered", list_count);// 过滤后的总记录数
|
|
|
|
|
maps.put("data", list); // 分页列表
|
|
|
|
|
maps.put("recordsTotal", list_count); // 总记录数
|
|
|
|
|
maps.put("recordsFiltered", list_count); // 过滤后的总记录数
|
|
|
|
|
maps.put("data", list); // 分页列表
|
|
|
|
|
return maps; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping("/save") |
|
|
|
|
@ResponseBody |
|
|
|
|
public ReturnT<String> triggerLog(int triggerLogId, String status, String msg) { |
|
|
|
|
XxlJobLog log = xxlJobLogDao.load(triggerLogId); |
|
|
|
|
if (log!=null) { |
|
|
|
|
log.setHandleTime(new Date()); |
|
|
|
|
log.setHandleStatus(status); |
|
|
|
|
log.setHandleMsg(msg); |
|
|
|
|
xxlJobLogDao.updateHandleInfo(log); |
|
|
|
|
return ReturnT.SUCCESS; |
|
|
|
|
} |
|
|
|
|
return ReturnT.FAIL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|