Selaa lähdekoodia

调度报表优化,支持时间区间筛选;

xuxueli 8 vuotta sitten
vanhempi
commit
0e1ef7f3ed

+ 5 - 5
doc/XXL-JOB官方文档.md Näytä tiedosto

1057
 - 9、任务注解调整为 “@JobHandler”,与任务注解统一;
1057
 - 9、任务注解调整为 “@JobHandler”,与任务注解统一;
1058
 - 10、执行器端口支持随机生成(小于等于0时),避免端口定义冲突;
1058
 - 10、执行器端口支持随机生成(小于等于0时),避免端口定义冲突;
1059
 - 11、任务Cron长度扩展支持至128位;
1059
 - 11、任务Cron长度扩展支持至128位;
1060
+- 12、调度报表优化,支持时间区间筛选;
1060
 
1061
 
1061
 ### TODO LIST
1062
 ### TODO LIST
1062
 - 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限;
1063
 - 1、任务权限管理:执行器为粒度分配权限,核心操作校验权限;
1075
 - 14、脚本任务 Shell、Python和Nodejs,如何友好获取分片参数;
1076
 - 14、脚本任务 Shell、Python和Nodejs,如何友好获取分片参数;
1076
 - 15、Bean模式任务,JobHandler自动从执行器中查询展示为下拉框,选择后自动填充任务名称等属性;
1077
 - 15、Bean模式任务,JobHandler自动从执行器中查询展示为下拉框,选择后自动填充任务名称等属性;
1077
 - 16、任务告警邮件优化,调整为表格形式;
1078
 - 16、任务告警邮件优化,调整为表格形式;
1078
-- 17、任务报表,支持时间筛选;
1079
-- 18、JobHandler提供 init/destroy 方法,支持自定义任务线程销毁逻辑;
1080
-- 19、cron表达式的最大长度调整,兼容复杂类型cron;
1081
-- 20、执行器回调地址/日志地址格式兼容,是否已"/"结尾均支持;
1082
-- 21、任务单机多线程:提升任务单机并行处理能力;
1079
+- 17、JobHandler提供 init/destroy 方法,支持自定义任务线程销毁逻辑;
1080
+- 18、cron表达式的最大长度调整,兼容复杂类型cron;
1081
+- 19、执行器回调地址/日志地址格式兼容,是否已"/"结尾均支持;
1082
+- 20、任务单机多线程:提升任务单机并行处理能力;
1083
 
1083
 
1084
 
1084
 
1085
 ## 七、其他
1085
 ## 七、其他

+ 14 - 2
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/IndexController.java Näytä tiedosto

6
 import com.xxl.job.admin.service.XxlJobService;
6
 import com.xxl.job.admin.service.XxlJobService;
7
 import com.xxl.job.core.biz.model.ReturnT;
7
 import com.xxl.job.core.biz.model.ReturnT;
8
 import org.apache.commons.lang.StringUtils;
8
 import org.apache.commons.lang.StringUtils;
9
+import org.springframework.beans.propertyeditors.CustomDateEditor;
9
 import org.springframework.stereotype.Controller;
10
 import org.springframework.stereotype.Controller;
10
 import org.springframework.ui.Model;
11
 import org.springframework.ui.Model;
12
+import org.springframework.web.bind.WebDataBinder;
13
+import org.springframework.web.bind.annotation.InitBinder;
11
 import org.springframework.web.bind.annotation.RequestMapping;
14
 import org.springframework.web.bind.annotation.RequestMapping;
12
 import org.springframework.web.bind.annotation.RequestMethod;
15
 import org.springframework.web.bind.annotation.RequestMethod;
13
 import org.springframework.web.bind.annotation.ResponseBody;
16
 import org.springframework.web.bind.annotation.ResponseBody;
15
 import javax.annotation.Resource;
18
 import javax.annotation.Resource;
16
 import javax.servlet.http.HttpServletRequest;
19
 import javax.servlet.http.HttpServletRequest;
17
 import javax.servlet.http.HttpServletResponse;
20
 import javax.servlet.http.HttpServletResponse;
21
+import java.text.SimpleDateFormat;
22
+import java.util.Date;
18
 import java.util.Map;
23
 import java.util.Map;
19
 
24
 
