xueli.xue 10 年 前
コミット
51259d8c8e

+ 4 - 4
xxl-job-admin/src/main/java/com/xxl/controller/IndexController.java ファイルの表示

1
 package com.xxl.controller;
1
 package com.xxl.controller;
2
 
2
 
3
-import java.util.Set;
3
+import java.util.List;
4
+import java.util.Map;
4
 
5
 
5
-import org.quartz.JobKey;
6
 import org.springframework.stereotype.Controller;
6
 import org.springframework.stereotype.Controller;
7
 import org.springframework.ui.Model;
7
 import org.springframework.ui.Model;
8
 import org.springframework.web.bind.annotation.RequestMapping;
8
 import org.springframework.web.bind.annotation.RequestMapping;
16
 	
16
 	
17
 	@RequestMapping("index")
17
 	@RequestMapping("index")
18
 	public String index(Model model) {
18
 	public String index(Model model) {
19
-		Set<JobKey> list = DynamicSchedulerUtil.getJobKeys();
20
-		model.addAttribute("jobList", list);
19
+		List<Map<String, Object>> jobList = DynamicSchedulerUtil.getJobList();
20
+		model.addAttribute("jobList", jobList);
21
 		return "job/index";
21
 		return "job/index";
22
 	}
22
 	}
23
 	
23
 	

+ 21 - 9
xxl-job-admin/src/main/java/com/xxl/quartz/DynamicSchedulerUtil.java ファイルの表示

1
 package com.xxl.quartz;
1
 package com.xxl.quartz;
2
 
2
 
3
+import java.util.ArrayList;
3
 import java.util.Date;
4
 import java.util.Date;
5
+import java.util.HashMap;
6
+import java.util.List;
4
 import java.util.Map;
7
 import java.util.Map;
5
 import java.util.Set;
8
 import java.util.Set;
6
 
9
 
38
     }
41
     }
39
 	
42
 	
40
 	// getJobKeys
43
 	// getJobKeys
41
-	public static Set<JobKey> getJobKeys(){
44
+	public static List<Map<String, Object>> getJobList(){
45
+		List<Map<String, Object>> jobList = new ArrayList<Map<String,Object>>();
46
+		
42
 		try {
47
 		try {
43
 			String groupName = scheduler.getJobGroupNames().get(0);
48
 			String groupName = scheduler.getJobGroupNames().get(0);
44
-			return scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName));
49
+			Set<JobKey> jobKeys = scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName));
50
+			if (jobKeys!=null && jobKeys.size()>0) {
51
+				for (JobKey jobKey : jobKeys) {
52
+			        TriggerKey triggerKey = TriggerKey.triggerKey(jobKey.getName(), Scheduler.DEFAULT_GROUP);
53
+			        Trigger trigger = scheduler.getTrigger(triggerKey);
54
+			        JobDetail jobDetail = scheduler.getJobDetail(jobKey);
55
+			        Map<String, Object> jobMap = new HashMap<String, Object>();
56
+			        jobMap.put("TriggerKey", triggerKey);
57
+			        jobMap.put("Trigger", trigger);
58
+			        jobMap.put("JobDetail", jobDetail);
59
+			        jobList.add(jobMap);
60
+				}
61
+			}
62
+			
45
 		} catch (SchedulerException e) {
63
 		} catch (SchedulerException e) {
46
 			e.printStackTrace();
64
 			e.printStackTrace();
47
 			return null;
65
 			return null;
48
 		}
66
 		}
49
-	}
50
-	
51
-	public static void getJobDetail(String triggerKeyName){
52
-		// TriggerKey : name + group
53
-    	String group = Scheduler.DEFAULT_GROUP;
54
-        TriggerKey triggerKey = TriggerKey.triggerKey(triggerKeyName, group);
55
-        
67
+		return jobList;
56
 	}
68
 	}
57
 
69
 
58
 	// addJob 新增
70
 	// addJob 新增

