xuxueli 6 years ago
parent
commit
50b1c67943

+ 32 - 32
xxl-job-admin/src/main/java/com/xxl/job/admin/core/jobbean/RemoteHttpJobBean.java View File

@@ -1,33 +1,33 @@
1
-package com.xxl.job.admin.core.jobbean;
2
-
3
-import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
4
-import org.quartz.JobExecutionContext;
5
-import org.quartz.JobExecutionException;
6
-import org.quartz.JobKey;
7
-import org.slf4j.Logger;
8
-import org.slf4j.LoggerFactory;
9
-import org.springframework.scheduling.quartz.QuartzJobBean;
10
-
11
-/**
12
- * http job bean
13
- * “@DisallowConcurrentExecution” diable concurrent, thread size can not be only one, better given more
14
- * @author xuxueli 2015-12-17 18:20:34
15
- */
16
-//@DisallowConcurrentExecution
17
-public class RemoteHttpJobBean extends QuartzJobBean {
18
-	private static Logger logger = LoggerFactory.getLogger(RemoteHttpJobBean.class);
19
-
20
-	@Override
21
-	protected void executeInternal(JobExecutionContext context)
22
-			throws JobExecutionException {
23
-
24
-		// load jobId
25
-		JobKey jobKey = context.getTrigger().getJobKey();
26
-		Integer jobId = Integer.valueOf(jobKey.getName());
27
-
28
-		// trigger
29
-		//XxlJobTrigger.trigger(jobId);
30
-		JobTriggerPoolHelper.trigger(jobId, -1);
31
-	}
32
-
1
+package com.xxl.job.admin.core.jobbean;
2
+
3
+import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
4
+import org.quartz.JobExecutionContext;
5
+import org.quartz.JobExecutionException;
6
+import org.quartz.JobKey;
7
+import org.slf4j.Logger;
8
+import org.slf4j.LoggerFactory;
9
+import org.springframework.scheduling.quartz.QuartzJobBean;
10
+
11
+/**
12
+ * http job bean
13
+ * “@DisallowConcurrentExecution” diable concurrent, thread size can not be only one, better given more
14
+ * @author xuxueli 2015-12-17 18:20:34
15
+ */
16
+//@DisallowConcurrentExecution
17
+public class RemoteHttpJobBean extends QuartzJobBean {
18
+	private static Logger logger = LoggerFactory.getLogger(RemoteHttpJobBean.class);
19
+
20
+	@Override
21
+	protected void executeInternal(JobExecutionContext context)
22
+			throws JobExecutionException {
23
+
24
+		// load jobId
25
+		JobKey jobKey = context.getTrigger().getJobKey();
26
+		Integer jobId = Integer.valueOf(jobKey.getName());
27
+
28
+		// trigger
29
+		//XxlJobTrigger.trigger(jobId);
30
+		JobTriggerPoolHelper.trigger(jobId, -1);
31
+	}
32
+
33 33
 }

+ 155 - 155
xxl-job-admin/src/main/java/com/xxl/job/admin/core/model/XxlJobLog.java View File

@@ -1,155 +1,155 @@
1
-package com.xxl.job.admin.core.model;
2
-
3
-import java.util.Date;
4
-
5
-/**
6
- * xxl-job log, used to track trigger process
7
- * @author xuxueli  2015-12-19 23:19:09
8
- */
9
-public class XxlJobLog {
10
-	
11
-	private int id;
12
-	
13
-	// job info
14
-	private int jobGroup;
15
-	private int jobId;
16
-
17
-	// glueType
18
-	private String glueType;
19
-
20
-	// execute info
21
-	private String executorAddress;
22
-	private String executorHandler;
23
-	private String executorParam;
24
-	private int executorFailRetryCount;
25
-	
26
-	// trigger info
27
-	private Date triggerTime;
28
-	private int triggerCode;
29
-	private String triggerMsg;
30
-	
31
-	// handle info
32
-	private Date handleTime;
33
-	private int handleCode;
34
-	private String handleMsg;
35
-
36
-	public int getId() {
37
-		return id;
38
-	}
39
-
40
-	public void setId(int id) {
41
-		this.id = id;
42
-	}
43
-
44
-	public int getJobGroup() {
45
-		return jobGroup;
46
-	}
47
-
48
-	public void setJobGroup(int jobGroup) {
49
-		this.jobGroup = jobGroup;
50
-	}
51
-
52
-	public int getJobId() {
53
-		return jobId;
54
-	}
55
-
56
-	public void setJobId(int jobId) {
57
-		this.jobId = jobId;
58
-	}
59
-
60
-	public String getGlueType() {
61
-		return glueType;
62
-	}
63
-
64
-	public void setGlueType(String glueType) {
65
-		this.glueType = glueType;
66
-	}
67
-
68
-	public String getExecutorAddress() {
69
-		return executorAddress;
70
-	}
71
-
72
-	public void setExecutorAddress(String executorAddress) {
73
-		this.executorAddress = executorAddress;
74
-	}
75
-
76
-	public String getExecutorHandler() {
77
-		return executorHandler;
78
-	}
79
-
80
-	public void setExecutorHandler(String executorHandler) {
81
-		this.executorHandler = executorHandler;
82
-	}
83
-
84
-	public String getExecutorParam() {
85
-		return executorParam;
86
-	}
87
-
88
-	public void setExecutorParam(String executorParam) {
89
-		this.executorParam = executorParam;
90
-	}
91
-
92
-	public int getExecutorFailRetryCount() {
93
-		return executorFailRetryCount;
94
-	}
95
-
96
-	public void setExecutorFailRetryCount(int executorFailRetryCount) {
97
-		this.executorFailRetryCount = executorFailRetryCount;
98
-	}
99
-
100
-	public Date getTriggerTime() {
101
-		return triggerTime;
102
-	}
103
-
104
-	public void setTriggerTime(Date triggerTime) {
105
-		this.triggerTime = triggerTime;
106
-	}
107
-
108
-	public int getTriggerCode() {
109
-		return triggerCode;
110
-	}
111
-
112
-	public void setTriggerCode(int triggerCode) {
113
-		this.triggerCode = triggerCode;
114
-	}
115
-
116
-	public String getTriggerMsg() {
117
-		return triggerMsg;
118
-	}
119
-
120
-	public void setTriggerMsg(String triggerMsg) {
121
-		// plugin
122
-		if (triggerMsg!=null && triggerMsg.length()>2000) {
123
-			triggerMsg = triggerMsg.substring(0, 2000);
124
-		}
125
-		this.triggerMsg = triggerMsg;
126
-	}
127
-
128
-	public Date getHandleTime() {
129
-		return handleTime;
130
-	}
131
-
132
-	public void setHandleTime(Date handleTime) {
133
-		this.handleTime = handleTime;
134
-	}
135
-
136
-	public int getHandleCode() {
137
-		return handleCode;
138
-	}
139
-
140
-	public void setHandleCode(int handleCode) {
141
-		this.handleCode = handleCode;
142
-	}
143
-
144
-	public String getHandleMsg() {
145
-		return handleMsg;
146
-	}
147
-
148
-	public void setHandleMsg(String handleMsg) {
149
-		// plugin
150
-		if (handleMsg!=null && handleMsg.length()>2000) {
151
-			handleMsg = handleMsg.substring(0, 2000);
152
-		}
153
-		this.handleMsg = handleMsg;
154
-	}
155
-}
1
+package com.xxl.job.admin.core.model;
2
+
3
+import java.util.Date;
4
+
5
+/**
6
+ * xxl-job log, used to track trigger process
7
+ * @author xuxueli  2015-12-19 23:19:09
8
+ */
9
+public class XxlJobLog {
10
+	
11
+	private int id;
12
+	
13
+	// job info
14
+	private int jobGroup;
15
+	private int jobId;
16
+
17
+	// glueType
18
+	private String glueType;
19
+
20
+	// execute info
21
+	private String executorAddress;
22
+	private String executorHandler;
23
+	private String executorParam;
24
+	private int executorFailRetryCount;
25
+	
26
+	// trigger info
27
+	private Date triggerTime;
28
+	private int triggerCode;
29
+	private String triggerMsg;
30
+	
31
+	// handle info
32
+	private Date handleTime;
33
+	private int handleCode;
34
+	private String handleMsg;
35
+
36
+	public int getId() {
37
+		return id;
38
+	}
39
+
40
+	public void setId(int id) {
41
+		this.id = id;
42
+	}
43
+
44
+	public int getJobGroup() {
45
+		return jobGroup;
46
+	}
47
+
48
+	public void setJobGroup(int jobGroup) {
49
+		this.jobGroup = jobGroup;
50
+	}
51
+
52
+	public int getJobId() {
53
+		return jobId;
54
+	}
55
+
56
+	public void setJobId(int jobId) {
57
+		this.jobId = jobId;
58
+	}
59
+
60
+	public String getGlueType() {
61
+		return glueType;
62
+	}
63
+
64
+	public void setGlueType(String glueType) {
65
+		this.glueType = glueType;
66
+	}
67
+
68
+	public String getExecutorAddress() {
69
+		return executorAddress;
70
+	}
71
+
72
+	public void setExecutorAddress(String executorAddress) {
73
+		this.executorAddress = executorAddress;
74
+	}
75
+
76
+	public String getExecutorHandler() {
77
+		return executorHandler;
78
+	}
79
+
80
+	public void setExecutorHandler(String executorHandler) {
81
+		this.executorHandler = executorHandler;
82
+	}
83
+
84
+	public String getExecutorParam() {
85
+		return executorParam;
86
+	}
87
+
88
+	public void setExecutorParam(String executorParam) {
89
+		this.executorParam = executorParam;
90
+	}
91
+
92
+	public int getExecutorFailRetryCount() {
93
+		return executorFailRetryCount;
94
+	}
95
+
96
+	public void setExecutorFailRetryCount(int executorFailRetryCount) {
97
+		this.executorFailRetryCount = executorFailRetryCount;
98
+	}
99
+
100
+	public Date getTriggerTime() {
101
+		return triggerTime;
102
+	}
103
+
104
+	public void setTriggerTime(Date triggerTime) {
105
+		this.triggerTime = triggerTime;
106
+	}
107
+
108
+	public int getTriggerCode() {
109
+		return triggerCode;
110
+	}
111
+
112
+	public void setTriggerCode(int triggerCode) {
113
+		this.triggerCode = triggerCode;
114
+	}
115
+
116
+	public String getTriggerMsg() {
117
+		return triggerMsg;
118
+	}
119
+
120
+	public void setTriggerMsg(String triggerMsg) {
121
+		// plugin
122
+		if (triggerMsg!=null && triggerMsg.length()>2000) {
123
+			triggerMsg = triggerMsg.substring(0, 2000);
124
+		}
125
+		this.triggerMsg = triggerMsg;
126
+	}
127
+
128
+	public Date getHandleTime() {
129
+		return handleTime;
130
+	}
131
+
132
+	public void setHandleTime(Date handleTime) {
133
+		this.handleTime = handleTime;
134
+	}
135
+
136
+	public int getHandleCode() {
137
+		return handleCode;
138
+	}
139
+
140
+	public void setHandleCode(int handleCode) {
141
+		this.handleCode = handleCode;
142
+	}
143
+
144
+	public String getHandleMsg() {
145
+		return handleMsg;
146
+	}
147
+
148
+	public void setHandleMsg(String handleMsg) {
149
+		// plugin
150
+		if (handleMsg!=null && handleMsg.length()>2000) {
151
+			handleMsg = handleMsg.substring(0, 2000);
152
+		}
153
+		this.handleMsg = handleMsg;
154
+	}
155
+}

+ 216 - 216
xxl-job-admin/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml View File

@@ -1,217 +1,217 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
3
-	"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
4
-<mapper namespace="com.xxl.job.admin.dao.XxlJobLogDao">
5
-	
6
-	<resultMap id="XxlJobLog" type="com.xxl.job.admin.core.model.XxlJobLog" >
7
-		<result column="id" property="id" />
8
-
9
-		<result column="job_group" property="jobGroup" />
10
-		<result column="job_id" property="jobId" />
11
-
12
-		<result column="glue_type" property="glueType" />
13
-
14
-		<result column="executor_address" property="executorAddress" />
15
-		<result column="executor_handler" property="executorHandler" />
16
-	    <result column="executor_param" property="executorParam" />
17
-		<result column="executor_fail_retry_count" property="executorFailRetryCount" />
18
-	    
19
-	    <result column="trigger_time" property="triggerTime" />
20
-	    <result column="trigger_code" property="triggerCode" />
21
-	    <result column="trigger_msg" property="triggerMsg" />
22
-	    
23
-	    <result column="handle_time" property="handleTime" />
24
-	    <result column="handle_code" property="handleCode" />
25
-	    <result column="handle_msg" property="handleMsg" />
26
-	    
27
-	</resultMap>
28
-
29
-	<sql id="Base_Column_List">
30
-		t.id,
31
-		t.job_group,
32
-		t.job_id,
33
-		t.glue_type,
34
-		t.executor_address,
35
-		t.executor_handler,
36
-		t.executor_param,
37
-		t.executor_fail_retry_count,
38
-		t.trigger_time,
39
-		t.trigger_code,
40
-		t.trigger_msg,
41
-		t.handle_time,
42
-		t.handle_code,
43
-		t.handle_msg
44
-	</sql>
45
-	
46
-	<select id="pageList" resultMap="XxlJobLog">
47
-		SELECT <include refid="Base_Column_List" />
48
-		FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
49
-		<trim prefix="WHERE" prefixOverrides="AND | OR" >
50
-			<if test="jobGroup gt 0">
51
-				AND t.job_group = #{jobGroup}
52
-			</if>
53
-			<if test="jobId gt 0">
54
-				AND t.job_id = #{jobId}
55
-			</if>
56
-			<if test="triggerTimeStart != null">
57
-				AND t.trigger_time <![CDATA[ >= ]]> #{triggerTimeStart}
58
-			</if>
59
-			<if test="triggerTimeEnd != null">
60
-				AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}
61
-			</if>
62
-			<if test="logStatus == 1" >
63
-				AND t.handle_code = 200
64
-			</if>
65
-			<if test="logStatus == 2" >
66
-				AND (
67
-					t.trigger_code NOT IN (0, 200) OR
68
-					t.handle_code NOT IN (0, 200)
69
-				)
70
-			</if>
71
-			<if test="logStatus == 3" >
72
-				AND t.trigger_code = 200
73
-				AND t.handle_code = 0
74
-			</if>
75
-		</trim>
76
-		ORDER BY id DESC
77
-		LIMIT #{offset}, #{pagesize}
78
-	</select>
79
-	
80
-	<select id="pageListCount" resultType="int">
81
-		SELECT count(1)
82
-		FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
83
-		<trim prefix="WHERE" prefixOverrides="AND | OR" >
84
-			<if test="jobGroup gt 0">
85
-				AND t.job_group = #{jobGroup}
86
-			</if>
87
-			<if test="jobId gt 0">
88
-				AND t.job_id = #{jobId}
89
-			</if>
90
-			<if test="triggerTimeStart != null">
91
-				AND t.trigger_time <![CDATA[ >= ]]> #{triggerTimeStart}
92
-			</if>
93
-			<if test="triggerTimeEnd != null">
94
-				AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}
95
-			</if>
96
-			<if test="logStatus == 1" >
97
-				AND t.handle_code = 200
98
-			</if>
99
-			<if test="logStatus == 2" >
100
-				AND (
101
-					t.trigger_code NOT IN (0, 200) OR
102
-					t.handle_code NOT IN (0, 200)
103
-				)
104
-			</if>
105
-			<if test="logStatus == 3" >
106
-				AND t.trigger_code = 200
107
-				AND t.handle_code = 0
108
-			</if>
109
-		</trim>
110
-	</select>
111
-	
112
-	<select id="load" parameterType="java.lang.Integer" resultMap="XxlJobLog">
113
-		SELECT <include refid="Base_Column_List" />
114
-		FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
115
-		WHERE t.id = #{id}
116
-	</select>
117
-
118
-	
119
-	<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobLog" useGeneratedKeys="true" keyProperty="id" >
120
-		INSERT INTO XXL_JOB_QRTZ_TRIGGER_LOG (
121
-			`job_group`,
122
-			`job_id`,
123
-			`trigger_code`,
124
-			`handle_code`
125
-		) VALUES (
126
-			#{jobGroup},
127
-			#{jobId},
128
-			#{triggerCode},
129
-			#{handleCode}
130
-		);
131
-		<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
132
-			SELECT LAST_INSERT_ID() 
133
-		</selectKey>-->
134
-	</insert>
135
-
136
-	<update id="updateTriggerInfo" >
137
-		UPDATE XXL_JOB_QRTZ_TRIGGER_LOG
138
-		SET
139
-		    `glue_type`= #{glueType},
140
-			`trigger_time`= #{triggerTime},
141
-			`trigger_code`= #{triggerCode},
142
-			`trigger_msg`= #{triggerMsg},
143
-			`executor_address`= #{executorAddress},
144
-			`executor_handler`=#{executorHandler},
145
-			`executor_param`= #{executorParam},
146
-			`executor_fail_retry_count`= #{executorFailRetryCount}
147
-		WHERE `id`= #{id}
148
-	</update>
149
-
150
-	<update id="updateHandleInfo">
151
-		UPDATE XXL_JOB_QRTZ_TRIGGER_LOG
152
-		SET 
153
-			`handle_time`= #{handleTime}, 
154
-			`handle_code`= #{handleCode},
155
-			`handle_msg`= #{handleMsg} 
156
-		WHERE `id`= #{id}
157
-	</update>
158
-	
159
-	<delete id="delete" >
160
-		delete from XXL_JOB_QRTZ_TRIGGER_LOG
161
-		WHERE job_id = #{jobId}
162
-	</delete>
163
-
164
-	<select id="triggerCountByHandleCode" resultType="int" >
165
-		SELECT count(1)
166
-		FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
167
-		<trim prefix="WHERE" prefixOverrides="AND | OR" >
168
-			<if test="handleCode gt 0">
169
-				AND t.handle_code = #{handleCode}
170
-			</if>
171
-		</trim>
172
-	</select>
173
-
174
-    <select id="triggerCountByDay" resultType="java.util.Map" >
175
-		SELECT
176
-			DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay,
177
-			COUNT(handle_code) triggerDayCount,
178
-			SUM(CASE WHEN (trigger_code = 200 and handle_code = 0) then 1 else 0 end) as triggerDayCountRunning,
179
-			SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSuc
180
-		FROM XXL_JOB_QRTZ_TRIGGER_LOG
181
-		WHERE trigger_time BETWEEN #{from} and #{to}
182
-		GROUP BY triggerDay;
183
-    </select>
184
-
185
-	<delete id="clearLog" >
186
-		delete from XXL_JOB_QRTZ_TRIGGER_LOG
187
-		<trim prefix="WHERE" prefixOverrides="AND | OR" >
188
-			<if test="jobGroup gt 0">
189
-				AND job_group = #{jobGroup}
190
-			</if>
191
-			<if test="jobId gt 0">
192
-				AND job_id = #{jobId}
193
-			</if>
194
-			<if test="clearBeforeTime != null">
195
-				AND trigger_time <![CDATA[ <= ]]> #{clearBeforeTime}
196
-			</if>
197
-			<if test="clearBeforeNum gt 0">
198
-				AND id NOT in(
199
-					SELECT id FROM(
200
-						SELECT id FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
201
-						<trim prefix="WHERE" prefixOverrides="AND | OR" >
202
-							<if test="jobGroup gt 0">
203
-								AND t.job_group = #{jobGroup}
204
-							</if>
205
-							<if test="jobId gt 0">
206
-								AND t.job_id = #{jobId}
207
-							</if>
208
-						</trim>
209
-						ORDER BY t.trigger_time desc
210
-						LIMIT 0, #{clearBeforeNum}
211
-					) t1
212
-				)
213
-			</if>
214
-		</trim>
215
-	</delete>
216
-	
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
3
+	"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
4
+<mapper namespace="com.xxl.job.admin.dao.XxlJobLogDao">
5
+	
6
+	<resultMap id="XxlJobLog" type="com.xxl.job.admin.core.model.XxlJobLog" >
7
+		<result column="id" property="id" />
8
+
9
+		<result column="job_group" property="jobGroup" />
10
+		<result column="job_id" property="jobId" />
11
+
12
+		<result column="glue_type" property="glueType" />
13
+
14
+		<result column="executor_address" property="executorAddress" />
15
+		<result column="executor_handler" property="executorHandler" />
16
+	    <result column="executor_param" property="executorParam" />
17
+		<result column="executor_fail_retry_count" property="executorFailRetryCount" />
18
+	    
19
+	    <result column="trigger_time" property="triggerTime" />
20
+	    <result column="trigger_code" property="triggerCode" />
21
+	    <result column="trigger_msg" property="triggerMsg" />
22
+	    
23
+	    <result column="handle_time" property="handleTime" />
24
+	    <result column="handle_code" property="handleCode" />
25
+	    <result column="handle_msg" property="handleMsg" />
26
+	    
27
+	</resultMap>
28
+
29
+	<sql id="Base_Column_List">
30
+		t.id,
31
+		t.job_group,
32
+		t.job_id,
33
+		t.glue_type,
34
+		t.executor_address,
35
+		t.executor_handler,
36
+		t.executor_param,
37
+		t.executor_fail_retry_count,
38
+		t.trigger_time,
39
+		t.trigger_code,
40
+		t.trigger_msg,
41
+		t.handle_time,
42
+		t.handle_code,
43
+		t.handle_msg
44
+	</sql>
45
+	
46
+	<select id="pageList" resultMap="XxlJobLog">
47
+		SELECT <include refid="Base_Column_List" />
48
+		FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
49
+		<trim prefix="WHERE" prefixOverrides="AND | OR" >
50
+			<if test="jobGroup gt 0">
51
+				AND t.job_group = #{jobGroup}
52
+			</if>
53
+			<if test="jobId gt 0">
54
+				AND t.job_id = #{jobId}
55
+			</if>
56
+			<if test="triggerTimeStart != null">
57
+				AND t.trigger_time <![CDATA[ >= ]]> #{triggerTimeStart}
58
+			</if>
59
+			<if test="triggerTimeEnd != null">
60
+				AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}
61
+			</if>
62
+			<if test="logStatus == 1" >
63
+				AND t.handle_code = 200
64
+			</if>
65
+			<if test="logStatus == 2" >
66
+				AND (
67
+					t.trigger_code NOT IN (0, 200) OR
68
+					t.handle_code NOT IN (0, 200)
69
+				)
70
+			</if>
71
+			<if test="logStatus == 3" >
72
+				AND t.trigger_code = 200
73
+				AND t.handle_code = 0
74
+			</if>
75
+		</trim>
76
+		ORDER BY id DESC
77
+		LIMIT #{offset}, #{pagesize}
78
+	</select>
79
+	
80
+	<select id="pageListCount" resultType="int">
81
+		SELECT count(1)
82
+		FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
83
+		<trim prefix="WHERE" prefixOverrides="AND | OR" >
84
+			<if test="jobGroup gt 0">
85
+				AND t.job_group = #{jobGroup}
86
+			</if>
87
+			<if test="jobId gt 0">
88
+				AND t.job_id = #{jobId}
89
+			</if>
90
+			<if test="triggerTimeStart != null">
91
+				AND t.trigger_time <![CDATA[ >= ]]> #{triggerTimeStart}
92
+			</if>
93
+			<if test="triggerTimeEnd != null">
94
+				AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}
95
+			</if>
96
+			<if test="logStatus == 1" >
97
+				AND t.handle_code = 200
98
+			</if>
99
+			<if test="logStatus == 2" >
100
+				AND (
101
+					t.trigger_code NOT IN (0, 200) OR
102
+					t.handle_code NOT IN (0, 200)
103
+				)
104
+			</if>
105
+			<if test="logStatus == 3" >
106
+				AND t.trigger_code = 200
107
+				AND t.handle_code = 0
108
+			</if>
109
+		</trim>
110
+	</select>
111
+	
112
+	<select id="load" parameterType="java.lang.Integer" resultMap="XxlJobLog">
113
+		SELECT <include refid="Base_Column_List" />
114
+		FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
115
+		WHERE t.id = #{id}
116
+	</select>
117
+
118
+	
119
+	<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobLog" useGeneratedKeys="true" keyProperty="id" >
120
+		INSERT INTO XXL_JOB_QRTZ_TRIGGER_LOG (
121
+			`job_group`,
122
+			`job_id`,
123
+			`trigger_code`,
124
+			`handle_code`
125
+		) VALUES (
126
+			#{jobGroup},
127
+			#{jobId},
128
+			#{triggerCode},
129
+			#{handleCode}
130
+		);
131
+		<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
132
+			SELECT LAST_INSERT_ID() 
133
+		</selectKey>-->
134
+	</insert>
135
+
136
+	<update id="updateTriggerInfo" >
137
+		UPDATE XXL_JOB_QRTZ_TRIGGER_LOG
138
+		SET
139
+		    `glue_type`= #{glueType},
140
+			`trigger_time`= #{triggerTime},
141
+			`trigger_code`= #{triggerCode},
142
+			`trigger_msg`= #{triggerMsg},
143
+			`executor_address`= #{executorAddress},
144
+			`executor_handler`=#{executorHandler},
145
+			`executor_param`= #{executorParam},
146
+			`executor_fail_retry_count`= #{executorFailRetryCount}
147
+		WHERE `id`= #{id}
148
+	</update>
149
+
150
+	<update id="updateHandleInfo">
151
+		UPDATE XXL_JOB_QRTZ_TRIGGER_LOG
152
+		SET 
153
+			`handle_time`= #{handleTime}, 
154
+			`handle_code`= #{handleCode},
155
+			`handle_msg`= #{handleMsg} 
156
+		WHERE `id`= #{id}
157
+	</update>
158
+	
159
+	<delete id="delete" >
160
+		delete from XXL_JOB_QRTZ_TRIGGER_LOG
161
+		WHERE job_id = #{jobId}
162
+	</delete>
163
+
164
+	<select id="triggerCountByHandleCode" resultType="int" >
165
+		SELECT count(1)
166
+		FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
167
+		<trim prefix="WHERE" prefixOverrides="AND | OR" >
168
+			<if test="handleCode gt 0">
169
+				AND t.handle_code = #{handleCode}
170
+			</if>
171
+		</trim>
172
+	</select>
173
+
174
+    <select id="triggerCountByDay" resultType="java.util.Map" >
175
+		SELECT
176
+			DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay,
177
+			COUNT(handle_code) triggerDayCount,
178
+			SUM(CASE WHEN (trigger_code = 200 and handle_code = 0) then 1 else 0 end) as triggerDayCountRunning,
179
+			SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSuc
180
+		FROM XXL_JOB_QRTZ_TRIGGER_LOG
181
+		WHERE trigger_time BETWEEN #{from} and #{to}
182
+		GROUP BY triggerDay;
183
+    </select>
184
+
185
+	<delete id="clearLog" >
186
+		delete from XXL_JOB_QRTZ_TRIGGER_LOG
187
+		<trim prefix="WHERE" prefixOverrides="AND | OR" >
188
+			<if test="jobGroup gt 0">
189
+				AND job_group = #{jobGroup}
190
+			</if>
191
+			<if test="jobId gt 0">
192
+				AND job_id = #{jobId}
193
+			</if>
194
+			<if test="clearBeforeTime != null">
195
+				AND trigger_time <![CDATA[ <= ]]> #{clearBeforeTime}
196
+			</if>
197
+			<if test="clearBeforeNum gt 0">
198
+				AND id NOT in(
199
+					SELECT id FROM(
200
+						SELECT id FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
201
+						<trim prefix="WHERE" prefixOverrides="AND | OR" >
202
+							<if test="jobGroup gt 0">
203
+								AND t.job_group = #{jobGroup}
204
+							</if>
205
+							<if test="jobId gt 0">
206
+								AND t.job_id = #{jobId}
207
+							</if>
208
+						</trim>
209
+						ORDER BY t.trigger_time desc
210
+						LIMIT 0, #{clearBeforeNum}
211
+					) t1
212
+				)
213
+			</if>
214
+		</trim>
215
+	</delete>
216
+	
217 217
 </mapper>

