提交 50b1c679 authored 作者: xuxueli's avatar xuxueli

RM

上级 7a0f63f7
package com.xxl.job.admin.core.jobbean; package com.xxl.job.admin.core.jobbean;
import com.xxl.job.admin.core.thread.JobTriggerPoolHelper; import com.xxl.job.admin.core.thread.JobTriggerPoolHelper;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException; import org.quartz.JobExecutionException;
import org.quartz.JobKey; import org.quartz.JobKey;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.scheduling.quartz.QuartzJobBean; import org.springframework.scheduling.quartz.QuartzJobBean;
/** /**
* http job bean * http job bean
* “@DisallowConcurrentExecution” diable concurrent, thread size can not be only one, better given more * “@DisallowConcurrentExecution” diable concurrent, thread size can not be only one, better given more
* @author xuxueli 2015-12-17 18:20:34 * @author xuxueli 2015-12-17 18:20:34
*/ */
//@DisallowConcurrentExecution //@DisallowConcurrentExecution
public class RemoteHttpJobBean extends QuartzJobBean { public class RemoteHttpJobBean extends QuartzJobBean {
private static Logger logger = LoggerFactory.getLogger(RemoteHttpJobBean.class); private static Logger logger = LoggerFactory.getLogger(RemoteHttpJobBean.class);
@Override @Override
protected void executeInternal(JobExecutionContext context) protected void executeInternal(JobExecutionContext context)
throws JobExecutionException { throws JobExecutionException {
// load jobId // load jobId
JobKey jobKey = context.getTrigger().getJobKey(); JobKey jobKey = context.getTrigger().getJobKey();
Integer jobId = Integer.valueOf(jobKey.getName()); Integer jobId = Integer.valueOf(jobKey.getName());
// trigger // trigger
//XxlJobTrigger.trigger(jobId); //XxlJobTrigger.trigger(jobId);
JobTriggerPoolHelper.trigger(jobId, -1); JobTriggerPoolHelper.trigger(jobId, -1);
} }
} }
\ No newline at end of file
package com.xxl.job.admin.core.model; package com.xxl.job.admin.core.model;
import java.util.Date; import java.util.Date;
/** /**
* xxl-job log, used to track trigger process * xxl-job log, used to track trigger process
* @author xuxueli 2015-12-19 23:19:09 * @author xuxueli 2015-12-19 23:19:09
*/ */
public class XxlJobLog { public class XxlJobLog {
private int id; private int id;
// job info // job info
private int jobGroup; private int jobGroup;
private int jobId; private int jobId;
// glueType // glueType
private String glueType; private String glueType;
// execute info // execute info
private String executorAddress; private String executorAddress;
private String executorHandler; private String executorHandler;
private String executorParam; private String executorParam;
private int executorFailRetryCount; private int executorFailRetryCount;
// trigger info // trigger info
private Date triggerTime; private Date triggerTime;
private int triggerCode; private int triggerCode;
private String triggerMsg; private String triggerMsg;
// handle info // handle info
private Date handleTime; private Date handleTime;
private int handleCode; private int handleCode;
private String handleMsg; private String handleMsg;
public int getId() { public int getId() {
return id; return id;
} }
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
public int getJobGroup() { public int getJobGroup() {
return jobGroup; return jobGroup;
} }
public void setJobGroup(int jobGroup) { public void setJobGroup(int jobGroup) {
this.jobGroup = jobGroup; this.jobGroup = jobGroup;
} }
public int getJobId() { public int getJobId() {
return jobId; return jobId;
} }
public void setJobId(int jobId) { public void setJobId(int jobId) {
this.jobId = jobId; this.jobId = jobId;
} }
public String getGlueType() { public String getGlueType() {
return glueType; return glueType;
} }
public void setGlueType(String glueType) { public void setGlueType(String glueType) {
this.glueType = glueType; this.glueType = glueType;
} }
public String getExecutorAddress() { public String getExecutorAddress() {
return executorAddress; return executorAddress;
} }
public void setExecutorAddress(String executorAddress) { public void setExecutorAddress(String executorAddress) {
this.executorAddress = executorAddress; this.executorAddress = executorAddress;
} }
public String getExecutorHandler() { public String getExecutorHandler() {
return executorHandler; return executorHandler;
} }
public void setExecutorHandler(String executorHandler) { public void setExecutorHandler(String executorHandler) {
this.executorHandler = executorHandler; this.executorHandler = executorHandler;
} }
public String getExecutorParam() { public String getExecutorParam() {
return executorParam; return executorParam;
} }
public void setExecutorParam(String executorParam) { public void setExecutorParam(String executorParam) {
this.executorParam = executorParam; this.executorParam = executorParam;
} }
public int getExecutorFailRetryCount() { public int getExecutorFailRetryCount() {
return executorFailRetryCount; return executorFailRetryCount;
} }
public void setExecutorFailRetryCount(int executorFailRetryCount) { public void setExecutorFailRetryCount(int executorFailRetryCount) {
this.executorFailRetryCount = executorFailRetryCount; this.executorFailRetryCount = executorFailRetryCount;
} }
public Date getTriggerTime() { public Date getTriggerTime() {
return triggerTime; return triggerTime;
} }
public void setTriggerTime(Date triggerTime) { public void setTriggerTime(Date triggerTime) {
this.triggerTime = triggerTime; this.triggerTime = triggerTime;
} }
public int getTriggerCode() { public int getTriggerCode() {
return triggerCode; return triggerCode;
} }
public void setTriggerCode(int triggerCode) { public void setTriggerCode(int triggerCode) {
this.triggerCode = triggerCode; this.triggerCode = triggerCode;
} }
public String getTriggerMsg() { public String getTriggerMsg() {
return triggerMsg; return triggerMsg;
} }
public void setTriggerMsg(String triggerMsg) { public void setTriggerMsg(String triggerMsg) {
// plugin // plugin
if (triggerMsg!=null && triggerMsg.length()>2000) { if (triggerMsg!=null && triggerMsg.length()>2000) {
triggerMsg = triggerMsg.substring(0, 2000); triggerMsg = triggerMsg.substring(0, 2000);
} }
this.triggerMsg = triggerMsg; this.triggerMsg = triggerMsg;
} }
public Date getHandleTime() { public Date getHandleTime() {
return handleTime; return handleTime;
} }
public void setHandleTime(Date handleTime) { public void setHandleTime(Date handleTime) {
this.handleTime = handleTime; this.handleTime = handleTime;
} }
public int getHandleCode() { public int getHandleCode() {
return handleCode; return handleCode;
} }
public void setHandleCode(int handleCode) { public void setHandleCode(int handleCode) {
this.handleCode = handleCode; this.handleCode = handleCode;
} }
public String getHandleMsg() { public String getHandleMsg() {
return handleMsg; return handleMsg;
} }
public void setHandleMsg(String handleMsg) { public void setHandleMsg(String handleMsg) {
// plugin // plugin
if (handleMsg!=null && handleMsg.length()>2000) { if (handleMsg!=null && handleMsg.length()>2000) {
handleMsg = handleMsg.substring(0, 2000); handleMsg = handleMsg.substring(0, 2000);
} }
this.handleMsg = handleMsg; this.handleMsg = handleMsg;
} }
} }
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.xxl.job.admin.dao.XxlJobLogDao"> <mapper namespace="com.xxl.job.admin.dao.XxlJobLogDao">
<resultMap id="XxlJobLog" type="com.xxl.job.admin.core.model.XxlJobLog" > <resultMap id="XxlJobLog" type="com.xxl.job.admin.core.model.XxlJobLog" >
<result column="id" property="id" /> <result column="id" property="id" />
<result column="job_group" property="jobGroup" /> <result column="job_group" property="jobGroup" />
<result column="job_id" property="jobId" /> <result column="job_id" property="jobId" />
<result column="glue_type" property="glueType" /> <result column="glue_type" property="glueType" />
<result column="executor_address" property="executorAddress" /> <result column="executor_address" property="executorAddress" />
<result column="executor_handler" property="executorHandler" /> <result column="executor_handler" property="executorHandler" />
<result column="executor_param" property="executorParam" /> <result column="executor_param" property="executorParam" />
<result column="executor_fail_retry_count" property="executorFailRetryCount" /> <result column="executor_fail_retry_count" property="executorFailRetryCount" />
<result column="trigger_time" property="triggerTime" /> <result column="trigger_time" property="triggerTime" />
<result column="trigger_code" property="triggerCode" /> <result column="trigger_code" property="triggerCode" />
<result column="trigger_msg" property="triggerMsg" /> <result column="trigger_msg" property="triggerMsg" />
<result column="handle_time" property="handleTime" /> <result column="handle_time" property="handleTime" />
<result column="handle_code" property="handleCode" /> <result column="handle_code" property="handleCode" />
<result column="handle_msg" property="handleMsg" /> <result column="handle_msg" property="handleMsg" />
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
t.id, t.id,
t.job_group, t.job_group,
t.job_id, t.job_id,
t.glue_type, t.glue_type,
t.executor_address, t.executor_address,
t.executor_handler, t.executor_handler,
t.executor_param, t.executor_param,
t.executor_fail_retry_count, t.executor_fail_retry_count,
t.trigger_time, t.trigger_time,
t.trigger_code, t.trigger_code,
t.trigger_msg, t.trigger_msg,
t.handle_time, t.handle_time,
t.handle_code, t.handle_code,
t.handle_msg t.handle_msg
</sql> </sql>
<select id="pageList" resultMap="XxlJobLog"> <select id="pageList" resultMap="XxlJobLog">
SELECT <include refid="Base_Column_List" /> SELECT <include refid="Base_Column_List" />
FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" > <trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0"> <if test="jobGroup gt 0">
AND t.job_group = #{jobGroup} AND t.job_group = #{jobGroup}
</if> </if>
<if test="jobId gt 0"> <if test="jobId gt 0">
AND t.job_id = #{jobId} AND t.job_id = #{jobId}
</if> </if>
<if test="triggerTimeStart != null"> <if test="triggerTimeStart != null">
AND t.trigger_time <![CDATA[ >= ]]> #{triggerTimeStart} AND t.trigger_time <![CDATA[ >= ]]> #{triggerTimeStart}
</if> </if>
<if test="triggerTimeEnd != null"> <if test="triggerTimeEnd != null">
AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd} AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}
</if> </if>
<if test="logStatus == 1" > <if test="logStatus == 1" >
AND t.handle_code = 200 AND t.handle_code = 200
</if> </if>
<if test="logStatus == 2" > <if test="logStatus == 2" >
AND ( AND (
t.trigger_code NOT IN (0, 200) OR t.trigger_code NOT IN (0, 200) OR
t.handle_code NOT IN (0, 200) t.handle_code NOT IN (0, 200)
) )
</if> </if>
<if test="logStatus == 3" > <if test="logStatus == 3" >
AND t.trigger_code = 200 AND t.trigger_code = 200
AND t.handle_code = 0 AND t.handle_code = 0
</if> </if>
</trim> </trim>
ORDER BY id DESC ORDER BY id DESC
LIMIT #{offset}, #{pagesize} LIMIT #{offset}, #{pagesize}
</select> </select>
<select id="pageListCount" resultType="int"> <select id="pageListCount" resultType="int">
SELECT count(1) SELECT count(1)
FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" > <trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0"> <if test="jobGroup gt 0">
AND t.job_group = #{jobGroup} AND t.job_group = #{jobGroup}
</if> </if>
<if test="jobId gt 0"> <if test="jobId gt 0">
AND t.job_id = #{jobId} AND t.job_id = #{jobId}
</if> </if>
<if test="triggerTimeStart != null"> <if test="triggerTimeStart != null">
AND t.trigger_time <![CDATA[ >= ]]> #{triggerTimeStart} AND t.trigger_time <![CDATA[ >= ]]> #{triggerTimeStart}
</if> </if>
<if test="triggerTimeEnd != null"> <if test="triggerTimeEnd != null">
AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd} AND t.trigger_time <![CDATA[ <= ]]> #{triggerTimeEnd}
</if> </if>
<if test="logStatus == 1" > <if test="logStatus == 1" >
AND t.handle_code = 200 AND t.handle_code = 200
</if> </if>
<if test="logStatus == 2" > <if test="logStatus == 2" >
AND ( AND (
t.trigger_code NOT IN (0, 200) OR t.trigger_code NOT IN (0, 200) OR
t.handle_code NOT IN (0, 200) t.handle_code NOT IN (0, 200)
) )
</if> </if>
<if test="logStatus == 3" > <if test="logStatus == 3" >
AND t.trigger_code = 200 AND t.trigger_code = 200
AND t.handle_code = 0 AND t.handle_code = 0
</if> </if>
</trim> </trim>
</select> </select>
<select id="load" parameterType="java.lang.Integer" resultMap="XxlJobLog"> <select id="load" parameterType="java.lang.Integer" resultMap="XxlJobLog">
SELECT <include refid="Base_Column_List" /> SELECT <include refid="Base_Column_List" />
FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
WHERE t.id = #{id} WHERE t.id = #{id}
</select> </select>
<insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobLog" useGeneratedKeys="true" keyProperty="id" > <insert id="save" parameterType="com.xxl.job.admin.core.model.XxlJobLog" useGeneratedKeys="true" keyProperty="id" >
INSERT INTO XXL_JOB_QRTZ_TRIGGER_LOG ( INSERT INTO XXL_JOB_QRTZ_TRIGGER_LOG (
`job_group`, `job_group`,
`job_id`, `job_id`,
`trigger_code`, `trigger_code`,
`handle_code` `handle_code`
) VALUES ( ) VALUES (
#{jobGroup}, #{jobGroup},
#{jobId}, #{jobId},
#{triggerCode}, #{triggerCode},
#{handleCode} #{handleCode}
); );
<!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id"> <!--<selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
SELECT LAST_INSERT_ID() SELECT LAST_INSERT_ID()
</selectKey>--> </selectKey>-->
</insert> </insert>
<update id="updateTriggerInfo" > <update id="updateTriggerInfo" >
UPDATE XXL_JOB_QRTZ_TRIGGER_LOG UPDATE XXL_JOB_QRTZ_TRIGGER_LOG
SET SET
`glue_type`= #{glueType}, `glue_type`= #{glueType},
`trigger_time`= #{triggerTime}, `trigger_time`= #{triggerTime},
`trigger_code`= #{triggerCode}, `trigger_code`= #{triggerCode},
`trigger_msg`= #{triggerMsg}, `trigger_msg`= #{triggerMsg},
`executor_address`= #{executorAddress}, `executor_address`= #{executorAddress},
`executor_handler`=#{executorHandler}, `executor_handler`=#{executorHandler},
`executor_param`= #{executorParam}, `executor_param`= #{executorParam},
`executor_fail_retry_count`= #{executorFailRetryCount} `executor_fail_retry_count`= #{executorFailRetryCount}
WHERE `id`= #{id} WHERE `id`= #{id}
</update> </update>
<update id="updateHandleInfo"> <update id="updateHandleInfo">
UPDATE XXL_JOB_QRTZ_TRIGGER_LOG UPDATE XXL_JOB_QRTZ_TRIGGER_LOG
SET SET
`handle_time`= #{handleTime}, `handle_time`= #{handleTime},
`handle_code`= #{handleCode}, `handle_code`= #{handleCode},
`handle_msg`= #{handleMsg} `handle_msg`= #{handleMsg}
WHERE `id`= #{id} WHERE `id`= #{id}
</update> </update>
<delete id="delete" > <delete id="delete" >
delete from XXL_JOB_QRTZ_TRIGGER_LOG delete from XXL_JOB_QRTZ_TRIGGER_LOG
WHERE job_id = #{jobId} WHERE job_id = #{jobId}
</delete> </delete>
<select id="triggerCountByHandleCode" resultType="int" > <select id="triggerCountByHandleCode" resultType="int" >
SELECT count(1) SELECT count(1)
FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" > <trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="handleCode gt 0"> <if test="handleCode gt 0">
AND t.handle_code = #{handleCode} AND t.handle_code = #{handleCode}
</if> </if>
</trim> </trim>
</select> </select>
<select id="triggerCountByDay" resultType="java.util.Map" > <select id="triggerCountByDay" resultType="java.util.Map" >
SELECT SELECT
DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay, DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay,
COUNT(handle_code) triggerDayCount, COUNT(handle_code) triggerDayCount,
SUM(CASE WHEN (trigger_code = 200 and handle_code = 0) then 1 else 0 end) as triggerDayCountRunning, SUM(CASE WHEN (trigger_code = 200 and handle_code = 0) then 1 else 0 end) as triggerDayCountRunning,
SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSuc SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSuc
FROM XXL_JOB_QRTZ_TRIGGER_LOG FROM XXL_JOB_QRTZ_TRIGGER_LOG
WHERE trigger_time BETWEEN #{from} and #{to} WHERE trigger_time BETWEEN #{from} and #{to}
GROUP BY triggerDay; GROUP BY triggerDay;
</select> </select>
<delete id="clearLog" > <delete id="clearLog" >
delete from XXL_JOB_QRTZ_TRIGGER_LOG delete from XXL_JOB_QRTZ_TRIGGER_LOG
<trim prefix="WHERE" prefixOverrides="AND | OR" > <trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0"> <if test="jobGroup gt 0">
AND job_group = #{jobGroup} AND job_group = #{jobGroup}
</if> </if>
<if test="jobId gt 0"> <if test="jobId gt 0">
AND job_id = #{jobId} AND job_id = #{jobId}
</if> </if>
<if test="clearBeforeTime != null"> <if test="clearBeforeTime != null">
AND trigger_time <![CDATA[ <= ]]> #{clearBeforeTime} AND trigger_time <![CDATA[ <= ]]> #{clearBeforeTime}
</if> </if>
<if test="clearBeforeNum gt 0"> <if test="clearBeforeNum gt 0">
AND id NOT in( AND id NOT in(
SELECT id FROM( SELECT id FROM(
SELECT id FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t SELECT id FROM XXL_JOB_QRTZ_TRIGGER_LOG AS t
<trim prefix="WHERE" prefixOverrides="AND | OR" > <trim prefix="WHERE" prefixOverrides="AND | OR" >
<if test="jobGroup gt 0"> <if test="jobGroup gt 0">
AND t.job_group = #{jobGroup} AND t.job_group = #{jobGroup}
</if> </if>
<if test="jobId gt 0"> <if test="jobId gt 0">
AND t.job_id = #{jobId} AND t.job_id = #{jobId}
</if> </if>
</trim> </trim>
ORDER BY t.trigger_time desc ORDER BY t.trigger_time desc
LIMIT 0, #{clearBeforeNum} LIMIT 0, #{clearBeforeNum}
) t1 ) t1
) )
</if> </if>
</trim> </trim>
</delete> </delete>
</mapper> </mapper>
\ No newline at end of file
$(function() { $(function() {
// jobGroup change, job list init and select // jobGroup change, job list init and select
$("#jobGroup").on("change", function () { $("#jobGroup").on("change", function () {
var jobGroup = $(this).children('option:selected').val(); var jobGroup = $(this).children('option:selected').val();
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
async: false, // async, avoid js invoke pagelist before jobId data init async: false, // async, avoid js invoke pagelist before jobId data init
url : base_url + '/joblog/getJobsByGroup', url : base_url + '/joblog/getJobsByGroup',
data : {"jobGroup":jobGroup}, data : {"jobGroup":jobGroup},
dataType : "json", dataType : "json",
success : function(data){ success : function(data){
if (data.code == 200) { if (data.code == 200) {
$("#jobId").html( '<option value="0" >'+ I18n.system_all +'</option>' ); $("#jobId").html( '<option value="0" >'+ I18n.system_all +'</option>' );
$.each(data.content, function (n, value) { $.each(data.content, function (n, value) {
$("#jobId").append('<option value="' + value.id + '" >' + value.jobDesc + '</option>'); $("#jobId").append('<option value="' + value.id + '" >' + value.jobDesc + '</option>');
}); });
if ($("#jobId").attr("paramVal")){ if ($("#jobId").attr("paramVal")){
$("#jobId").find("option[value='" + $("#jobId").attr("paramVal") + "']").attr("selected",true); $("#jobId").find("option[value='" + $("#jobId").attr("paramVal") + "']").attr("selected",true);
} }
} else { } else {
layer.open({ layer.open({
title: I18n.system_tips , title: I18n.system_tips ,
btn: [ I18n.system_ok ], btn: [ I18n.system_ok ],
content: (data.msg || I18n.system_api_error ), content: (data.msg || I18n.system_api_error ),
icon: '2' icon: '2'
}); });
} }
}, },
}); });
}); });
if ($("#jobGroup").attr("paramVal")){ if ($("#jobGroup").attr("paramVal")){
$("#jobGroup").find("option[value='" + $("#jobGroup").attr("paramVal") + "']").attr("selected",true); $("#jobGroup").find("option[value='" + $("#jobGroup").attr("paramVal") + "']").attr("selected",true);
$("#jobGroup").change(); $("#jobGroup").change();
} }
// filter Time // filter Time
var rangesConf = {}; var rangesConf = {};
rangesConf[I18n.daterangepicker_ranges_recent_hour] = [moment().subtract(1, 'hours'), moment()]; rangesConf[I18n.daterangepicker_ranges_recent_hour] = [moment().subtract(1, 'hours'), moment()];
rangesConf[I18n.daterangepicker_ranges_today] = [moment().startOf('day'), moment().endOf('day')]; rangesConf[I18n.daterangepicker_ranges_today] = [moment().startOf('day'), moment().endOf('day')];
rangesConf[I18n.daterangepicker_ranges_yesterday] = [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')]; rangesConf[I18n.daterangepicker_ranges_yesterday] = [moment().subtract(1, 'days').startOf('day'), moment().subtract(1, 'days').endOf('day')];
rangesConf[I18n.daterangepicker_ranges_this_month] = [moment().startOf('month'), moment().endOf('month')]; rangesConf[I18n.daterangepicker_ranges_this_month] = [moment().startOf('month'), moment().endOf('month')];
rangesConf[I18n.daterangepicker_ranges_last_month] = [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')]; rangesConf[I18n.daterangepicker_ranges_last_month] = [moment().subtract(1, 'months').startOf('month'), moment().subtract(1, 'months').endOf('month')];
rangesConf[I18n.daterangepicker_ranges_recent_week] = [moment().subtract(1, 'weeks').startOf('day'), moment().endOf('day')]; rangesConf[I18n.daterangepicker_ranges_recent_week] = [moment().subtract(1, 'weeks').startOf('day'), moment().endOf('day')];
rangesConf[I18n.daterangepicker_ranges_recent_month] = [moment().subtract(1, 'months').startOf('day'), moment().endOf('day')]; rangesConf[I18n.daterangepicker_ranges_recent_month] = [moment().subtract(1, 'months').startOf('day'), moment().endOf('day')];
$('#filterTime').daterangepicker({ $('#filterTime').daterangepicker({
autoApply:false, autoApply:false,
singleDatePicker:false, singleDatePicker:false,
showDropdowns:false, // 是否显示年月选择条件 showDropdowns:false, // 是否显示年月选择条件
timePicker: true, // 是否显示小时和分钟选择条件 timePicker: true, // 是否显示小时和分钟选择条件
timePickerIncrement: 10, // 时间的增量,单位为分钟 timePickerIncrement: 10, // 时间的增量,单位为分钟
timePicker24Hour : true, timePicker24Hour : true,
opens : 'left', //日期选择框的弹出位置 opens : 'left', //日期选择框的弹出位置
ranges: rangesConf, ranges: rangesConf,
locale : { locale : {
format: 'YYYY-MM-DD HH:mm:ss', format: 'YYYY-MM-DD HH:mm:ss',
separator : ' - ', separator : ' - ',
customRangeLabel : I18n.daterangepicker_custom_name , customRangeLabel : I18n.daterangepicker_custom_name ,
applyLabel : I18n.system_ok , applyLabel : I18n.system_ok ,
cancelLabel : I18n.system_cancel , cancelLabel : I18n.system_cancel ,
fromLabel : I18n.daterangepicker_custom_starttime , fromLabel : I18n.daterangepicker_custom_starttime ,
toLabel : I18n.daterangepicker_custom_endtime , toLabel : I18n.daterangepicker_custom_endtime ,
daysOfWeek : I18n.daterangepicker_custom_daysofweek.split(',') , // '日', '一', '二', '三', '四', '五', '六' daysOfWeek : I18n.daterangepicker_custom_daysofweek.split(',') , // '日', '一', '二', '三', '四', '五', '六'
monthNames : I18n.daterangepicker_custom_monthnames.split(',') , // '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月' monthNames : I18n.daterangepicker_custom_monthnames.split(',') , // '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'
firstDay : 1 firstDay : 1
}, },
startDate: rangesConf[I18n.daterangepicker_ranges_today][0], startDate: rangesConf[I18n.daterangepicker_ranges_today][0],
endDate: rangesConf[I18n.daterangepicker_ranges_today][1] endDate: rangesConf[I18n.daterangepicker_ranges_today][1]
}); });
// init date tables // init date tables
var logTable = $("#joblog_list").dataTable({ var logTable = $("#joblog_list").dataTable({
"deferRender": true, "deferRender": true,
"processing" : true, "processing" : true,
"serverSide": true, "serverSide": true,
"ajax": { "ajax": {
url: base_url + "/joblog/pageList" , url: base_url + "/joblog/pageList" ,
type:"post", type:"post",
data : function ( d ) { data : function ( d ) {
var obj = {}; var obj = {};
obj.jobGroup = $('#jobGroup').val(); obj.jobGroup = $('#jobGroup').val();
obj.jobId = $('#jobId').val(); obj.jobId = $('#jobId').val();
obj.logStatus = $('#logStatus').val(); obj.logStatus = $('#logStatus').val();
obj.filterTime = $('#filterTime').val(); obj.filterTime = $('#filterTime').val();
obj.start = d.start; obj.start = d.start;
obj.length = d.length; obj.length = d.length;
return obj; return obj;
} }
}, },
"searching": false, "searching": false,
"ordering": false, "ordering": false,
//"scrollX": false, //"scrollX": false,
"columns": [ "columns": [
{ {
"data": 'jobId', "data": 'jobId',
"visible" : true, "visible" : true,
"width":'10%', "width":'10%',
"render": function ( data, type, row ) { "render": function ( data, type, row ) {
var glueTypeTitle = GlueTypeEnum[row.glueType]; var glueTypeTitle = GlueTypeEnum[row.glueType];
if (row.executorHandler) { if (row.executorHandler) {
glueTypeTitle = glueTypeTitle +":" + row.executorHandler; glueTypeTitle = glueTypeTitle +":" + row.executorHandler;
} }
var temp = ''; var temp = '';
temp += I18n.joblog_field_executorAddress + ':' + (row.executorAddress?row.executorAddress:''); temp += I18n.joblog_field_executorAddress + ':' + (row.executorAddress?row.executorAddress:'');
temp += '<br>'+ I18n.jobinfo_field_gluetype +':' + glueTypeTitle; temp += '<br>'+ I18n.jobinfo_field_gluetype +':' + glueTypeTitle;
temp += '<br>'+ I18n.jobinfo_field_executorparam +':' + row.executorParam; temp += '<br>'+ I18n.jobinfo_field_executorparam +':' + row.executorParam;
return '<a class="logTips" href="javascript:;" >'+ row.jobId +'<span style="display:none;">'+ temp +'</span></a>'; return '<a class="logTips" href="javascript:;" >'+ row.jobId +'<span style="display:none;">'+ temp +'</span></a>';
} }
}, },
{ "data": 'jobGroup', "visible" : false}, { "data": 'jobGroup', "visible" : false},
{ {
"data": 'triggerTime', "data": 'triggerTime',
"width":'16%', "width":'16%',
"render": function ( data, type, row ) { "render": function ( data, type, row ) {
return data?moment(new Date(data)).format("YYYY-MM-DD HH:mm:ss"):""; return data?moment(new Date(data)).format("YYYY-MM-DD HH:mm:ss"):"";
} }
}, },
{ {
"data": 'triggerCode', "data": 'triggerCode',
"width":'12%', "width":'12%',
"render": function ( data, type, row ) { "render": function ( data, type, row ) {
var html = data; var html = data;
if (data == 200) { if (data == 200) {
html = '<span style="color: green">'+ I18n.system_success +'</span>'; html = '<span style="color: green">'+ I18n.system_success +'</span>';
} else if (data == 500) { } else if (data == 500) {
html = '<span style="color: red">'+ I18n.system_fail +'</span>'; html = '<span style="color: red">'+ I18n.system_fail +'</span>';
} else if (data == 0) { } else if (data == 0) {
html = ''; html = '';
} }
return html; return html;
} }
}, },
{ {
"data": 'triggerMsg', "data": 'triggerMsg',
"width":'12%', "width":'12%',
"render": function ( data, type, row ) { "render": function ( data, type, row ) {
return data?'<a class="logTips" href="javascript:;" >'+ I18n.system_show +'<span style="display:none;">'+ data +'</span></a>':I18n.system_empty; return data?'<a class="logTips" href="javascript:;" >'+ I18n.system_show +'<span style="display:none;">'+ data +'</span></a>':I18n.system_empty;
} }
}, },
{ {
"data": 'handleTime', "data": 'handleTime',
"width":'16%', "width":'16%',
"render": function ( data, type, row ) { "render": function ( data, type, row ) {
return data?moment(new Date(data)).format("YYYY-MM-DD HH:mm:ss"):""; return data?moment(new Date(data)).format("YYYY-MM-DD HH:mm:ss"):"";
} }
}, },
{ {
"data": 'handleCode', "data": 'handleCode',
"width":'12%', "width":'12%',
"render": function ( data, type, row ) { "render": function ( data, type, row ) {
var html = data; var html = data;
if (data == 200) { if (data == 200) {
html = '<span style="color: green">'+ I18n.joblog_handleCode_200 +'</span>'; html = '<span style="color: green">'+ I18n.joblog_handleCode_200 +'</span>';
} else if (data == 500) { } else if (data == 500) {
html = '<span style="color: red">'+ I18n.joblog_handleCode_500 +'</span>'; html = '<span style="color: red">'+ I18n.joblog_handleCode_500 +'</span>';
} else if (data == 502) { } else if (data == 502) {
html = '<span style="color: red">'+ I18n.joblog_handleCode_502 +'</span>'; html = '<span style="color: red">'+ I18n.joblog_handleCode_502 +'</span>';
} else if (data == 0) { } else if (data == 0) {
html = ''; html = '';
} }
return html; return html;
} }
}, },
{ {
"data": 'handleMsg', "data": 'handleMsg',
"width":'12%', "width":'12%',
"render": function ( data, type, row ) { "render": function ( data, type, row ) {
return data?'<a class="logTips" href="javascript:;" >'+ I18n.system_show +'<span style="display:none;">'+ data +'</span></a>':I18n.system_empty; return data?'<a class="logTips" href="javascript:;" >'+ I18n.system_show +'<span style="display:none;">'+ data +'</span></a>':I18n.system_empty;
} }
}, },
{ {
"data": 'handleMsg' , "data": 'handleMsg' ,
"bSortable": false, "bSortable": false,
"width":'10%', "width":'10%',
"render": function ( data, type, row ) { "render": function ( data, type, row ) {
// better support expression or string, not function // better support expression or string, not function
return function () { return function () {
if (row.triggerCode == 200){ if (row.triggerCode == 200){
var temp = '<a href="javascript:;" class="logDetail" _id="'+ row.id +'">'+ I18n.joblog_rolling_log +'</a>'; var temp = '<a href="javascript:;" class="logDetail" _id="'+ row.id +'">'+ I18n.joblog_rolling_log +'</a>';
if(row.handleCode == 0){ if(row.handleCode == 0){
temp += '<br><a href="javascript:;" class="logKill" _id="'+ row.id +'" style="color: red;" >'+ I18n.joblog_kill_log +'</a>'; temp += '<br><a href="javascript:;" class="logKill" _id="'+ row.id +'" style="color: red;" >'+ I18n.joblog_kill_log +'</a>';
} }
return temp; return temp;
} }
return null; return null;
} }
} }
} }
], ],
"language" : { "language" : {
"sProcessing" : I18n.dataTable_sProcessing , "sProcessing" : I18n.dataTable_sProcessing ,
"sLengthMenu" : I18n.dataTable_sLengthMenu , "sLengthMenu" : I18n.dataTable_sLengthMenu ,
"sZeroRecords" : I18n.dataTable_sZeroRecords , "sZeroRecords" : I18n.dataTable_sZeroRecords ,
"sInfo" : I18n.dataTable_sInfo , "sInfo" : I18n.dataTable_sInfo ,
"sInfoEmpty" : I18n.dataTable_sInfoEmpty , "sInfoEmpty" : I18n.dataTable_sInfoEmpty ,
"sInfoFiltered" : I18n.dataTable_sInfoFiltered , "sInfoFiltered" : I18n.dataTable_sInfoFiltered ,
"sInfoPostFix" : "", "sInfoPostFix" : "",
"sSearch" : I18n.dataTable_sSearch , "sSearch" : I18n.dataTable_sSearch ,
"sUrl" : "", "sUrl" : "",
"sEmptyTable" : I18n.dataTable_sEmptyTable , "sEmptyTable" : I18n.dataTable_sEmptyTable ,
"sLoadingRecords" : I18n.dataTable_sLoadingRecords , "sLoadingRecords" : I18n.dataTable_sLoadingRecords ,
"sInfoThousands" : ",", "sInfoThousands" : ",",
"oPaginate" : { "oPaginate" : {
"sFirst" : I18n.dataTable_sFirst , "sFirst" : I18n.dataTable_sFirst ,
"sPrevious" : I18n.dataTable_sPrevious , "sPrevious" : I18n.dataTable_sPrevious ,
"sNext" : I18n.dataTable_sNext , "sNext" : I18n.dataTable_sNext ,
"sLast" : I18n.dataTable_sLast "sLast" : I18n.dataTable_sLast
}, },
"oAria" : { "oAria" : {
"sSortAscending" : I18n.dataTable_sSortAscending , "sSortAscending" : I18n.dataTable_sSortAscending ,
"sSortDescending" : I18n.dataTable_sSortDescending "sSortDescending" : I18n.dataTable_sSortDescending
} }
} }
}); });
// logTips alert // logTips alert
$('#joblog_list').on('click', '.logTips', function(){ $('#joblog_list').on('click', '.logTips', function(){
var msg = $(this).find('span').html(); var msg = $(this).find('span').html();
ComAlertTec.show(msg); ComAlertTec.show(msg);
}); });
// search Btn // search Btn
$('#searchBtn').on('click', function(){ $('#searchBtn').on('click', function(){
logTable.fnDraw(); logTable.fnDraw();
}); });
// logDetail look // logDetail look
$('#joblog_list').on('click', '.logDetail', function(){ $('#joblog_list').on('click', '.logDetail', function(){
var _id = $(this).attr('_id'); var _id = $(this).attr('_id');
window.open(base_url + '/joblog/logDetailPage?id=' + _id); window.open(base_url + '/joblog/logDetailPage?id=' + _id);
return; return;
}); });
/** /**
* log Kill * log Kill
*/ */
$('#joblog_list').on('click', '.logKill', function(){ $('#joblog_list').on('click', '.logKill', function(){
var _id = $(this).attr('_id'); var _id = $(this).attr('_id');
layer.confirm( (I18n.system_ok + I18n.joblog_kill_log + '?'), { layer.confirm( (I18n.system_ok + I18n.joblog_kill_log + '?'), {
icon: 3, icon: 3,
title: I18n.system_tips , title: I18n.system_tips ,
btn: [ I18n.system_ok, I18n.system_cancel ] btn: [ I18n.system_ok, I18n.system_cancel ]
}, function(index){ }, function(index){
layer.close(index); layer.close(index);
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
url : base_url + '/joblog/logKill', url : base_url + '/joblog/logKill',
data : {"id":_id}, data : {"id":_id},
dataType : "json", dataType : "json",
success : function(data){ success : function(data){
if (data.code == 200) { if (data.code == 200) {
layer.open({ layer.open({
title: I18n.system_tips, title: I18n.system_tips,
btn: [ I18n.system_ok ], btn: [ I18n.system_ok ],
content: I18n.system_opt_suc , content: I18n.system_opt_suc ,
icon: '1', icon: '1',
end: function(layero, index){ end: function(layero, index){
logTable.fnDraw(); logTable.fnDraw();
} }
}); });
} else { } else {
layer.open({ layer.open({
title: I18n.system_tips, title: I18n.system_tips,
btn: [ I18n.system_ok ], btn: [ I18n.system_ok ],
content: (data.msg || I18n.system_opt_fail ), content: (data.msg || I18n.system_opt_fail ),
icon: '2' icon: '2'
}); });
} }
}, },
}); });
}); });
}); });
/** /**
* clear Log * clear Log
*/ */
$('#clearLog').on('click', function(){ $('#clearLog').on('click', function(){
var jobGroup = $('#jobGroup').val(); var jobGroup = $('#jobGroup').val();
var jobId = $('#jobId').val(); var jobId = $('#jobId').val();
var jobGroupText = $("#jobGroup").find("option:selected").text(); var jobGroupText = $("#jobGroup").find("option:selected").text();
var jobIdText = $("#jobId").find("option:selected").text(); var jobIdText = $("#jobId").find("option:selected").text();
$('#clearLogModal input[name=jobGroup]').val(jobGroup); $('#clearLogModal input[name=jobGroup]').val(jobGroup);
$('#clearLogModal input[name=jobId]').val(jobId); $('#clearLogModal input[name=jobId]').val(jobId);
$('#clearLogModal .jobGroupText').val(jobGroupText); $('#clearLogModal .jobGroupText').val(jobGroupText);
$('#clearLogModal .jobIdText').val(jobIdText); $('#clearLogModal .jobIdText').val(jobIdText);
$('#clearLogModal').modal('show'); $('#clearLogModal').modal('show');
}); });
$("#clearLogModal .ok").on('click', function(){ $("#clearLogModal .ok").on('click', function(){
$.post(base_url + "/joblog/clearLog", $("#clearLogModal .form").serialize(), function(data, status) { $.post(base_url + "/joblog/clearLog", $("#clearLogModal .form").serialize(), function(data, status) {
if (data.code == "200") { if (data.code == "200") {
$('#clearLogModal').modal('hide'); $('#clearLogModal').modal('hide');
layer.open({ layer.open({
title: I18n.system_tips , title: I18n.system_tips ,
btn: [ I18n.system_ok ], btn: [ I18n.system_ok ],
content: (I18n.joblog_clean_log + I18n.system_success) , content: (I18n.joblog_clean_log + I18n.system_success) ,
icon: '1', icon: '1',
end: function(layero, index){ end: function(layero, index){
logTable.fnDraw(); logTable.fnDraw();
} }
}); });
} else { } else {
layer.open({ layer.open({
title: I18n.system_tips , title: I18n.system_tips ,
btn: [ I18n.system_ok ], btn: [ I18n.system_ok ],
content: (data.msg || (I18n.joblog_clean_log + I18n.system_fail) ), content: (data.msg || (I18n.joblog_clean_log + I18n.system_fail) ),
icon: '2' icon: '2'
}); });
} }
}); });
}); });
$("#clearLogModal").on('hide.bs.modal', function () { $("#clearLogModal").on('hide.bs.modal', function () {
$("#clearLogModal .form")[0].reset(); $("#clearLogModal .form")[0].reset();
}); });
}); });
// Com Alert by Tec theme // Com Alert by Tec theme
var ComAlertTec = { var ComAlertTec = {
html:function(){ html:function(){
var html = var html =
'<div class="modal fade" id="ComAlertTec" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' + '<div class="modal fade" id="ComAlertTec" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
'<div class="modal-dialog">' + '<div class="modal-dialog">' +
'<div class="modal-content-tec">' + '<div class="modal-content-tec">' +
'<div class="modal-body"><div class="alert" style="color:#fff;"></div></div>' + '<div class="modal-body"><div class="alert" style="color:#fff;"></div></div>' +
'<div class="modal-footer">' + '<div class="modal-footer">' +
'<div class="text-center" >' + '<div class="text-center" >' +
'<button type="button" class="btn btn-info ok" data-dismiss="modal" >'+ I18n.system_ok +'</button>' + '<button type="button" class="btn btn-info ok" data-dismiss="modal" >'+ I18n.system_ok +'</button>' +
'</div>' + '</div>' +
'</div>' + '</div>' +
'</div>' + '</div>' +
'</div>' + '</div>' +
'</div>'; '</div>';
return html; return html;
}, },
show:function(msg, callback){ show:function(msg, callback){
// dom init // dom init
if ($('#ComAlertTec').length == 0){ if ($('#ComAlertTec').length == 0){
$('body').append(ComAlertTec.html()); $('body').append(ComAlertTec.html());
} }
// init com alert // init com alert
$('#ComAlertTec .alert').html(msg); $('#ComAlertTec .alert').html(msg);
$('#ComAlertTec').modal('show'); $('#ComAlertTec').modal('show');
$('#ComAlertTec .ok').click(function(){ $('#ComAlertTec .ok').click(function(){
$('#ComAlertTec').modal('hide'); $('#ComAlertTec').modal('hide');
if(typeof callback == 'function') { if(typeof callback == 'function') {
callback(); callback();
} }
}); });
} }
}; };
package com.xxl.job.core.handler; package com.xxl.job.core.handler;
import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.biz.model.ReturnT;
/** /**
* job handler * job handler
* *
* @author xuxueli 2015-12-19 19:06:38 * @author xuxueli 2015-12-19 19:06:38
*/ */
public abstract class IJobHandler { public abstract class IJobHandler {
/** success */ /** success */
public static final ReturnT<String> SUCCESS = new ReturnT<String>(200, null); public static final ReturnT<String> SUCCESS = new ReturnT<String>(200, null);
/** fail */ /** fail */
public static final ReturnT<String> FAIL = new ReturnT<String>(500, null); public static final ReturnT<String> FAIL = new ReturnT<String>(500, null);
/** fail timeout */ /** fail timeout */
public static final ReturnT<String> FAIL_TIMEOUT = new ReturnT<String>(502, null); public static final ReturnT<String> FAIL_TIMEOUT = new ReturnT<String>(502, null);
/** /**
* execute handler, invoked when executor receives a scheduling request * execute handler, invoked when executor receives a scheduling request
* *
* @param param * @param param
* @return * @return
* @throws Exception * @throws Exception
*/ */
public abstract ReturnT<String> execute(String param) throws Exception; public abstract ReturnT<String> execute(String param) throws Exception;
/** /**
* init handler, invoked when JobThread init * init handler, invoked when JobThread init
*/ */
public void init() { public void init() {
// TODO // TODO
} }
/** /**
* destroy handler, invoked when JobThread destroy * destroy handler, invoked when JobThread destroy
*/ */
public void destroy() { public void destroy() {
// TODO // TODO
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论