之前做过一次定时任务,使用的是quartz框架.好久没有使用过了.想起了又写了个demo,这里只做了添加定时任务及删除定时任务.修改和查看没有做!.测试结果是Ok的.话不多说了.直接上代码!!
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.quartz.demo</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- swagger ********************* Begin -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<!-- swagger ********************* End -->
<!-- lombok ********************* Begin -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- lombok ********************* End -->
<!-- 数据库连接 ********************* Begin -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.33</version>
</dependency>
<!-- 数据库连接 ********************* End -->
<!-- MyBatis-Plus依赖 ******************************* Begin-->
<!-- https://mvnrepository.com/artifact/com.baomidou/mybatis-plus-boot-starter -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>2.3.3</version>
</dependency>
<!--MyBatis 通用 Mapper-->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.0.0</version>
</dependency>
<!-- 定时器 -->
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz-jobs</artifactId>
<version>2.2.3</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>5.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<!--解决mapper.xml文件在编译时不会被编译到target目录下:亲测有效-->
<resources>
<resource>
<directory>src/main/java</directory>
<filtering>false</filtering>
<includes>
<include>**/*.xml
#���ݿ�������Ϣ
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/quartz?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&failOverReadOnly=false&useSSL=true&serverTimezone=Asia/Shanghai&allowMultiQueries=true
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.sql-script-encoding=utf-8
#jpa create table
spring.jpa.database=MYSQL
spring.jpa.hibernate.ddl-auto=update
########################### mybatis�ı��� ########################
#mybatis�ı���
mybatis.type-aliases-package=com.quartz.demo.pojo
#��������Ķ˿ں�
server.port=2080
server.connection-timeout=600000
# quartz配置
spring.quartz.properties.org.quartz.scheduler.instanceName=AdminClusteredScheduler
spring.quartz.properties.org.quartz.scheduler.instanceId=AUTO
spring.quartz.properties.org.quartz.scheduler.instanceIdGenerator.class=org.quartz.simpl.SimpleInstanceIdGenerator
spring.quartz.properties.org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
spring.quartz.properties.org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
spring.quartz.properties.org.quartz.jobStore.isClustered=true
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval=10000
spring.quartz.properties.org.quartz.jobStore.useProperties=false
spring.quartz.properties.org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
spring.quartz.properties.org.quartz.threadPool.threadCount=50
spring.quartz.properties.org.quartz.threadPool.threadPriority=5
spring.quartz.properties.org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread=true
spring.quartz.properties.org.quartz.dataSource.quartzDataSource.driver=com.mysql.jdbc.Driver
spring.quartz.properties.org.quartz.dataSource.quartzDataSource.URL=jdbc:mysql://127.0.0.1:3306/quartz
spring.quartz.properties.org.quartz.dataSource.quartzDataSource.user=root
spring.quartz.properties.org.quartz.dataSource.quartzDataSource.password=root
PS:任务就可以理解成就是任务,比方说:上班,打卡,闹钟 .定时任务就是到点了执行任务的实例.一个任务可以有多个定时任务,这里我就做了3个,同一个任务(打卡:上班打,下班也打)可以有多个定时任务!!!
这里没有做任务相关的增删改查,主要是为了操作定时任务.所以任务就手动创建到数据库表中就可以!!!
这里是做了一个任务id会实现3个定时任务功能
package com.quartz.demo.controller;
import com.quartz.demo.pojo.AddRequest;
import com.quartz.demo.pojo.ResultBO;
import com.quartz.demo.service.TimedTaskService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@Api(value = "定时任务", tags = {"定时任务"})
@Slf4j
@Validated
@RestController
@RequestMapping("/quartz")
public class VehicleJobController {
@Autowired
private TimedTaskService timedTaskService;
@ApiOperation("添加定时任务")
@PostMapping("/add")
public ResultBO add(@Validated @RequestBody AddRequest addRequest) throws Exception {
System.out.println("传过来的添加定时任务参数为:{}" + addRequest);
ResultBO resultBO = timedTaskService.addQuartzJob(addRequest);
return resultBO;
}
@ApiOperation("删除定时任务")
@GetMapping("/delete/{taskId}")
public ResultBO delete(@ApiParam(value = "定时任务id", required = true) @PathVariable String taskId) throws Exception {
System.out.println("传过来的删除定时任务id为:{}" + taskId);
ResultBO resultBO = timedTaskService.deleteQuartzJob(Integer.valueOf(taskId));
return resultBO;
}
}
package com.quartz.demo.service;
import com.baomidou.mybatisplus.service.IService;
import com.quartz.demo.pojo.Task;
/**
* @PackgeName: com.quartz.demo.service
* @ClassName: TaskService
* @Author: zjy
* Date: 2020/6/14 11:00
* project name: quartz
* @Version:
* @Description:
*/
public interface TaskService extends IService<Task> {
}
package com.quartz.demo.service;
import com.baomidou.mybatisplus.service.IService;
import com.quartz.demo.pojo.AddRequest;
import com.quartz.demo.pojo.ResultBO;
import com.quartz.demo.pojo.TimedTask;
/**
* @PackgeName: com.quartz.demo.service
* @ClassName: impl
* @Author: zjy
* Date: 2020/6/6 21:07
* project name: quartz
* @Version:
* @Description:
*/
public interface TimedTaskService extends IService<TimedTask> {
/**
* 添加定时任务
* @param addRequest
*/
ResultBO addQuartzJob(AddRequest addRequest);
/**
* 删除定时任务
* @param taskId
* @return
*/
ResultBO deleteQuartzJob(Integer taskId) throws Exception;
}
package com.quartz.demo.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.quartz.demo.mapper.TaskMapper;
import com.quartz.demo.pojo.Task;
import com.quartz.demo.service.TaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
/**
* @PackgeName: com.quartz.demo.service.impl
* @ClassName: TaskServiceImpl
* @Author: zjy
* Date: 2020/6/14 11:00
* project name: quartz
* @Version:
* @Description:
*/
@Slf4j
@Service
public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {
}
package com.quartz.demo.service.impl;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.quartz.demo.config.RemindJob;
import com.quartz.demo.mapper.TimedTaskMapper;
import com.quartz.demo.pojo.AddRequest;
import com.quartz.demo.pojo.ResultBO;
import com.quartz.demo.pojo.Task;
import com.quartz.demo.pojo.TimedTask;
import com.quartz.demo.service.TaskService;
import com.quartz.demo.service.TimedTaskService;
import com.quartz.demo.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* @PackgeName: com.quartz.demo.service.impl
* @ClassName: QuartzServiceImpl
* @Author: zjy
* Date: 2020/6/6 21:08
* project name: quartz
* @Version:
* @Description:
*/
@Slf4j
@Service
public class TimedTaskServiceImpl extends ServiceImpl<TimedTaskMapper, TimedTask> implements TimedTaskService {
@Autowired
private SchedulerFactoryBean schedulerFactoryBean;
@Autowired
private TaskService taskService;
@Autowired
private TimedTaskMapper timedTaskMapper;
@Override
public ResultBO addQuartzJob(AddRequest addRequest) {
ResultBO resultBO = new ResultBO();
Task task = taskService.selectById(addRequest.getTaskId());
if(null == task){
resultBO.setCode(400);
resultBO.setMsg("请核对任务id是否正确!");
resultBO.setSucceed(false);
return resultBO;
}
resultBO = addQuartz(addRequest, task);
return resultBO;
}
/**
* 删除定时任务
* @param taskId
* @return
*/
@Override
public ResultBO deleteQuartzJob(Integer taskId) throws Exception {
ResultBO resultBO = new ResultBO();
Task task = taskService.selectById(taskId);
if(null == task){
resultBO.setCode(400);
resultBO.setMsg("请核对任务id是否正确!");
resultBO.setSucceed(false);
return resultBO;
}
resultBO = deleteQuartz(task);
return resultBO;
}
/**
* 删除timedTask中的数据
* @param taskId
*/
private void deleteByTaskId(Integer taskId) {
timedTaskMapper.deleteByTaskId(taskId);
}
/**
* 添加定时任务
* @param request
* @param task
*/
public ResultBO addQuartz(AddRequest request, Task task) {
try {
addOneTime(request, task);
addTwoTime(request, task);
addThirdTime(request, task);
return ResultBO.success("添加定时任务成功!");
} catch (Exception e){
e.printStackTrace();
return ResultBO.fail("添加定时任务失败!");
}
}
/**
* 第一次提醒
*/
public void addOneTime(AddRequest request, Task task) {
TimedTask timedTask = new TimedTask();
Scheduler scheduler = schedulerFactoryBean.getScheduler();
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(DateUtils.timeToCron(request.getOneTime()));
CronTrigger trigger = TriggerBuilder.newTrigger()
.withIdentity("oneTime1" + task.getId(), "remind")
.withSchedule(cronScheduleBuilder)
.usingJobData("taskId", task.getId())
.usingJobData("taskName", task.getName())
.usingJobData("execution", request.getOneTime())
.build();
JobDetail jobDetail = JobBuilder.newJob(RemindJob.class)
.usingJobData("taskId", task.getId())
.usingJobData("taskName", task.getName())
.usingJobData("execution", request.getOneTime())
.withIdentity("oneTime1" + task.getId(), "remind")
.storeDurably()
.build();
try {
// 如果任务存在了就删除掉
if (scheduler.checkExists(jobDetail.getKey())) {
scheduler.deleteJob(jobDetail.getKey());
}
timedTask.setTaskId(task.getId());
timedTask.setCron(DateUtils.timeToCron(request.getOneTime()));
timedTask.setName(task.getName());
timedTask.setJobGroup("remind");
timedTask.setCreateTime(new Date());
timedTask.setDeleteFlag(0);
timedTask.setExecutionTime(DateUtils.timeToDate(request.getOneTime()));
insert(timedTask);
scheduler.scheduleJob(jobDetail, trigger);
} catch (SchedulerException e) {
e.printStackTrace();
}
}
/**
* 第二次提醒
*/
public void addTwoTime(AddRequest request, Task task) {
String time = request.getThirdTime();
Integer taskId = task.getId();
String taskName = task.getName();
TimedTask timedTask = new TimedTask();
Scheduler scheduler = schedulerFactoryBean.getScheduler();
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(DateUtils.timeToCron(time));
CronTrigger trigger = TriggerBuilder.newTrigger()
.withIdentity(taskName, "remind")
.withSchedule(cronScheduleBuilder)
.usingJobData("taskId", taskId)
.usingJobData("taskName", taskName)
.build();
JobDetail jobDetail = JobBuilder.newJob(RemindJob.class)
.usingJobData("taskId", taskId)
.usingJobData("taskName", taskName)
.withIdentity(taskName, "remind")
.storeDurably()
.build();
try {
// 如果任务存在了就删除掉
if (scheduler.checkExists(jobDetail.getKey())) {
scheduler.deleteJob(jobDetail.getKey());
}
timedTask.setTaskId(taskId);
timedTask.setCron(DateUtils.timeToCron(time));
timedTask.setName(taskName);
timedTask.setJobGroup("remind");
timedTask.setCreateTime(new Date());
timedTask.setDeleteFlag(0);
timedTask.setExecutionTime(DateUtils.timeToDate(time));
insert(timedTask);
scheduler.scheduleJob(jobDetail, trigger);
} catch (SchedulerException e) {
e.printStackTrace();
}
}
/**
* 第三次提醒
*/
public void addThirdTime(AddRequest request, Task task) {
String time = request.getThirdTime();
Integer taskId = task.getId();
String taskName = task.getName();
TimedTask timedTask = new TimedTask();
Scheduler scheduler = schedulerFactoryBean.getScheduler();
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(DateUtils.timeToCron(time));
CronTrigger trigger = TriggerBuilder.newTrigger()
.withIdentity(taskName, "remind")
.withSchedule(cronScheduleBuilder)
.usingJobData("taskId", taskId)
.usingJobData("taskName", taskName)
.build();
JobDetail jobDetail = JobBuilder.newJob(RemindJob.class)
.usingJobData("taskId", taskId)
.usingJobData("taskName", taskName)
.withIdentity(taskName, "remind")
.storeDurably()
.build();
try {
// 如果任务存在了就删除掉
if (scheduler.checkExists(jobDetail.getKey())) {
scheduler.deleteJob(jobDetail.getKey());
}
scheduler.scheduleJob(jobDetail, trigger);
timedTask.setTaskId(taskId);
timedTask.setCron(DateUtils.timeToCron(time));
timedTask.setName(taskName);
timedTask.setJobGroup("remind");
timedTask.setCreateTime(new Date());
timedTask.setDeleteFlag(0);
timedTask.setExecutionTime(DateUtils.timeToDate(time));
insert(timedTask);
} catch (SchedulerException e) {
e.printStackTrace();
}
}
/**
* 删除定时任务
* @param task
* @return
*/
private ResultBO deleteQuartz(Task task) throws Exception{
ResultBO resultBO = new ResultBO();
Scheduler scheduler = schedulerFactoryBean.getScheduler();
List<TimedTask> timedTaskList = selectByTaskId(task.getId());
for(TimedTask timedTask : timedTaskList){
scheduler.deleteJob(JobKey.jobKey(timedTask.getName(), "remind"));
}
resultBO.setSucceed(true);
resultBO.setMsg("删除定时任务成功!");
resultBO.setCode(200);
return resultBO;
}
/**
* 根据任务id查询定时任务列表
* @param id
* @return
*/
private List<TimedTask> selectByTaskId(Integer id) {
List<TimedTask> timedTasks = timedTaskMapper.selectByTaskId(id);
return timedTasks;
}
}
package com.quartz.demo.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.quartz.demo.pojo.Task;
import org.apache.ibatis.annotations.Mapper;
/**
* @PackgeName: com.quartz.demo.mapper
* @ClassName: TaskMapper
* @Author: zjy
* Date: 2020/6/14 11:02
* project name: quartz
* @Version:
* @Description:
*/
@Mapper
public interface TaskMapper extends BaseMapper<Task> {
}
package com.quartz.demo.mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.quartz.demo.pojo.TimedTask;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @PackgeName: com.quartz.demo.mapper
* @ClassName: TimedTaskMapper
* @Author: zjy
* Date: 2020/6/14 10:17
* project name: quartz
* @Version:
* @Description:
*/
@Mapper
public interface TimedTaskMapper extends BaseMapper<TimedTask> {
void deleteByTaskId(Integer taskId);
List<TimedTask> selectByTaskId(Integer taskId);
}
<?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.quartz.demo.mapper.TaskMapper">
<resultMap id="BaseMapper" type="com.quartz.demo.pojo.Task" >
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER"/>
</resultMap>
</mapper>
<?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.quartz.demo.mapper.TimedTaskMapper">
<resultMap id="BaseMapper" type="com.quartz.demo.pojo.TimedTask" >
<id column="id" property="id" jdbcType="INTEGER"/>
<id column="task_id" property="taskId" jdbcType="INTEGER"/>
<result column="job_group" property="jobGroup"/>
<result column="execution_time" property="executionTime" jdbcType="TIMESTAMP"/>
<result column="cron" property="cron"/>
<result column="name" property="name"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER"/>
</resultMap>
<delete id="deleteByTaskId">
update t_timed_task
set delete_flag = 1
where task_id = #{taskId}
</delete>
<select id="selectByTaskId" resultMap="BaseMapper">
select * from t_timed_task where task_id = #{taskId}
</select>
</mapper>
package com.quartz.demo.pojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "添加定时任务", description = "添加定时任务")
public class AddRequest {
/**
* 任务id
*/
@ApiModelProperty("任务id")
private long taskId;
/**
* 第一次提醒name
*/
@ApiModelProperty("第一次提醒name")
private String oneName;
/**
* 第一次提醒时间
*/
@ApiModelProperty("第一次提醒时间")
private String oneTime;
/**
* 第二次提醒name
*/
@ApiModelProperty("第二次提醒name")
private String twoName;
/**
* 第二次提醒时间
*/
@ApiModelProperty("第二次提醒时间")
private String twoTime;
/**
* 第三次提醒name
*/
@ApiModelProperty("第三次提醒name")
private String thirdName;
/**
* 第三次提醒时间
*/
@ApiModelProperty("第三次提醒时间")
private String thirdTime;
}
package com.quartz.demo.pojo;
import lombok.Data;
import java.io.Serializable;
/**
* @PackgeName: com.mini.demo.yinlian.unionpay
* @ClassName: ResultBO
* @Author: zjy
* Date: 2020/4/23 12:22
* project name: mini
* @Version:
* @Description:
*/
@Data
public class ResultBO<T> implements Serializable {
private boolean succeed = true;
private int code = 0;
private String msg;
private T content;
public ResultBO(T content) {
this.content = content;
}
public ResultBO(boolean succeed, int code, String msg, T content) {
this.succeed = succeed;
this.code = code;
this.msg = msg;
this.content = content;
}
public ResultBO(boolean succeed, int code, String msg) {
this.succeed = succeed;
this.code = code;
this.msg = msg;
}
public ResultBO() {
}
public static <T> ResultBO<T> success(T content) {
return new ResultBO<T>(content);
}
public static ResultBO success() {
return new ResultBO();
}
public static ResultBO fail(int code, String msg) {
return new ResultBO(false, code, msg);
}
public static ResultBO fail(String msg) {
return new ResultBO(false, -1, msg);
}
public static ResultBO fail() {
return fail("fail");
}
}
package com.quartz.demo.pojo;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import java.util.Date;
/**
* @PackgeName: com.quartz.demo.pojo
* @ClassName: Task
* @Author: zjy
* Date: 2020/6/14 10:53
* project name: quartz
* @Version:
* @Description:
*/
@Data
@TableName("t_task")
public class Task {
@TableId(value="id", type= IdType.AUTO)
private Integer id;
private String name;
private Date createTime;
private Date updateTime;
private int deleteFlag = 0;
}
package com.quartz.demo.pojo;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.Data;
import java.util.Date;
/**
* @PackgeName: com.mini.demo.quartz
* @ClassName: TimedTask
* @Author: zjy
* Date: 2020/6/6 10:08
* project name: mini
* @Version:
* @Description:
*/
@Data
@TableName("t_timed_task")
public class TimedTask {
/**
* 主键id
*/
@TableId(value="id", type= IdType.AUTO)
private Integer id;
/**
* 任务id
*/
private Integer taskId;
/**
* 任务分组
*/
private String jobGroup;
/**
* 执行时间
*/
private Date executionTime;
/**
* 定时任务表达式
*/
private String cron;
/**
* 定时任务说明
*/
private String name;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
/**
* 是否删除
*/
private int deleteFlag;
}
这里只写了一个时间转换的工具类
package com.quartz.demo.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @PackgeName: com.quartz.demo.utils
* @ClassName: DateUtils
* @Author: zjy
* Date: 2020/6/14 10:41
* project name: quartz
* @Version:
* @Description:
*/
public class DateUtils {
/**
* 将时间格式的字符串转换成cron表达式
*
* @param time yyyy-mm-dd HH:mm:ss
* @return 0/5 * * * * ? * 25 11 14 6 ?
*/
public static String timeToCron(String time) {
//前面传的是""或者null则把定时启动时间设置为2060年1月1日0点0分0秒执行
if (time == null || "".equals(time)) {
return "0 0 0 1 1 ? 2060";
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
try {
Date date = format.parse(time);
SimpleDateFormat sdf = new SimpleDateFormat("0 mm HH dd MM ? yyyy");
String formatTimeStr = sdf.format(date);
return formatTimeStr;
} catch (ParseException e) {
e.printStackTrace();
}
return "0 0 0 1 1 ? 2060";
}
/**
* 将时间格式的字符串转换成Date
*
* @param time yyyy-mm-dd HH:mm:ss
*/
public static Date timeToDate(String time) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
try {
Date date = format.parse(time);
return date;
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}
}
package com.quartz.demo.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.pathMapping("/")
.select()
.apis(RequestHandlerSelectors.any())
.apis(RequestHandlerSelectors.basePackage("com.quartz.demo.controller"))
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("springboot利用swagger构建api文档")
.description("swagger接口文档")
.version("1.0")
.build();
}
}
package com.quartz.demo.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
/**
* @PackgeName: com.quartz.demo.config
* @ClassName: DruidConfig
* @Author: zjy
* Date: 2020/6/13 16:32
* project name: quartz
* @Version:
* @Description:
*/
@Configuration
public class DruidConfig {
@ConfigurationProperties(prefix = "spring.datasource")
@Bean
public DataSource druidDataSource() {
return new DruidDataSource();
}
}
package com.quartz.demo.config;
import org.quartz.spi.JobFactory;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.scheduling.quartz.SpringBeanJobFactory;
import javax.sql.DataSource;
import java.io.IOException;
import java.util.Properties;
/**
* @PackgeName: com.quartz.demo.config
* @ClassName: ConfigureQuartz
* @Author: zjy
* Date: 2020/6/13 16:18
* project name: quartz
* @Version:
* @Description:
*/
@Configuration
public class ConfigureQuartz {
@Bean
public JobFactory jobFactory(ApplicationContext applicationContext) {
AutowiringSpringBeanJobFactory jobFactory = new AutowiringSpringBeanJobFactory();
jobFactory.setApplicationContext(applicationContext);
return jobFactory;
}
/**
* SchedulerFactoryBean这个类的真正作用提供了对org.quartz.Scheduler的创建与配置,并且会管理它的生命周期与Spring同步。
* org.quartz.Scheduler: 调度器。所有的调度都是由它控制。
* @param dataSource 为SchedulerFactory配置数据源
* @param jobFactory 为SchedulerFactory配置JobFactory
*/
@Bean
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource, JobFactory jobFactory) throws IOException {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
//可选,QuartzScheduler启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录
factory.setOverwriteExistingJobs(true);
factory.setAutoStartup(true); //设置自行启动
factory.setDataSource(dataSource);
factory.setJobFactory(jobFactory);
factory.setQuartzProperties(quartzProperties());
return factory;
}
//从quartz.properties文件中读取Quartz配置属性
@Bean
public Properties quartzProperties() throws IOException {
PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
propertiesFactoryBean.setLocation(new ClassPathResource("/quartz.properties"));
propertiesFactoryBean.afterPropertiesSet();
return propertiesFactoryBean.getObject();
}
//配置JobFactory,为quartz作业添加自动连接支持
public final class AutowiringSpringBeanJobFactory extends SpringBeanJobFactory implements
ApplicationContextAware {
private transient AutowireCapableBeanFactory beanFactory;
@Override
public void setApplicationContext(final ApplicationContext context) {
beanFactory = context.getAutowireCapableBeanFactory();
}
@Override
protected Object createJobInstance(final TriggerFiredBundle bundle) throws Exception {
final Object job = super.createJobInstance(bundle);
beanFactory.autowireBean(job);
return job;
}
}
}
package com.quartz.demo.config;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Service;
/**
* @program: vehicle-remote-control
* @description: 定时任务执行的方法
* @create: 2019-09-06 17:10
* @author: zhoujy
*/
@Slf4j
@Service
public class RemindJob extends QuartzJobBean {
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
JobDataMap params = jobExecutionContext.getMergedJobDataMap();
Integer taskId = params.getInt("taskId");
String taskName = params.getString("taskName");
String execution = params.getString("execution");
log.info("发送:{}任务, taskId为:{}, 执行时间为:{}", taskName, taskId, execution);
}
}
/*
Navicat Premium Data Transfer
Source Server : 本地库
Source Server Type : MySQL
Source Server Version : 50722
Source Host : localhost:3306
Source Schema : quartz
Target Server Type : MySQL
Target Server Version : 50722
File Encoding : 65001
Date: 14/06/2020 15:12:07
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for qrtz_blob_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_blob_triggers`;
CREATE TABLE `qrtz_blob_triggers` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计划名',
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT ' 触发器名称',
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器组',
`BLOB_DATA` blob NULL,
PRIMARY KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) USING BTREE,
INDEX `SCHED_NAME`(`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '以Blob 类型存储的触发器' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_calendars
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_calendars`;
CREATE TABLE `qrtz_calendars` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计划名称',
`CALENDAR_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`CALENDAR` blob NOT NULL,
PRIMARY KEY (`SCHED_NAME`, `CALENDAR_NAME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '日历信息' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_cron_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_cron_triggers`;
CREATE TABLE `qrtz_cron_triggers` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计划名称',
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT ' 触发器名称',
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器组',
`CRON_EXPRESSION` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '时间表达式',
`TIME_ZONE_ID` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '时区ID nvarchar 80',
PRIMARY KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '定时触发器' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of qrtz_cron_triggers
-- ----------------------------
INSERT INTO `qrtz_cron_triggers` VALUES ('schedulerFactoryBean', 'oneTime10', 'remind', '0 46 16 * * ?', 'GMT+08:00');
INSERT INTO `qrtz_cron_triggers` VALUES ('schedulerFactoryBean', 'oneTime13', 'remind', '0 12 15 14 06 ? 2020', 'GMT+08:00');
INSERT INTO `qrtz_cron_triggers` VALUES ('schedulerFactoryBean', 'thireTime30', 'remind', '0 47 16 * * ?', 'GMT+08:00');
INSERT INTO `qrtz_cron_triggers` VALUES ('schedulerFactoryBean', 'twoTime20', 'remind', '0 48 16 * * ?', 'GMT+08:00');
INSERT INTO `qrtz_cron_triggers` VALUES ('schedulerFactoryBean', '上班', 'remind', '0 13 15 14 06 ? 2020', 'GMT+08:00');
-- ----------------------------
-- Table structure for qrtz_fired_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_fired_triggers`;
CREATE TABLE `qrtz_fired_triggers` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计划名称',
`ENTRY_ID` varchar(95) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '组标识',
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器名称',
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器组',
`INSTANCE_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '当前实例的名称',
`FIRED_TIME` bigint(13) NOT NULL COMMENT '当前执行时间',
`SCHED_TIME` bigint(13) NOT NULL COMMENT ' 计划时间',
`PRIORITY` int(11) NOT NULL COMMENT '权重',
`STATE` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '状态',
`JOB_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '作业名称',
`JOB_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '作业组',
`IS_NONCONCURRENT` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否并行',
`REQUESTS_RECOVERY` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否要求唤醒',
PRIMARY KEY (`SCHED_NAME`, `ENTRY_ID`) USING BTREE,
INDEX `IDX_QRTZ_FT_TRIG_INST_NAME`(`SCHED_NAME`, `INSTANCE_NAME`) USING BTREE,
INDEX `IDX_QRTZ_FT_INST_JOB_REQ_RCVRY`(`SCHED_NAME`, `INSTANCE_NAME`, `REQUESTS_RECOVERY`) USING BTREE,
INDEX `IDX_QRTZ_FT_J_G`(`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`) USING BTREE,
INDEX `IDX_QRTZ_FT_JG`(`SCHED_NAME`, `JOB_GROUP`) USING BTREE,
INDEX `IDX_QRTZ_FT_T_G`(`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) USING BTREE,
INDEX `IDX_QRTZ_FT_TG`(`SCHED_NAME`, `TRIGGER_GROUP`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '保存已经触发的触发器状态信息' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_job_details
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_job_details`;
CREATE TABLE `qrtz_job_details` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计划名称',
`JOB_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '作业名称',
`JOB_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '作业组',
`DESCRIPTION` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述',
`JOB_CLASS_NAME` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '作业程序类名',
`IS_DURABLE` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '是否持久',
`IS_NONCONCURRENT` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '是否并行',
`IS_UPDATE_DATA` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '是否更新',
`REQUESTS_RECOVERY` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '是否要求唤醒',
`JOB_DATA` blob NULL COMMENT '作业名称',
PRIMARY KEY (`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`) USING BTREE,
INDEX `IDX_QRTZ_J_REQ_RECOVERY`(`SCHED_NAME`, `REQUESTS_RECOVERY`) USING BTREE,
INDEX `IDX_QRTZ_J_GRP`(`SCHED_NAME`, `JOB_GROUP`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'job 详细信息' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of qrtz_job_details
-- ----------------------------
INSERT INTO `qrtz_job_details` VALUES ('schedulerFactoryBean', 'oneTime10', 'remind', NULL, 'com.quartz.demo.config.RemindJob', '1', '0', '0', '0', 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C7708000000100000000274000376696E740001307400046F7065727400086F6E6554696D65317800);
INSERT INTO `qrtz_job_details` VALUES ('schedulerFactoryBean', 'oneTime11', 'remind', NULL, 'com.quartz.demo.config.RemindJob', '1', '0', '0', '0', 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C770800000010000000027400087461736B4E616D657400086F6E6554696D65317400067461736B4964737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870000000017800);
INSERT INTO `qrtz_job_details` VALUES ('schedulerFactoryBean', 'oneTime12', 'remind', NULL, 'com.quartz.demo.config.RemindJob', '1', '0', '0', '0', 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C770800000010000000027400046F7065727400086F6E6554696D65317400067461736B4964737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870000000027800);
INSERT INTO `qrtz_job_details` VALUES ('schedulerFactoryBean', 'oneTime13', 'remind', NULL, 'com.quartz.demo.config.RemindJob', '1', '0', '0', '0', 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C77080000001000000003740009657865637574696F6E740010323032302D30362D31342031353A31327400087461736B4E616D65740006E4B88AE78FAD7400067461736B4964737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870000000037800);
INSERT INTO `qrtz_job_details` VALUES ('schedulerFactoryBean', 'thireTime30', 'remind', NULL, 'com.quartz.demo.config.RemindJob', '1', '0', '0', '0', 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C7708000000100000000274000376696E740001307400046F70657274000A746869726554696D65337800);
INSERT INTO `qrtz_job_details` VALUES ('schedulerFactoryBean', 'thireTime31', 'remind', NULL, 'com.quartz.demo.config.RemindJob', '1', '0', '0', '0', 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C770800000010000000027400087461736B4E616D6574000A746869726554696D65337400067461736B4964737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870000000017800);
INSERT INTO `qrtz_job_details` VALUES ('schedulerFactoryBean', 'thireTime32', 'remind', NULL, 'com.quartz.demo.config.RemindJob', '1', '0', '0', '0', 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C770800000010000000027400046F70657274000A746869726554696D65337400067461736B4964737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870000000027800);
INSERT INTO `qrtz_job_details` VALUES ('schedulerFactoryBean', 'twoTime20', 'remind', NULL, 'com.quartz.demo.config.RemindJob', '1', '0', '0', '0', 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C7708000000100000000274000376696E740001307400046F70657274000874776F54696D65327800);
INSERT INTO `qrtz_job_details` VALUES ('schedulerFactoryBean', 'twoTime21', 'remind', NULL, 'com.quartz.demo.config.RemindJob', '1', '0', '0', '0', 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C770800000010000000027400087461736B4E616D6574000874776F54696D65327400067461736B4964737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870000000017800);
INSERT INTO `qrtz_job_details` VALUES ('schedulerFactoryBean', 'twoTime22', 'remind', NULL, 'com.quartz.demo.config.RemindJob', '1', '0', '0', '0', 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C770800000010000000027400046F70657274000874776F54696D65327400067461736B4964737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870000000027800);
INSERT INTO `qrtz_job_details` VALUES ('schedulerFactoryBean', '上班', 'remind', NULL, 'com.quartz.demo.config.RemindJob', '1', '0', '0', '0', 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C770800000010000000027400087461736B4E616D65740006E4B88AE78FAD7400067461736B4964737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870000000037800);
-- ----------------------------
-- Table structure for qrtz_locks
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_locks`;
CREATE TABLE `qrtz_locks` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计划名称',
`LOCK_NAME` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '锁名称',
PRIMARY KEY (`SCHED_NAME`, `LOCK_NAME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '存储程序的悲观锁的信息(假如使用了悲观锁) ' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of qrtz_locks
-- ----------------------------
INSERT INTO `qrtz_locks` VALUES ('schedulerFactoryBean', 'TRIGGER_ACCESS');
-- ----------------------------
-- Table structure for qrtz_paused_trigger_grps
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_paused_trigger_grps`;
CREATE TABLE `qrtz_paused_trigger_grps` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计划名称',
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器组',
PRIMARY KEY (`SCHED_NAME`, `TRIGGER_GROUP`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '存放暂停掉的触发器' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_scheduler_state
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_scheduler_state`;
CREATE TABLE `qrtz_scheduler_state` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计划名称',
`INSTANCE_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '实例名称',
`LAST_CHECKIN_TIME` bigint(13) NOT NULL COMMENT '最后的检查时间',
`CHECKIN_INTERVAL` bigint(13) NOT NULL COMMENT '检查间隔',
PRIMARY KEY (`SCHED_NAME`, `INSTANCE_NAME`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '调度器状态' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_simple_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_simple_triggers`;
CREATE TABLE `qrtz_simple_triggers` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计划名称',
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器名称',
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器组',
`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`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '简单的触发器' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_simprop_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_simprop_triggers`;
CREATE TABLE `qrtz_simprop_triggers` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计划名称',
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器名称',
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器组',
`STR_PROP_1` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '计划名称',
`STR_PROP_2` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '计划名称',
`STR_PROP_3` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '计划名称',
`INT_PROP_1` int(11) NULL DEFAULT NULL,
`INT_PROP_2` int(11) NULL DEFAULT NULL,
`LONG_PROP_1` bigint(20) NULL DEFAULT NULL,
`LONG_PROP_2` bigint(20) NULL DEFAULT NULL,
`DEC_PROP_1` decimal(13, 4) NULL DEFAULT NULL,
`DEC_PROP_2` decimal(13, 4) NULL DEFAULT NULL,
`BOOL_PROP_1` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`BOOL_PROP_2` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
PRIMARY KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '存储CalendarIntervalTrigger和DailyTimeIntervalTrigger两种类型的触发器' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for qrtz_triggers
-- ----------------------------
DROP TABLE IF EXISTS `qrtz_triggers`;
CREATE TABLE `qrtz_triggers` (
`SCHED_NAME` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '计划名称',
`TRIGGER_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器名称',
`TRIGGER_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器组',
`JOB_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '作业名称',
`JOB_GROUP` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '作业组',
`DESCRIPTION` varchar(250) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '描述',
`NEXT_FIRE_TIME` bigint(13) NULL DEFAULT NULL COMMENT '下次执行时间',
`PREV_FIRE_TIME` bigint(13) NULL DEFAULT NULL COMMENT '前一次',
`PRIORITY` int(11) NULL DEFAULT NULL COMMENT '优先权',
`TRIGGER_STATE` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器状态',
`TRIGGER_TYPE` varchar(8) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '触发器类型',
`START_TIME` bigint(13) NOT NULL COMMENT '开始时间',
`END_TIME` bigint(13) NULL DEFAULT NULL COMMENT '结束时间',
`CALENDAR_NAME` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '日历名称',
`MISFIRE_INSTR` smallint(2) NULL DEFAULT NULL COMMENT '失败次数',
`JOB_DATA` blob NULL COMMENT '作业数据',
PRIMARY KEY (`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`) USING BTREE,
INDEX `IDX_QRTZ_T_J`(`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`) USING BTREE,
INDEX `IDX_QRTZ_T_JG`(`SCHED_NAME`, `JOB_GROUP`) USING BTREE,
INDEX `IDX_QRTZ_T_C`(`SCHED_NAME`, `CALENDAR_NAME`) USING BTREE,
INDEX `IDX_QRTZ_T_G`(`SCHED_NAME`, `TRIGGER_GROUP`) USING BTREE,
INDEX `IDX_QRTZ_T_STATE`(`SCHED_NAME`, `TRIGGER_STATE`) USING BTREE,
INDEX `IDX_QRTZ_T_N_STATE`(`SCHED_NAME`, `TRIGGER_NAME`, `TRIGGER_GROUP`, `TRIGGER_STATE`) USING BTREE,
INDEX `IDX_QRTZ_T_N_G_STATE`(`SCHED_NAME`, `TRIGGER_GROUP`, `TRIGGER_STATE`) USING BTREE,
INDEX `IDX_QRTZ_T_NEXT_FIRE_TIME`(`SCHED_NAME`, `NEXT_FIRE_TIME`) USING BTREE,
INDEX `IDX_QRTZ_T_NFT_ST`(`SCHED_NAME`, `TRIGGER_STATE`, `NEXT_FIRE_TIME`) USING BTREE,
INDEX `IDX_QRTZ_T_NFT_MISFIRE`(`SCHED_NAME`, `MISFIRE_INSTR`, `NEXT_FIRE_TIME`) USING BTREE,
INDEX `IDX_QRTZ_T_NFT_ST_MISFIRE`(`SCHED_NAME`, `MISFIRE_INSTR`, `NEXT_FIRE_TIME`, `TRIGGER_STATE`) USING BTREE,
INDEX `IDX_QRTZ_T_NFT_ST_MISFIRE_GRP`(`SCHED_NAME`, `MISFIRE_INSTR`, `NEXT_FIRE_TIME`, `TRIGGER_GROUP`, `TRIGGER_STATE`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '触发器' ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of qrtz_triggers
-- ----------------------------
INSERT INTO `qrtz_triggers` VALUES ('schedulerFactoryBean', 'oneTime10', 'remind', 'oneTime10', 'remind', NULL, 1592124360000, 1592037960000, 5, 'WAITING', 'CRON', 1592037869000, 0, NULL, 0, 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C7708000000100000000274000376696E740001307400046F7065727400086F6E6554696D65317800);
INSERT INTO `qrtz_triggers` VALUES ('schedulerFactoryBean', 'oneTime13', 'remind', 'oneTime13', 'remind', NULL, 1592118720000, -1, 5, 'WAITING', 'CRON', 1592118666000, 0, NULL, 0, 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C77080000001000000003740009657865637574696F6E740010323032302D30362D31342031353A31327400087461736B4E616D65740006E4B88AE78FAD7400067461736B4964737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870000000037800);
INSERT INTO `qrtz_triggers` VALUES ('schedulerFactoryBean', 'thireTime30', 'remind', 'thireTime30', 'remind', NULL, 1592124420000, 1592038020000, 5, 'WAITING', 'CRON', 1592037869000, 0, NULL, 0, 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C7708000000100000000274000376696E740001307400046F70657274000A746869726554696D65337800);
INSERT INTO `qrtz_triggers` VALUES ('schedulerFactoryBean', 'twoTime20', 'remind', 'twoTime20', 'remind', NULL, 1592124480000, 1592038080000, 5, 'WAITING', 'CRON', 1592037869000, 0, NULL, 0, 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C7708000000100000000274000376696E740001307400046F70657274000874776F54696D65327800);
INSERT INTO `qrtz_triggers` VALUES ('schedulerFactoryBean', '上班', 'remind', '上班', 'remind', NULL, 1592118780000, -1, 5, 'WAITING', 'CRON', 1592118666000, 0, NULL, 0, 0xACED0005737200156F72672E71756172747A2E4A6F62446174614D61709FB083E8BFA9B0CB020000787200266F72672E71756172747A2E7574696C732E537472696E674B65794469727479466C61674D61708208E8C3FBC55D280200015A0013616C6C6F77735472616E7369656E74446174617872001D6F72672E71756172747A2E7574696C732E4469727479466C61674D617013E62EAD28760ACE0200025A000564697274794C00036D617074000F4C6A6176612F7574696C2F4D61703B787001737200116A6176612E7574696C2E486173684D61700507DAC1C31660D103000246000A6C6F6164466163746F724900097468726573686F6C6478703F4000000000000C770800000010000000027400087461736B4E616D65740006E4B88AE78FAD7400067461736B4964737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B0200007870000000037800);
-- ----------------------------
-- Table structure for t_task
-- ----------------------------
DROP TABLE IF EXISTS `t_task`;
CREATE TABLE `t_task` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务名称',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
`delete_flag` int(2) NULL DEFAULT NULL COMMENT '是否删除 0:否 1:删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of t_task
-- ----------------------------
INSERT INTO `t_task` VALUES (1, '闹钟', '2020-06-14 10:55:56', NULL, 0);
INSERT INTO `t_task` VALUES (2, '打卡', '2020-06-14 10:56:20', NULL, 0);
INSERT INTO `t_task` VALUES (3, '上班', '2020-06-14 10:56:34', NULL, 0);
-- ----------------------------
-- Table structure for t_timed_task
-- ----------------------------
DROP TABLE IF EXISTS `t_timed_task`;
CREATE TABLE `t_timed_task` (
`id` int(32) NOT NULL AUTO_INCREMENT COMMENT 'id',
`task_id` int(32) NOT NULL COMMENT '任务id',
`job_group` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务分组',
`execution_time` datetime(0) NULL DEFAULT NULL COMMENT '执行时间',
`cron` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '执行的cron',
`name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '任务说明',
`create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
`delete_flag` tinyint(4) NULL DEFAULT 0 COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of t_timed_task
-- ----------------------------
INSERT INTO `t_timed_task` VALUES (1, 1, '111', NULL, NULL, NULL, NULL, NULL, 0);
INSERT INTO `t_timed_task` VALUES (2, 1, 'remind', '2020-06-14 11:49:00', '0 49 11 14 06 ? 2020', '第一次提醒', '2020-06-14 11:48:46', NULL, 0);
INSERT INTO `t_timed_task` VALUES (3, 1, 'remind', '2020-06-14 11:52:00', '0 52 11 14 06 ? 2020', '第二次提醒', '2020-06-14 11:48:46', NULL, 0);
INSERT INTO `t_timed_task` VALUES (4, 1, 'remind', '2020-06-14 11:51:00', '0 51 11 14 06 ? 2020', '第三次提醒', '2020-06-14 11:48:46', NULL, 0);
INSERT INTO `t_timed_task` VALUES (5, 1, 'remind', '2020-06-14 12:09:00', '0 09 12 14 06 ? 2020', '第一次提醒', '2020-06-14 12:08:36', NULL, 0);
INSERT INTO `t_timed_task` VALUES (6, 1, 'remind', '2020-06-14 12:11:00', '0 11 12 14 06 ? 2020', '第二次提醒', '2020-06-14 12:08:36', NULL, 0);
INSERT INTO `t_timed_task` VALUES (7, 1, 'remind', '2020-06-14 12:10:00', '0 10 12 14 06 ? 2020', '第三次提醒', '2020-06-14 12:08:36', NULL, 0);
INSERT INTO `t_timed_task` VALUES (8, 3, 'remind', '2020-06-14 15:09:00', '0 09 15 14 06 ? 2020', '上班', '2020-06-14 15:07:56', NULL, 1);
INSERT INTO `t_timed_task` VALUES (9, 3, 'remind', '2020-06-14 15:10:00', '0 10 15 14 06 ? 2020', '上班', '2020-06-14 15:07:57', NULL, 1);
INSERT INTO `t_timed_task` VALUES (10, 3, 'remind', '2020-06-14 15:10:00', '0 10 15 14 06 ? 2020', '上班', '2020-06-14 15:07:57', NULL, 1);
INSERT INTO `t_timed_task` VALUES (11, 3, 'remind', '2020-06-14 15:12:00', '0 12 15 14 06 ? 2020', '上班', '2020-06-14 15:11:07', NULL, 0);
INSERT INTO `t_timed_task` VALUES (12, 3, 'remind', '2020-06-14 15:13:00', '0 13 15 14 06 ? 2020', '上班', '2020-06-14 15:11:07', NULL, 0);
INSERT INTO `t_timed_task` VALUES (13, 3, 'remind', '2020-06-14 15:13:00', '0 13 15 14 06 ? 2020', '上班', '2020-06-14 15:11:07', NULL, 0);
SET FOREIGN_KEY_CHECKS = 1;
到这里就所有代码及配置都写完了.
启动项目提示这个说明quartz已经起来了:
这里配置了swagger就使用swagger测试.启动项目访问:http://localhost:2080/swagger-ui.html
请求参数:
结果:
执行了2个定时时间之后,我立马执行了个删除操作
结果:
测试是OK的.定时任务被删除了
码云地址:https://gitee.com/zhou_lao/quartz.git
这篇博客写的真累,没有想到这么多代码!希望大佬能喜欢!!
欢迎大佬们留言评论,共同学习!!!感谢!!!
===========================
原创文章,转载注明出处!