+ 57 - 14
xxl-job-admin/src/main/webapp/WEB-INF/template/job/index.ftl ファイルの表示

4
   	<title>调度中心</title>
4
   	<title>调度中心</title>
5
   	<#import "/common/common.macro.ftl" as netCommon>
5
   	<#import "/common/common.macro.ftl" as netCommon>
6
 	<@netCommon.commonStyle />
6
 	<@netCommon.commonStyle />
7
+	<!-- DataTables -->
8
+  	<link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.css">
9
+  
7
 </head>
10
 </head>
8
 <body class="hold-transition skin-blue sidebar-mini">
11
 <body class="hold-transition skin-blue sidebar-mini">
9
 <div class="wrapper">
12
 <div class="wrapper">
22
 				<li class="active">使用教程</li>
25
 				<li class="active">使用教程</li>
23
 			</ol>
26
 			</ol>
24
 		</section>
27
 		</section>
25
-
28
+		
26
 		<!-- Main content -->
29
 		<!-- Main content -->
27
-		<section class="content">
28
-            <div class="callout callout-info">
29
-				<h4>在线任务:</h4>
30
-				<#if jobList?exists && jobList?size gt 0>
31
-				<#list jobList as item>
32
-				<p>${item}</p>
33
-				</#list>
34
-				</#if>
35
-            </div>
36
-            
37
-		</section>
38
-		<!-- /.content -->
30
+	    <section class="content">
31
+			<div class="row">
32
+				<div class="col-xs-12">
33
+					<div class="box">
34
+			            <div class="box-header"><h3 class="box-title">任务列表</h3></div>
35
+			            <div class="box-body">
36
+			              	<table id="example1" class="table table-bordered table-striped">
37
+				                <thead>
38
+					            	<tr>
39
+					                	<th>任务ID</th>
40
+					                  	<th>cron</th>
41
+					                  	<th>Job类路径</th>
42
+					                  	<th>简介</th>
43
+					                  	<th>操作</th>
44
+					                </tr>
45
+				                </thead>
46
+				                <tbody>
47
+			                		<#if jobList?exists && jobList?size gt 0>
48
+									<#list jobList as item>
49
+									<tr>
50
+					            		<td>${item['TriggerKey'].name}</td>
51
+					                  	<td>${item['Trigger'].cronExpression}</td>
52
+					                  	<td>${item['JobDetail'].jobClass}</td>
53
+					                  	<td>-</td>
54
+					                  	<td>X</td>
55
+					                </tr>
56
+									</#list>
57
+									</#if>
58
+				                </tbody>
59
+				                <tfoot>
60
+					            	<tr>
61
+					                  	<th>任务ID</th>
62
+					                  	<th>cron</th>
63
+					                  	<th>Job类路径</th>
64
+					                  	<th>简介</th>
65
+					                  	<th>操作</th>
66
+					                </tr>
67
+				                </tfoot>
68
+							</table>
69
+						</div>
70
+					</div>
71
+				</div>
72
+			</div>
73
+	    </section>
39
 	</div>
74
 	</div>
40
-	<!-- /.content-wrapper -->
41
 	
75
 	
42
 	<!-- footer -->
76
 	<!-- footer -->
43
 	<@netCommon.commonFooter />
77
 	<@netCommon.commonFooter />
45
 	<@netCommon.commonControl />
79
 	<@netCommon.commonControl />
46
 </div>
80
 </div>
47
 <@netCommon.commonScript />
81
 <@netCommon.commonScript />
82
+<!-- DataTables -->
83
+<script src="${request.contextPath}/static/adminlte/plugins/datatables/jquery.dataTables.min.js"></script>
84
+<script src="${request.contextPath}/static/adminlte/plugins/datatables/dataTables.bootstrap.min.js"></script>
85
+<!-- page script -->
86
+<script>
87
+  $(function () {
88
+		$("#example1").DataTable();
89
+  });
90
+</script>
48
 </body>
91
 </body>
49
 </html>
92
 </html>