diff --git a/xxl-job-admin/src/main/java/com/xxl/controller/IndexController.java b/xxl-job-admin/src/main/java/com/xxl/controller/IndexController.java index c0d061ca..d7f21bdf 100644 --- a/xxl-job-admin/src/main/java/com/xxl/controller/IndexController.java +++ b/xxl-job-admin/src/main/java/com/xxl/controller/IndexController.java @@ -1,8 +1,8 @@ package com.xxl.controller; -import java.util.Set; +import java.util.List; +import java.util.Map; -import org.quartz.JobKey; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; @@ -16,8 +16,8 @@ public class IndexController { @RequestMapping("index") public String index(Model model) { - Set list = DynamicSchedulerUtil.getJobKeys(); - model.addAttribute("jobList", list); + List> jobList = DynamicSchedulerUtil.getJobList(); + model.addAttribute("jobList", jobList); return "job/index"; } diff --git a/xxl-job-admin/src/main/java/com/xxl/quartz/DynamicSchedulerUtil.java b/xxl-job-admin/src/main/java/com/xxl/quartz/DynamicSchedulerUtil.java index 537ccf3b..d7d3a7b4 100644 --- a/xxl-job-admin/src/main/java/com/xxl/quartz/DynamicSchedulerUtil.java +++ b/xxl-job-admin/src/main/java/com/xxl/quartz/DynamicSchedulerUtil.java @@ -1,6 +1,9 @@ package com.xxl.quartz; +import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; @@ -38,21 +41,30 @@ public final class DynamicSchedulerUtil implements InitializingBean { } // getJobKeys - public static Set getJobKeys(){ + public static List> getJobList(){ + List> jobList = new ArrayList>(); + try { String groupName = scheduler.getJobGroupNames().get(0); - return scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName)); + Set jobKeys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName)); + if (jobKeys!=null && jobKeys.size()>0) { + for (JobKey jobKey : jobKeys) { + TriggerKey triggerKey = TriggerKey.triggerKey(jobKey.getName(), Scheduler.DEFAULT_GROUP); + Trigger trigger = scheduler.getTrigger(triggerKey); + JobDetail jobDetail = scheduler.getJobDetail(jobKey); + Map jobMap = new HashMap(); + jobMap.put("TriggerKey", triggerKey); + jobMap.put("Trigger", trigger); + jobMap.put("JobDetail", jobDetail); + jobList.add(jobMap); + } + } + } catch (SchedulerException e) { e.printStackTrace(); return null; } - } - - public static void getJobDetail(String triggerKeyName){ - // TriggerKey : name + group - String group = Scheduler.DEFAULT_GROUP; - TriggerKey triggerKey = TriggerKey.triggerKey(triggerKeyName, group); - + return jobList; } // addJob 新增 diff --git a/xxl-job-admin/src/main/webapp/WEB-INF/template/job/index.ftl b/xxl-job-admin/src/main/webapp/WEB-INF/template/job/index.ftl index 5b3b75a1..0b318205 100644 --- a/xxl-job-admin/src/main/webapp/WEB-INF/template/job/index.ftl +++ b/xxl-job-admin/src/main/webapp/WEB-INF/template/job/index.ftl @@ -29,7 +29,10 @@

在线任务:

<#if jobList?exists && jobList?size gt 0> <#list jobList as item> -

${item}

+

${item['TriggerKey']}

+

${item['Trigger']}

+

${item['Trigger'].cronExpression}

+

${item['JobDetail']}