20
 /**
25
 /**
38
 
43
 
39
     @RequestMapping("/triggerChartDate")
44
     @RequestMapping("/triggerChartDate")
40
 	@ResponseBody
45
 	@ResponseBody
41
-	public ReturnT<Map<String, Object>> triggerChartDate() {
42
-        ReturnT<Map<String, Object>> triggerChartDate = xxlJobService.triggerChartDate();
46
+	public ReturnT<Map<String, Object>> triggerChartDate(Date startDate, Date endDate) {
47
+        ReturnT<Map<String, Object>> triggerChartDate = xxlJobService.triggerChartDate(startDate, endDate);
43
         return triggerChartDate;
48
         return triggerChartDate;
44
     }
49
     }
45
 	
50
 	
91
 
96
 
92
 		return "help";
97
 		return "help";
93
 	}
98
 	}
99
+
100
+	@InitBinder
101
+	public void initBinder(WebDataBinder binder) {
102
+		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
103
+		dateFormat.setLenient(false);
104
+		binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
105
+	}
94
 	
106
 	
95
 }
107
 }

+ 2 - 1
xxl-job-admin/src/main/java/com/xxl/job/admin/service/XxlJobService.java Näytä tiedosto

4
 import com.xxl.job.admin.core.model.XxlJobInfo;
4
 import com.xxl.job.admin.core.model.XxlJobInfo;
5
 import com.xxl.job.core.biz.model.ReturnT;
5
 import com.xxl.job.core.biz.model.ReturnT;
6
 
6
 
7
+import java.util.Date;
7
 import java.util.Map;
8
 import java.util.Map;
8
 
9
 
9
 /**
10
 /**
29
 
30
 
30
 	public Map<String,Object> dashboardInfo();
31
 	public Map<String,Object> dashboardInfo();
31
 
32
 
32
-	public ReturnT<Map<String,Object>> triggerChartDate();
33
+	public ReturnT<Map<String,Object>> triggerChartDate(Date startDate, Date endDate);
33
 
34
 
34
 }
35
 }

+ 3 - 6
xxl-job-admin/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java Näytä tiedosto

310
 	}
310
 	}
311
 
311
 
312
 	@Override
312
 	@Override
313
-	public ReturnT<Map<String, Object>> triggerChartDate() {
314
-		Date from = DateUtils.addDays(new Date(), -30);
315
-		Date to = new Date();
316
-
313
+	public ReturnT<Map<String, Object>> triggerChartDate(Date startDate, Date endDate) {
317
 		List<String> triggerDayList = new ArrayList<String>();
314
 		List<String> triggerDayList = new ArrayList<String>();
318
 		List<Integer> triggerDayCountSucList = new ArrayList<Integer>();
315
 		List<Integer> triggerDayCountSucList = new ArrayList<Integer>();
319
 		List<Integer> triggerDayCountFailList = new ArrayList<Integer>();
316
 		List<Integer> triggerDayCountFailList = new ArrayList<Integer>();
320
 		int triggerCountSucTotal = 0;
317
 		int triggerCountSucTotal = 0;
321
 		int triggerCountFailTotal = 0;
318
 		int triggerCountFailTotal = 0;
322
 
319
 
323
-		List<Map<String, Object>> triggerCountMapAll = xxlJobLogDao.triggerCountByDay(from, to, -1);
324
-		List<Map<String, Object>> triggerCountMapSuc = xxlJobLogDao.triggerCountByDay(from, to, ReturnT.SUCCESS_CODE);
320
+		List<Map<String, Object>> triggerCountMapAll = xxlJobLogDao.triggerCountByDay(startDate, endDate, -1);
321
+		List<Map<String, Object>> triggerCountMapSuc = xxlJobLogDao.triggerCountByDay(startDate, endDate, ReturnT.SUCCESS_CODE);
325
 		if (CollectionUtils.isNotEmpty(triggerCountMapAll)) {
322
 		if (CollectionUtils.isNotEmpty(triggerCountMapAll)) {
326
 			for (Map<String, Object> item: triggerCountMapAll) {
323
 			for (Map<String, Object> item: triggerCountMapAll) {
327
 				String day = String.valueOf(item.get("triggerDay"));
324
 				String day = String.valueOf(item.get("triggerDay"));

+ 21 - 7
xxl-job-admin/src/main/webapp/WEB-INF/template/index.ftl Näytä tiedosto

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
+    <!-- daterangepicker -->
8
+    <link rel="stylesheet" href="${request.contextPath}/static/adminlte/plugins/daterangepicker/daterangepicker.css">
7
 </head>
9
 </head>
8
 <body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">
10
 <body class="hold-transition skin-blue sidebar-mini <#if cookieMap?exists && "off" == cookieMap["xxljob_adminlte_settings"].value >sidebar-collapse</#if> ">
9
 <div class="wrapper">
11
 <div class="wrapper">
43
                             <div class="progress">
45
                             <div class="progress">
44
                                 <div class="progress-bar" style="width: 100%"></div>
46
                                 <div class="progress-bar" style="width: 100%"></div>
45
                             </div>
47
                             </div>
46
-                            <span class="progress-description">系统中配置的任务数量</span>
48
+                            <span class="progress-description">调度中心运行的任务数量</span>
47
                         </div>
49
                         </div>
48
                     </div>
50
                     </div>
49
                 </div>
51
                 </div>
82
                             <div class="progress">
84
                             <div class="progress">
83
                                 <div class="progress-bar" style="width: 100%"></div>
85
                                 <div class="progress-bar" style="width: 100%"></div>
84
                             </div>
86
                             </div>
85
-                            <span class="progress-description">心跳检测成功的执行器机器数量</span>
87
+                            <span class="progress-description">调度中心注册发现的执行器机器数量</span>
86
                         </div>
88
                         </div>
87
                     </div>
89
                     </div>
88
                 </div>
90
                 </div>
94
                 <div class="col-md-12">
96
                 <div class="col-md-12">
95
                     <div class="box">
97
                     <div class="box">
96
                         <div class="box-header with-border">
98
                         <div class="box-header with-border">
97
-                            <h3 class="box-title">调度报表(一月之内)</h3>
99
+                            <h3 class="box-title">调度报表</h3>
98
                             <#--<input type="text" class="form-control" id="filterTime" readonly >-->
100
                             <#--<input type="text" class="form-control" id="filterTime" readonly >-->
101
+
102
+                            <!-- tools box -->
103
+                            <div class="pull-right box-tools">
104
+                                <button type="button" class="btn btn-primary btn-sm daterange pull-right" data-toggle="tooltip" id="filterTime" >
105
+                                    <i class="fa fa-calendar"></i>
106
+                                </button>
107
+                                <#--<button type="button" class="btn btn-primary btn-sm pull-right" data-widget="collapse" data-toggle="tooltip" title="" style="margin-right: 5px;" data-original-title="Collapse">
108
+                                    <i class="fa fa-minus"></i>
109
+                                </button>-->
110
+                            </div>
111
+                            <!-- /. tools -->
112
+
99
                         </div>
113
                         </div>
100
                         <div class="box-body">
114
                         <div class="box-body">
101
                             <div class="row">
115
                             <div class="row">
113
                 </div>
127
                 </div>
114
             </div>
128
             </div>
115
 
129
 
116
-
117
 		</section>
130
 		</section>
118
 		<!-- /.content -->
131
 		<!-- /.content -->
119
 	</div>
132
 	</div>
123
 	<@netCommon.commonFooter />
136
 	<@netCommon.commonFooter />
124
 </div>
137
 </div>
125
 <@netCommon.commonScript />
138
 <@netCommon.commonScript />
126
-<#--<script src="${request.contextPath}/static/adminlte/plugins/daterangepicker/moment.min.js"></script>
127
-<script src="${request.contextPath}/static/adminlte/plugins/daterangepicker/daterangepicker.js"></script>-->
139
+<!-- daterangepicker -->
140
+<script src="${request.contextPath}/static/adminlte/plugins/daterangepicker/moment.min.js"></script>
141
+<script src="${request.contextPath}/static/adminlte/plugins/daterangepicker/daterangepicker.js"></script>
142
+<#-- echarts -->
128
 <script src="${request.contextPath}/static/plugins/echarts/echarts.common.min.js"></script>
143
 <script src="${request.contextPath}/static/plugins/echarts/echarts.common.min.js"></script>
129
 <script src="${request.contextPath}/static/js/index.js"></script>
144
 <script src="${request.contextPath}/static/js/index.js"></script>
130
-
131
 </body>
145
 </body>
132
 </html>
146
 </html>

+ 64 - 53
xxl-job-admin/src/main/webapp/static/js/index.js Näytä tiedosto

5
 
5
 
6
 $(function () {
6
 $(function () {
7
 
7
 
8
+    // 过滤时间
9
+    var _startDate = moment().subtract(1, 'months');
10
+    var _endDate = moment();
11
+    $('#filterTime').daterangepicker({
12
+        autoApply:false,
13
+        singleDatePicker:false,
14
+        showDropdowns:false,        // 是否显示年月选择条件
15
+        timePicker: true, 			// 是否显示小时和分钟选择条件
16
+        timePickerIncrement: 10, 	// 时间的增量,单位为分钟
17
+        timePicker24Hour : true,
18
+        opens : 'left', //日期选择框的弹出位置
19
+        ranges: {
20
+            //'最近1小时': [moment().subtract(1, 'hours'), moment()],
21
+            '今日': [moment().startOf('day'), moment().endOf('day')],
22
+            '昨日': [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')],
23
+            '最近7日': [moment().subtract(7, 'days'), moment()],
24
+            '最近30日': [moment().subtract(1, 'months'), moment()],
25
+            '本月': [moment().startOf('month'), moment().endOf('month')],
26
+            '上个月': [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')]
27
+        },
28
+        locale : {
29
+            format: 'YYYY-MM-DD HH:mm:ss',
30
+            separator : ' - ',
31
+            customRangeLabel : '自定义',
32
+            applyLabel : '确定',
33
+            cancelLabel : '取消',
34
+            fromLabel : '起始时间',
35
+            toLabel : '结束时间',
36
+            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
37
+            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月' ],
38
+            firstDay : 1
39
+        },
40
+        startDate:_startDate,
41
+        endDate: _endDate
42
+    }, function (start, end, label) {
43
+        freshChartDate(start, end);
44
+    });
45
+    freshChartDate(_startDate, _endDate);
46
+
8
     /**
47
     /**
48
+     * 刷新报表
9
      *
49
      *
50
+     * @param startDate
51
+     * @param endDate
10
      */
