定时任务支持Class类调用&多类型参数
This commit is contained in:
@@ -8,8 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<id property="jobLogId" column="job_log_id" />
|
||||
<result property="jobName" column="job_name" />
|
||||
<result property="jobGroup" column="job_group" />
|
||||
<result property="methodName" column="method_name" />
|
||||
<result property="methodParams" column="method_params" />
|
||||
<result property="invokeTarget" column="invoke_target" />
|
||||
<result property="jobMessage" column="job_message" />
|
||||
<result property="status" column="status" />
|
||||
<result property="exceptionInfo" column="exception_info" />
|
||||
@@ -17,7 +16,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectJobLogVo">
|
||||
select job_log_id, job_name, job_group, method_name, method_params, job_message, status, exception_info, create_time
|
||||
select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time
|
||||
from sys_job_log
|
||||
</sql>
|
||||
|
||||
@@ -30,8 +29,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="methodName != null and methodName != ''">
|
||||
AND method_name like concat('%', #{methodName}, '%')
|
||||
<if test="invokeTarget != null and invokeTarget != ''">
|
||||
AND invoke_target like concat('%', #{invokeTarget}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||
@@ -71,8 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="jobLogId != null and jobLogId != 0">job_log_id,</if>
|
||||
<if test="jobName != null and jobName != ''">job_name,</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">job_group,</if>
|
||||
<if test="methodName != null and methodName != ''">method_name,</if>
|
||||
<if test="methodParams != null and methodParams != ''">method_params,</if>
|
||||
<if test="invokeTarget != null and invokeTarget != ''">invoke_target,</if>
|
||||
<if test="jobMessage != null and jobMessage != ''">job_message,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="exceptionInfo != null and exceptionInfo != ''">exception_info,</if>
|
||||
@@ -81,8 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="jobLogId != null and jobLogId != 0">#{jobLogId},</if>
|
||||
<if test="jobName != null and jobName != ''">#{jobName},</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if>
|
||||
<if test="methodName != null and methodName != ''">#{methodName},</if>
|
||||
<if test="methodParams != null and methodParams != ''">#{methodParams},</if>
|
||||
<if test="invokeTarget != null and invokeTarget != ''">#{invokeTarget},</if>
|
||||
<if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if>
|
||||
|
@@ -8,8 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<id property="jobId" column="job_id" />
|
||||
<result property="jobName" column="job_name" />
|
||||
<result property="jobGroup" column="job_group" />
|
||||
<result property="methodName" column="method_name" />
|
||||
<result property="methodParams" column="method_params" />
|
||||
<result property="invokeTarget" column="invoke_target" />
|
||||
<result property="cronExpression" column="cron_expression" />
|
||||
<result property="misfirePolicy" column="misfire_policy" />
|
||||
<result property="concurrent" column="concurrent" />
|
||||
@@ -22,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectJobVo">
|
||||
select job_id, job_name, job_group, method_name, method_params, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark
|
||||
select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark
|
||||
from sys_job
|
||||
</sql>
|
||||
|
||||
@@ -32,11 +31,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="jobName != null and jobName != ''">
|
||||
AND job_name like concat('%', #{jobName}, '%')
|
||||
</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">
|
||||
AND job_group = #{jobGroup}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="methodName != null and methodName != ''">
|
||||
AND method_name like concat('%', #{methodName}, '%')
|
||||
<if test="invokeTarget != null and invokeTarget != ''">
|
||||
AND invoke_target like concat('%', #{invokeTarget}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
@@ -66,8 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<set>
|
||||
<if test="jobName != null and jobName != ''">job_name = #{jobName},</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">job_group = #{jobGroup},</if>
|
||||
<if test="methodName != null and methodName != ''">method_name = #{methodName},</if>
|
||||
<if test="methodParams != null">method_params = #{methodParams},</if>
|
||||
<if test="invokeTarget != null and invokeTarget != ''">invoke_target = #{invokeTarget},</if>
|
||||
<if test="cronExpression != null and cronExpression != ''">cron_expression = #{cronExpression},</if>
|
||||
<if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy = #{misfirePolicy},</if>
|
||||
<if test="concurrent != null and concurrent != ''">concurrent = #{concurrent},</if>
|
||||
@@ -84,8 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="jobId != null and jobId != 0">job_id,</if>
|
||||
<if test="jobName != null and jobName != ''">job_name,</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">job_group,</if>
|
||||
<if test="methodName != null and methodName != ''">method_name,</if>
|
||||
<if test="methodParams != null and methodParams != ''">method_params,</if>
|
||||
<if test="invokeTarget != null and invokeTarget != ''">invoke_target,</if>
|
||||
<if test="cronExpression != null and cronExpression != ''">cron_expression,</if>
|
||||
<if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy,</if>
|
||||
<if test="concurrent != null and concurrent != ''">concurrent,</if>
|
||||
@@ -97,8 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="jobId != null and jobId != 0">#{jobId},</if>
|
||||
<if test="jobName != null and jobName != ''">#{jobName},</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if>
|
||||
<if test="methodName != null and methodName != ''">#{methodName},</if>
|
||||
<if test="methodParams != null and methodParams != ''">#{methodParams},</if>
|
||||
<if test="invokeTarget != null and invokeTarget != ''">#{invokeTarget},</if>
|
||||
<if test="cronExpression != null and cronExpression != ''">#{cronExpression},</if>
|
||||
<if test="misfirePolicy != null and misfirePolicy != ''">#{misfirePolicy},</if>
|
||||
<if test="concurrent != null and concurrent != ''">#{concurrent},</if>
|
||||
|
@@ -14,21 +14,20 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务组名:</label>
|
||||
<label class="col-sm-3 control-label">任务分组:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="jobGroup" id="jobGroup" required>
|
||||
<select name="jobGroup" class="form-control m-b" th:with="type=${@dict.getType('sys_job_group')}">
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label ">方法名称:</label>
|
||||
<label class="col-sm-3 control-label ">调用目标字符串:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="methodName" id="methodName" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label ">方法参数:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="methodParams" id="methodParams">
|
||||
<input class="form-control" type="text" name="invokeTarget" id="invokeTarget" required>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Bean调用示例:ryTask.ryParams('ry')</span>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Class类调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry')</span>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 参数说明:支持字符串,布尔类型,长整型,浮点型,整形</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@@ -18,13 +18,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务组名:</label>
|
||||
<label class="col-sm-3 control-label">任务分组:</label>
|
||||
<div class="form-control-static" th:text="${jobLog.jobGroup}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务方法:</label>
|
||||
<div class="form-control-static" th:text="${jobLog.methodName} + '(' + ${#strings.defaultString(jobLog.methodParams,'')} + ')'">
|
||||
<label class="col-sm-3 control-label">调用目标字符串:</label>
|
||||
<div class="form-control-static" th:text="${jobLog.invokeTarget}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -56,13 +56,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务组名:</label>
|
||||
<label class="col-sm-3 control-label">任务分组:</label>
|
||||
<div class="form-control-static" th:text="${job.jobGroup}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务方法:</label>
|
||||
<div class="form-control-static" th:text="${job.methodName} + '(' + ${#strings.defaultString(job.methodParams,'')} + ')'">
|
||||
<label class="col-sm-3 control-label">调用目标字符串:</label>
|
||||
<div class="form-control-static" th:text="${job.invokeTarget}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
@@ -15,21 +15,20 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务组名:</label>
|
||||
<label class="col-sm-3 control-label">任务分组:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="jobGroup" id="jobGroup" th:field="*{jobGroup}" required>
|
||||
<select name="jobGroup" class="form-control m-b" th:with="type=${@dict.getType('sys_job_group')}">
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{jobGroup}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label ">方法名称:</label>
|
||||
<label class="col-sm-3 control-label ">调用目标字符串:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="methodName" id="methodName" th:field="*{methodName}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label ">方法参数:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="methodParams" id="methodParams" th:field="*{methodParams}">
|
||||
<input class="form-control" type="text" name="invokeTarget" id="invokeTarget" th:field="*{invokeTarget}" required>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Bean调用示例:ryTask.ryParams('ry')</span>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Class类调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry')</span>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 参数说明:支持字符串,布尔类型,长整型,浮点型,整形</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -77,15 +76,6 @@
|
||||
$("#form-job-edit").validate({
|
||||
onkeyup: false,
|
||||
rules:{
|
||||
jobName:{
|
||||
required:true,
|
||||
},
|
||||
jobGroup:{
|
||||
required:true,
|
||||
},
|
||||
methodName:{
|
||||
required:true,
|
||||
},
|
||||
cronExpression:{
|
||||
required:true,
|
||||
remote: {
|
||||
|
@@ -14,7 +14,10 @@
|
||||
任务名称:<input type="text" name="jobName"/>
|
||||
</li>
|
||||
<li>
|
||||
方法名称:<input type="text" name="methodName"/>
|
||||
任务分组:<select name="jobGroup" th:with="type=${@dict.getType('sys_job_group')}">
|
||||
<option value="">所有</option>
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
任务状态:<select name="status" th:with="type=${@dict.getType('sys_job_status')}">
|
||||
@@ -60,7 +63,7 @@
|
||||
var editFlag = [[${@permission.hasPermi('monitor:job:edit')}]];
|
||||
var removeFlag = [[${@permission.hasPermi('monitor:job:remove')}]];
|
||||
var statusFlag = [[${@permission.hasPermi('monitor:job:changeStatus')}]];
|
||||
var datas = [[${@dict.getType('sys_job_status')}]];
|
||||
var datas = [[${@dict.getType('sys_job_group')}]];
|
||||
var prefix = ctx + "monitor/job";
|
||||
|
||||
$(function() {
|
||||
@@ -84,20 +87,20 @@
|
||||
{
|
||||
field: 'jobName',
|
||||
title: '任务名称',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'jobGroup',
|
||||
title: '任务组名',
|
||||
sortable: true
|
||||
title: '任务分组',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.selectDictLabel(datas, value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'methodName',
|
||||
title: '方法名称'
|
||||
},
|
||||
{
|
||||
field: 'methodParams',
|
||||
title: '方法参数'
|
||||
field: 'invokeTarget',
|
||||
title: '调用目标字符串',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.tooltip(value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'cronExpression',
|
||||
@@ -121,7 +124,7 @@
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-primary btn-xs ' + statusFlag + '" href="javascript:void(0)" onclick="run(\'' + row.jobId + '\')"><i class="fa fa-play-circle-o"></i> 执行一次</a> ');
|
||||
actions.push('<a class="btn btn-primary btn-xs ' + statusFlag + '" href="javascript:void(0)" onclick="run(\'' + row.jobId + '\', \'' + row.jobGroup + '\')"><i class="fa fa-play-circle-o"></i> 执行一次</a> ');
|
||||
actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.jobId + '\')"><i class="fa fa-search"></i>详细</a> ');
|
||||
return actions.join('');
|
||||
}
|
||||
@@ -133,30 +136,30 @@
|
||||
/* 调度任务状态显示 */
|
||||
function statusTools(row) {
|
||||
if (row.status == 1) {
|
||||
return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="start(\'' + row.jobId + '\')"></i> ';
|
||||
return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="start(\'' + row.jobId + '\', \'' + row.jobGroup + '\')"></i> ';
|
||||
} else {
|
||||
return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="stop(\'' + row.jobId + '\')"></i> ';
|
||||
return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="stop(\'' + row.jobId + '\', \'' + row.jobGroup + '\')"></i> ';
|
||||
}
|
||||
}
|
||||
|
||||
/* 立即执行一次 */
|
||||
function run(jobId) {
|
||||
function run(jobId, jobGroup) {
|
||||
$.modal.confirm("确认要立即执行一次任务吗?", function() {
|
||||
$.operate.post(prefix + "/run", { "jobId": jobId});
|
||||
$.operate.post(prefix + "/run", { "jobId": jobId, "jobId": jobId, "jobGroup": jobGroup});
|
||||
})
|
||||
}
|
||||
|
||||
/* 调度任务-停用 */
|
||||
function stop(jobId) {
|
||||
function stop(jobId, jobGroup) {
|
||||
$.modal.confirm("确认要停用任务吗?", function() {
|
||||
$.operate.post(prefix + "/changeStatus", { "jobId": jobId, "status": 1 });
|
||||
$.operate.post(prefix + "/changeStatus", { "jobId": jobId, "jobGroup": jobGroup, "status": 1 });
|
||||
})
|
||||
}
|
||||
|
||||
/* 调度任务-启用 */
|
||||
function start(jobId) {
|
||||
function start(jobId, jobGroup) {
|
||||
$.modal.confirm("确认要启用任务吗?", function() {
|
||||
$.operate.post(prefix + "/changeStatus", { "jobId": jobId, "status": 0 });
|
||||
$.operate.post(prefix + "/changeStatus", { "jobId": jobId, "jobGroup": jobGroup, "status": 0 });
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -58,7 +58,8 @@
|
||||
<th:block th:include="include :: footer" />
|
||||
<script th:inline="javascript">
|
||||
var detailFlag = [[${@permission.hasPermi('monitor:job:detail')}]];
|
||||
var datas = [[${@dict.getType('sys_common_status')}]];
|
||||
var statusDatas = [[${@dict.getType('sys_common_status')}]];
|
||||
var groupDatas = [[${@dict.getType('sys_job_group')}]];
|
||||
var prefix = ctx + "monitor/jobLog";
|
||||
|
||||
$(function() {
|
||||
@@ -80,21 +81,21 @@
|
||||
},
|
||||
{
|
||||
field: 'jobName',
|
||||
title: '任务名称',
|
||||
sortable: true
|
||||
title: '任务名称'
|
||||
},
|
||||
{
|
||||
field: 'jobGroup',
|
||||
title: '任务组名',
|
||||
sortable: true
|
||||
title: '任务分组',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.selectDictLabel(groupDatas, value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'methodName',
|
||||
title: '方法名称'
|
||||
},
|
||||
{
|
||||
field: 'methodParams',
|
||||
title: '方法参数'
|
||||
field: 'invokeTarget',
|
||||
title: '调用目标字符串',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.tooltip(value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'jobMessage',
|
||||
@@ -105,7 +106,7 @@
|
||||
title: '状态',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.selectDictLabel(datas, value);
|
||||
return $.table.selectDictLabel(statusDatas, value);
|
||||
}
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user