+ 367 - 367
xxl-job-admin/src/main/webapp/static/js/joblog.index.1.js View File

@@ -1,367 +1,367 @@
1
-$(function() {
2
-
3
-	// jobGroup change, job list init and select
4
-	$("#jobGroup").on("change", function () {
5
-		var jobGroup = $(this).children('option:selected').val();
6
-		$.ajax({
7
-			type : 'POST',
8
-            async: false,   // async, avoid js invoke pagelist before jobId data init
9
-			url : base_url + '/joblog/getJobsByGroup',
10
-			data : {"jobGroup":jobGroup},
11
-			dataType : "json",
12
-			success : function(data){
13
-				if (data.code == 200) {
14
-					$("#jobId").html( '<option value="0" >'+ I18n.system_all +'</option>' );
15
-					$.each(data.content, function (n, value) {
16
-                        $("#jobId").append('<option value="' + value.id + '" >' + value.jobDesc + '</option>');
17
-                    });
18
-                    if ($("#jobId").attr("paramVal")){
19
-                        $("#jobId").find("option[value='" + $("#jobId").attr("paramVal") + "']").attr("selected",true);
20
-                    }
21
-				} else {
22
-					layer.open({
23
-						title: I18n.system_tips ,
24
-                        btn: [ I18n.system_ok ],
25
-						content: (data.msg || I18n.system_api_error ),
26
-						icon: '2'
27
-					});
28
-				}
29
-			},
30
-		});
31
-	});
32
-	if ($("#jobGroup").attr("paramVal")){
33
-		$("#jobGroup").find("option[value='" + $("#jobGroup").attr("paramVal") + "']").attr("selected",true);
34
-        $("#jobGroup").change();
35
-	}
36
-
37
-	// filter Time
38
-    var rangesConf = {};
39
-    rangesConf[I18n.daterangepicker_ranges_recent_hour] = [moment().subtract(1, 'hours'), moment()];
40
-    rangesConf[I18n.daterangepicker_ranges_today] = [moment().startOf('day'), moment().endOf('day')];
41
-    rangesConf[I18n.daterangepicker_ranges_yesterday] = [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')];
42
-    rangesConf[I18n.daterangepicker_ranges_this_month] = [moment().startOf('month'), moment().endOf('month')];
43
-    rangesConf[I18n.daterangepicker_ranges_last_month] = [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')];
44
-    rangesConf[I18n.daterangepicker_ranges_recent_week] = [moment().subtract(1, 'weeks').startOf('day'), moment().endOf('day')];
45
-    rangesConf[I18n.daterangepicker_ranges_recent_month] = [moment().subtract(1, 'months').startOf('day'), moment().endOf('day')];
46
-
47
-	$('#filterTime').daterangepicker({
48
-        autoApply:false,
49
-        singleDatePicker:false,
50
-        showDropdowns:false,        // 是否显示年月选择条件
51
-		timePicker: true, 			// 是否显示小时和分钟选择条件
52
-		timePickerIncrement: 10, 	// 时间的增量,单位为分钟
53
-        timePicker24Hour : true,
54
-        opens : 'left', //日期选择框的弹出位置
55
-		ranges: rangesConf,
56
-        locale : {
57
-            format: 'YYYY-MM-DD HH:mm:ss',
58
-            separator : ' - ',
59
-            customRangeLabel : I18n.daterangepicker_custom_name ,
60
-            applyLabel : I18n.system_ok ,
61
-            cancelLabel : I18n.system_cancel ,
62
-            fromLabel : I18n.daterangepicker_custom_starttime ,
63
-            toLabel : I18n.daterangepicker_custom_endtime ,
64
-            daysOfWeek : I18n.daterangepicker_custom_daysofweek.split(',') ,        // '日', '一', '二', '三', '四', '五', '六'
65
-            monthNames : I18n.daterangepicker_custom_monthnames.split(',') ,        // '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'
66
-            firstDay : 1
67
-        },
68
-        startDate: rangesConf[I18n.daterangepicker_ranges_today][0],
69
-        endDate: rangesConf[I18n.daterangepicker_ranges_today][1]
70
-	});
71
-
72
-	// init date tables
73
-	var logTable = $("#joblog_list").dataTable({
74
-		"deferRender": true,
75
-		"processing" : true, 
76
-	    "serverSide": true,
77
-		"ajax": {
78
-	        url: base_url + "/joblog/pageList" ,
79
-            type:"post",
80
-	        data : function ( d ) {
81
-	        	var obj = {};
82
-	        	obj.jobGroup = $('#jobGroup').val();
83
-	        	obj.jobId = $('#jobId').val();
84
-                obj.logStatus = $('#logStatus').val();
85
-				obj.filterTime = $('#filterTime').val();
86
-	        	obj.start = d.start;
87
-	        	obj.length = d.length;
88
-                return obj;
89
-            }
90
-	    },
91
-	    "searching": false,
92
-	    "ordering": false,
93
-	    //"scrollX": false,
94
-	    "columns": [
95
-					{
96
-						"data": 'jobId',
97
-						"visible" : true,
98
-                        "width":'10%',
99
-						"render": function ( data, type, row ) {
100
-
101
-                            var glueTypeTitle = GlueTypeEnum[row.glueType];
102
-                            if (row.executorHandler) {
103
-                                glueTypeTitle = glueTypeTitle +":" + row.executorHandler;
104
-                            }
105
-
106
-							var temp = '';
107
-							temp += I18n.joblog_field_executorAddress + ':' + (row.executorAddress?row.executorAddress:'');
108
-							temp += '<br>'+ I18n.jobinfo_field_gluetype +':' + glueTypeTitle;
109
-							temp += '<br>'+ I18n.jobinfo_field_executorparam +':' + row.executorParam;
110
-
111
-							return '<a class="logTips" href="javascript:;" >'+ row.jobId +'<span style="display:none;">'+ temp +'</span></a>';
112
-						}
113
-					},
114
-					{ "data": 'jobGroup', "visible" : false},
115
-					{
116
-						"data": 'triggerTime',
117
-                        "width":'16%',
118
-						"render": function ( data, type, row ) {
119
-							return data?moment(new Date(data)).format("YYYY-MM-DD HH:mm:ss"):"";
120
-						}
121
-					},
122
-					{
123
-						"data": 'triggerCode',
124
-                        "width":'12%',
125
-						"render": function ( data, type, row ) {
126
-							var html = data;
127
-							if (data == 200) {
128
-								html = '<span style="color: green">'+ I18n.system_success +'</span>';
129
-							} else if (data == 500) {
130
-								html = '<span style="color: red">'+ I18n.system_fail +'</span>';
131
-							} else if (data == 0) {
132
-                                html = '';
133
-							}
134
-                            return html;
135
-						}
136
-					},
137
-					{
138
-						"data": 'triggerMsg',
139
-                        "width":'12%',
140
-						"render": function ( data, type, row ) {
141
-							return data?'<a class="logTips" href="javascript:;" >'+ I18n.system_show +'<span style="display:none;">'+ data +'</span></a>':I18n.system_empty;
142
-						}
143
-					},
144
-	                { 
145
-	                	"data": 'handleTime',
146
-                        "width":'16%',
147
-	                	"render": function ( data, type, row ) {
148
-	                		return data?moment(new Date(data)).format("YYYY-MM-DD HH:mm:ss"):"";
149
-	                	}
150
-	                },
151
-	                {
152
-						"data": 'handleCode',
153
-                        "width":'12%',
154
-						"render": function ( data, type, row ) {
155
-                            var html = data;
156
-                            if (data == 200) {
157
-                                html = '<span style="color: green">'+ I18n.joblog_handleCode_200 +'</span>';
158
-                            } else if (data == 500) {
159
-                                html = '<span style="color: red">'+ I18n.joblog_handleCode_500 +'</span>';
160
-                            } else if (data == 502) {
161
-                                html = '<span style="color: red">'+ I18n.joblog_handleCode_502 +'</span>';
162
-                            } else if (data == 0) {
163
-                                html = '';
164
-                            }
165
-                            return html;
166
-						}
167
-	                },
168
-	                { 
169
-	                	"data": 'handleMsg',
170
-                        "width":'12%',
171
-	                	"render": function ( data, type, row ) {
172
-	                		return data?'<a class="logTips" href="javascript:;" >'+ I18n.system_show +'<span style="display:none;">'+ data +'</span></a>':I18n.system_empty;
173
-	                	}
174
-	                },
175
-	                {
176
-						"data": 'handleMsg' ,
177
-						"bSortable": false,
178
-                        "width":'10%',
179
-	                	"render": function ( data, type, row ) {
180
-	                		// better support expression or string, not function
181
-	                		return function () {
182
-		                		if (row.triggerCode == 200){
183
-		                			var temp = '<a href="javascript:;" class="logDetail" _id="'+ row.id +'">'+ I18n.joblog_rolling_log +'</a>';
184
-		                			if(row.handleCode == 0){
185
-		                				temp += '<br><a href="javascript:;" class="logKill" _id="'+ row.id +'" style="color: red;" >'+ I18n.joblog_kill_log +'</a>';
186
-		                			}
187
-		                			return temp;
188
-		                		}
189
-		                		return null;	
190
-	                		}
191
-	                	}
192
-	                }
193
-	            ],
194
-        "language" : {
195
-            "sProcessing" : I18n.dataTable_sProcessing ,
196
-            "sLengthMenu" : I18n.dataTable_sLengthMenu ,
197
-            "sZeroRecords" : I18n.dataTable_sZeroRecords ,
198
-            "sInfo" : I18n.dataTable_sInfo ,
199
-            "sInfoEmpty" : I18n.dataTable_sInfoEmpty ,
200
-            "sInfoFiltered" : I18n.dataTable_sInfoFiltered ,
201
-            "sInfoPostFix" : "",
202
-            "sSearch" : I18n.dataTable_sSearch ,
203
-            "sUrl" : "",
204
-            "sEmptyTable" : I18n.dataTable_sEmptyTable ,
205
-            "sLoadingRecords" : I18n.dataTable_sLoadingRecords ,
206
-            "sInfoThousands" : ",",
207
-            "oPaginate" : {
208
-                "sFirst" : I18n.dataTable_sFirst ,
209
-                "sPrevious" : I18n.dataTable_sPrevious ,
210
-                "sNext" : I18n.dataTable_sNext ,
211
-                "sLast" : I18n.dataTable_sLast
212
-            },
213
-            "oAria" : {
214
-                "sSortAscending" : I18n.dataTable_sSortAscending ,
215
-                "sSortDescending" : I18n.dataTable_sSortDescending
216
-            }
217
-        }
218
-	});
219
-	
220
-	// logTips alert
221
-	$('#joblog_list').on('click', '.logTips', function(){
222
-		var msg = $(this).find('span').html();
223
-		ComAlertTec.show(msg);
224
-	});
225
-	
226
-	// search Btn
227
-	$('#searchBtn').on('click', function(){
228
-		logTable.fnDraw();
229
-	});
230
-	
231
-	// logDetail look
232
-	$('#joblog_list').on('click', '.logDetail', function(){
233
-		var _id = $(this).attr('_id');
234
-		
235
-		window.open(base_url + '/joblog/logDetailPage?id=' + _id);
236
-		return;
237
-	});
238
-
239
-	/**
240
-	 * log Kill
241
-	 */
242
-	$('#joblog_list').on('click', '.logKill', function(){
243
-		var _id = $(this).attr('_id');
244
-
245
-        layer.confirm( (I18n.system_ok + I18n.joblog_kill_log + '?'), {
246
-        	icon: 3,
247
-			title: I18n.system_tips ,
248
-            btn: [ I18n.system_ok, I18n.system_cancel ]
249
-		}, function(index){
250
-            layer.close(index);
251
-
252
-            $.ajax({
253
-                type : 'POST',
254
-                url : base_url + '/joblog/logKill',
255
-                data : {"id":_id},
256
-                dataType : "json",
257
-                success : function(data){
258
-                    if (data.code == 200) {
259
-                        layer.open({
260
-                            title: I18n.system_tips,
261
-                            btn: [ I18n.system_ok ],
262
-                            content: I18n.system_opt_suc ,
263
-                            icon: '1',
264
-                            end: function(layero, index){
265
-                                logTable.fnDraw();
266
-                            }
267
-                        });
268
-                    } else {
269
-                        layer.open({
270
-                            title: I18n.system_tips,
271
-                            btn: [ I18n.system_ok ],
272
-                            content: (data.msg || I18n.system_opt_fail ),
273
-                            icon: '2'
274
-                        });
275
-                    }
276
-                },
277
-            });
278
-        });
279
-
280
-	});
281
-
282
-	/**
283
-	 * clear Log
284
-	 */
285
-	$('#clearLog').on('click', function(){
286
-
287
-		var jobGroup = $('#jobGroup').val();
288
-		var jobId = $('#jobId').val();
289
-
290
-		var jobGroupText = $("#jobGroup").find("option:selected").text();
291
-		var jobIdText = $("#jobId").find("option:selected").text();
292
-
293
-		$('#clearLogModal input[name=jobGroup]').val(jobGroup);
294
-		$('#clearLogModal input[name=jobId]').val(jobId);
295
-
296
-		$('#clearLogModal .jobGroupText').val(jobGroupText);
297
-		$('#clearLogModal .jobIdText').val(jobIdText);
298
-
299
-		$('#clearLogModal').modal('show');
300
-
301
-	});
302
-	$("#clearLogModal .ok").on('click', function(){
303
-		$.post(base_url + "/joblog/clearLog",  $("#clearLogModal .form").serialize(), function(data, status) {
304
-			if (data.code == "200") {
305
-				$('#clearLogModal').modal('hide');
306
-				layer.open({
307
-					title: I18n.system_tips ,
308
-                    btn: [ I18n.system_ok ],
309
-					content: (I18n.joblog_clean_log + I18n.system_success) ,
310
-					icon: '1',
311
-					end: function(layero, index){
312
-						logTable.fnDraw();
313
-					}
314
-				});
315
-			} else {
316
-				layer.open({
317
-					title: I18n.system_tips ,
318
-                    btn: [ I18n.system_ok ],
319
-					content: (data.msg || (I18n.joblog_clean_log + I18n.system_fail) ),
320
-					icon: '2'
321
-				});
322
-			}
323
-		});
324
-	});
325
-	$("#clearLogModal").on('hide.bs.modal', function () {
326
-		$("#clearLogModal .form")[0].reset();
327
-	});
328
-
329
-});
330
-
331
-
332
-// Com Alert by Tec theme
333
-var ComAlertTec = {
334
-	html:function(){
335
-		var html =
336
-			'<div class="modal fade" id="ComAlertTec" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
337
-			'<div class="modal-dialog">' +
338
-			'<div class="modal-content-tec">' +
339
-			'<div class="modal-body"><div class="alert" style="color:#fff;"></div></div>' +
340
-			'<div class="modal-footer">' +
341
-			'<div class="text-center" >' +
342
-			'<button type="button" class="btn btn-info ok" data-dismiss="modal" >'+ I18n.system_ok +'</button>' +
343
-			'</div>' +
344
-			'</div>' +
345
-			'</div>' +
346
-			'</div>' +
347
-			'</div>';
348
-		return html;
349
-	},
350
-	show:function(msg, callback){
351
-		// dom init
352
-		if ($('#ComAlertTec').length == 0){
353
-			$('body').append(ComAlertTec.html());
354
-		}
355
-
356
-		// init com alert
357
-		$('#ComAlertTec .alert').html(msg);
358
-		$('#ComAlertTec').modal('show');
359
-
360
-		$('#ComAlertTec .ok').click(function(){
361
-			$('#ComAlertTec').modal('hide');
362
-			if(typeof callback == 'function') {
363
-				callback();
364
-			}
365
-		});
366
-	}
367
-};
1
+$(function() {
2
+
3
+	// jobGroup change, job list init and select
4
+	$("#jobGroup").on("change", function () {
5
+		var jobGroup = $(this).children('option:selected').val();
6
+		$.ajax({
7
+			type : 'POST',
8
+            async: false,   // async, avoid js invoke pagelist before jobId data init
9
+			url : base_url + '/joblog/getJobsByGroup',
10
+			data : {"jobGroup":jobGroup},
11
+			dataType : "json",
12
+			success : function(data){
13
+				if (data.code == 200) {
14
+					$("#jobId").html( '<option value="0" >'+ I18n.system_all +'</option>' );
15
+					$.each(data.content, function (n, value) {
16
+                        $("#jobId").append('<option value="' + value.id + '" >' + value.jobDesc + '</option>');
17
+                    });
18
+                    if ($("#jobId").attr("paramVal")){
19
+                        $("#jobId").find("option[value='" + $("#jobId").attr("paramVal") + "']").attr("selected",true);
20
+                    }
21
+				} else {
22
+					layer.open({
23
+						title: I18n.system_tips ,
24
+                        btn: [ I18n.system_ok ],
25
+						content: (data.msg || I18n.system_api_error ),
26
+						icon: '2'
27
+					});
28
+				}
29
+			},
30
+		});
31
+	});
32
+	if ($("#jobGroup").attr("paramVal")){
33
+		$("#jobGroup").find("option[value='" + $("#jobGroup").attr("paramVal") + "']").attr("selected",true);
34
+        $("#jobGroup").change();
35
+	}
36
+
37
+	// filter Time
38
+    var rangesConf = {};
39
+    rangesConf[I18n.daterangepicker_ranges_recent_hour] = [moment().subtract(1, 'hours'), moment()];
40
+    rangesConf[I18n.daterangepicker_ranges_today] = [moment().startOf('day'), moment().endOf('day')];
41
+    rangesConf[I18n.daterangepicker_ranges_yesterday] = [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')];
42
+    rangesConf[I18n.daterangepicker_ranges_this_month] = [moment().startOf('month'), moment().endOf('month')];
43
+    rangesConf[I18n.daterangepicker_ranges_last_month] = [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')];
44
+    rangesConf[I18n.daterangepicker_ranges_recent_week] = [moment().subtract(1, 'weeks').startOf('day'), moment().endOf('day')];
45
+    rangesConf[I18n.daterangepicker_ranges_recent_month] = [moment().subtract(1, 'months').startOf('day'), moment().endOf('day')];
46
+
47
+	$('#filterTime').daterangepicker({
48
+        autoApply:false,
49
+        singleDatePicker:false,
50
+        showDropdowns:false,        // 是否显示年月选择条件
51
+		timePicker: true, 			// 是否显示小时和分钟选择条件
52
+		timePickerIncrement: 10, 	// 时间的增量,单位为分钟
53
+        timePicker24Hour : true,
54
+        opens : 'left', //日期选择框的弹出位置
55
+		ranges: rangesConf,
56
+        locale : {
57
+            format: 'YYYY-MM-DD HH:mm:ss',
58
+            separator : ' - ',
59
+            customRangeLabel : I18n.daterangepicker_custom_name ,
60
+            applyLabel : I18n.system_ok ,
61
+            cancelLabel : I18n.system_cancel ,
62
+            fromLabel : I18n.daterangepicker_custom_starttime ,
63
+            toLabel : I18n.daterangepicker_custom_endtime ,
64
+            daysOfWeek : I18n.daterangepicker_custom_daysofweek.split(',') ,        // '日', '一', '二', '三', '四', '五', '六'
65
+            monthNames : I18n.daterangepicker_custom_monthnames.split(',') ,        // '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'
66
+            firstDay : 1
67
+        },
68
+        startDate: rangesConf[I18n.daterangepicker_ranges_today][0],
69
+        endDate: rangesConf[I18n.daterangepicker_ranges_today][1]
70
+	});
71
+
72
+	// init date tables
73
+	var logTable = $("#joblog_list").dataTable({
74
+		"deferRender": true,
75
+		"processing" : true, 
76
+	    "serverSide": true,
77
+		"ajax": {
78
+	        url: base_url + "/joblog/pageList" ,
79
+            type:"post",
80
+	        data : function ( d ) {
81
+	        	var obj = {};
82
+	        	obj.jobGroup = $('#jobGroup').val();
83
+	        	obj.jobId = $('#jobId').val();
84
+                obj.logStatus = $('#logStatus').val();
85
+				obj.filterTime = $('#filterTime').val();
86
+	        	obj.start = d.start;
87
+	        	obj.length = d.length;
88
+                return obj;
89
+            }
90
+	    },
91
+	    "searching": false,
92
+	    "ordering": false,
93
+	    //"scrollX": false,
94
+	    "columns": [
95
+					{
96
+						"data": 'jobId',
97
+						"visible" : true,
98
+                        "width":'10%',
99
+						"render": function ( data, type, row ) {
100
+
101
+                            var glueTypeTitle = GlueTypeEnum[row.glueType];
102
+                            if (row.executorHandler) {
103
+                                glueTypeTitle = glueTypeTitle +":" + row.executorHandler;
104
+                            }
105
+
106
+							var temp = '';
107
+							temp += I18n.joblog_field_executorAddress + ':' + (row.executorAddress?row.executorAddress:'');
108
+							temp += '<br>'+ I18n.jobinfo_field_gluetype +':' + glueTypeTitle;
109
+							temp += '<br>'+ I18n.jobinfo_field_executorparam +':' + row.executorParam;
110
+
111
+							return '<a class="logTips" href="javascript:;" >'+ row.jobId +'<span style="display:none;">'+ temp +'</span></a>';
112
+						}
113
+					},
114
+					{ "data": 'jobGroup', "visible" : false},
115
+					{
116
+						"data": 'triggerTime',
117
+                        "width":'16%',
118
+						"render": function ( data, type, row ) {
119
+							return data?moment(new Date(data)).format("YYYY-MM-DD HH:mm:ss"):"";
120
+						}
121
+					},
122
+					{
123
+						"data": 'triggerCode',
124
+                        "width":'12%',
125
+						"render": function ( data, type, row ) {
126
+							var html = data;
127
+							if (data == 200) {
128
+								html = '<span style="color: green">'+ I18n.system_success +'</span>';
129
+							} else if (data == 500) {
130
+								html = '<span style="color: red">'+ I18n.system_fail +'</span>';
131
+							} else if (data == 0) {
132
+                                html = '';
133
+							}
134
+                            return html;
135
+						}
136
+					},
137
+					{
138
+						"data": 'triggerMsg',
139
+                        "width":'12%',
140
+						"render": function ( data, type, row ) {
141
+							return data?'<a class="logTips" href="javascript:;" >'+ I18n.system_show +'<span style="display:none;">'+ data +'</span></a>':I18n.system_empty;
142
+						}
143
+					},
144
+	                { 
145
+	                	"data": 'handleTime',
146
+                        "width":'16%',
147
+	                	"render": function ( data, type, row ) {
148
+	                		return data?moment(new Date(data)).format("YYYY-MM-DD HH:mm:ss"):"";
149
+	                	}
150
+	                },
151
+	                {
152
+						"data": 'handleCode',
153
+                        "width":'12%',
154
+						"render": function ( data, type, row ) {
155
+                            var html = data;
156
+                            if (data == 200) {
157
+                                html = '<span style="color: green">'+ I18n.joblog_handleCode_200 +'</span>';
158
+                            } else if (data == 500) {
159
+                                html = '<span style="color: red">'+ I18n.joblog_handleCode_500 +'</span>';
160
+                            } else if (data == 502) {
161
+                                html = '<span style="color: red">'+ I18n.joblog_handleCode_502 +'</span>';
162
+                            } else if (data == 0) {
163
+                                html = '';
164
+                            }
165
+                            return html;
166
+						}
167
+	                },
168
+	                { 
169
+	                	"data": 'handleMsg',
170
+                        "width":'12%',
171
+	                	"render": function ( data, type, row ) {
172
+	                		return data?'<a class="logTips" href="javascript:;" >'+ I18n.system_show +'<span style="display:none;">'+ data +'</span></a>':I18n.system_empty;
173
+	                	}
174
+	                },
175
+	                {
176
+						"data": 'handleMsg' ,
177
+						"bSortable": false,
178
+                        "width":'10%',
179
+	                	"render": function ( data, type, row ) {
180
+	                		// better support expression or string, not function
181
+	                		return function () {
182
+		                		if (row.triggerCode == 200){
183
+		                			var temp = '<a href="javascript:;" class="logDetail" _id="'+ row.id +'">'+ I18n.joblog_rolling_log +'</a>';
184
+		                			if(row.handleCode == 0){
185
+		                				temp += '<br><a href="javascript:;" class="logKill" _id="'+ row.id +'" style="color: red;" >'+ I18n.joblog_kill_log +'</a>';
186
+		                			}
187
+		                			return temp;
188
+		                		}
189
+		                		return null;	
190
+	                		}
191
+	                	}
192
+	                }
193
+	            ],
194
+        "language" : {
195
+            "sProcessing" : I18n.dataTable_sProcessing ,
196
+            "sLengthMenu" : I18n.dataTable_sLengthMenu ,
197
+            "sZeroRecords" : I18n.dataTable_sZeroRecords ,
198
+            "sInfo" : I18n.dataTable_sInfo ,
199
+            "sInfoEmpty" : I18n.dataTable_sInfoEmpty ,
200
+            "sInfoFiltered" : I18n.dataTable_sInfoFiltered ,
201
+            "sInfoPostFix" : "",
202
+            "sSearch" : I18n.dataTable_sSearch ,
203
+            "sUrl" : "",
204
+            "sEmptyTable" : I18n.dataTable_sEmptyTable ,
205
+            "sLoadingRecords" : I18n.dataTable_sLoadingRecords ,
206
+            "sInfoThousands" : ",",
207
+            "oPaginate" : {
208
+                "sFirst" : I18n.dataTable_sFirst ,
209
+                "sPrevious" : I18n.dataTable_sPrevious ,
210
+                "sNext" : I18n.dataTable_sNext ,
211
+                "sLast" : I18n.dataTable_sLast
212
+            },
213
+            "oAria" : {
214
+                "sSortAscending" : I18n.dataTable_sSortAscending ,
215
+                "sSortDescending" : I18n.dataTable_sSortDescending
216
+            }
217
+        }
218
+	});
219
+	
220
+	// logTips alert
221
+	$('#joblog_list').on('click', '.logTips', function(){
222
+		var msg = $(this).find('span').html();
223
+		ComAlertTec.show(msg);
224
+	});
225
+	
226
+	// search Btn
227
+	$('#searchBtn').on('click', function(){
228
+		logTable.fnDraw();
229
+	});
230
+	
231
+	// logDetail look
232
+	$('#joblog_list').on('click', '.logDetail', function(){
233
+		var _id = $(this).attr('_id');
234
+		
235
+		window.open(base_url + '/joblog/logDetailPage?id=' + _id);
236
+		return;
237
+	});
238
+
239
+	/**
240
+	 * log Kill
241
+	 */
242
+	$('#joblog_list').on('click', '.logKill', function(){
243
+		var _id = $(this).attr('_id');
244
+
245
+        layer.confirm( (I18n.system_ok + I18n.joblog_kill_log + '?'), {
246
+        	icon: 3,
247
+			title: I18n.system_tips ,
248
+            btn: [ I18n.system_ok, I18n.system_cancel ]
249
+		}, function(index){
250
+            layer.close(index);
251
+
252
+            $.ajax({
253
+                type : 'POST',
254
+                url : base_url + '/joblog/logKill',
255
+                data : {"id":_id},
256
+                dataType : "json",
257
+                success : function(data){
258
+                    if (data.code == 200) {
259
+                        layer.open({
260
+                            title: I18n.system_tips,
261
+                            btn: [ I18n.system_ok ],
262
+                            content: I18n.system_opt_suc ,
263
+                            icon: '1',
264
+                            end: function(layero, index){
265
+                                logTable.fnDraw();
266
+                            }
267
+                        });
268
+                    } else {
269
+                        layer.open({
270
+                            title: I18n.system_tips,
271
+                            btn: [ I18n.system_ok ],
272
+                            content: (data.msg || I18n.system_opt_fail ),
273
+                            icon: '2'
274
+                        });
275
+                    }
276
+                },
277
+            });
278
+        });
279
+
280
+	});
281
+
282
+	/**
283
+	 * clear Log
284
+	 */
285
+	$('#clearLog').on('click', function(){
286
+
287
+		var jobGroup = $('#jobGroup').val();
288
+		var jobId = $('#jobId').val();
289
+
290
+		var jobGroupText = $("#jobGroup").find("option:selected").text();
291
+		var jobIdText = $("#jobId").find("option:selected").text();
292
+
293
+		$('#clearLogModal input[name=jobGroup]').val(jobGroup);
294
+		$('#clearLogModal input[name=jobId]').val(jobId);
295
+
296
+		$('#clearLogModal .jobGroupText').val(jobGroupText);
297
+		$('#clearLogModal .jobIdText').val(jobIdText);
298
+
299
+		$('#clearLogModal').modal('show');
300
+
301
+	});
302
+	$("#clearLogModal .ok").on('click', function(){
303
+		$.post(base_url + "/joblog/clearLog",  $("#clearLogModal .form").serialize(), function(data, status) {
304
+			if (data.code == "200") {
305
+				$('#clearLogModal').modal('hide');
306
+				layer.open({
307
+					title: I18n.system_tips ,
308
+                    btn: [ I18n.system_ok ],
309
+					content: (I18n.joblog_clean_log + I18n.system_success) ,
310
+					icon: '1',
311
+					end: function(layero, index){
312
+						logTable.fnDraw();
313
+					}
314
+				});
315
+			} else {
316
+				layer.open({
317
+					title: I18n.system_tips ,
318
+                    btn: [ I18n.system_ok ],
319
+					content: (data.msg || (I18n.joblog_clean_log + I18n.system_fail) ),
320
+					icon: '2'
321
+				});
322
+			}
323
+		});
324
+	});
325
+	$("#clearLogModal").on('hide.bs.modal', function () {
326
+		$("#clearLogModal .form")[0].reset();
327
+	});
328
+
329
+});
330
+
331
+
332
+// Com Alert by Tec theme
333
+var ComAlertTec = {
334
+	html:function(){
335
+		var html =
336
+			'<div class="modal fade" id="ComAlertTec" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
337
+			'<div class="modal-dialog">' +
338
+			'<div class="modal-content-tec">' +
339
+			'<div class="modal-body"><div class="alert" style="color:#fff;"></div></div>' +
340
+			'<div class="modal-footer">' +
341
+			'<div class="text-center" >' +
342
+			'<button type="button" class="btn btn-info ok" data-dismiss="modal" >'+ I18n.system_ok +'</button>' +
343
+			'</div>' +
344
+			'</div>' +
345
+			'</div>' +
346
+			'</div>' +
347
+			'</div>';
348
+		return html;
349
+	},
350
+	show:function(msg, callback){
351
+		// dom init
352
+		if ($('#ComAlertTec').length == 0){
353
+			$('body').append(ComAlertTec.html());
354
+		}
355
+
356
+		// init com alert
357
+		$('#ComAlertTec .alert').html(msg);
358
+		$('#ComAlertTec').modal('show');
359
+
360
+		$('#ComAlertTec .ok').click(function(){
361
+			$('#ComAlertTec').modal('hide');
362
+			if(typeof callback == 'function') {
363
+				callback();
364
+			}
365
+		});
366
+	}
367
+};

+ 47 - 47
xxl-job-core/src/main/java/com/xxl/job/core/handler/IJobHandler.java View File

@@ -1,47 +1,47 @@
1
-package com.xxl.job.core.handler;
2
-
3
-import com.xxl.job.core.biz.model.ReturnT;
4
-
5
-/**
6
- * job handler
7
- *
8
- * @author xuxueli 2015-12-19 19:06:38
9
- */
10
-public abstract class IJobHandler {
11
-
12
-
13
-	/** success */
14
-	public static final ReturnT<String> SUCCESS = new ReturnT<String>(200, null);
15
-	/** fail */
16
-	public static final ReturnT<String> FAIL = new ReturnT<String>(500, null);
17
-	/** fail timeout */
18
-	public static final ReturnT<String> FAIL_TIMEOUT = new ReturnT<String>(502, null);
19
-
20
-
21
-	/**
22
-	 * execute handler, invoked when executor receives a scheduling request
23
-	 *
24
-	 * @param param
25
-	 * @return
26
-	 * @throws Exception
27
-	 */
28
-	public abstract ReturnT<String> execute(String param) throws Exception;
29
-
30
-
31
-	/**
32
-	 * init handler, invoked when JobThread init
33
-	 */
34
-	public void init() {
35
-		// TODO
36
-	}
37
-
38
-
39
-	/**
40
-	 * destroy handler, invoked when JobThread destroy
41
-	 */
42
-	public void destroy() {
43
-		// TODO
44
-	}
45
-
46
-
47
-}
1
+package com.xxl.job.core.handler;
2
+
3
+import com.xxl.job.core.biz.model.ReturnT;
4
+
5
+/**
6
+ * job handler
7
+ *
8
+ * @author xuxueli 2015-12-19 19:06:38
9
+ */
10
+public abstract class IJobHandler {
11
+
12
+
13
+	/** success */
14
+	public static final ReturnT<String> SUCCESS = new ReturnT<String>(200, null);
15
+	/** fail */
16
+	public static final ReturnT<String> FAIL = new ReturnT<String>(500, null);
17
+	/** fail timeout */
18
+	public static final ReturnT<String> FAIL_TIMEOUT = new ReturnT<String>(502, null);
19
+
20
+
21
+	/**
22
+	 * execute handler, invoked when executor receives a scheduling request
23
+	 *
24
+	 * @param param
25
+	 * @return
26
+	 * @throws Exception
27
+	 */
28
+	public abstract ReturnT<String> execute(String param) throws Exception;
29
+
30
+
31
+	/**
32
+	 * init handler, invoked when JobThread init
33
+	 */
34
+	public void init() {
35
+		// TODO
36
+	}
37
+
38
+
39
+	/**
40
+	 * destroy handler, invoked when JobThread destroy
41
+	 */
42
+	public void destroy() {
43
+		// TODO
44
+	}
45
+
46
+
47
+}