52
      */
11
-    $.ajax({
12
-        type : 'POST',
13
-        url : base_url + '/triggerChartDate',
14
-        data : {        },
15
-        dataType : "json",
16
-        success : function(data){
17
-            if (data.code == 200) {
18
-                lineChartInit(data)
19
-                pieChartInit(data);
20
-            } else {
21
-                layer.open({
22
-                    title: '系统提示',
23
-                    content: (data.msg || '调度报表数据加载异常'),
24
-                    icon: '2'
25
-                });
53
+    function freshChartDate(startDate, endDate) {
54
+        $.ajax({
55
+            type : 'POST',
56
+            url : base_url + '/triggerChartDate',
57
+            data : {
58
+                'startDate':startDate.format('YYYY-MM-DD HH:mm:ss'),
59
+                'endDate':endDate.format('YYYY-MM-DD HH:mm:ss')
60
+            },
61
+            dataType : "json",
62
+            success : function(data){
63
+                if (data.code == 200) {
64
+                    lineChartInit(data)
65
+                    pieChartInit(data);
66
+                } else {
67
+                    layer.open({
68
+                        title: '系统提示',
69
+                        content: (data.msg || '调度报表数据加载异常'),
70
+                        icon: '2'
71
+                    });
72
+                }
26
             }
73
             }
27
-        }
28
-    });
29
-
30
-
74
+        });
75
+    }
31
 
