parent
505ee1d63e
commit
2cc14e5f56
@ -0,0 +1,80 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询定时任务调度列表
|
||||
export function listJob(query) {
|
||||
return request({
|
||||
url: '/monitor/job/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询定时任务调度详细
|
||||
export function getJob(jobId) {
|
||||
return request({
|
||||
url: '/monitor/job/' + jobId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增定时任务调度
|
||||
export function addJob(data) {
|
||||
return request({
|
||||
url: '/monitor/job',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改定时任务调度
|
||||
export function updateJob(data) {
|
||||
return request({
|
||||
url: '/monitor/job',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除定时任务调度
|
||||
export function delJob(jobId) {
|
||||
return request({
|
||||
url: '/monitor/job/' + jobId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 导出定时任务调度
|
||||
export function exportJob(query) {
|
||||
return request({
|
||||
url: '/monitor/job/export',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 任务状态修改
|
||||
export function changeJobStatus(jobId, status) {
|
||||
const data = {
|
||||
jobId,
|
||||
status
|
||||
}
|
||||
return request({
|
||||
url: '/monitor/job/changeStatus',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 定时任务立即执行一次
|
||||
export function runJob(jobId, jobGroup) {
|
||||
const data = {
|
||||
jobId,
|
||||
jobGroup
|
||||
}
|
||||
return request({
|
||||
url: '/monitor/job/run',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询调度日志列表
|
||||
export function listJobLog(query) {
|
||||
return request({
|
||||
url: '/monitor/jobLog/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 删除调度日志
|
||||
export function delJobLog(jobLogId) {
|
||||
return request({
|
||||
url: '/monitor/jobLog/' + jobLogId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 清空调度日志
|
||||
export function cleanJobLog() {
|
||||
return request({
|
||||
url: '/monitor/jobLog/clean',
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 导出调度日志
|
||||
export function exportJobLog(query) {
|
||||
return request({
|
||||
url: '/monitor/jobLog/export',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
@ -0,0 +1,295 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
|
||||
<el-form-item label="任务名称" prop="jobName">
|
||||
<el-input
|
||||
v-model="queryParams.jobName"
|
||||
placeholder="请输入任务名称"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="任务组名" prop="jobGroup">
|
||||
<el-select
|
||||
v-model="queryParams.jobGroup"
|
||||
placeholder="请任务组名"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in jobGroupOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="执行状态" prop="status">
|
||||
<el-select
|
||||
v-model="queryParams.status"
|
||||
placeholder="请选择执行状态"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in statusOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="执行时间">
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
size="small"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['monitor:job:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
@click="handleClean"
|
||||
v-hasPermi="['monitor:job:remove']"
|
||||
>清空</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleExport"
|
||||
v-hasPermi="['monitor:jobLog:export']"
|
||||
>导出</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="jobLogList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="日志编号" width="80" align="center" prop="jobLogId" />
|
||||
<el-table-column label="任务名称" align="center" prop="jobName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="任务组名" align="center" prop="jobGroup" :formatter="jobGroupFormat" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="调用目标字符串" align="center" prop="invokeTarget" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="日志信息" align="center" prop="jobMessage" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="执行状态" align="center" prop="status" :formatter="statusFormat" />
|
||||
<el-table-column label="执行时间" align="center" prop="createTime" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-view"
|
||||
@click="handleView(scope.row)"
|
||||
v-hasPermi="['monitor:job:query']"
|
||||
>详细</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 调度日志详细 -->
|
||||
<el-dialog title="调度日志详细" :visible.sync="open" width="700px">
|
||||
<el-form ref="form" :model="form" label-width="100px" size="mini">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="日志序号:">{{ form.jobLogId }}</el-form-item>
|
||||
<el-form-item label="任务名称:">{{ form.jobName }}</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="任务分组:">{{ form.jobGroup }}</el-form-item>
|
||||
<el-form-item label="执行时间:">{{ form.createTime }}</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="调用方法:">{{ form.invokeTarget }}</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="日志信息:">{{ form.jobMessage }}</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="执行状态:">
|
||||
<div v-if="form.status == 0">正常</div>
|
||||
<div v-else-if="form.status == 1">失败</div>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="异常信息:" v-if="form.status == 1">{{ form.exceptionInfo }}</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="open = false">关 闭</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listJobLog, delJobLog, exportJobLog, cleanJobLog } from "@/api/monitor/jobLog";
|
||||
|
||||
export default {
|
||||
name: "JobLog",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 调度日志表格数据
|
||||
jobLogList: [],
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 日期范围
|
||||
dateRange: [],
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 执行状态字典
|
||||
statusOptions: [],
|
||||
// 任务组名字典
|
||||
jobGroupOptions: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
jobName: undefined,
|
||||
jobGroup: undefined,
|
||||
status: undefined
|
||||
},
|
||||
// 表单参数
|
||||
form: {}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getDicts("sys_job_status").then(response => {
|
||||
this.statusOptions = response.data;
|
||||
});
|
||||
this.getDicts("sys_job_group").then(response => {
|
||||
this.jobGroupOptions = response.data;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/** 查询调度日志列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listJobLog(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||||
this.jobLogList = response.rows;
|
||||
this.total = response.total;
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
},
|
||||
// 执行状态字典翻译
|
||||
statusFormat(row, column) {
|
||||
return this.selectDictLabel(this.statusOptions, row.status);
|
||||
},
|
||||
// 任务组名字典翻译
|
||||
jobGroupFormat(row, column) {
|
||||
return this.selectDictLabel(this.jobGroupOptions, row.jobGroup);
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dateRange = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.jobLogId);
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/** 详细按钮操作 */
|
||||
handleView(row) {
|
||||
this.open = true;
|
||||
this.form = row;
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const jobLogIds = this.ids;
|
||||
this.$confirm('是否确认删除调度日志编号为"' + jobLogIds + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return delJobLog(jobLogIds);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("删除成功");
|
||||
}).catch(function() {});
|
||||
},
|
||||
/** 清空按钮操作 */
|
||||
handleClean() {
|
||||
this.$confirm("是否确认清空所有调度日志数据项?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return cleanJobLog();
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.msgSuccess("清空成功");
|
||||
}).catch(function() {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
this.$confirm("是否确认导出所有调度日志数据项?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
}).then(function() {
|
||||
return exportJobLog(queryParams);
|
||||
}).then(response => {
|
||||
this.download(response.msg);
|
||||
}).catch(function() {});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
@ -0,0 +1,50 @@
|
||||
package com.ruoyi.common.constant;
|
||||
|
||||
/**
|
||||
* 任务调度通用常量
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ScheduleConstants
|
||||
{
|
||||
public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";
|
||||
|
||||
/** 执行目标key */
|
||||
public static final String TASK_PROPERTIES = "TASK_PROPERTIES";
|
||||
|
||||
/** 默认 */
|
||||
public static final String MISFIRE_DEFAULT = "0";
|
||||
|
||||
/** 立即触发执行 */
|
||||
public static final String MISFIRE_IGNORE_MISFIRES = "1";
|
||||
|
||||
/** 触发一次执行 */
|
||||
public static final String MISFIRE_FIRE_AND_PROCEED = "2";
|
||||
|
||||
/** 不触发立即执行 */
|
||||
public static final String MISFIRE_DO_NOTHING = "3";
|
||||
|
||||
public enum Status
|
||||
{
|
||||
/**
|
||||
* 正常
|
||||
*/
|
||||
NORMAL("0"),
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
PAUSE("1");
|
||||
|
||||
private String value;
|
||||
|
||||
private Status(String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.ruoyi.common.exception.job;
|
||||
|
||||
/**
|
||||
* 计划策略异常
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class TaskException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Code code;
|
||||
|
||||
public TaskException(String msg, Code code)
|
||||
{
|
||||
this(msg, code, null);
|
||||
}
|
||||
|
||||
public TaskException(String msg, Code code, Exception nestedEx)
|
||||
{
|
||||
super(msg, nestedEx);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Code getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public enum Code
|
||||
{
|
||||
TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
|
||||
/**
|
||||
* 错误信息处理类。
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class ExceptionUtil
|
||||
{
|
||||
/**
|
||||
* 获取exception的详细错误信息。
|
||||
*/
|
||||
public static String getExceptionMessage(Throwable e)
|
||||
{
|
||||
StringWriter sw = new StringWriter();
|
||||
e.printStackTrace(new PrintWriter(sw, true));
|
||||
String str = sw.toString();
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String getRootErrorMseeage(Exception e)
|
||||
{
|
||||
Throwable root = ExceptionUtils.getRootCause(e);
|
||||
root = (root == null ? e : root);
|
||||
if (root == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
String msg = root.getMessage();
|
||||
if (msg == null)
|
||||
{
|
||||
return "null";
|
||||
}
|
||||
return StringUtils.defaultString(msg);
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package com.ruoyi.common.utils.job;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Date;
|
||||
import org.quartz.CronExpression;
|
||||
|
||||
/**
|
||||
* cron表达式工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*
|
||||
*/
|
||||
public class CronUtils
|
||||
{
|
||||
/**
|
||||
* 返回一个布尔值代表一个给定的Cron表达式的有效性
|
||||
*
|
||||
* @param cronExpression Cron表达式
|
||||
* @return boolean 表达式是否有效
|
||||
*/
|
||||
public static boolean isValid(String cronExpression)
|
||||
{
|
||||
return CronExpression.isValidExpression(cronExpression);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个字符串值,表示该消息无效Cron表达式给出有效性
|
||||
*
|
||||
* @param cronExpression Cron表达式
|
||||
* @return String 无效时返回表达式错误描述,如果有效返回null
|
||||
*/
|
||||
public static String getInvalidMessage(String cronExpression)
|
||||
{
|
||||
try
|
||||
{
|
||||
new CronExpression(cronExpression);
|
||||
return null;
|
||||
}
|
||||
catch (ParseException pe)
|
||||
{
|
||||
return pe.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回下一个执行时间根据给定的Cron表达式
|
||||
*
|
||||
* @param cronExpression Cron表达式
|
||||
* @return Date 下次Cron表达式执行时间
|
||||
*/
|
||||
public static Date getNextExecution(String cronExpression)
|
||||
{
|
||||
try
|
||||
{
|
||||
CronExpression cron = new CronExpression(cronExpression);
|
||||
return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis()));
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
throw new IllegalArgumentException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
package com.ruoyi.common.utils.job;
|
||||
|
||||
import org.quartz.CronScheduleBuilder;
|
||||
import org.quartz.CronTrigger;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobBuilder;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.JobKey;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.TriggerBuilder;
|
||||
import org.quartz.TriggerKey;
|
||||
import com.ruoyi.common.constant.ScheduleConstants;
|
||||
import com.ruoyi.common.exception.job.TaskException;
|
||||
import com.ruoyi.common.exception.job.TaskException.Code;
|
||||
import com.ruoyi.project.monitor.domain.SysJob;
|
||||
|
||||
/**
|
||||
* 定时任务工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*
|
||||
*/
|
||||
public class ScheduleUtils
|
||||
{
|
||||
/**
|
||||
* 得到quartz任务类
|
||||
*
|
||||
* @param sysJob 执行计划
|
||||
* @return 具体执行任务类
|
||||
*/
|
||||
private static Class<? extends Job> getQuartzJobClass(SysJob sysJob)
|
||||
{
|
||||
boolean isConcurrent = "0".equals(sysJob.getConcurrent());
|
||||
return isConcurrent ? QuartzJobExecution.class : QuartzDisallowConcurrentExecution.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建任务触发对象
|
||||
*/
|
||||
public static TriggerKey getTriggerKey(Long jobId, String jobGroup)
|
||||
{
|
||||
return TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建任务键对象
|
||||
*/
|
||||
public static JobKey getJobKey(Long jobId, String jobGroup)
|
||||
{
|
||||
return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建定时任务
|
||||
*/
|
||||
public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException
|
||||
{
|
||||
Class<? extends Job> jobClass = getQuartzJobClass(job);
|
||||
// 构建job信息
|
||||
Long jobId = job.getJobId();
|
||||
String jobGroup = job.getJobGroup();
|
||||
JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build();
|
||||
|
||||
// 表达式调度构建器
|
||||
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
|
||||
cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder);
|
||||
|
||||
// 按新的cronExpression表达式构建一个新的trigger
|
||||
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup))
|
||||
.withSchedule(cronScheduleBuilder).build();
|
||||
|
||||
// 放入参数,运行时的方法可以获取
|
||||
jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job);
|
||||
|
||||
// 判断是否存在
|
||||
if (scheduler.checkExists(getJobKey(jobId, jobGroup)))
|
||||
{
|
||||
// 防止创建时存在数据问题 先移除,然后在执行创建操作
|
||||
scheduler.deleteJob(getJobKey(jobId, jobGroup));
|
||||
}
|
||||
|
||||
scheduler.scheduleJob(jobDetail, trigger);
|
||||
|
||||
// 暂停任务
|
||||
if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue()))
|
||||
{
|
||||
scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置定时任务策略
|
||||
*/
|
||||
public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb)
|
||||
throws TaskException
|
||||
{
|
||||
switch (job.getMisfirePolicy())
|
||||
{
|
||||
case ScheduleConstants.MISFIRE_DEFAULT:
|
||||
return cb;
|
||||
case ScheduleConstants.MISFIRE_IGNORE_MISFIRES:
|
||||
return cb.withMisfireHandlingInstructionIgnoreMisfires();
|
||||
case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED:
|
||||
return cb.withMisfireHandlingInstructionFireAndProceed();
|
||||
case ScheduleConstants.MISFIRE_DO_NOTHING:
|
||||
return cb.withMisfireHandlingInstructionDoNothing();
|
||||
default:
|
||||
throw new TaskException("The task misfire policy '" + job.getMisfirePolicy()
|
||||
+ "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.ruoyi.framework.task;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* 定时任务调度测试
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component("ryTask")
|
||||
public class RyTask
|
||||
{
|
||||
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
|
||||
{
|
||||
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
|
||||
}
|
||||
|
||||
public void ryParams(String params)
|
||||
{
|
||||
System.out.println("执行有参方法:" + params);
|
||||
}
|
||||
|
||||
public void ryNoParams()
|
||||
{
|
||||
System.out.println("执行无参方法");
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
package com.ruoyi.project.monitor.controller;
|
||||
|
||||
import java.util.List;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.exception.job.TaskException;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
||||
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
import com.ruoyi.framework.web.domain.AjaxResult;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.project.monitor.domain.SysJob;
|
||||
import com.ruoyi.project.monitor.service.ISysJobService;
|
||||
|
||||
/**
|
||||
* 调度任务信息操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/job")
|
||||
public class SysJobController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysJobService jobService;
|
||||
|
||||
/**
|
||||
* 查询定时任务列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysJob sysJob)
|
||||
{
|
||||
startPage();
|
||||
List<SysJob> list = jobService.selectJobList(sysJob);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出定时任务列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
||||
@Log(title = "定时任务", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysJob sysJob)
|
||||
{
|
||||
List<SysJob> list = jobService.selectJobList(sysJob);
|
||||
ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class);
|
||||
return util.exportExcel(list, "定时任务");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取定时任务详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:query')")
|
||||
@GetMapping(value = "/{jobId}")
|
||||
public AjaxResult getInfo(@PathVariable("jobId") Long jobId)
|
||||
{
|
||||
return AjaxResult.success(jobService.selectJobById(jobId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增定时任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:add')")
|
||||
@Log(title = "定时任务", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
|
||||
{
|
||||
return toAjax(jobService.insertJob(sysJob));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改定时任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:edit')")
|
||||
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException
|
||||
{
|
||||
return toAjax(jobService.updateJob(sysJob));
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务状态修改
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
|
||||
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException
|
||||
{
|
||||
SysJob newJob = jobService.selectJobById(job.getJobId());
|
||||
newJob.setStatus(job.getStatus());
|
||||
return toAjax(jobService.changeStatus(newJob));
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时任务立即执行一次
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
|
||||
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/run")
|
||||
public AjaxResult run(@RequestBody SysJob job) throws SchedulerException
|
||||
{
|
||||
jobService.run(job);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除定时任务
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
||||
@Log(title = "定时任务", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{jobIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException
|
||||
{
|
||||
jobService.deleteJobByIds(jobIds);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.ruoyi.project.monitor.controller;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
||||
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
||||
import com.ruoyi.project.monitor.domain.SysJobLog;
|
||||
import com.ruoyi.project.monitor.service.ISysJobLogService;
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
import com.ruoyi.framework.web.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 调度日志操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/jobLog")
|
||||
public class SysJobLogController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysJobLogService jobLogService;
|
||||
|
||||
/**
|
||||
* 查询定时任务调度日志列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysJobLog sysJobLog)
|
||||
{
|
||||
startPage();
|
||||
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出定时任务调度日志列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
||||
@Log(title = "任务调度日志", businessType = BusinessType.EXPORT)
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysJobLog sysJobLog)
|
||||
{
|
||||
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
|
||||
ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
|
||||
return util.exportExcel(list, "调度日志");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据调度编号获取详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:query')")
|
||||
@GetMapping(value = "/{configId}")
|
||||
public AjaxResult getInfo(@PathVariable Long jobLogId)
|
||||
{
|
||||
return AjaxResult.success(jobLogService.selectJobLogById(jobLogId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除定时任务调度日志
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
||||
@Log(title = "定时任务调度日志", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{jobLogIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] jobLogIds)
|
||||
{
|
||||
return toAjax(jobLogService.deleteJobLogByIds(jobLogIds));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
||||
@Log(title = "调度日志", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clean")
|
||||
public AjaxResult clean()
|
||||
{
|
||||
jobLogService.cleanJobLog();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.ruoyi.project.monitor.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.project.monitor.domain.SysJobLog;
|
||||
|
||||
/**
|
||||
* 调度任务日志信息 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysJobLogMapper
|
||||
{
|
||||
/**
|
||||
* 获取quartz调度器日志的计划任务
|
||||
*
|
||||
* @param jobLog 调度日志信息
|
||||
* @return 调度任务日志集合
|
||||
*/
|
||||
public List<SysJobLog> selectJobLogList(SysJobLog jobLog);
|
||||
|
||||
/**
|
||||
* 查询所有调度任务日志
|
||||
*
|
||||
* @return 调度任务日志列表
|
||||
*/
|
||||
public List<SysJobLog> selectJobLogAll();
|
||||
|
||||
/**
|
||||
* 通过调度任务日志ID查询调度信息
|
||||
*
|
||||
* @param jobLogId 调度任务日志ID
|
||||
* @return 调度任务日志对象信息
|
||||
*/
|
||||
public SysJobLog selectJobLogById(Long jobLogId);
|
||||
|
||||
/**
|
||||
* 新增任务日志
|
||||
*
|
||||
* @param jobLog 调度日志信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertJobLog(SysJobLog jobLog);
|
||||
|
||||
/**
|
||||
* 批量删除调度日志信息
|
||||
*
|
||||
* @param logIds 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteJobLogByIds(Long[] logIds);
|
||||
|
||||
/**
|
||||
* 删除任务日志
|
||||
*
|
||||
* @param jobId 调度日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteJobLogById(Long jobId);
|
||||
|
||||
/**
|
||||
* 清空任务日志
|
||||
*/
|
||||
public void cleanJobLog();
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.ruoyi.project.monitor.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.project.monitor.domain.SysJob;
|
||||
|
||||
/**
|
||||
* 调度任务信息 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysJobMapper
|
||||
{
|
||||
/**
|
||||
* 查询调度任务日志集合
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 操作日志集合
|
||||
*/
|
||||
public List<SysJob> selectJobList(SysJob job);
|
||||
|
||||
/**
|
||||
* 查询所有调度任务
|
||||
*
|
||||
* @return 调度任务列表
|
||||
*/
|
||||
public List<SysJob> selectJobAll();
|
||||
|
||||
/**
|
||||
* 通过调度ID查询调度任务信息
|
||||
*
|
||||
* @param jobId 调度ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
public SysJob selectJobById(Long jobId);
|
||||
|
||||
/**
|
||||
* 通过调度ID删除调度任务信息
|
||||
*
|
||||
* @param jobId 调度ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteJobById(Long jobId);
|
||||
|
||||
/**
|
||||
* 批量删除调度任务信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteJobByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 修改调度任务信息
|
||||
*
|
||||
* @param job 调度任务信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateJob(SysJob job);
|
||||
|
||||
/**
|
||||
* 新增调度任务信息
|
||||
*
|
||||
* @param job 调度任务信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertJob(SysJob job);
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.ruoyi.project.monitor.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.project.monitor.domain.SysJobLog;
|
||||
|
||||
/**
|
||||
* 定时任务调度日志信息信息 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysJobLogService
|
||||
{
|
||||
/**
|
||||
* 获取quartz调度器日志的计划任务
|
||||
*
|
||||
* @param jobLog 调度日志信息
|
||||
* @return 调度任务日志集合
|
||||
*/
|
||||
public List<SysJobLog> selectJobLogList(SysJobLog jobLog);
|
||||
|
||||
/**
|
||||
* 通过调度任务日志ID查询调度信息
|
||||
*
|
||||
* @param jobLogId 调度任务日志ID
|
||||
* @return 调度任务日志对象信息
|
||||
*/
|
||||
public SysJobLog selectJobLogById(Long jobLogId);
|
||||
|
||||
/**
|
||||
* 新增任务日志
|
||||
*
|
||||
* @param jobLog 调度日志信息
|
||||
*/
|
||||
public void addJobLog(SysJobLog jobLog);
|
||||
|
||||
/**
|
||||
* 批量删除调度日志信息
|
||||
*
|
||||
* @param logIds 需要删除的日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteJobLogByIds(Long[] logIds);
|
||||
|
||||
/**
|
||||
* 删除任务日志
|
||||
*
|
||||
* @param jobId 调度日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteJobLogById(Long jobId);
|
||||
|
||||
/**
|
||||
* 清空任务日志
|
||||
*/
|
||||
public void cleanJobLog();
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.ruoyi.project.monitor.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.project.monitor.domain.SysJobLog;
|
||||
import com.ruoyi.project.monitor.mapper.SysJobLogMapper;
|
||||
import com.ruoyi.project.monitor.service.ISysJobLogService;
|
||||
|
||||
/**
|
||||
* 定时任务调度日志信息 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysJobLogServiceImpl implements ISysJobLogService
|
||||
{
|
||||
@Autowired
|
||||
private SysJobLogMapper jobLogMapper;
|
||||
|
||||
/**
|
||||
* 获取quartz调度器日志的计划任务
|
||||
*
|
||||
* @param jobLog 调度日志信息
|
||||
* @return 调度任务日志集合
|
||||
*/
|
||||
@Override
|
||||
public List<SysJobLog> selectJobLogList(SysJobLog jobLog)
|
||||
{
|
||||
return jobLogMapper.selectJobLogList(jobLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过调度任务日志ID查询调度信息
|
||||
*
|
||||
* @param jobLogId 调度任务日志ID
|
||||
* @return 调度任务日志对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysJobLog selectJobLogById(Long jobLogId)
|
||||
{
|
||||
return jobLogMapper.selectJobLogById(jobLogId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增任务日志
|
||||
*
|
||||
* @param jobLog 调度日志信息
|
||||
*/
|
||||
@Override
|
||||
public void addJobLog(SysJobLog jobLog)
|
||||
{
|
||||
jobLogMapper.insertJobLog(jobLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除调度日志信息
|
||||
*
|
||||
* @param logIds 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteJobLogByIds(Long[] logIds)
|
||||
{
|
||||
return jobLogMapper.deleteJobLogByIds(logIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务日志
|
||||
*
|
||||
* @param jobId 调度日志ID
|
||||
*/
|
||||
@Override
|
||||
public int deleteJobLogById(Long jobId)
|
||||
{
|
||||
return jobLogMapper.deleteJobLogById(jobId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空任务日志
|
||||
*/
|
||||
@Override
|
||||
public void cleanJobLog()
|
||||
{
|
||||
jobLogMapper.cleanJobLog();
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.project.monitor.mapper.SysJobLogMapper">
|
||||
|
||||
<resultMap type="SysJobLog" id="SysJobLogResult">
|
||||
<id property="jobLogId" column="job_log_id" />
|
||||
<result property="jobName" column="job_name" />
|
||||
<result property="jobGroup" column="job_group" />
|
||||
<result property="invokeTarget" column="invoke_target" />
|
||||
<result property="jobMessage" column="job_message" />
|
||||
<result property="status" column="status" />
|
||||
<result property="exceptionInfo" column="exception_info" />
|
||||
<result property="createTime" column="create_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectJobLogVo">
|
||||
select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time
|
||||
from sys_job_log
|
||||
</sql>
|
||||
|
||||
<select id="selectJobLogList" parameterType="SysJobLog" resultMap="SysJobLogResult">
|
||||
<include refid="selectJobLogVo"/>
|
||||
<where>
|
||||
<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="invokeTarget != null and invokeTarget != ''">
|
||||
AND invoke_target like concat('%', #{invokeTarget}, '%')
|
||||
</if>
|
||||
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
|
||||
</if>
|
||||
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
|
||||
and date_format(create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectJobLogAll" resultMap="SysJobLogResult">
|
||||
<include refid="selectJobLogVo"/>
|
||||
</select>
|
||||
|
||||
<select id="selectJobLogById" parameterType="Long" resultMap="SysJobLogResult">
|
||||
<include refid="selectJobLogVo"/>
|
||||
where job_log_id = #{jobLogId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteJobLogById" parameterType="Long">
|
||||
delete from sys_job_log where job_log_id = #{jobLogId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteJobLogByIds" parameterType="Long">
|
||||
delete from sys_job_log where job_log_id in
|
||||
<foreach collection="array" item="jobLogId" open="(" separator="," close=")">
|
||||
#{jobLogId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="cleanJobLog">
|
||||
truncate table sys_job_log
|
||||
</update>
|
||||
|
||||
<insert id="insertJobLog" parameterType="SysJobLog">
|
||||
insert into sys_job_log(
|
||||
<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="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>
|
||||
create_time
|
||||
)values(
|
||||
<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="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>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.project.monitor.mapper.SysJobMapper">
|
||||
|
||||
<resultMap type="SysJob" id="SysJobResult">
|
||||
<id property="jobId" column="job_id" />
|
||||
<result property="jobName" column="job_name" />
|
||||
<result property="jobGroup" column="job_group" />
|
||||
<result property="invokeTarget" column="invoke_target" />
|
||||
<result property="cronExpression" column="cron_expression" />
|
||||
<result property="misfirePolicy" column="misfire_policy" />
|
||||
<result property="concurrent" column="concurrent" />
|
||||
<result property="status" column="status" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectJobVo">
|
||||
select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark
|
||||
from sys_job
|
||||
</sql>
|
||||
|
||||
<select id="selectJobList" parameterType="SysJob" resultMap="SysJobResult">
|
||||
<include refid="selectJobVo"/>
|
||||
<where>
|
||||
<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="invokeTarget != null and invokeTarget != ''">
|
||||
AND invoke_target like concat('%', #{invokeTarget}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectJobAll" resultMap="SysJobResult">
|
||||
<include refid="selectJobVo"/>
|
||||
</select>
|
||||
|
||||
<select id="selectJobById" parameterType="Long" resultMap="SysJobResult">
|
||||
<include refid="selectJobVo"/>
|
||||
where job_id = #{jobId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteJobById" parameterType="Long">
|
||||
delete from sys_job where job_id = #{jobId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteJobByIds" parameterType="Long">
|
||||
delete from sys_job where job_id in
|
||||
<foreach collection="array" item="jobId" open="(" separator="," close=")">
|
||||
#{jobId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="updateJob" parameterType="SysJob">
|
||||
update sys_job
|
||||
<set>
|
||||
<if test="jobName != null and jobName != ''">job_name = #{jobName},</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">job_group = #{jobGroup},</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>
|
||||
<if test="status !=null">status = #{status},</if>
|
||||
<if test="remark != null and remark != ''">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where job_id = #{jobId}
|
||||
</update>
|
||||
|
||||
<insert id="insertJob" parameterType="SysJob" useGeneratedKeys="true" keyProperty="jobId">
|
||||
insert into sys_job(
|
||||
<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="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>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
<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="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>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
Loading…
Reference in new issue