Просмотр исходного кода

执行日志,支持根据运行 "状态" 筛选日志;

xuxueli 8 лет назад
Родитель
Сommit
d46bc28a04

+ 2 - 2
db/tables_xxl_job.sql Просмотреть файл

@@ -176,10 +176,10 @@ CREATE TABLE `XXL_JOB_QRTZ_TRIGGER_LOG` (
176 176
   `executor_handler` varchar(255) DEFAULT NULL COMMENT '执行器任务handler',
177 177
   `executor_param` varchar(255) DEFAULT NULL COMMENT 'executor_param',
178 178
   `trigger_time` datetime DEFAULT NULL COMMENT '调度-时间',
179
-  `trigger_code` varchar(255) DEFAULT NULL COMMENT '调度-结果',
179
+  `trigger_code` varchar(255) NOT NULL DEFAULT '0' COMMENT '调度-结果',
180 180
   `trigger_msg` varchar(2048) DEFAULT NULL COMMENT '调度-日志',
181 181
   `handle_time` datetime DEFAULT NULL COMMENT '执行-时间',
182
-  `handle_code` varchar(255) DEFAULT NULL COMMENT '执行-状态',
182
+  `handle_code` varchar(255) NOT NULL DEFAULT '0' COMMENT '执行-状态',
183 183
   `handle_msg` varchar(2048) DEFAULT NULL COMMENT '执行-日志',
184 184
   PRIMARY KEY (`id`)
185 185
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

+ 3 - 3
xxl-job-admin/src/main/java/com/xxl/job/admin/controller/JobLogController.java Просмотреть файл

@@ -67,7 +67,7 @@ public class JobLogController {
67 67
 	@ResponseBody
68 68
 	public Map<String, Object> pageList(@RequestParam(required = false, defaultValue = "0") int start,  
69 69
 			@RequestParam(required = false, defaultValue = "10") int length,
70
-			int jobGroup, int jobId, String filterTime) {
70
+			int jobGroup, int jobId, int logStatus, String filterTime) {
71 71
 		
72 72
 		// parse param
73 73
 		Date triggerTimeStart = null;
@@ -83,8 +83,8 @@ public class JobLogController {
83 83
 		}
84 84
 		
85 85
 		// page query
86
-		List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd);
87
-		int list_count = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd);
86
+		List<XxlJobLog> list = xxlJobLogDao.pageList(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
87
+		int list_count = xxlJobLogDao.pageListCount(start, length, jobGroup, jobId, triggerTimeStart, triggerTimeEnd, logStatus);
88 88
 		
89 89
 		// package result
90 90
 		Map<String, Object> maps = new HashMap<String, Object>();

+ 2 - 2
xxl-job-admin/src/main/java/com/xxl/job/admin/dao/IXxlJobLogDao.java Просмотреть файл

@@ -12,8 +12,8 @@ import java.util.Map;
12 12
  */
13 13
 public interface IXxlJobLogDao {
14 14
 	
15
-	public List<XxlJobLog> pageList(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd);
16
-	public int pageListCount(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd);
15
+	public List<XxlJobLog> pageList(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd, int logStatus);
16
+	public int pageListCount(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd, int logStatus);
17 17
 	
18 18
 	public XxlJobLog load(int id);
19 19
 

+ 4 - 2
xxl-job-admin/src/main/java/com/xxl/job/admin/dao/impl/XxlJobLogDaoImpl.java Просмотреть файл

@@ -22,7 +22,7 @@ public class XxlJobLogDaoImpl implements IXxlJobLogDao {
22 22
 	public SqlSessionTemplate sqlSessionTemplate;
23 23
 
24 24
 	@Override
25
-	public List<XxlJobLog> pageList(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd) {
25
+	public List<XxlJobLog> pageList(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd, int logStatus) {
26 26
 		HashMap<String, Object> params = new HashMap<String, Object>();
27 27
 		params.put("offset", offset);
28 28
 		params.put("pagesize", pagesize);
@@ -30,12 +30,13 @@ public class XxlJobLogDaoImpl implements IXxlJobLogDao {
30 30
 		params.put("jobId", jobId);
31 31
 		params.put("triggerTimeStart", triggerTimeStart);
32 32
 		params.put("triggerTimeEnd", triggerTimeEnd);
33
+		params.put("logStatus", logStatus);
33 34
 		
34 35
 		return sqlSessionTemplate.selectList("XxlJobLogMapper.pageList", params);
35 36
 	}
36 37
 
37 38
 	@Override
38
-	public int pageListCount(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd) {
39
+	public int pageListCount(int offset, int pagesize, int jobGroup, int jobId, Date triggerTimeStart, Date triggerTimeEnd, int logStatus) {
39 40
 		HashMap<String, Object> params = new HashMap<String, Object>();
40 41
 		params.put("offset", offset);
41 42
 		params.put("pagesize", pagesize);
@@ -43,6 +44,7 @@ public class XxlJobLogDaoImpl implements IXxlJobLogDao {
43 44
 		params.put("jobId", jobId);
44 45
 		params.put("triggerTimeStart", triggerTimeStart);
45 46
 		params.put("triggerTimeEnd", triggerTimeEnd);
47
+		params.put("logStatus", logStatus);
46 48
 		
47 49
 		return sqlSessionTemplate.selectOne("XxlJobLogMapper.pageListCount", params);
48 50
 	}

+ 24 - 0
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml Просмотреть файл

@@ -57,6 +57,18 @@
57 57
 			<if test="triggerTimeEnd != null">
58 58
 				AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}
59 59
 			</if>
60
+			<if test="logStatus == 1" >
61
+				AND t.handle_code = 200
62
+			</if>
63
+			<if test="logStatus == 2" >
64
+				AND (
65
+					(t.trigger_code <![CDATA[ > ]]> 0 AND t.trigger_code!=200) ||
66
+					(t.handle_code <![CDATA[ > ]]> 0 AND t.handle_code!=200)
67
+				)
68
+			</if>
69
+			<if test="logStatus == 3" >
70
+				AND (t.trigger_code = 200 AND t.handle_code=0)
71
+			</if>
60 72
 		</trim>
61 73
 		ORDER BY id DESC
62 74
 		LIMIT #{offset}, #{pagesize}
@@ -78,6 +90,18 @@
78 90
 			<if test="triggerTimeEnd != null">
79 91
 				AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}
80 92
 			</if>
93
+			<if test="logStatus == 1" >
94
+				AND t.handle_code = 200
95
+			</if>
96
+			<if test="logStatus == 2" >
97
+				AND (
98
+				(t.trigger_code <![CDATA[ > ]]> 0 AND t.trigger_code!=200) ||
99
+				(t.handle_code <![CDATA[ > ]]> 0 AND t.handle_code!=200)
100
+				)
101
+			</if>
102
+			<if test="logStatus == 3" >
103
+				AND (t.trigger_code = 200 AND t.handle_code=0)
104
+			</if>
81 105
 		</trim>
82 106
 	</select>
83 107
 	

+ 15 - 2
xxl-job-admin/src/main/webapp/WEB-INF/template/joblog/joblog.index.ftl Просмотреть файл

@@ -32,7 +32,7 @@
32 32
 		<!-- Main content -->
33 33
 	    <section class="content">
34 34
 	    	<div class="row">
35
-	    		<div class="col-xs-3">
35
+	    		<div class="col-xs-2">
36 36
  					<div class="input-group">
37 37
 	                	<span class="input-group-addon">执行器</span>
38 38
                 		<select class="form-control" id="jobGroup"  paramVal="<#if jobInfo?exists>${jobInfo.jobGroup}</#if>" >
@@ -43,7 +43,7 @@
43 43
 	                  	</select>
44 44
 	              	</div>
45 45
 	            </div>
46
-	            <div class="col-xs-3">
46
+	            <div class="col-xs-2">
47 47
 	              	<div class="input-group">
48 48
 	                	<span class="input-group-addon">任务</span>
49 49
                         <select class="form-control" id="jobId" paramVal="<#if jobInfo?exists>${jobInfo.id}</#if>" >
@@ -51,6 +51,19 @@
51 51
 						</select>
52 52
 	              	</div>
53 53
 	            </div>
54
+
55
+                <div class="col-xs-2">
56
+                    <div class="input-group">
57
+                        <span class="input-group-addon">状态</span>
58
+                        <select class="form-control" id="logStatus" >
59
+                            <option value="-1" >全部</option>
60
+                            <option value="1" >成功</option>
61
+                            <option value="2" >失败</option>
62
+                            <option value="3" >进行中</option>
63
+                        </select>
64
+                    </div>
65
+                </div>
66
+
54 67
 	            <div class="col-xs-4">
55 68
               		<div class="input-group">
56 69
                 		<span class="input-group-addon">

+ 1 - 0
xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js Просмотреть файл

@@ -78,6 +78,7 @@ $(function() {
78 78
 	        	var obj = {};
79 79
 	        	obj.jobGroup = $('#jobGroup').val();
80 80
 	        	obj.jobId = $('#jobId').val();
81
+                obj.logStatus = $('#logStatus').val();
81 82
 				obj.filterTime = $('#filterTime').val();
82 83
 	        	obj.start = d.start;
83 84
 	        	obj.length = d.length;