76
 
32
     /**
77
     /**
33
      * 折线图
78
      * 折线图
151
         pieChart.setOption(option);
196
         pieChart.setOption(option);
152
     }
197
     }
153
 
198
 
154
-    // 过滤时间
155
-    /*$('#filterTime').daterangepicker({
156
-        autoApply:false,
157
-        singleDatePicker:false,
158
-        showDropdowns:false,        // 是否显示年月选择条件
159
-        timePicker: true, 			// 是否显示小时和分钟选择条件
160
-        timePickerIncrement: 10, 	// 时间的增量,单位为分钟
161
-        timePicker24Hour : true,
162
-        opens : 'left', //日期选择框的弹出位置
163
-        ranges: {
164
-            '最近1小时': [moment().subtract(1, 'hours'), moment()],
165
-            '今日': [moment().startOf('day'), moment().endOf('day')],
166
-            '昨日': [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')],
167
-            '最近7日': [moment().subtract(6, 'days'), moment()],
168
-            '最近30日': [moment().subtract(29, 'days'), moment()],
169
-            '本月': [moment().startOf('month'), moment().endOf('month')],
170
-            '上个月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
171
-        },
172
-        locale : {
173
-            format: 'YYYY-MM-DD HH:mm:ss',
174
-            separator : ' - ',
175
-            customRangeLabel : '自定义',
176
-            applyLabel : '确定',
177
-            cancelLabel : '取消',
178
-            fromLabel : '起始时间',
179
-            toLabel : '结束时间',
180
-            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
181
-            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月' ],
182
-            firstDay : 1,
183
-            startDate: moment().startOf('day'),
184
-            endDate: moment().endOf('day')
185
-        }
186
-    });*/
187
-
188
 });
199
 });