parent
b20d556c99
commit
364b5bda41
@ -0,0 +1,184 @@
|
|||||||
|
package com.farm.quartz.server;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
|
||||||
|
import org.quartz.SchedulerException;
|
||||||
|
|
||||||
|
import com.farm.quartz.domain.FarmQzScheduler;
|
||||||
|
import com.farm.quartz.domain.FarmQzTask;
|
||||||
|
import com.farm.quartz.domain.FarmQzTrigger;
|
||||||
|
import com.farm.core.auth.domain.LoginUser;
|
||||||
|
import com.farm.core.sql.query.DataQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计划任务管理
|
||||||
|
*
|
||||||
|
* @author MAC_wd
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface FarmQzSchedulerManagerInter {
|
||||||
|
/**
|
||||||
|
*新增实体
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
public FarmQzScheduler insertSchedulerEntity(FarmQzScheduler entity,
|
||||||
|
LoginUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动一个任务
|
||||||
|
*
|
||||||
|
* @param SchedulerId
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
* 类class无法解析
|
||||||
|
* @throws ParseException
|
||||||
|
* 计划字符串脚本无法解析
|
||||||
|
* @throws SchedulerException
|
||||||
|
*/
|
||||||
|
public void startTask(String SchedulerId) throws ClassNotFoundException,
|
||||||
|
ParseException, SchedulerException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止一个任务
|
||||||
|
*
|
||||||
|
* @param SchedulerId
|
||||||
|
* @throws SchedulerException
|
||||||
|
*/
|
||||||
|
public void stopTask(String SchedulerId) throws SchedulerException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启动调度引擎
|
||||||
|
*
|
||||||
|
* @throws ParseException
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
*/
|
||||||
|
public void start() throws SchedulerException, ParseException,
|
||||||
|
ClassNotFoundException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*修改实体
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
public FarmQzScheduler editSchedulerEntity(FarmQzScheduler entity,
|
||||||
|
LoginUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*删除实体
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
public void deleteSchedulerEntity(String entity, LoginUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*获得实体
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public FarmQzScheduler getSchedulerEntity(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个基本查询用来查询当前实体
|
||||||
|
*
|
||||||
|
* @param query
|
||||||
|
* 传入的查询条件封装
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public DataQuery createSchedulerSimpleQuery(DataQuery query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断一个任务计划是否启动
|
||||||
|
*
|
||||||
|
* @param SchedulerId
|
||||||
|
* @return
|
||||||
|
* @throws SchedulerException
|
||||||
|
*/
|
||||||
|
public boolean isRunningFindScheduler(String SchedulerId)
|
||||||
|
throws SchedulerException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*新增触发器定义实体
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
public FarmQzTrigger insertTriggerEntity(FarmQzTrigger entity,
|
||||||
|
LoginUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*修改触发器定义实体
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
public FarmQzTrigger editTriggerEntity(FarmQzTrigger entity, LoginUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*删除触发器定义实体
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
public void deleteTriggerEntity(String entity, LoginUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*获得触发器定义实体
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public FarmQzTrigger getTriggerEntity(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个基本查询用来查询当前触发器定义实体
|
||||||
|
*
|
||||||
|
* @param query
|
||||||
|
* 传入的查询条件封装
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public DataQuery createTriggerSimpleQuery(DataQuery query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*新增任务定义实体
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
public FarmQzTask insertTaskEntity(FarmQzTask entity, LoginUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*修改任务定义实体
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
public FarmQzTask editTaskEntity(FarmQzTask entity, LoginUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*删除任务定义实体
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
*/
|
||||||
|
public void deleteTaskEntity(String entity, LoginUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*获得任务定义实体
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public FarmQzTask getTaskEntity(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建一个基本查询用来查询当前任务定义实体
|
||||||
|
*
|
||||||
|
* @param query
|
||||||
|
* 传入的查询条件封装
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public DataQuery createTaskSimpleQuery(DataQuery query);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 由一个实例获得任务对象
|
||||||
|
*
|
||||||
|
* @param schedulerId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public FarmQzTask getTaskBySchedulerId(String schedulerId);
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
org.quartz.scheduler.instanceName = MyScheduler
|
||||||
|
org.quartz.threadPool.threadCount = 3
|
||||||
|
org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
|
@ -0,0 +1,87 @@
|
|||||||
|
package com.farm.web.tag;
|
||||||
|
// 声明该类所在的包为 com.farm.web.tag
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
// 导入用于处理输入输出异常的类,后续在向 JSP 输出内容时可能会用到
|
||||||
|
|
||||||
|
import javax.servlet.jsp.JspException;
|
||||||
|
// 导入 JSP 标签异常类,用于处理自定义标签在执行过程中可能出现的异常
|
||||||
|
|
||||||
|
import javax.servlet.jsp.JspWriter;
|
||||||
|
// 导入 JSP 输出流类,用于向客户端输出内容
|
||||||
|
|
||||||
|
import javax.servlet.jsp.tagext.TagSupport;
|
||||||
|
// 导入 TagSupport 类,作为自定义 JSP 标签的基类
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
// 导入 Log4j 的日志记录器类,用于记录程序运行中的日志信息
|
||||||
|
|
||||||
|
import com.farm.core.time.TimeTool;
|
||||||
|
// 导入时间处理工具类,用于对时间进行格式化等操作
|
||||||
|
|
||||||
|
public class TimeFormat extends TagSupport {
|
||||||
|
// 定义一个名为 TimeFormat 的类,继承自 TagSupport 类,用于创建自定义 JSP 标签
|
||||||
|
|
||||||
|
private String date;
|
||||||
|
// 定义一个字符串变量,用于存储需要格式化的日期时间数据
|
||||||
|
|
||||||
|
private String yyyyMMddHHmmss;
|
||||||
|
// 定义一个字符串变量,用于存储日期时间的格式化模式,例如 "yyyy-MM-dd HH:mm:ss" 这样的格式字符串
|
||||||
|
|
||||||
|
static final Logger log = Logger.getLogger(TimeFormat.class);
|
||||||
|
// 创建一个静态的日志记录器,用于记录该类的日志信息
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
// 定义序列化版本号,确保在序列化和反序列化过程中类的版本一致性
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int doEndTag() throws JspException {
|
||||||
|
// 重写 doEndTag 方法,该方法在标签结束时执行
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return 0;
|
||||||
|
// 返回 0 表示继续处理页面的后续内容
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int doStartTag() throws JspException {
|
||||||
|
// 重写 doStartTag 方法,该方法在标签开始时执行
|
||||||
|
|
||||||
|
JspWriter jspw = this.pageContext.getOut();
|
||||||
|
// 获取当前 JSP 页面的输出流对象,用于向客户端输出内容
|
||||||
|
|
||||||
|
try {
|
||||||
|
jspw.print(TimeTool.getFormatTimeDate12(date, yyyyMMddHHmmss));
|
||||||
|
// 调用 TimeTool 类的 getFormatTimeDate12 方法,传入需要格式化的日期时间数据 date 和格式化模式 yyyyMMddHHmmss
|
||||||
|
// 将格式化后的日期时间结果通过 JspWriter 输出到客户端页面
|
||||||
|
} catch (IOException e) {
|
||||||
|
// 捕获输出内容时可能出现的输入输出异常
|
||||||
|
log.error(e.getMessage());
|
||||||
|
// 将异常信息记录到日志中
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
// 返回 0 表示继续处理页面的后续内容
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDate() {
|
||||||
|
// 获取需要格式化的日期时间数据的方法
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(String date) {
|
||||||
|
// 设置需要格式化的日期时间数据的方法
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getYyyyMMddHHmmss() {
|
||||||
|
// 获取日期时间格式化模式的方法
|
||||||
|
return yyyyMMddHHmmss;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYyyyMMddHHmmss(String yyyyMMddHHmmss) {
|
||||||
|
// 设置日期时间格式化模式的方法
|
||||||
|
this.yyyyMMddHHmmss = yyyyMMddHHmmss;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue