mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-17 16:56:39 +08:00
remove 移除 quartz 相关代码与依赖
This commit is contained in:
parent
03e2ff587e
commit
95dcae1a85
8
pom.xml
8
pom.xml
@ -257,13 +257,6 @@
|
|||||||
<version>${tlog.version}</version>
|
<version>${tlog.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 定时任务 @deprecated 3.4.0删除 迁移至xxl-job -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-quartz</artifactId>
|
|
||||||
<version>${ruoyi-vue-plus.version}</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 定时任务 -->
|
<!-- 定时任务 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
@ -320,7 +313,6 @@
|
|||||||
<module>ruoyi-admin</module>
|
<module>ruoyi-admin</module>
|
||||||
<module>ruoyi-framework</module>
|
<module>ruoyi-framework</module>
|
||||||
<module>ruoyi-system</module>
|
<module>ruoyi-system</module>
|
||||||
<module>ruoyi-quartz</module>
|
|
||||||
<module>ruoyi-job</module>
|
<module>ruoyi-job</module>
|
||||||
<module>ruoyi-generator</module>
|
<module>ruoyi-generator</module>
|
||||||
<module>ruoyi-common</module>
|
<module>ruoyi-common</module>
|
||||||
|
@ -41,12 +41,6 @@
|
|||||||
<artifactId>ruoyi-system</artifactId>
|
<artifactId>ruoyi-system</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 定时任务 @deprecated 3.4.0删除 迁移至xxl-job -->
|
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>com.ruoyi</groupId>-->
|
|
||||||
<!-- <artifactId>ruoyi-quartz</artifactId>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.ruoyi</groupId>
|
<groupId>com.ruoyi</groupId>
|
||||||
<artifactId>ruoyi-job</artifactId>
|
<artifactId>ruoyi-job</artifactId>
|
||||||
|
@ -293,34 +293,3 @@ management:
|
|||||||
endpoint:
|
endpoint:
|
||||||
logfile:
|
logfile:
|
||||||
external-file: ./logs/sys-console.log
|
external-file: ./logs/sys-console.log
|
||||||
|
|
||||||
--- # 定时任务配置
|
|
||||||
spring:
|
|
||||||
quartz:
|
|
||||||
scheduler-name: RuoyiScheduler
|
|
||||||
startup-delay: 1s
|
|
||||||
overwrite-existing-jobs: true
|
|
||||||
auto-startup: true
|
|
||||||
job-store-type: jdbc
|
|
||||||
properties:
|
|
||||||
org:
|
|
||||||
quartz:
|
|
||||||
# Scheduler 相关配置
|
|
||||||
scheduler:
|
|
||||||
instanceName: RuoyiScheduler
|
|
||||||
instanceId: AUTO
|
|
||||||
# 线程池相关配置
|
|
||||||
threadPool:
|
|
||||||
class: org.quartz.simpl.SimpleThreadPool
|
|
||||||
threadCount: 20
|
|
||||||
threadPriority: 5
|
|
||||||
# JobStore 集群配置
|
|
||||||
jobStore:
|
|
||||||
class: org.quartz.impl.jdbcjobstore.JobStoreTX
|
|
||||||
isClustered: true
|
|
||||||
clusterCheckinInterval: 15000
|
|
||||||
txIsolationLevelSerializable: true
|
|
||||||
misfireThreshold: 60000
|
|
||||||
tablePrefix: QRTZ_
|
|
||||||
# sqlserver 启用
|
|
||||||
# selectWithLockSQL: SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?
|
|
||||||
|
@ -22,5 +22,3 @@ outagedetection=true
|
|||||||
outagedetectioninterval=2
|
outagedetectioninterval=2
|
||||||
# 是否过滤 Log
|
# 是否过滤 Log
|
||||||
filter=true
|
filter=true
|
||||||
# 过滤 Log 时所排除的表名列表,以逗号分隔
|
|
||||||
exclude=QRTZ_
|
|
||||||
|
@ -133,13 +133,4 @@ public class Constants {
|
|||||||
*/
|
*/
|
||||||
public static final String SYS_DICT_KEY = "sys_dict:";
|
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||||
|
|
||||||
/**
|
|
||||||
* RMI 远程方法调用
|
|
||||||
*/
|
|
||||||
public static final String LOOKUP_RMI = "rmi://";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LDAP 远程方法调用
|
|
||||||
*/
|
|
||||||
public static final String LOOKUP_LDAP = "ldap://";
|
|
||||||
}
|
}
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
package com.ruoyi.common.constant;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 任务调度通用常量
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
package com.ruoyi.common.exception.job;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 计划策略异常
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-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
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>ruoyi-vue-plus</artifactId>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<version>3.3.0</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>ruoyi-quartz</artifactId>
|
|
||||||
|
|
||||||
<description>
|
|
||||||
quartz定时任务
|
|
||||||
</description>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
|
|
||||||
<!-- 定时任务 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-quartz</artifactId>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.mchange</groupId>
|
|
||||||
<artifactId>c3p0</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 通用工具-->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.ruoyi</groupId>
|
|
||||||
<artifactId>ruoyi-common</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
@ -1,15 +0,0 @@
|
|||||||
package com.ruoyi.quartz.config;
|
|
||||||
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务配置
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author Lion Li
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
@Configuration
|
|
||||||
public class ScheduleConfig {
|
|
||||||
|
|
||||||
}
|
|
@ -1,160 +0,0 @@
|
|||||||
package com.ruoyi.quartz.controller;
|
|
||||||
|
|
||||||
import com.ruoyi.common.annotation.Log;
|
|
||||||
import com.ruoyi.common.constant.Constants;
|
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
|
||||||
import com.ruoyi.common.exception.job.TaskException;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
||||||
import com.ruoyi.quartz.domain.SysJob;
|
|
||||||
import com.ruoyi.quartz.service.ISysJobService;
|
|
||||||
import com.ruoyi.quartz.util.CronUtils;
|
|
||||||
import org.quartz.SchedulerException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调度任务信息操作处理
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @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)
|
|
||||||
{
|
|
||||||
return jobService.selectPageJobList(sysJob);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出定时任务列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
|
||||||
@Log(title = "定时任务", businessType = BusinessType.EXPORT)
|
|
||||||
@GetMapping("/export")
|
|
||||||
public void export(SysJob sysJob, HttpServletResponse response)
|
|
||||||
{
|
|
||||||
List<SysJob> list = jobService.selectJobList(sysJob);
|
|
||||||
ExcelUtil.exportExcel(list, "定时任务", SysJob.class, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取定时任务详细信息
|
|
||||||
*/
|
|
||||||
@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 job) throws SchedulerException, TaskException
|
|
||||||
{
|
|
||||||
if (!CronUtils.isValid(job.getCronExpression()))
|
|
||||||
{
|
|
||||||
return error("新增任务'" + job.getJobName() + "'失败,Cron表达式不正确");
|
|
||||||
}
|
|
||||||
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
|
|
||||||
{
|
|
||||||
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi://'调用");
|
|
||||||
}
|
|
||||||
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_LDAP))
|
|
||||||
{
|
|
||||||
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap://'调用");
|
|
||||||
}
|
|
||||||
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
|
||||||
{
|
|
||||||
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用");
|
|
||||||
}
|
|
||||||
job.setCreateBy(getUsername());
|
|
||||||
return toAjax(jobService.insertJob(job));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改定时任务
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:edit')")
|
|
||||||
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@RequestBody SysJob job) throws SchedulerException, TaskException
|
|
||||||
{
|
|
||||||
if (!CronUtils.isValid(job.getCronExpression()))
|
|
||||||
{
|
|
||||||
return error("修改任务'" + job.getJobName() + "'失败,Cron表达式不正确");
|
|
||||||
}
|
|
||||||
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_RMI))
|
|
||||||
{
|
|
||||||
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'rmi://'调用");
|
|
||||||
}
|
|
||||||
else if (StringUtils.containsIgnoreCase(job.getInvokeTarget(), Constants.LOOKUP_LDAP))
|
|
||||||
{
|
|
||||||
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap://'调用");
|
|
||||||
}
|
|
||||||
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
|
||||||
{
|
|
||||||
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)//'调用");
|
|
||||||
}
|
|
||||||
job.setUpdateBy(getUsername());
|
|
||||||
return toAjax(jobService.updateJob(job));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务状态修改
|
|
||||||
*/
|
|
||||||
@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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,86 +0,0 @@
|
|||||||
package com.ruoyi.quartz.controller;
|
|
||||||
|
|
||||||
import com.ruoyi.common.annotation.Log;
|
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
||||||
import com.ruoyi.quartz.domain.SysJobLog;
|
|
||||||
import com.ruoyi.quartz.service.ISysJobLogService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调度日志操作处理
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @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)
|
|
||||||
{
|
|
||||||
return jobLogService.selectPageJobLogList(sysJobLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出定时任务调度日志列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
|
||||||
@Log(title = "任务调度日志", businessType = BusinessType.EXPORT)
|
|
||||||
@GetMapping("/export")
|
|
||||||
public void export(SysJobLog sysJobLog, HttpServletResponse response)
|
|
||||||
{
|
|
||||||
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
|
|
||||||
ExcelUtil.exportExcel(list, "调度日志", SysJobLog.class, response);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据调度编号获取详细信息
|
|
||||||
*/
|
|
||||||
@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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,140 +0,0 @@
|
|||||||
package com.ruoyi.quartz.domain;
|
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.ruoyi.common.annotation.ExcelDictFormat;
|
|
||||||
import com.ruoyi.common.constant.ScheduleConstants;
|
|
||||||
import com.ruoyi.common.convert.ExcelDictConvert;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import com.ruoyi.quartz.util.CronUtils;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.Size;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务调度表 sys_job
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@TableName("sys_job")
|
|
||||||
@ExcelIgnoreUnannotated
|
|
||||||
public class SysJob implements Serializable {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 任务ID
|
|
||||||
*/
|
|
||||||
@ExcelProperty(value = "任务序号")
|
|
||||||
@TableId(value = "job_id", type = IdType.AUTO)
|
|
||||||
private Long jobId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 任务名称
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "任务名称不能为空")
|
|
||||||
@Size(min = 0, max = 64, message = "任务名称不能超过64个字符")
|
|
||||||
@ExcelProperty(value = "任务名称")
|
|
||||||
private String jobName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 任务组名
|
|
||||||
*/
|
|
||||||
@ExcelProperty(value = "任务组名", converter = ExcelDictConvert.class)
|
|
||||||
@ExcelDictFormat(dictType = "sys_job_group")
|
|
||||||
private String jobGroup;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调用目标字符串
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "调用目标字符串不能为空")
|
|
||||||
@Size(min = 0, max = 500, message = "调用目标字符串长度不能超过500个字符")
|
|
||||||
@ExcelProperty(value = "调用目标字符串")
|
|
||||||
private String invokeTarget;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cron执行表达式
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "Cron执行表达式不能为空")
|
|
||||||
@Size(min = 0, max = 255, message = "Cron执行表达式不能超过255个字符")
|
|
||||||
@ExcelProperty(value = "执行表达式")
|
|
||||||
private String cronExpression;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cron计划策略
|
|
||||||
*/
|
|
||||||
@ExcelProperty(value = "计划策略 ", converter = ExcelDictConvert.class)
|
|
||||||
@ExcelDictFormat(readConverterExp = "0=默认,1=立即触发执行,2=触发一次执行,3=不触发立即执行")
|
|
||||||
private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否并发执行(0允许 1禁止)
|
|
||||||
*/
|
|
||||||
@ExcelProperty(value = "并发执行", converter = ExcelDictConvert.class)
|
|
||||||
@ExcelDictFormat(readConverterExp = "0=允许,1=禁止")
|
|
||||||
private String concurrent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 任务状态(0正常 1暂停)
|
|
||||||
*/
|
|
||||||
@ExcelProperty(value = "任务状态", converter = ExcelDictConvert.class)
|
|
||||||
@ExcelDictFormat(dictType = "sys_job_status")
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建者
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新者
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private String updateBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 备注
|
|
||||||
*/
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求参数
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> params = new HashMap<>();
|
|
||||||
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
public Date getNextValidTime() {
|
|
||||||
if (StringUtils.isNotEmpty(cronExpression)) {
|
|
||||||
return CronUtils.getNextExecution(cronExpression);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
package com.ruoyi.quartz.domain;
|
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
|
||||||
import com.ruoyi.common.annotation.ExcelDictFormat;
|
|
||||||
import com.ruoyi.common.convert.ExcelDictConvert;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务调度日志表 sys_job_log
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Accessors(chain = true)
|
|
||||||
@TableName("sys_job_log")
|
|
||||||
@ExcelIgnoreUnannotated
|
|
||||||
public class SysJobLog
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** ID */
|
|
||||||
@ExcelProperty(value = "日志序号")
|
|
||||||
@TableId(value = "job_log_id", type = IdType.AUTO)
|
|
||||||
private Long jobLogId;
|
|
||||||
|
|
||||||
/** 任务名称 */
|
|
||||||
@ExcelProperty(value = "任务名称")
|
|
||||||
private String jobName;
|
|
||||||
|
|
||||||
/** 任务组名 */
|
|
||||||
@ExcelProperty(value = "任务组名", converter = ExcelDictConvert.class)
|
|
||||||
@ExcelDictFormat(dictType = "sys_job_group")
|
|
||||||
private String jobGroup;
|
|
||||||
|
|
||||||
/** 调用目标字符串 */
|
|
||||||
@ExcelProperty(value = "调用目标字符串")
|
|
||||||
private String invokeTarget;
|
|
||||||
|
|
||||||
/** 日志信息 */
|
|
||||||
@ExcelProperty(value = "日志信息")
|
|
||||||
private String jobMessage;
|
|
||||||
|
|
||||||
/** 执行状态(0正常 1失败) */
|
|
||||||
@ExcelProperty(value = "执行状态", converter = ExcelDictConvert.class)
|
|
||||||
@ExcelDictFormat(dictType = "sys_common_status")
|
|
||||||
private String status;
|
|
||||||
|
|
||||||
/** 异常信息 */
|
|
||||||
@ExcelProperty(value = "异常信息")
|
|
||||||
private String exceptionInfo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 请求参数
|
|
||||||
*/
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Map<String, Object> params = new HashMap<>();
|
|
||||||
|
|
||||||
/** 开始时间 */
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Date startTime;
|
|
||||||
|
|
||||||
/** 停止时间 */
|
|
||||||
@TableField(exist = false)
|
|
||||||
private Date stopTime;
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package com.ruoyi.quartz.mapper;
|
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
|
||||||
import com.ruoyi.quartz.domain.SysJobLog;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调度任务日志信息 数据层
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public interface SysJobLogMapper extends BaseMapperPlus<SysJobLog> {
|
|
||||||
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
package com.ruoyi.quartz.mapper;
|
|
||||||
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.BaseMapperPlus;
|
|
||||||
import com.ruoyi.quartz.domain.SysJob;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调度任务信息 数据层
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public interface SysJobMapper extends BaseMapperPlus<SysJob> {
|
|
||||||
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
package com.ruoyi.quartz.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
import com.ruoyi.quartz.domain.SysJobLog;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务调度日志信息信息 服务层
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public interface ISysJobLogService extends IService<SysJobLog> {
|
|
||||||
|
|
||||||
|
|
||||||
TableDataInfo<SysJobLog> selectPageJobLogList(SysJobLog jobLog);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取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();
|
|
||||||
}
|
|
@ -1,107 +0,0 @@
|
|||||||
package com.ruoyi.quartz.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
import com.ruoyi.common.exception.job.TaskException;
|
|
||||||
import com.ruoyi.quartz.domain.SysJob;
|
|
||||||
import org.quartz.SchedulerException;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务调度信息信息 服务层
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public interface ISysJobService extends IService<SysJob> {
|
|
||||||
/**
|
|
||||||
* 获取quartz调度器的计划任务
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
* @return 调度任务集合
|
|
||||||
*/
|
|
||||||
public TableDataInfo<SysJob> selectPageJobList(SysJob job);
|
|
||||||
|
|
||||||
public List<SysJob> selectJobList(SysJob job);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过调度任务ID查询调度信息
|
|
||||||
*
|
|
||||||
* @param jobId 调度任务ID
|
|
||||||
* @return 调度任务对象信息
|
|
||||||
*/
|
|
||||||
public SysJob selectJobById(Long jobId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 暂停任务
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int pauseJob(SysJob job) throws SchedulerException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 恢复任务
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int resumeJob(SysJob job) throws SchedulerException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除任务后,所对应的trigger也将被删除
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int deleteJob(SysJob job) throws SchedulerException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除调度信息
|
|
||||||
*
|
|
||||||
* @param jobIds 需要删除的任务ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public void deleteJobByIds(Long[] jobIds) throws SchedulerException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 任务调度状态修改
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int changeStatus(SysJob job) throws SchedulerException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 立即运行任务
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public void run(SysJob job) throws SchedulerException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增任务
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int insertJob(SysJob job) throws SchedulerException, TaskException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新任务
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public int updateJob(SysJob job) throws SchedulerException, TaskException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验cron表达式是否有效
|
|
||||||
*
|
|
||||||
* @param cronExpression 表达式
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
public boolean checkCronExpressionIsValid(String cronExpression);
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
package com.ruoyi.quartz.service.impl;
|
|
||||||
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
import com.ruoyi.common.utils.PageUtils;
|
|
||||||
import com.ruoyi.quartz.domain.SysJobLog;
|
|
||||||
import com.ruoyi.quartz.mapper.SysJobLogMapper;
|
|
||||||
import com.ruoyi.quartz.service.ISysJobLogService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务调度日志信息 服务层
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SysJobLogServiceImpl extends ServicePlusImpl<SysJobLogMapper, SysJobLog, SysJobLog> implements ISysJobLogService {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableDataInfo<SysJobLog> selectPageJobLogList(SysJobLog jobLog) {
|
|
||||||
Map<String, Object> params = jobLog.getParams();
|
|
||||||
LambdaQueryWrapper<SysJobLog> lqw = new LambdaQueryWrapper<SysJobLog>()
|
|
||||||
.like(StringUtils.isNotBlank(jobLog.getJobName()), SysJobLog::getJobName, jobLog.getJobName())
|
|
||||||
.eq(StringUtils.isNotBlank(jobLog.getJobGroup()), SysJobLog::getJobGroup, jobLog.getJobGroup())
|
|
||||||
.eq(StringUtils.isNotBlank(jobLog.getStatus()), SysJobLog::getStatus, jobLog.getStatus())
|
|
||||||
.like(StringUtils.isNotBlank(jobLog.getInvokeTarget()), SysJobLog::getInvokeTarget, jobLog.getInvokeTarget())
|
|
||||||
.apply(StringUtils.isNotEmpty(params.get("beginTime")),
|
|
||||||
"date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')",
|
|
||||||
params.get("beginTime"))
|
|
||||||
.apply(StringUtils.isNotEmpty(params.get("endTime")),
|
|
||||||
"date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')",
|
|
||||||
params.get("endTime"));
|
|
||||||
return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取quartz调度器日志的计划任务
|
|
||||||
*
|
|
||||||
* @param jobLog 调度日志信息
|
|
||||||
* @return 调度任务日志集合
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysJobLog> selectJobLogList(SysJobLog jobLog) {
|
|
||||||
Map<String, Object> params = jobLog.getParams();
|
|
||||||
return list(new LambdaQueryWrapper<SysJobLog>()
|
|
||||||
.like(StringUtils.isNotBlank(jobLog.getJobName()), SysJobLog::getJobName, jobLog.getJobName())
|
|
||||||
.eq(StringUtils.isNotBlank(jobLog.getJobGroup()), SysJobLog::getJobGroup, jobLog.getJobGroup())
|
|
||||||
.eq(StringUtils.isNotBlank(jobLog.getStatus()), SysJobLog::getStatus, jobLog.getStatus())
|
|
||||||
.like(StringUtils.isNotBlank(jobLog.getInvokeTarget()), SysJobLog::getInvokeTarget, jobLog.getInvokeTarget())
|
|
||||||
.apply(StringUtils.isNotEmpty(params.get("beginTime")),
|
|
||||||
"date_format(create_time,'%y%m%d') >= date_format({0},'%y%m%d')",
|
|
||||||
params.get("beginTime"))
|
|
||||||
.apply(StringUtils.isNotEmpty(params.get("endTime")),
|
|
||||||
"date_format(create_time,'%y%m%d') <= date_format({0},'%y%m%d')",
|
|
||||||
params.get("endTime")));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过调度任务日志ID查询调度信息
|
|
||||||
*
|
|
||||||
* @param jobLogId 调度任务日志ID
|
|
||||||
* @return 调度任务日志对象信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public SysJobLog selectJobLogById(Long jobLogId) {
|
|
||||||
return getById(jobLogId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增任务日志
|
|
||||||
*
|
|
||||||
* @param jobLog 调度日志信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void addJobLog(SysJobLog jobLog) {
|
|
||||||
baseMapper.insert(jobLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除调度日志信息
|
|
||||||
*
|
|
||||||
* @param logIds 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int deleteJobLogByIds(Long[] logIds) {
|
|
||||||
return baseMapper.deleteBatchIds(Arrays.asList(logIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除任务日志
|
|
||||||
*
|
|
||||||
* @param jobId 调度日志ID
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int deleteJobLogById(Long jobId) {
|
|
||||||
return baseMapper.deleteById(jobId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 清空任务日志
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void cleanJobLog() {
|
|
||||||
remove(new LambdaQueryWrapper<>());
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,247 +0,0 @@
|
|||||||
package com.ruoyi.quartz.service.impl;
|
|
||||||
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.ruoyi.common.constant.ScheduleConstants;
|
|
||||||
import com.ruoyi.common.core.mybatisplus.core.ServicePlusImpl;
|
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
import com.ruoyi.common.exception.job.TaskException;
|
|
||||||
import com.ruoyi.common.utils.PageUtils;
|
|
||||||
import com.ruoyi.quartz.domain.SysJob;
|
|
||||||
import com.ruoyi.quartz.mapper.SysJobMapper;
|
|
||||||
import com.ruoyi.quartz.service.ISysJobService;
|
|
||||||
import com.ruoyi.quartz.util.CronUtils;
|
|
||||||
import com.ruoyi.quartz.util.ScheduleUtils;
|
|
||||||
import org.quartz.JobDataMap;
|
|
||||||
import org.quartz.JobKey;
|
|
||||||
import org.quartz.Scheduler;
|
|
||||||
import org.quartz.SchedulerException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务调度信息 服务层
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class SysJobServiceImpl extends ServicePlusImpl<SysJobMapper, SysJob, SysJob> implements ISysJobService {
|
|
||||||
@Autowired
|
|
||||||
private Scheduler scheduler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 项目启动时,初始化定时器 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据)
|
|
||||||
*/
|
|
||||||
@PostConstruct
|
|
||||||
public void init() throws SchedulerException, TaskException {
|
|
||||||
scheduler.clear();
|
|
||||||
List<SysJob> jobList = list();
|
|
||||||
for (SysJob job : jobList) {
|
|
||||||
ScheduleUtils.createScheduleJob(scheduler, job);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TableDataInfo<SysJob> selectPageJobList(SysJob job) {
|
|
||||||
LambdaQueryWrapper<SysJob> lqw = new LambdaQueryWrapper<SysJob>()
|
|
||||||
.like(StringUtils.isNotBlank(job.getJobName()), SysJob::getJobName, job.getJobName())
|
|
||||||
.eq(StringUtils.isNotBlank(job.getJobGroup()), SysJob::getJobGroup, job.getJobGroup())
|
|
||||||
.eq(StringUtils.isNotBlank(job.getStatus()), SysJob::getStatus, job.getStatus())
|
|
||||||
.like(StringUtils.isNotBlank(job.getInvokeTarget()), SysJob::getInvokeTarget, job.getInvokeTarget());
|
|
||||||
return PageUtils.buildDataInfo(page(PageUtils.buildPage(), lqw));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取quartz调度器的计划任务列表
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<SysJob> selectJobList(SysJob job) {
|
|
||||||
return list(new LambdaQueryWrapper<SysJob>()
|
|
||||||
.like(StringUtils.isNotBlank(job.getJobName()), SysJob::getJobName, job.getJobName())
|
|
||||||
.eq(StringUtils.isNotBlank(job.getJobGroup()), SysJob::getJobGroup, job.getJobGroup())
|
|
||||||
.eq(StringUtils.isNotBlank(job.getStatus()), SysJob::getStatus, job.getStatus())
|
|
||||||
.like(StringUtils.isNotBlank(job.getInvokeTarget()), SysJob::getInvokeTarget, job.getInvokeTarget()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过调度任务ID查询调度信息
|
|
||||||
*
|
|
||||||
* @param jobId 调度任务ID
|
|
||||||
* @return 调度任务对象信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public SysJob selectJobById(Long jobId) {
|
|
||||||
return getById(jobId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 暂停任务
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public int pauseJob(SysJob job) throws SchedulerException {
|
|
||||||
Long jobId = job.getJobId();
|
|
||||||
String jobGroup = job.getJobGroup();
|
|
||||||
job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
|
|
||||||
int rows = baseMapper.updateById(job);
|
|
||||||
if (rows > 0) {
|
|
||||||
scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup));
|
|
||||||
}
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 恢复任务
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public int resumeJob(SysJob job) throws SchedulerException {
|
|
||||||
Long jobId = job.getJobId();
|
|
||||||
String jobGroup = job.getJobGroup();
|
|
||||||
job.setStatus(ScheduleConstants.Status.NORMAL.getValue());
|
|
||||||
int rows = baseMapper.updateById(job);
|
|
||||||
if (rows > 0) {
|
|
||||||
scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup));
|
|
||||||
}
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除任务后,所对应的trigger也将被删除
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public int deleteJob(SysJob job) throws SchedulerException {
|
|
||||||
Long jobId = job.getJobId();
|
|
||||||
String jobGroup = job.getJobGroup();
|
|
||||||
int rows = baseMapper.deleteById(jobId);
|
|
||||||
if (rows > 0) {
|
|
||||||
scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup));
|
|
||||||
}
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 批量删除调度信息
|
|
||||||
*
|
|
||||||
* @param jobIds 需要删除的任务ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void deleteJobByIds(Long[] jobIds) throws SchedulerException {
|
|
||||||
for (Long jobId : jobIds) {
|
|
||||||
SysJob job = getById(jobId);
|
|
||||||
deleteJob(job);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 任务调度状态修改
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public int changeStatus(SysJob job) throws SchedulerException {
|
|
||||||
int rows = 0;
|
|
||||||
String status = job.getStatus();
|
|
||||||
if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) {
|
|
||||||
rows = resumeJob(job);
|
|
||||||
} else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) {
|
|
||||||
rows = pauseJob(job);
|
|
||||||
}
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 立即运行任务
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void run(SysJob job) throws SchedulerException {
|
|
||||||
Long jobId = job.getJobId();
|
|
||||||
String jobGroup = job.getJobGroup();
|
|
||||||
SysJob properties = selectJobById(job.getJobId());
|
|
||||||
// 参数
|
|
||||||
JobDataMap dataMap = new JobDataMap();
|
|
||||||
dataMap.put(ScheduleConstants.TASK_PROPERTIES, properties);
|
|
||||||
scheduler.triggerJob(ScheduleUtils.getJobKey(jobId, jobGroup), dataMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增任务
|
|
||||||
*
|
|
||||||
* @param job 调度信息 调度信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public int insertJob(SysJob job) throws SchedulerException, TaskException {
|
|
||||||
job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
|
|
||||||
int rows = baseMapper.insert(job);
|
|
||||||
if (rows > 0) {
|
|
||||||
ScheduleUtils.createScheduleJob(scheduler, job);
|
|
||||||
}
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新任务的时间表达式
|
|
||||||
*
|
|
||||||
* @param job 调度信息
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public int updateJob(SysJob job) throws SchedulerException, TaskException {
|
|
||||||
SysJob properties = selectJobById(job.getJobId());
|
|
||||||
int rows = baseMapper.updateById(job);
|
|
||||||
if (rows > 0) {
|
|
||||||
updateSchedulerJob(job, properties.getJobGroup());
|
|
||||||
}
|
|
||||||
return rows;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新任务
|
|
||||||
*
|
|
||||||
* @param job 任务对象
|
|
||||||
* @param jobGroup 任务组名
|
|
||||||
*/
|
|
||||||
public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException {
|
|
||||||
Long jobId = job.getJobId();
|
|
||||||
// 判断是否存在
|
|
||||||
JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup);
|
|
||||||
if (scheduler.checkExists(jobKey)) {
|
|
||||||
// 防止创建时存在数据问题 先移除,然后在执行创建操作
|
|
||||||
scheduler.deleteJob(jobKey);
|
|
||||||
}
|
|
||||||
ScheduleUtils.createScheduleJob(scheduler, job);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验cron表达式是否有效
|
|
||||||
*
|
|
||||||
* @param cronExpression 表达式
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean checkCronExpressionIsValid(String cronExpression) {
|
|
||||||
return CronUtils.isValid(cronExpression);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package com.ruoyi.quartz.task;
|
|
||||||
|
|
||||||
import cn.hutool.core.lang.Console;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务调度测试
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@Component("ryTask")
|
|
||||||
public class RyTask
|
|
||||||
{
|
|
||||||
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
|
|
||||||
{
|
|
||||||
Console.log(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ryParams(String params)
|
|
||||||
{
|
|
||||||
Console.log("执行有参方法:" + params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ryNoParams()
|
|
||||||
{
|
|
||||||
Console.log("执行无参方法");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,109 +0,0 @@
|
|||||||
package com.ruoyi.quartz.util;
|
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
|
||||||
import cn.hutool.core.exceptions.ExceptionUtil;
|
|
||||||
import com.ruoyi.common.constant.Constants;
|
|
||||||
import com.ruoyi.common.constant.ScheduleConstants;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
|
||||||
import com.ruoyi.quartz.domain.SysJob;
|
|
||||||
import com.ruoyi.quartz.domain.SysJobLog;
|
|
||||||
import com.ruoyi.quartz.service.ISysJobLogService;
|
|
||||||
import org.quartz.Job;
|
|
||||||
import org.quartz.JobExecutionContext;
|
|
||||||
import org.quartz.JobExecutionException;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 抽象quartz调用
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public abstract class AbstractQuartzJob implements Job
|
|
||||||
{
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 线程本地变量
|
|
||||||
*/
|
|
||||||
private static ThreadLocal<Date> threadLocal = new ThreadLocal<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(JobExecutionContext context) throws JobExecutionException
|
|
||||||
{
|
|
||||||
SysJob sysJob = new SysJob();
|
|
||||||
BeanUtil.copyProperties(context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES),sysJob);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
before(context, sysJob);
|
|
||||||
if (StringUtils.isNotNull(sysJob))
|
|
||||||
{
|
|
||||||
doExecute(context, sysJob);
|
|
||||||
}
|
|
||||||
after(context, sysJob, null);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
log.error("任务执行异常 - :", e);
|
|
||||||
after(context, sysJob, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 执行前
|
|
||||||
*
|
|
||||||
* @param context 工作执行上下文对象
|
|
||||||
* @param sysJob 系统计划任务
|
|
||||||
*/
|
|
||||||
protected void before(JobExecutionContext context, SysJob sysJob)
|
|
||||||
{
|
|
||||||
threadLocal.set(new Date());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 执行后
|
|
||||||
*
|
|
||||||
* @param context 工作执行上下文对象
|
|
||||||
* @param sysJob 系统计划任务
|
|
||||||
*/
|
|
||||||
protected void after(JobExecutionContext context, SysJob sysJob, Exception e)
|
|
||||||
{
|
|
||||||
Date startTime = threadLocal.get();
|
|
||||||
threadLocal.remove();
|
|
||||||
|
|
||||||
final SysJobLog sysJobLog = new SysJobLog();
|
|
||||||
sysJobLog.setJobName(sysJob.getJobName());
|
|
||||||
sysJobLog.setJobGroup(sysJob.getJobGroup());
|
|
||||||
sysJobLog.setInvokeTarget(sysJob.getInvokeTarget());
|
|
||||||
sysJobLog.setStartTime(startTime);
|
|
||||||
sysJobLog.setStopTime(new Date());
|
|
||||||
long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime();
|
|
||||||
sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
|
|
||||||
if (e != null)
|
|
||||||
{
|
|
||||||
sysJobLog.setStatus(Constants.FAIL);
|
|
||||||
String errorMsg = StringUtils.substring(ExceptionUtil.stacktraceToString(e), 0, 2000);
|
|
||||||
sysJobLog.setExceptionInfo(errorMsg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sysJobLog.setStatus(Constants.SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 写入数据库当中
|
|
||||||
SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 执行方法,由子类重载
|
|
||||||
*
|
|
||||||
* @param context 工作执行上下文对象
|
|
||||||
* @param sysJob 系统计划任务
|
|
||||||
* @throws Exception 执行过程中的异常
|
|
||||||
*/
|
|
||||||
protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception;
|
|
||||||
}
|
|
@ -1,65 +0,0 @@
|
|||||||
package com.ruoyi.quartz.util;
|
|
||||||
|
|
||||||
import org.quartz.CronExpression;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cron表达式工具类
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,183 +0,0 @@
|
|||||||
package com.ruoyi.quartz.util;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
|
||||||
import com.ruoyi.quartz.domain.SysJob;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 任务执行工具
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class JobInvokeUtil
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 执行方法
|
|
||||||
*
|
|
||||||
* @param sysJob 系统任务
|
|
||||||
*/
|
|
||||||
public static void invokeMethod(SysJob sysJob) throws Exception
|
|
||||||
{
|
|
||||||
String invokeTarget = sysJob.getInvokeTarget();
|
|
||||||
String beanName = getBeanName(invokeTarget);
|
|
||||||
String methodName = getMethodName(invokeTarget);
|
|
||||||
List<Object[]> methodParams = getMethodParams(invokeTarget);
|
|
||||||
|
|
||||||
if (!isValidClassName(beanName))
|
|
||||||
{
|
|
||||||
Object bean = SpringUtils.getBean(beanName);
|
|
||||||
invokeMethod(bean, methodName, methodParams);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Object bean = Class.forName(beanName).newInstance();
|
|
||||||
invokeMethod(bean, methodName, methodParams);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调用任务方法
|
|
||||||
*
|
|
||||||
* @param bean 目标对象
|
|
||||||
* @param methodName 方法名称
|
|
||||||
* @param methodParams 方法参数
|
|
||||||
*/
|
|
||||||
private static void invokeMethod(Object bean, String methodName, List<Object[]> methodParams)
|
|
||||||
throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException,
|
|
||||||
InvocationTargetException
|
|
||||||
{
|
|
||||||
if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0)
|
|
||||||
{
|
|
||||||
Method method = bean.getClass().getDeclaredMethod(methodName, getMethodParamsType(methodParams));
|
|
||||||
method.invoke(bean, getMethodParamsValue(methodParams));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Method method = bean.getClass().getDeclaredMethod(methodName);
|
|
||||||
method.invoke(bean);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验是否为为class包名
|
|
||||||
*
|
|
||||||
* @param str 名称
|
|
||||||
* @return true是 false否
|
|
||||||
*/
|
|
||||||
public static boolean isValidClassName(String invokeTarget)
|
|
||||||
{
|
|
||||||
return StringUtils.countMatches(invokeTarget, ".") > 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取bean名称
|
|
||||||
*
|
|
||||||
* @param invokeTarget 目标字符串
|
|
||||||
* @return bean名称
|
|
||||||
*/
|
|
||||||
public static String getBeanName(String invokeTarget)
|
|
||||||
{
|
|
||||||
String beanName = StringUtils.substringBefore(invokeTarget, "(");
|
|
||||||
return StringUtils.substringBeforeLast(beanName, ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取bean方法
|
|
||||||
*
|
|
||||||
* @param invokeTarget 目标字符串
|
|
||||||
* @return method方法
|
|
||||||
*/
|
|
||||||
public static String getMethodName(String invokeTarget)
|
|
||||||
{
|
|
||||||
String methodName = StringUtils.substringBefore(invokeTarget, "(");
|
|
||||||
return StringUtils.substringAfterLast(methodName, ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取method方法参数相关列表
|
|
||||||
*
|
|
||||||
* @param invokeTarget 目标字符串
|
|
||||||
* @return method方法相关参数列表
|
|
||||||
*/
|
|
||||||
public static List<Object[]> getMethodParams(String invokeTarget)
|
|
||||||
{
|
|
||||||
String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")");
|
|
||||||
if (StringUtils.isEmpty(methodStr))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String[] methodParams = methodStr.split(",");
|
|
||||||
List<Object[]> classs = new LinkedList<>();
|
|
||||||
for (int i = 0; i < methodParams.length; i++)
|
|
||||||
{
|
|
||||||
String str = StringUtils.trimToEmpty(methodParams[i]);
|
|
||||||
// String字符串类型,包含'
|
|
||||||
if (StringUtils.contains(str, "'"))
|
|
||||||
{
|
|
||||||
classs.add(new Object[] { StringUtils.replace(str, "'", ""), String.class });
|
|
||||||
}
|
|
||||||
// boolean布尔类型,等于true或者false
|
|
||||||
else if (StringUtils.equals(str, "true") || StringUtils.equalsIgnoreCase(str, "false"))
|
|
||||||
{
|
|
||||||
classs.add(new Object[] { Boolean.valueOf(str), Boolean.class });
|
|
||||||
}
|
|
||||||
// long长整形,包含L
|
|
||||||
else if (StringUtils.containsIgnoreCase(str, "L"))
|
|
||||||
{
|
|
||||||
classs.add(new Object[] { Long.valueOf(StringUtils.replaceIgnoreCase(str, "L", "")), Long.class });
|
|
||||||
}
|
|
||||||
// double浮点类型,包含D
|
|
||||||
else if (StringUtils.containsIgnoreCase(str, "D"))
|
|
||||||
{
|
|
||||||
classs.add(new Object[] { Double.valueOf(StringUtils.replaceIgnoreCase(str, "D", "")), Double.class });
|
|
||||||
}
|
|
||||||
// 其他类型归类为整形
|
|
||||||
else
|
|
||||||
{
|
|
||||||
classs.add(new Object[] { Integer.valueOf(str), Integer.class });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return classs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取参数类型
|
|
||||||
*
|
|
||||||
* @param methodParams 参数相关列表
|
|
||||||
* @return 参数类型列表
|
|
||||||
*/
|
|
||||||
public static Class<?>[] getMethodParamsType(List<Object[]> methodParams)
|
|
||||||
{
|
|
||||||
Class<?>[] classs = new Class<?>[methodParams.size()];
|
|
||||||
int index = 0;
|
|
||||||
for (Object[] os : methodParams)
|
|
||||||
{
|
|
||||||
classs[index] = (Class<?>) os[1];
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
return classs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取参数值
|
|
||||||
*
|
|
||||||
* @param methodParams 参数相关列表
|
|
||||||
* @return 参数值列表
|
|
||||||
*/
|
|
||||||
public static Object[] getMethodParamsValue(List<Object[]> methodParams)
|
|
||||||
{
|
|
||||||
Object[] classs = new Object[methodParams.size()];
|
|
||||||
int index = 0;
|
|
||||||
for (Object[] os : methodParams)
|
|
||||||
{
|
|
||||||
classs[index] = (Object) os[0];
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
return classs;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package com.ruoyi.quartz.util;
|
|
||||||
|
|
||||||
import org.quartz.DisallowConcurrentExecution;
|
|
||||||
import org.quartz.JobExecutionContext;
|
|
||||||
import com.ruoyi.quartz.domain.SysJob;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务处理(禁止并发执行)
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@DisallowConcurrentExecution
|
|
||||||
public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception
|
|
||||||
{
|
|
||||||
JobInvokeUtil.invokeMethod(sysJob);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
package com.ruoyi.quartz.util;
|
|
||||||
|
|
||||||
import org.quartz.JobExecutionContext;
|
|
||||||
import com.ruoyi.quartz.domain.SysJob;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务处理(允许并发执行)
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @author ruoyi
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class QuartzJobExecution extends AbstractQuartzJob
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception
|
|
||||||
{
|
|
||||||
JobInvokeUtil.invokeMethod(sysJob);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
package com.ruoyi.quartz.util;
|
|
||||||
|
|
||||||
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.quartz.domain.SysJob;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务工具类
|
|
||||||
*
|
|
||||||
* @deprecated 3.4.0删除 迁移至xxl-job
|
|
||||||
* @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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
<?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.quartz.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>
|
|
||||||
|
|
||||||
</mapper>
|
|
@ -1,23 +0,0 @@
|
|||||||
<?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.quartz.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>
|
|
||||||
|
|
||||||
</mapper>
|
|
@ -1,174 +0,0 @@
|
|||||||
DROP TABLE IF EXISTS QRTZ_FIRED_TRIGGERS;
|
|
||||||
DROP TABLE IF EXISTS QRTZ_PAUSED_TRIGGER_GRPS;
|
|
||||||
DROP TABLE IF EXISTS QRTZ_SCHEDULER_STATE;
|
|
||||||
DROP TABLE IF EXISTS QRTZ_LOCKS;
|
|
||||||
DROP TABLE IF EXISTS QRTZ_SIMPLE_TRIGGERS;
|
|
||||||
DROP TABLE IF EXISTS QRTZ_SIMPROP_TRIGGERS;
|
|
||||||
DROP TABLE IF EXISTS QRTZ_CRON_TRIGGERS;
|
|
||||||
DROP TABLE IF EXISTS QRTZ_BLOB_TRIGGERS;
|
|
||||||
DROP TABLE IF EXISTS QRTZ_TRIGGERS;
|
|
||||||
DROP TABLE IF EXISTS QRTZ_JOB_DETAILS;
|
|
||||||
DROP TABLE IF EXISTS QRTZ_CALENDARS;
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 1、存储每一个已配置的 jobDetail 的详细信息
|
|
||||||
-- ----------------------------
|
|
||||||
create table QRTZ_JOB_DETAILS (
|
|
||||||
sched_name varchar(120) not null comment '调度名称',
|
|
||||||
job_name varchar(200) not null comment '任务名称',
|
|
||||||
job_group varchar(200) not null comment '任务组名',
|
|
||||||
description varchar(250) null comment '相关介绍',
|
|
||||||
job_class_name varchar(250) not null comment '执行任务类名称',
|
|
||||||
is_durable varchar(1) not null comment '是否持久化',
|
|
||||||
is_nonconcurrent varchar(1) not null comment '是否并发',
|
|
||||||
is_update_data varchar(1) not null comment '是否更新数据',
|
|
||||||
requests_recovery varchar(1) not null comment '是否接受恢复执行',
|
|
||||||
job_data blob null comment '存放持久化job对象',
|
|
||||||
primary key (sched_name, job_name, job_group)
|
|
||||||
) engine=innodb comment = '任务详细信息表';
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 2、 存储已配置的 Trigger 的信息
|
|
||||||
-- ----------------------------
|
|
||||||
create table QRTZ_TRIGGERS (
|
|
||||||
sched_name varchar(120) not null comment '调度名称',
|
|
||||||
trigger_name varchar(200) not null comment '触发器的名字',
|
|
||||||
trigger_group varchar(200) not null comment '触发器所属组的名字',
|
|
||||||
job_name varchar(200) not null comment 'qrtz_job_details表job_name的外键',
|
|
||||||
job_group varchar(200) not null comment 'qrtz_job_details表job_group的外键',
|
|
||||||
description varchar(250) null comment '相关介绍',
|
|
||||||
next_fire_time bigint(13) null comment '上一次触发时间(毫秒)',
|
|
||||||
prev_fire_time bigint(13) null comment '下一次触发时间(默认为-1表示不触发)',
|
|
||||||
priority integer null comment '优先级',
|
|
||||||
trigger_state varchar(16) not null comment '触发器状态',
|
|
||||||
trigger_type varchar(8) not null comment '触发器的类型',
|
|
||||||
start_time bigint(13) not null comment '开始时间',
|
|
||||||
end_time bigint(13) null comment '结束时间',
|
|
||||||
calendar_name varchar(200) null comment '日程表名称',
|
|
||||||
misfire_instr smallint(2) null comment '补偿执行的策略',
|
|
||||||
job_data blob null comment '存放持久化job对象',
|
|
||||||
primary key (sched_name, trigger_name, trigger_group),
|
|
||||||
foreign key (sched_name, job_name, job_group) references QRTZ_JOB_DETAILS(sched_name, job_name, job_group)
|
|
||||||
) engine=innodb comment = '触发器详细信息表';
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 3、 存储简单的 Trigger,包括重复次数,间隔,以及已触发的次数
|
|
||||||
-- ----------------------------
|
|
||||||
create table QRTZ_SIMPLE_TRIGGERS (
|
|
||||||
sched_name varchar(120) not null comment '调度名称',
|
|
||||||
trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_name的外键',
|
|
||||||
trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键',
|
|
||||||
repeat_count bigint(7) not null comment '重复的次数统计',
|
|
||||||
repeat_interval bigint(12) not null comment '重复的间隔时间',
|
|
||||||
times_triggered bigint(10) not null comment '已经触发的次数',
|
|
||||||
primary key (sched_name, trigger_name, trigger_group),
|
|
||||||
foreign key (sched_name, trigger_name, trigger_group) references QRTZ_TRIGGERS(sched_name, trigger_name, trigger_group)
|
|
||||||
) engine=innodb comment = '简单触发器的信息表';
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 4、 存储 Cron Trigger,包括 Cron 表达式和时区信息
|
|
||||||
-- ----------------------------
|
|
||||||
create table QRTZ_CRON_TRIGGERS (
|
|
||||||
sched_name varchar(120) not null comment '调度名称',
|
|
||||||
trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_name的外键',
|
|
||||||
trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键',
|
|
||||||
cron_expression varchar(200) not null comment 'cron表达式',
|
|
||||||
time_zone_id varchar(80) comment '时区',
|
|
||||||
primary key (sched_name, trigger_name, trigger_group),
|
|
||||||
foreign key (sched_name, trigger_name, trigger_group) references QRTZ_TRIGGERS(sched_name, trigger_name, trigger_group)
|
|
||||||
) engine=innodb comment = 'Cron类型的触发器表';
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 5、 Trigger 作为 Blob 类型存储(用于 Quartz 用户用 JDBC 创建他们自己定制的 Trigger 类型,JobStore 并不知道如何存储实例的时候)
|
|
||||||
-- ----------------------------
|
|
||||||
create table QRTZ_BLOB_TRIGGERS (
|
|
||||||
sched_name varchar(120) not null comment '调度名称',
|
|
||||||
trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_name的外键',
|
|
||||||
trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键',
|
|
||||||
blob_data blob null comment '存放持久化Trigger对象',
|
|
||||||
primary key (sched_name, trigger_name, trigger_group),
|
|
||||||
foreign key (sched_name, trigger_name, trigger_group) references QRTZ_TRIGGERS(sched_name, trigger_name, trigger_group)
|
|
||||||
) engine=innodb comment = 'Blob类型的触发器表';
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 6、 以 Blob 类型存储存放日历信息, quartz可配置一个日历来指定一个时间范围
|
|
||||||
-- ----------------------------
|
|
||||||
create table QRTZ_CALENDARS (
|
|
||||||
sched_name varchar(120) not null comment '调度名称',
|
|
||||||
calendar_name varchar(200) not null comment '日历名称',
|
|
||||||
calendar blob not null comment '存放持久化calendar对象',
|
|
||||||
primary key (sched_name, calendar_name)
|
|
||||||
) engine=innodb comment = '日历信息表';
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 7、 存储已暂停的 Trigger 组的信息
|
|
||||||
-- ----------------------------
|
|
||||||
create table QRTZ_PAUSED_TRIGGER_GRPS (
|
|
||||||
sched_name varchar(120) not null comment '调度名称',
|
|
||||||
trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键',
|
|
||||||
primary key (sched_name, trigger_group)
|
|
||||||
) engine=innodb comment = '暂停的触发器表';
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 8、 存储与已触发的 Trigger 相关的状态信息,以及相联 Job 的执行信息
|
|
||||||
-- ----------------------------
|
|
||||||
create table QRTZ_FIRED_TRIGGERS (
|
|
||||||
sched_name varchar(120) not null comment '调度名称',
|
|
||||||
entry_id varchar(95) not null comment '调度器实例id',
|
|
||||||
trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_name的外键',
|
|
||||||
trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键',
|
|
||||||
instance_name varchar(200) not null comment '调度器实例名',
|
|
||||||
fired_time bigint(13) not null comment '触发的时间',
|
|
||||||
sched_time bigint(13) not null comment '定时器制定的时间',
|
|
||||||
priority integer not null comment '优先级',
|
|
||||||
state varchar(16) not null comment '状态',
|
|
||||||
job_name varchar(200) null comment '任务名称',
|
|
||||||
job_group varchar(200) null comment '任务组名',
|
|
||||||
is_nonconcurrent varchar(1) null comment '是否并发',
|
|
||||||
requests_recovery varchar(1) null comment '是否接受恢复执行',
|
|
||||||
primary key (sched_name, entry_id)
|
|
||||||
) engine=innodb comment = '已触发的触发器表';
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 9、 存储少量的有关 Scheduler 的状态信息,假如是用于集群中,可以看到其他的 Scheduler 实例
|
|
||||||
-- ----------------------------
|
|
||||||
create table QRTZ_SCHEDULER_STATE (
|
|
||||||
sched_name varchar(120) not null comment '调度名称',
|
|
||||||
instance_name varchar(200) not null comment '实例名称',
|
|
||||||
last_checkin_time bigint(13) not null comment '上次检查时间',
|
|
||||||
checkin_interval bigint(13) not null comment '检查间隔时间',
|
|
||||||
primary key (sched_name, instance_name)
|
|
||||||
) engine=innodb comment = '调度器状态表';
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 10、 存储程序的悲观锁的信息(假如使用了悲观锁)
|
|
||||||
-- ----------------------------
|
|
||||||
create table QRTZ_LOCKS (
|
|
||||||
sched_name varchar(120) not null comment '调度名称',
|
|
||||||
lock_name varchar(40) not null comment '悲观锁名称',
|
|
||||||
primary key (sched_name, lock_name)
|
|
||||||
) engine=innodb comment = '存储的悲观锁信息表';
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 11、 Quartz集群实现同步机制的行锁表
|
|
||||||
-- ----------------------------
|
|
||||||
create table QRTZ_SIMPROP_TRIGGERS (
|
|
||||||
sched_name varchar(120) not null comment '调度名称',
|
|
||||||
trigger_name varchar(200) not null comment 'qrtz_triggers表trigger_name的外键',
|
|
||||||
trigger_group varchar(200) not null comment 'qrtz_triggers表trigger_group的外键',
|
|
||||||
str_prop_1 varchar(512) null comment 'String类型的trigger的第一个参数',
|
|
||||||
str_prop_2 varchar(512) null comment 'String类型的trigger的第二个参数',
|
|
||||||
str_prop_3 varchar(512) null comment 'String类型的trigger的第三个参数',
|
|
||||||
int_prop_1 int null comment 'int类型的trigger的第一个参数',
|
|
||||||
int_prop_2 int null comment 'int类型的trigger的第二个参数',
|
|
||||||
long_prop_1 bigint null comment 'long类型的trigger的第一个参数',
|
|
||||||
long_prop_2 bigint null comment 'long类型的trigger的第二个参数',
|
|
||||||
dec_prop_1 numeric(13,4) null comment 'decimal类型的trigger的第一个参数',
|
|
||||||
dec_prop_2 numeric(13,4) null comment 'decimal类型的trigger的第二个参数',
|
|
||||||
bool_prop_1 varchar(1) null comment 'Boolean类型的trigger的第一个参数',
|
|
||||||
bool_prop_2 varchar(1) null comment 'Boolean类型的trigger的第二个参数',
|
|
||||||
primary key (sched_name, trigger_name, trigger_group),
|
|
||||||
foreign key (sched_name, trigger_name, trigger_group) references QRTZ_TRIGGERS(sched_name, trigger_name, trigger_group)
|
|
||||||
) engine=innodb comment = '同步机制的行锁表';
|
|
||||||
|
|
||||||
commit;
|
|
Loading…
Reference in New Issue
Block a user