项目初始化
This commit is contained in:
46
ruoyi-quartz/pom.xml
Normal file
46
ruoyi-quartz/pom.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?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</artifactId>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<version>4.7.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>ruoyi-quartz</artifactId>
|
||||
|
||||
<description>
|
||||
quartz定时任务
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- 定时任务 -->
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.27</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
8
ruoyi-quartz/ruoyi-quartz.iml
Normal file
8
ruoyi-quartz/ruoyi-quartz.iml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="Spring" name="Spring">
|
||||
<configuration />
|
||||
</facet>
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,57 @@
|
||||
//package com.ruoyi.quartz.config;
|
||||
//
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||
//import javax.sql.DataSource;
|
||||
//import java.util.Properties;
|
||||
//
|
||||
///**
|
||||
// * 定时任务配置(单机部署建议默认走内存,如需集群需要创建qrtz数据库表/打开类注释)
|
||||
// *
|
||||
// * @author ruoyi
|
||||
// */
|
||||
//@Configuration
|
||||
//public class ScheduleConfig
|
||||
//{
|
||||
// @Bean
|
||||
// public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource)
|
||||
// {
|
||||
// SchedulerFactoryBean factory = new SchedulerFactoryBean();
|
||||
// factory.setDataSource(dataSource);
|
||||
//
|
||||
// // quartz参数
|
||||
// Properties prop = new Properties();
|
||||
// prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler");
|
||||
// prop.put("org.quartz.scheduler.instanceId", "AUTO");
|
||||
// // 线程池配置
|
||||
// prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
|
||||
// prop.put("org.quartz.threadPool.threadCount", "20");
|
||||
// prop.put("org.quartz.threadPool.threadPriority", "5");
|
||||
// // JobStore配置
|
||||
// prop.put("org.quartz.jobStore.class", "org.springframework.scheduling.quartz.LocalDataSourceJobStore");
|
||||
// // 集群配置
|
||||
// prop.put("org.quartz.jobStore.isClustered", "true");
|
||||
// prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000");
|
||||
// prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1");
|
||||
// prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true");
|
||||
//
|
||||
// // sqlserver 启用
|
||||
// // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?");
|
||||
// prop.put("org.quartz.jobStore.misfireThreshold", "12000");
|
||||
// prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
|
||||
// factory.setQuartzProperties(prop);
|
||||
//
|
||||
// factory.setSchedulerName("RuoyiScheduler");
|
||||
// // 延时启动
|
||||
// factory.setStartupDelay(1);
|
||||
// factory.setApplicationContextSchedulerContextKey("applicationContextKey");
|
||||
// // 可选,QuartzScheduler
|
||||
// // 启动时更新己存在的Job,这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了
|
||||
// factory.setOverwriteExistingJobs(true);
|
||||
// // 设置自动启动,默认为true
|
||||
// factory.setAutoStartup(true);
|
||||
//
|
||||
// return factory;
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,247 @@
|
||||
package com.ruoyi.quartz.controller;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
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 com.ruoyi.quartz.util.ScheduleUtils;
|
||||
|
||||
/**
|
||||
* 调度任务信息操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/monitor/job")
|
||||
public class SysJobController extends BaseController
|
||||
{
|
||||
private String prefix = "monitor/job";
|
||||
|
||||
@Autowired
|
||||
private ISysJobService jobService;
|
||||
|
||||
//@RequiresPermissions("monitor:job:view")
|
||||
@GetMapping()
|
||||
public String job()
|
||||
{
|
||||
return prefix + "/job";
|
||||
}
|
||||
|
||||
//@RequiresPermissions("monitor:job:list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(SysJob job)
|
||||
{
|
||||
startPage();
|
||||
List<SysJob> list = jobService.selectJobList(job);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "定时任务", businessType = BusinessType.EXPORT)
|
||||
//@RequiresPermissions("monitor:job:export")
|
||||
@PostMapping("/export")
|
||||
@ResponseBody
|
||||
public AjaxResult export(SysJob job)
|
||||
{
|
||||
List<SysJob> list = jobService.selectJobList(job);
|
||||
ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class);
|
||||
return util.exportExcel(list, "定时任务");
|
||||
}
|
||||
|
||||
@Log(title = "定时任务", businessType = BusinessType.DELETE)
|
||||
//@RequiresPermissions("monitor:job:remove")
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids) throws SchedulerException
|
||||
{
|
||||
jobService.deleteJobByIds(ids);
|
||||
return success();
|
||||
}
|
||||
|
||||
//@RequiresPermissions("monitor:job:detail")
|
||||
@GetMapping("/detail/{jobId}")
|
||||
public String detail(@PathVariable("jobId") Long jobId, ModelMap mmap)
|
||||
{
|
||||
mmap.put("name", "job");
|
||||
mmap.put("job", jobService.selectJobById(jobId));
|
||||
return prefix + "/detail";
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务调度状态修改
|
||||
*/
|
||||
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
||||
//@RequiresPermissions("monitor:job:changeStatus")
|
||||
@PostMapping("/changeStatus")
|
||||
@ResponseBody
|
||||
public AjaxResult changeStatus(SysJob job) throws SchedulerException
|
||||
{
|
||||
SysJob newJob = jobService.selectJobById(job.getJobId());
|
||||
newJob.setStatus(job.getStatus());
|
||||
return toAjax(jobService.changeStatus(newJob));
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务调度立即执行一次
|
||||
*/
|
||||
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
||||
//@RequiresPermissions("monitor:job:changeStatus")
|
||||
@PostMapping("/run")
|
||||
@ResponseBody
|
||||
public AjaxResult run(SysJob job) throws SchedulerException
|
||||
{
|
||||
boolean result = jobService.run(job);
|
||||
return result ? success() : error("任务不存在或已过期!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增调度
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public String add()
|
||||
{
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存调度
|
||||
*/
|
||||
@Log(title = "定时任务", businessType = BusinessType.INSERT)
|
||||
//@RequiresPermissions("monitor:job:add")
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(@Validated 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.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS }))
|
||||
{
|
||||
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap(s)'调用");
|
||||
}
|
||||
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
||||
{
|
||||
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)'调用");
|
||||
}
|
||||
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR))
|
||||
{
|
||||
return error("新增任务'" + job.getJobName() + "'失败,目标字符串存在违规");
|
||||
}
|
||||
else if (!ScheduleUtils.whiteList(job.getInvokeTarget()))
|
||||
{
|
||||
return error("新增任务'" + job.getJobName() + "'失败,目标字符串不在白名单内");
|
||||
}
|
||||
job.setCreateBy(getLoginName());
|
||||
return toAjax(jobService.insertJob(job));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改调度
|
||||
*/
|
||||
//@RequiresPermissions("monitor:job:edit")
|
||||
@GetMapping("/edit/{jobId}")
|
||||
public String edit(@PathVariable("jobId") Long jobId, ModelMap mmap)
|
||||
{
|
||||
mmap.put("job", jobService.selectJobById(jobId));
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存调度
|
||||
*/
|
||||
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
||||
//@RequiresPermissions("monitor:job:edit")
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(@Validated 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.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.LOOKUP_LDAP, Constants.LOOKUP_LDAPS }))
|
||||
{
|
||||
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'ldap'调用");
|
||||
}
|
||||
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), new String[] { Constants.HTTP, Constants.HTTPS }))
|
||||
{
|
||||
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不允许'http(s)'调用");
|
||||
}
|
||||
else if (StringUtils.containsAnyIgnoreCase(job.getInvokeTarget(), Constants.JOB_ERROR_STR))
|
||||
{
|
||||
return error("修改任务'" + job.getJobName() + "'失败,目标字符串存在违规");
|
||||
}
|
||||
else if (!ScheduleUtils.whiteList(job.getInvokeTarget()))
|
||||
{
|
||||
return error("修改任务'" + job.getJobName() + "'失败,目标字符串不在白名单内");
|
||||
}
|
||||
return toAjax(jobService.updateJob(job));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验cron表达式是否有效
|
||||
*/
|
||||
@PostMapping("/checkCronExpressionIsValid")
|
||||
@ResponseBody
|
||||
public boolean checkCronExpressionIsValid(SysJob job)
|
||||
{
|
||||
return jobService.checkCronExpressionIsValid(job.getCronExpression());
|
||||
}
|
||||
|
||||
/**
|
||||
* Cron表达式在线生成
|
||||
*/
|
||||
@GetMapping("/cron")
|
||||
public String cron()
|
||||
{
|
||||
return prefix + "/cron";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询cron表达式近5次的执行时间
|
||||
*/
|
||||
@GetMapping("/queryCronExpression")
|
||||
@ResponseBody
|
||||
public AjaxResult queryCronExpression(@RequestParam(value = "cronExpression", required = false) String cronExpression)
|
||||
{
|
||||
if (jobService.checkCronExpressionIsValid(cronExpression))
|
||||
{
|
||||
List<String> dateList = CronUtils.getRecentTriggerTime(cronExpression);
|
||||
return success(dateList);
|
||||
}
|
||||
else
|
||||
{
|
||||
return error("表达式无效");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.ruoyi.quartz.controller;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
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.StringUtils;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.quartz.domain.SysJob;
|
||||
import com.ruoyi.quartz.domain.SysJobLog;
|
||||
import com.ruoyi.quartz.service.ISysJobLogService;
|
||||
import com.ruoyi.quartz.service.ISysJobService;
|
||||
|
||||
/**
|
||||
* 调度日志操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/monitor/jobLog")
|
||||
public class SysJobLogController extends BaseController
|
||||
{
|
||||
private String prefix = "monitor/job";
|
||||
|
||||
@Autowired
|
||||
private ISysJobService jobService;
|
||||
|
||||
@Autowired
|
||||
private ISysJobLogService jobLogService;
|
||||
|
||||
//@RequiresPermissions("monitor:job:view")
|
||||
@GetMapping()
|
||||
public String jobLog(@RequestParam(value = "jobId", required = false) Long jobId, ModelMap mmap)
|
||||
{
|
||||
if (StringUtils.isNotNull(jobId))
|
||||
{
|
||||
SysJob job = jobService.selectJobById(jobId);
|
||||
mmap.put("job", job);
|
||||
}
|
||||
return prefix + "/jobLog";
|
||||
}
|
||||
|
||||
//@RequiresPermissions("monitor:job:list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(SysJobLog jobLog)
|
||||
{
|
||||
startPage();
|
||||
List<SysJobLog> list = jobLogService.selectJobLogList(jobLog);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@Log(title = "调度日志", businessType = BusinessType.EXPORT)
|
||||
//@RequiresPermissions("monitor:job:export")
|
||||
@PostMapping("/export")
|
||||
@ResponseBody
|
||||
public AjaxResult export(SysJobLog jobLog)
|
||||
{
|
||||
List<SysJobLog> list = jobLogService.selectJobLogList(jobLog);
|
||||
ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
|
||||
return util.exportExcel(list, "调度日志");
|
||||
}
|
||||
|
||||
@Log(title = "调度日志", businessType = BusinessType.DELETE)
|
||||
//@RequiresPermissions("monitor:job:remove")
|
||||
@PostMapping("/remove")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
return toAjax(jobLogService.deleteJobLogByIds(ids));
|
||||
}
|
||||
|
||||
//@RequiresPermissions("monitor:job:detail")
|
||||
@GetMapping("/detail/{jobLogId}")
|
||||
public String detail(@PathVariable("jobLogId") Long jobLogId, ModelMap mmap)
|
||||
{
|
||||
mmap.put("name", "jobLog");
|
||||
mmap.put("jobLog", jobLogService.selectJobLogById(jobLogId));
|
||||
return prefix + "/detail";
|
||||
}
|
||||
|
||||
@Log(title = "调度日志", businessType = BusinessType.CLEAN)
|
||||
//@RequiresPermissions("monitor:job:remove")
|
||||
@PostMapping("/clean")
|
||||
@ResponseBody
|
||||
public AjaxResult clean()
|
||||
{
|
||||
jobLogService.cleanJobLog();
|
||||
return success();
|
||||
}
|
||||
}
|
||||
154
ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/PlanNow.java
Normal file
154
ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/PlanNow.java
Normal file
@@ -0,0 +1,154 @@
|
||||
package com.ruoyi.quartz.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 上报计划对象 plan_now
|
||||
*
|
||||
* @author wld
|
||||
* @date 2025-06-10
|
||||
*/
|
||||
public class PlanNow
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 订单号 */
|
||||
@Excel(name = "订单号")
|
||||
private String orderId;
|
||||
private int orderNo;
|
||||
private String message;
|
||||
|
||||
/** 计划类型 */
|
||||
@Excel(name = "计划类型")
|
||||
private String planType;
|
||||
|
||||
/** 牌号 */
|
||||
@Excel(name = "牌号")
|
||||
private String materialCode;
|
||||
|
||||
/** 物料编码 */
|
||||
@Excel(name = "物料编码")
|
||||
private String erpCode;
|
||||
|
||||
/** 批次 */
|
||||
@Excel(name = "批次")
|
||||
private String productBatch;
|
||||
|
||||
/** 数量 */
|
||||
@Excel(name = "数量")
|
||||
private String planQuantity;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态")
|
||||
private Long status;
|
||||
|
||||
/** 出入类型 */
|
||||
@Excel(name = "出入类型")
|
||||
private String operateType;
|
||||
|
||||
public void setOrderId(String orderId)
|
||||
{
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public String getOrderId()
|
||||
{
|
||||
return orderId;
|
||||
}
|
||||
public void setPlanType(String planType)
|
||||
{
|
||||
this.planType = planType;
|
||||
}
|
||||
|
||||
public String getPlanType()
|
||||
{
|
||||
return planType;
|
||||
}
|
||||
public void setMaterialCode(String materialCode)
|
||||
{
|
||||
this.materialCode = materialCode;
|
||||
}
|
||||
|
||||
public String getMaterialCode()
|
||||
{
|
||||
return materialCode;
|
||||
}
|
||||
public void setErpCode(String erpCode)
|
||||
{
|
||||
this.erpCode = erpCode;
|
||||
}
|
||||
|
||||
public String getErpCode()
|
||||
{
|
||||
return erpCode;
|
||||
}
|
||||
public void setProductBatch(String productBatch)
|
||||
{
|
||||
this.productBatch = productBatch;
|
||||
}
|
||||
|
||||
public String getProductBatch()
|
||||
{
|
||||
return productBatch;
|
||||
}
|
||||
public void setPlanQuantity(String planQuantity)
|
||||
{
|
||||
this.planQuantity = planQuantity;
|
||||
}
|
||||
|
||||
public String getPlanQuantity()
|
||||
{
|
||||
return planQuantity;
|
||||
}
|
||||
public void setStatus(Long status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Long getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
public void setOperateType(String operateType)
|
||||
{
|
||||
this.operateType = operateType;
|
||||
}
|
||||
|
||||
public String getOperateType()
|
||||
{
|
||||
return operateType;
|
||||
}
|
||||
|
||||
public int getOrderNo() {
|
||||
return orderNo;
|
||||
}
|
||||
|
||||
public void setOrderNo(int orderNo) {
|
||||
this.orderNo = orderNo;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("orderId", getOrderId())
|
||||
.append("planType", getPlanType())
|
||||
.append("materialCode", getMaterialCode())
|
||||
.append("erpCode", getErpCode())
|
||||
.append("productBatch", getProductBatch())
|
||||
.append("planQuantity", getPlanQuantity())
|
||||
.append("status", getStatus())
|
||||
.append("operateType", getOperateType())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.quartz.domain;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ResponceObject {
|
||||
|
||||
|
||||
private String orderID;
|
||||
private List<PlanNow> orderList;
|
||||
|
||||
public String getOrderID() {
|
||||
return orderID;
|
||||
}
|
||||
|
||||
public void setOrderID(String orderID) {
|
||||
this.orderID = orderID;
|
||||
}
|
||||
|
||||
public List<PlanNow> getOrderList() {
|
||||
return orderList;
|
||||
}
|
||||
|
||||
public void setOrderList(List<PlanNow> orderList) {
|
||||
this.orderList = orderList;
|
||||
}
|
||||
}
|
||||
169
ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java
Normal file
169
ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java
Normal file
@@ -0,0 +1,169 @@
|
||||
package com.ruoyi.quartz.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import javax.validation.constraints.*;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.annotation.Excel.ColumnType;
|
||||
import com.ruoyi.common.constant.ScheduleConstants;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.quartz.util.CronUtils;
|
||||
|
||||
/**
|
||||
* 定时任务调度表 sys_job
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SysJob extends BaseEntity implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 任务ID */
|
||||
@Excel(name = "任务序号", cellType = ColumnType.NUMERIC)
|
||||
private Long jobId;
|
||||
|
||||
/** 任务名称 */
|
||||
@Excel(name = "任务名称")
|
||||
private String jobName;
|
||||
|
||||
/** 任务组名 */
|
||||
@Excel(name = "任务组名")
|
||||
private String jobGroup;
|
||||
|
||||
/** 调用目标字符串 */
|
||||
@Excel(name = "调用目标字符串")
|
||||
private String invokeTarget;
|
||||
|
||||
/** cron执行表达式 */
|
||||
@Excel(name = "执行表达式 ")
|
||||
private String cronExpression;
|
||||
|
||||
/** cron计划策略 */
|
||||
@Excel(name = "计划策略 ", readConverterExp = "0=默认,1=立即触发执行,2=触发一次执行,3=不触发立即执行")
|
||||
private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT;
|
||||
|
||||
/** 是否并发执行(0允许 1禁止) */
|
||||
@Excel(name = "并发执行", readConverterExp = "0=允许,1=禁止")
|
||||
private String concurrent;
|
||||
|
||||
/** 任务状态(0正常 1暂停) */
|
||||
@Excel(name = "任务状态", readConverterExp = "0=正常,1=暂停")
|
||||
private String status;
|
||||
|
||||
public Long getJobId()
|
||||
{
|
||||
return jobId;
|
||||
}
|
||||
|
||||
public void setJobId(Long jobId)
|
||||
{
|
||||
this.jobId = jobId;
|
||||
}
|
||||
|
||||
@NotBlank(message = "任务名称不能为空")
|
||||
@Size(min = 0, max = 64, message = "任务名称不能超过64个字符")
|
||||
public String getJobName()
|
||||
{
|
||||
return jobName;
|
||||
}
|
||||
|
||||
public void setJobName(String jobName)
|
||||
{
|
||||
this.jobName = jobName;
|
||||
}
|
||||
|
||||
public String getJobGroup()
|
||||
{
|
||||
return jobGroup;
|
||||
}
|
||||
|
||||
public void setJobGroup(String jobGroup)
|
||||
{
|
||||
this.jobGroup = jobGroup;
|
||||
}
|
||||
|
||||
@NotBlank(message = "调用目标字符串不能为空")
|
||||
@Size(min = 0, max = 1000, message = "调用目标字符串长度不能超过500个字符")
|
||||
public String getInvokeTarget()
|
||||
{
|
||||
return invokeTarget;
|
||||
}
|
||||
|
||||
public void setInvokeTarget(String invokeTarget)
|
||||
{
|
||||
this.invokeTarget = invokeTarget;
|
||||
}
|
||||
|
||||
@NotBlank(message = "Cron执行表达式不能为空")
|
||||
@Size(min = 0, max = 255, message = "Cron执行表达式不能超过255个字符")
|
||||
public String getCronExpression()
|
||||
{
|
||||
return cronExpression;
|
||||
}
|
||||
|
||||
public void setCronExpression(String cronExpression)
|
||||
{
|
||||
this.cronExpression = cronExpression;
|
||||
}
|
||||
|
||||
public Date getNextValidTime()
|
||||
{
|
||||
if (StringUtils.isNotEmpty(cronExpression))
|
||||
{
|
||||
return CronUtils.getNextExecution(cronExpression);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMisfirePolicy()
|
||||
{
|
||||
return misfirePolicy;
|
||||
}
|
||||
|
||||
public void setMisfirePolicy(String misfirePolicy)
|
||||
{
|
||||
this.misfirePolicy = misfirePolicy;
|
||||
}
|
||||
|
||||
public String getConcurrent()
|
||||
{
|
||||
return concurrent;
|
||||
}
|
||||
|
||||
public void setConcurrent(String concurrent)
|
||||
{
|
||||
this.concurrent = concurrent;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("jobId", getJobId())
|
||||
.append("jobName", getJobName())
|
||||
.append("jobGroup", getJobGroup())
|
||||
.append("cronExpression", getCronExpression())
|
||||
.append("nextValidTime", getNextValidTime())
|
||||
.append("misfirePolicy", getMisfirePolicy())
|
||||
.append("concurrent", getConcurrent())
|
||||
.append("status", getStatus())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
package com.ruoyi.quartz.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 定时任务调度日志表 sys_job_log
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class SysJobLog extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ID */
|
||||
@Excel(name = "日志序号")
|
||||
private Long jobLogId;
|
||||
|
||||
/** 任务名称 */
|
||||
@Excel(name = "任务名称")
|
||||
private String jobName;
|
||||
|
||||
/** 任务组名 */
|
||||
@Excel(name = "任务组名")
|
||||
private String jobGroup;
|
||||
|
||||
/** 调用目标字符串 */
|
||||
@Excel(name = "调用目标字符串")
|
||||
private String invokeTarget;
|
||||
|
||||
/** 日志信息 */
|
||||
@Excel(name = "日志信息")
|
||||
private String jobMessage;
|
||||
|
||||
/** 执行状态(0正常 1失败) */
|
||||
@Excel(name = "执行状态", readConverterExp = "0=正常,1=失败")
|
||||
private String status;
|
||||
|
||||
/** 异常信息 */
|
||||
@Excel(name = "异常信息")
|
||||
private String exceptionInfo;
|
||||
|
||||
/** 开始时间 */
|
||||
private Date startTime;
|
||||
|
||||
/** 结束时间 */
|
||||
private Date endTime;
|
||||
|
||||
public Long getJobLogId()
|
||||
{
|
||||
return jobLogId;
|
||||
}
|
||||
|
||||
public void setJobLogId(Long jobLogId)
|
||||
{
|
||||
this.jobLogId = jobLogId;
|
||||
}
|
||||
|
||||
public String getJobName()
|
||||
{
|
||||
return jobName;
|
||||
}
|
||||
|
||||
public void setJobName(String jobName)
|
||||
{
|
||||
this.jobName = jobName;
|
||||
}
|
||||
|
||||
public String getJobGroup()
|
||||
{
|
||||
return jobGroup;
|
||||
}
|
||||
|
||||
public void setJobGroup(String jobGroup)
|
||||
{
|
||||
this.jobGroup = jobGroup;
|
||||
}
|
||||
|
||||
public String getInvokeTarget()
|
||||
{
|
||||
return invokeTarget;
|
||||
}
|
||||
|
||||
public void setInvokeTarget(String invokeTarget)
|
||||
{
|
||||
this.invokeTarget = invokeTarget;
|
||||
}
|
||||
|
||||
public String getJobMessage()
|
||||
{
|
||||
return jobMessage;
|
||||
}
|
||||
|
||||
public void setJobMessage(String jobMessage)
|
||||
{
|
||||
this.jobMessage = jobMessage;
|
||||
}
|
||||
|
||||
public String getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status)
|
||||
{
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getExceptionInfo()
|
||||
{
|
||||
return exceptionInfo;
|
||||
}
|
||||
|
||||
public void setExceptionInfo(String exceptionInfo)
|
||||
{
|
||||
this.exceptionInfo = exceptionInfo;
|
||||
}
|
||||
|
||||
public Date getStartTime()
|
||||
{
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Date startTime)
|
||||
{
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Date getEndTime()
|
||||
{
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Date endTime)
|
||||
{
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("jobLogId", getJobLogId())
|
||||
.append("jobName", getJobName())
|
||||
.append("jobGroup", getJobGroup())
|
||||
.append("jobMessage", getJobMessage())
|
||||
.append("status", getStatus())
|
||||
.append("exceptionInfo", getExceptionInfo())
|
||||
.append("startTime", getStartTime())
|
||||
.append("endTime", getEndTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.ruoyi.quartz.mapper;
|
||||
|
||||
|
||||
|
||||
import com.ruoyi.quartz.domain.PlanNow;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 上报计划Mapper接口
|
||||
*
|
||||
* @author wld
|
||||
* @date 2025-06-10
|
||||
*/
|
||||
public interface PlanNowMapper
|
||||
{
|
||||
/**
|
||||
* 查询上报计划
|
||||
*
|
||||
* @param orderId 上报计划主键
|
||||
* @return 上报计划
|
||||
*/
|
||||
public PlanNow selectPlanNowByOrderId(String orderId);
|
||||
|
||||
/**
|
||||
* 查询上报计划列表
|
||||
*
|
||||
* @param planNow 上报计划
|
||||
* @return 上报计划集合
|
||||
*/
|
||||
public List<PlanNow> selectPlanNowList(PlanNow planNow);
|
||||
|
||||
/**
|
||||
* 新增上报计划
|
||||
*
|
||||
* @param planNow 上报计划
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPlanNow(PlanNow planNow);
|
||||
|
||||
/**
|
||||
* 修改上报计划
|
||||
*
|
||||
* @param planNow 上报计划
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePlanNow(PlanNow planNow);
|
||||
|
||||
/**
|
||||
* 删除上报计划
|
||||
*
|
||||
* @param orderId 上报计划主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePlanNowByOrderId(String orderId);
|
||||
|
||||
/**
|
||||
* 批量删除上报计划
|
||||
*
|
||||
* @param orderIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePlanNowByOrderIds(String[] orderIds);
|
||||
|
||||
PlanNow selectPlanNow(long status);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ruoyi.quartz.mapper;
|
||||
|
||||
import com.ruoyi.quartz.domain.SysJobLog;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 调度任务日志信息 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysJobLogMapper
|
||||
{
|
||||
/**
|
||||
* 获取quartz调度器日志的计划任务
|
||||
*
|
||||
* @param jobLog 调度日志信息
|
||||
* @return 调度任务日志集合
|
||||
*/
|
||||
public List<SysJobLog> selectJobLogList(SysJobLog jobLog);
|
||||
|
||||
/**
|
||||
* 查询所有调度任务日志
|
||||
*
|
||||
* @return 调度任务日志列表
|
||||
*/
|
||||
public List<SysJobLog> selectJobLogAll();
|
||||
|
||||
/**
|
||||
* 通过调度任务日志ID查询调度信息
|
||||
*
|
||||
* @param jobLogId 调度任务日志ID
|
||||
* @return 调度任务日志对象信息
|
||||
*/
|
||||
public SysJobLog selectJobLogById(Long jobLogId);
|
||||
|
||||
/**
|
||||
* 新增任务日志
|
||||
*
|
||||
* @param jobLog 调度日志信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertJobLog(SysJobLog jobLog);
|
||||
|
||||
/**
|
||||
* 批量删除调度日志信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteJobLogByIds(String[] ids);
|
||||
|
||||
/**
|
||||
* 删除任务日志
|
||||
*
|
||||
* @param jobId 调度日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteJobLogById(Long jobId);
|
||||
|
||||
/**
|
||||
* 清空任务日志
|
||||
*/
|
||||
public void cleanJobLog();
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.ruoyi.quartz.mapper;
|
||||
|
||||
import com.ruoyi.quartz.domain.SysJob;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 调度任务信息 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface SysJobMapper
|
||||
{
|
||||
/**
|
||||
* 查询调度任务日志集合
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 操作日志集合
|
||||
*/
|
||||
public List<SysJob> selectJobList(SysJob job);
|
||||
|
||||
/**
|
||||
* 查询所有调度任务
|
||||
*
|
||||
* @return 调度任务列表
|
||||
*/
|
||||
public List<SysJob> selectJobAll();
|
||||
|
||||
/**
|
||||
* 通过调度ID查询调度任务信息
|
||||
*
|
||||
* @param jobId 调度ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
public SysJob selectJobById(Long jobId);
|
||||
|
||||
/**
|
||||
* 通过调度ID删除调度任务信息
|
||||
*
|
||||
* @param jobId 调度ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteJobById(Long jobId);
|
||||
|
||||
/**
|
||||
* 批量删除调度任务信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteJobByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 修改调度任务信息
|
||||
*
|
||||
* @param job 调度任务信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateJob(SysJob job);
|
||||
|
||||
/**
|
||||
* 新增调度任务信息
|
||||
*
|
||||
* @param job 调度任务信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertJob(SysJob job);
|
||||
void prepareOut(HashMap<String,Object> map);
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.ruoyi.quartz.plannow.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.PlanNow;
|
||||
import com.ruoyi.quartz.plannow.service.IPlanNowService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 上报计划Controller
|
||||
*
|
||||
* @author wld
|
||||
* @date 2025-06-10
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/plannow/plannow")
|
||||
public class PlanNowController extends BaseController
|
||||
{
|
||||
private String prefix = "system/nowplan";
|
||||
|
||||
@Autowired
|
||||
private IPlanNowService planNowService;
|
||||
|
||||
// @RequiresPermissions("plannow:plannow:view")
|
||||
@GetMapping()
|
||||
public String plannow()
|
||||
{
|
||||
return prefix + "/nowplan";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询上报计划列表
|
||||
*/
|
||||
// @RequiresPermissions("plannow:plannow:list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(PlanNow planNow)
|
||||
{
|
||||
startPage();
|
||||
|
||||
List<PlanNow> list = planNowService.selectPlanNowList(planNow);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出上报计划列表
|
||||
*/
|
||||
// @RequiresPermissions("plannow:plannow:export")
|
||||
@Log(title = "上报计划", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
@ResponseBody
|
||||
public AjaxResult export(PlanNow planNow)
|
||||
{
|
||||
List<PlanNow> list = planNowService.selectPlanNowList(planNow);
|
||||
ExcelUtil<PlanNow> util = new ExcelUtil<PlanNow>(PlanNow.class);
|
||||
return util.exportExcel(list, "上报计划数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增上报计划
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public String add()
|
||||
{
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存上报计划
|
||||
*/
|
||||
// @RequiresPermissions("plannow:plannow:add")
|
||||
@Log(title = "上报计划", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(PlanNow planNow)
|
||||
{
|
||||
return toAjax(planNowService.insertPlanNow(planNow));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改上报计划
|
||||
*/
|
||||
// @RequiresPermissions("plannow:plannow:edit")
|
||||
@GetMapping("/edit/{orderId}")
|
||||
public String edit(@PathVariable("orderId") String orderId, ModelMap mmap)
|
||||
{
|
||||
PlanNow planNow = planNowService.selectPlanNowByOrderId(orderId);
|
||||
mmap.put("planNow", planNow);
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存上报计划
|
||||
*/
|
||||
// @RequiresPermissions("plannow:plannow:edit")
|
||||
@Log(title = "上报计划", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(PlanNow planNow)
|
||||
{
|
||||
return toAjax(planNowService.updatePlanNow(planNow));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除上报计划
|
||||
*/
|
||||
// @RequiresPermissions("plannow:plannow:remove")
|
||||
@Log(title = "上报计划", businessType = BusinessType.DELETE)
|
||||
@PostMapping( "/remove")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
return toAjax(planNowService.deletePlanNowByOrderIds(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.ruoyi.quartz.plannow.service;
|
||||
|
||||
|
||||
|
||||
import com.ruoyi.quartz.domain.PlanNow;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 上报计划Service接口
|
||||
*
|
||||
* @author wld
|
||||
* @date 2025-06-10
|
||||
*/
|
||||
public interface IPlanNowService
|
||||
{
|
||||
/**
|
||||
* 查询上报计划
|
||||
*
|
||||
* @param orderId 上报计划主键
|
||||
* @return 上报计划
|
||||
*/
|
||||
public PlanNow selectPlanNowByOrderId(String orderId);
|
||||
|
||||
/**
|
||||
* 查询上报计划列表
|
||||
*
|
||||
* @param planNow 上报计划
|
||||
* @return 上报计划集合
|
||||
*/
|
||||
public List<PlanNow> selectPlanNowList(PlanNow planNow);
|
||||
public PlanNow selectPlanNow(long status);
|
||||
|
||||
/**
|
||||
* 新增上报计划
|
||||
*
|
||||
* @param planNow 上报计划
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPlanNow(PlanNow planNow);
|
||||
|
||||
/**
|
||||
* 修改上报计划
|
||||
*
|
||||
* @param planNow 上报计划
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePlanNow(PlanNow planNow);
|
||||
|
||||
/**
|
||||
* 批量删除上报计划
|
||||
*
|
||||
* @param orderIds 需要删除的上报计划主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePlanNowByOrderIds(String orderIds);
|
||||
|
||||
/**
|
||||
* 删除上报计划信息
|
||||
*
|
||||
* @param orderId 上报计划主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePlanNowByOrderId(String orderId);
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.ruoyi.quartz.plannow.service.impl;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.quartz.domain.PlanNow;
|
||||
import com.ruoyi.quartz.mapper.PlanNowMapper;
|
||||
import com.ruoyi.quartz.plannow.service.IPlanNowService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 上报计划Service业务层处理
|
||||
*
|
||||
* @author wld
|
||||
* @date 2025-06-10
|
||||
*/
|
||||
@Service
|
||||
public class PlanNowServiceImpl implements IPlanNowService
|
||||
{
|
||||
@Autowired
|
||||
private PlanNowMapper planNowMapper;
|
||||
|
||||
/**
|
||||
* 查询上报计划
|
||||
*
|
||||
* @param orderId 上报计划主键
|
||||
* @return 上报计划
|
||||
*/
|
||||
@Override
|
||||
public PlanNow selectPlanNowByOrderId(String orderId)
|
||||
{
|
||||
return planNowMapper.selectPlanNowByOrderId(orderId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询上报计划列表
|
||||
*
|
||||
* @param planNow 上报计划
|
||||
* @return 上报计划
|
||||
*/
|
||||
@Override
|
||||
public List<PlanNow> selectPlanNowList(PlanNow planNow)
|
||||
{
|
||||
return planNowMapper.selectPlanNowList(planNow);
|
||||
}
|
||||
@Override
|
||||
public PlanNow selectPlanNow(long status)
|
||||
{
|
||||
return planNowMapper.selectPlanNow(status);
|
||||
}
|
||||
/**
|
||||
* 新增上报计划
|
||||
*
|
||||
* @param planNow 上报计划
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertPlanNow(PlanNow planNow)
|
||||
{
|
||||
return planNowMapper.insertPlanNow(planNow);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改上报计划
|
||||
*
|
||||
* @param planNow 上报计划
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePlanNow(PlanNow planNow)
|
||||
{
|
||||
return planNowMapper.updatePlanNow(planNow);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除上报计划
|
||||
*
|
||||
* @param orderIds 需要删除的上报计划主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePlanNowByOrderIds(String orderIds)
|
||||
{
|
||||
return planNowMapper.deletePlanNowByOrderIds(Convert.toStrArray(orderIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除上报计划信息
|
||||
*
|
||||
* @param orderId 上报计划主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePlanNowByOrderId(String orderId)
|
||||
{
|
||||
return planNowMapper.deletePlanNowByOrderId(orderId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.ruoyi.quartz.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.quartz.domain.SysJobLog;
|
||||
|
||||
/**
|
||||
* 定时任务调度日志信息信息 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysJobLogService
|
||||
{
|
||||
/**
|
||||
* 获取quartz调度器日志的计划任务
|
||||
*
|
||||
* @param jobLog 调度日志信息
|
||||
* @return 调度任务日志集合
|
||||
*/
|
||||
public List<SysJobLog> selectJobLogList(SysJobLog jobLog);
|
||||
|
||||
/**
|
||||
* 通过调度任务日志ID查询调度信息
|
||||
*
|
||||
* @param jobLogId 调度任务日志ID
|
||||
* @return 调度任务日志对象信息
|
||||
*/
|
||||
public SysJobLog selectJobLogById(Long jobLogId);
|
||||
|
||||
/**
|
||||
* 新增任务日志
|
||||
*
|
||||
* @param jobLog 调度日志信息
|
||||
*/
|
||||
public void addJobLog(SysJobLog jobLog);
|
||||
|
||||
/**
|
||||
* 批量删除调度日志信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteJobLogByIds(String ids);
|
||||
|
||||
/**
|
||||
* 删除任务日志
|
||||
*
|
||||
* @param jobId 调度日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteJobLogById(Long jobId);
|
||||
|
||||
/**
|
||||
* 清空任务日志
|
||||
*/
|
||||
public void cleanJobLog();
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.ruoyi.quartz.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import org.quartz.SchedulerException;
|
||||
import com.ruoyi.common.exception.job.TaskException;
|
||||
import com.ruoyi.quartz.domain.SysJob;
|
||||
|
||||
/**
|
||||
* 定时任务调度信息信息 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ISysJobService
|
||||
{
|
||||
/**
|
||||
* 获取quartz调度器的计划任务
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 调度任务集合
|
||||
*/
|
||||
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 ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public void deleteJobByIds(String ids) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 任务调度状态修改
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 结果
|
||||
*/
|
||||
public int changeStatus(SysJob job) throws SchedulerException;
|
||||
|
||||
/**
|
||||
* 立即运行任务
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean 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);
|
||||
|
||||
AjaxResult sendplanFinish();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.ruoyi.quartz.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.quartz.domain.SysJobLog;
|
||||
import com.ruoyi.quartz.mapper.SysJobLogMapper;
|
||||
import com.ruoyi.quartz.service.ISysJobLogService;
|
||||
|
||||
/**
|
||||
* 定时任务调度日志信息 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysJobLogServiceImpl implements ISysJobLogService
|
||||
{
|
||||
@Autowired
|
||||
private SysJobLogMapper jobLogMapper;
|
||||
|
||||
/**
|
||||
* 获取quartz调度器日志的计划任务
|
||||
*
|
||||
* @param jobLog 调度日志信息
|
||||
* @return 调度任务日志集合
|
||||
*/
|
||||
@Override
|
||||
public List<SysJobLog> selectJobLogList(SysJobLog jobLog)
|
||||
{
|
||||
return jobLogMapper.selectJobLogList(jobLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过调度任务日志ID查询调度信息
|
||||
*
|
||||
* @param jobLogId 调度任务日志ID
|
||||
* @return 调度任务日志对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysJobLog selectJobLogById(Long jobLogId)
|
||||
{
|
||||
return jobLogMapper.selectJobLogById(jobLogId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增任务日志
|
||||
*
|
||||
* @param jobLog 调度日志信息
|
||||
*/
|
||||
@Override
|
||||
public void addJobLog(SysJobLog jobLog)
|
||||
{
|
||||
jobLogMapper.insertJobLog(jobLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除调度日志信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteJobLogByIds(String ids)
|
||||
{
|
||||
return jobLogMapper.deleteJobLogByIds(Convert.toStrArray(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务日志
|
||||
*
|
||||
* @param jobId 调度日志ID
|
||||
*/
|
||||
@Override
|
||||
public int deleteJobLogById(Long jobId)
|
||||
{
|
||||
return jobLogMapper.deleteJobLogById(jobId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空任务日志
|
||||
*/
|
||||
@Override
|
||||
public void cleanJobLog()
|
||||
{
|
||||
jobLogMapper.cleanJobLog();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,317 @@
|
||||
package com.ruoyi.quartz.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.quartz.domain.PlanNow;
|
||||
import com.ruoyi.quartz.domain.ResponceObject;
|
||||
import com.ruoyi.quartz.plannow.service.IPlanNowService;
|
||||
import com.ruoyi.quartz.sysurl.domain.SysUrl;
|
||||
import com.ruoyi.quartz.sysurl.mapper.SysUrlMapper;
|
||||
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 com.ruoyi.common.constant.ScheduleConstants;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.exception.job.TaskException;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 定时任务调度信息 服务层
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysJobServiceImpl implements ISysJobService
|
||||
{
|
||||
@Autowired
|
||||
private Scheduler scheduler;
|
||||
|
||||
@Autowired
|
||||
private SysUrlMapper sysUrlMapper;
|
||||
@Autowired
|
||||
private SysJobMapper jobMapper;
|
||||
|
||||
@Autowired
|
||||
private IPlanNowService planNowService;
|
||||
|
||||
/**
|
||||
* 项目启动时,初始化定时器
|
||||
* 主要是防止手动修改数据库导致未同步到定时任务处理(注:不能手动修改数据库ID和任务组名,否则会导致脏数据)
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init() throws SchedulerException, TaskException
|
||||
{
|
||||
scheduler.clear();
|
||||
List<SysJob> jobList = jobMapper.selectJobAll();
|
||||
for (SysJob job : jobList)
|
||||
{
|
||||
ScheduleUtils.createScheduleJob(scheduler, job);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取quartz调度器的计划任务列表
|
||||
*
|
||||
* @param job 调度信息
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<SysJob> selectJobList(SysJob job)
|
||||
{
|
||||
return jobMapper.selectJobList(job);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过调度任务ID查询调度信息
|
||||
*
|
||||
* @param jobId 调度任务ID
|
||||
* @return 调度任务对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysJob selectJobById(Long jobId)
|
||||
{
|
||||
return jobMapper.selectJobById(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 = jobMapper.updateJob(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 = jobMapper.updateJob(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 = jobMapper.deleteJobById(jobId);
|
||||
if (rows > 0)
|
||||
{
|
||||
scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup));
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除调度信息
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteJobByIds(String ids) throws SchedulerException
|
||||
{
|
||||
Long[] jobIds = Convert.toLongArray(ids);
|
||||
for (Long jobId : jobIds)
|
||||
{
|
||||
SysJob job = jobMapper.selectJobById(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 boolean run(SysJob job) throws SchedulerException
|
||||
{
|
||||
boolean result = false;
|
||||
Long jobId = job.getJobId();
|
||||
SysJob tmpObj = selectJobById(job.getJobId());
|
||||
// 参数
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
dataMap.put(ScheduleConstants.TASK_PROPERTIES, tmpObj);
|
||||
JobKey jobKey = ScheduleUtils.getJobKey(jobId, tmpObj.getJobGroup());
|
||||
if (scheduler.checkExists(jobKey))
|
||||
{
|
||||
result = true;
|
||||
scheduler.triggerJob(jobKey, dataMap);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增任务
|
||||
*
|
||||
* @param job 调度信息 调度信息
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertJob(SysJob job) throws SchedulerException, TaskException
|
||||
{
|
||||
job.setStatus(ScheduleConstants.Status.PAUSE.getValue());
|
||||
int rows = jobMapper.insertJob(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 = jobMapper.updateJob(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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult sendplanFinish() {
|
||||
PlanNow planNow = planNowService.selectPlanNow(0);
|
||||
if (planNow != null) {
|
||||
List<PlanNow> planNows = planNowService.selectPlanNowList(planNow);
|
||||
ResponceObject result = new ResponceObject();
|
||||
result.setOrderID(planNow.getOrderId());
|
||||
result.setOrderList(planNows);
|
||||
SysUrl sysUrl = sysUrlMapper.selectSysUrlByIp("1");
|
||||
String url = sysUrl.getAddress();
|
||||
try {
|
||||
String res = JSONUtil.toJsonStr(result);
|
||||
String resStr = HttpUtil.post(url, res);
|
||||
System.out.println("1");
|
||||
JSONObject json = JSONUtil.parseObj(resStr);
|
||||
System.out.println(resStr);
|
||||
String resStr1 = resStr.replaceAll(",",":").split(":")[1];
|
||||
if (Integer.parseInt(resStr1)==1) {
|
||||
planNow.setStatus(1L);
|
||||
planNow.setMessage((String) json.get("message"));
|
||||
planNowService.updatePlanNow(planNow);
|
||||
return AjaxResult.error("回传成功");
|
||||
} else {
|
||||
planNow.setMessage((String) json.get("message"));
|
||||
planNow.setOrderNo(planNow.getOrderNo() + 1);
|
||||
planNowService.updatePlanNow(planNow);
|
||||
return AjaxResult.error("回传失败");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
planNow.setMessage("MES接口连接失败");
|
||||
planNow.setOrderNo(planNow.getOrderNo() + 1);
|
||||
planNowService.updatePlanNow(planNow);
|
||||
return AjaxResult.error("回传失败");
|
||||
}
|
||||
|
||||
}
|
||||
return AjaxResult.error("回传失败");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.ruoyi.quartz.sysurl.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.sysurl.domain.SysUrl;
|
||||
import com.ruoyi.quartz.sysurl.service.ISysUrlService;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 接口地址Controller
|
||||
*
|
||||
* @author wld
|
||||
* @date 2025-01-17
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/project/url")
|
||||
public class SysUrlController extends BaseController
|
||||
{
|
||||
private String prefix = "project/url";
|
||||
|
||||
@Autowired
|
||||
private ISysUrlService sysUrlService;
|
||||
|
||||
@RequiresPermissions("project:url:view")
|
||||
@GetMapping()
|
||||
public String url()
|
||||
{
|
||||
return prefix + "/url";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询接口地址列表
|
||||
*/
|
||||
@RequiresPermissions("project:url:list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
public TableDataInfo list(SysUrl sysUrl)
|
||||
{
|
||||
startPage();
|
||||
List<SysUrl> list = sysUrlService.selectSysUrlList(sysUrl);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出接口地址列表
|
||||
*/
|
||||
@RequiresPermissions("project:url:export")
|
||||
@Log(title = "接口地址", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
@ResponseBody
|
||||
public AjaxResult export(SysUrl sysUrl)
|
||||
{
|
||||
List<SysUrl> list = sysUrlService.selectSysUrlList(sysUrl);
|
||||
ExcelUtil<SysUrl> util = new ExcelUtil<SysUrl>(SysUrl.class);
|
||||
return util.exportExcel(list, "接口地址数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增接口地址
|
||||
*/
|
||||
@GetMapping("/add")
|
||||
public String add()
|
||||
{
|
||||
return prefix + "/add";
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存接口地址
|
||||
*/
|
||||
@RequiresPermissions("project:url:add")
|
||||
@Log(title = "接口地址", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public AjaxResult addSave(SysUrl sysUrl)
|
||||
{
|
||||
return toAjax(sysUrlService.insertSysUrl(sysUrl));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改接口地址
|
||||
*/
|
||||
@RequiresPermissions("project:url:edit")
|
||||
@GetMapping("/edit/{ip}")
|
||||
public String edit(@PathVariable("ip") String ip, ModelMap mmap)
|
||||
{
|
||||
SysUrl sysUrl = sysUrlService.selectSysUrlByIp(ip);
|
||||
mmap.put("sysUrl", sysUrl);
|
||||
return prefix + "/edit";
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存接口地址
|
||||
*/
|
||||
@RequiresPermissions("project:url:edit")
|
||||
@Log(title = "接口地址", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/edit")
|
||||
@ResponseBody
|
||||
public AjaxResult editSave(SysUrl sysUrl)
|
||||
{
|
||||
return toAjax(sysUrlService.updateSysUrl(sysUrl));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除接口地址
|
||||
*/
|
||||
@RequiresPermissions("project:url:remove")
|
||||
@Log(title = "接口地址", businessType = BusinessType.DELETE)
|
||||
@PostMapping( "/remove")
|
||||
@ResponseBody
|
||||
public AjaxResult remove(String ids)
|
||||
{
|
||||
return toAjax(sysUrlService.deleteSysUrlByIps(ids));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.ruoyi.quartz.sysurl.domain;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 接口地址对象 sys_url
|
||||
*
|
||||
* @author wld
|
||||
* @date 2025-01-17
|
||||
*/
|
||||
public class SysUrl extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** ip */
|
||||
@Excel(name = "ip")
|
||||
private String ip;
|
||||
|
||||
/** 端口 */
|
||||
@Excel(name = "端口")
|
||||
private String port;
|
||||
|
||||
/** 地址 */
|
||||
@Excel(name = "地址")
|
||||
private String address;
|
||||
|
||||
/** 类型 */
|
||||
@Excel(name = "类型")
|
||||
private String type;
|
||||
|
||||
public void setIp(String ip)
|
||||
{
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getIp()
|
||||
{
|
||||
return ip;
|
||||
}
|
||||
public void setPort(String port)
|
||||
{
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getPort()
|
||||
{
|
||||
return port;
|
||||
}
|
||||
public void setAddress(String address)
|
||||
{
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getAddress()
|
||||
{
|
||||
return address;
|
||||
}
|
||||
public void setType(String type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("ip", getIp())
|
||||
.append("port", getPort())
|
||||
.append("address", getAddress())
|
||||
.append("type", getType())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.ruoyi.quartz.sysurl.mapper;
|
||||
|
||||
|
||||
|
||||
import com.ruoyi.quartz.sysurl.domain.SysUrl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 接口地址Mapper接口
|
||||
*
|
||||
* @author wld
|
||||
* @date 2025-01-17
|
||||
*/
|
||||
public interface SysUrlMapper
|
||||
{
|
||||
/**
|
||||
* 查询接口地址
|
||||
*
|
||||
* @param ip 接口地址主键
|
||||
* @return 接口地址
|
||||
*/
|
||||
public SysUrl selectSysUrlByIp(String ip);
|
||||
|
||||
/**
|
||||
* 查询接口地址列表
|
||||
*
|
||||
* @param sysUrl 接口地址
|
||||
* @return 接口地址集合
|
||||
*/
|
||||
public List<SysUrl> selectSysUrlList(SysUrl sysUrl);
|
||||
|
||||
/**
|
||||
* 新增接口地址
|
||||
*
|
||||
* @param sysUrl 接口地址
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysUrl(SysUrl sysUrl);
|
||||
|
||||
/**
|
||||
* 修改接口地址
|
||||
*
|
||||
* @param sysUrl 接口地址
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysUrl(SysUrl sysUrl);
|
||||
|
||||
/**
|
||||
* 删除接口地址
|
||||
*
|
||||
* @param ip 接口地址主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysUrlByIp(String ip);
|
||||
|
||||
/**
|
||||
* 批量删除接口地址
|
||||
*
|
||||
* @param ips 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysUrlByIps(String[] ips);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.ruoyi.quartz.sysurl.service;
|
||||
|
||||
|
||||
import com.ruoyi.quartz.sysurl.domain.SysUrl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 接口地址Service接口
|
||||
*
|
||||
* @author wld
|
||||
* @date 2025-01-17
|
||||
*/
|
||||
public interface ISysUrlService
|
||||
{
|
||||
/**
|
||||
* 查询接口地址
|
||||
*
|
||||
* @param ip 接口地址主键
|
||||
* @return 接口地址
|
||||
*/
|
||||
public SysUrl selectSysUrlByIp(String ip);
|
||||
|
||||
/**
|
||||
* 查询接口地址列表
|
||||
*
|
||||
* @param sysUrl 接口地址
|
||||
* @return 接口地址集合
|
||||
*/
|
||||
public List<SysUrl> selectSysUrlList(SysUrl sysUrl);
|
||||
|
||||
/**
|
||||
* 新增接口地址
|
||||
*
|
||||
* @param sysUrl 接口地址
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysUrl(SysUrl sysUrl);
|
||||
|
||||
/**
|
||||
* 修改接口地址
|
||||
*
|
||||
* @param sysUrl 接口地址
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysUrl(SysUrl sysUrl);
|
||||
|
||||
/**
|
||||
* 批量删除接口地址
|
||||
*
|
||||
* @param ips 需要删除的接口地址主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysUrlByIps(String ips);
|
||||
|
||||
/**
|
||||
* 删除接口地址信息
|
||||
*
|
||||
* @param ip 接口地址主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysUrlByIp(String ip);
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.ruoyi.quartz.sysurl.service.impl;
|
||||
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.quartz.sysurl.domain.SysUrl;
|
||||
import com.ruoyi.quartz.sysurl.mapper.SysUrlMapper;
|
||||
import com.ruoyi.quartz.sysurl.service.ISysUrlService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 接口地址Service业务层处理
|
||||
*
|
||||
* @author wld
|
||||
* @date 2025-01-17
|
||||
*/
|
||||
@Service
|
||||
public class SysUrlServiceImpl implements ISysUrlService
|
||||
{
|
||||
@Autowired
|
||||
private SysUrlMapper sysUrlMapper;
|
||||
|
||||
/**
|
||||
* 查询接口地址
|
||||
*
|
||||
* @param ip 接口地址主键
|
||||
* @return 接口地址
|
||||
*/
|
||||
@Override
|
||||
public SysUrl selectSysUrlByIp(String ip)
|
||||
{
|
||||
return sysUrlMapper.selectSysUrlByIp(ip);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询接口地址列表
|
||||
*
|
||||
* @param sysUrl 接口地址
|
||||
* @return 接口地址
|
||||
*/
|
||||
@Override
|
||||
public List<SysUrl> selectSysUrlList(SysUrl sysUrl)
|
||||
{
|
||||
return sysUrlMapper.selectSysUrlList(sysUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增接口地址
|
||||
*
|
||||
* @param sysUrl 接口地址
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysUrl(SysUrl sysUrl)
|
||||
{
|
||||
return sysUrlMapper.insertSysUrl(sysUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改接口地址
|
||||
*
|
||||
* @param sysUrl 接口地址
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysUrl(SysUrl sysUrl)
|
||||
{
|
||||
return sysUrlMapper.updateSysUrl(sysUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除接口地址
|
||||
*
|
||||
* @param ips 需要删除的接口地址主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysUrlByIps(String ips)
|
||||
{
|
||||
return sysUrlMapper.deleteSysUrlByIps(Convert.toStrArray(ips));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除接口地址信息
|
||||
*
|
||||
* @param ip 接口地址主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysUrlByIp(String ip)
|
||||
{
|
||||
return sysUrlMapper.deleteSysUrlByIp(ip);
|
||||
}
|
||||
}
|
||||
44
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
Normal file
44
ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package com.ruoyi.quartz.task;
|
||||
|
||||
import com.ruoyi.quartz.mapper.SysJobMapper;
|
||||
import com.ruoyi.quartz.service.ISysJobService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 定时任务调度测试
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Component("ryTask")
|
||||
public class RyTask
|
||||
{
|
||||
@Autowired
|
||||
private SysJobMapper sysJobMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysJobService sysJobService;
|
||||
|
||||
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
|
||||
{
|
||||
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
|
||||
}
|
||||
|
||||
public void ryParams(String params)
|
||||
{
|
||||
System.out.println("执行有参方法:" + params);
|
||||
}
|
||||
|
||||
public void ryNoParams()
|
||||
{
|
||||
HashMap<String,Object> map = new HashMap<>();
|
||||
sysJobMapper.prepareOut(map);
|
||||
}
|
||||
public void ryNoParams1()
|
||||
{
|
||||
sysJobService.sendplanFinish();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.ruoyi.quartz.util;
|
||||
|
||||
import java.util.Date;
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.ScheduleConstants;
|
||||
import com.ruoyi.common.utils.ExceptionUtil;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.bean.BeanUtils;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 抽象quartz调用
|
||||
*
|
||||
* @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();
|
||||
BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES));
|
||||
try
|
||||
{
|
||||
before(context, sysJob);
|
||||
if (sysJob != null)
|
||||
{
|
||||
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 sysScheduleJob 系统计划任务
|
||||
*/
|
||||
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.setEndTime(new Date());
|
||||
long runMs = sysJobLog.getEndTime().getTime() - sysJobLog.getStartTime().getTime();
|
||||
sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
|
||||
if (e != null)
|
||||
{
|
||||
sysJobLog.setStatus(Constants.FAIL);
|
||||
String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(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;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.ruoyi.quartz.util;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.quartz.CronExpression;
|
||||
import org.quartz.TriggerUtils;
|
||||
import org.quartz.impl.triggers.CronTriggerImpl;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
|
||||
/**
|
||||
* cron表达式工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*
|
||||
*/
|
||||
public class CronUtils
|
||||
{
|
||||
/**
|
||||
* 返回一个布尔值代表一个给定的Cron表达式的有效性
|
||||
*
|
||||
* @param cronExpression Cron表达式
|
||||
* @return boolean 表达式是否有效
|
||||
*/
|
||||
public static boolean isValid(String cronExpression)
|
||||
{
|
||||
return CronExpression.isValidExpression(cronExpression);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回一个字符串值,表示该消息无效Cron表达式给出有效性
|
||||
*
|
||||
* @param cronExpression Cron表达式
|
||||
* @return String 无效时返回表达式错误描述,如果有效返回null
|
||||
*/
|
||||
public static String getInvalidMessage(String cronExpression)
|
||||
{
|
||||
try
|
||||
{
|
||||
new CronExpression(cronExpression);
|
||||
return null;
|
||||
}
|
||||
catch (ParseException pe)
|
||||
{
|
||||
return pe.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回下一个执行时间根据给定的Cron表达式
|
||||
*
|
||||
* @param cronExpression Cron表达式
|
||||
* @return Date 下次Cron表达式执行时间
|
||||
*/
|
||||
public static Date getNextExecution(String cronExpression)
|
||||
{
|
||||
try
|
||||
{
|
||||
CronExpression cron = new CronExpression(cronExpression);
|
||||
return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis()));
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
throw new IllegalArgumentException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过表达式获取近10次的执行时间
|
||||
*
|
||||
* @param cron 表达式
|
||||
* @return 时间列表
|
||||
*/
|
||||
public static List<String> getRecentTriggerTime(String cron)
|
||||
{
|
||||
List<String> list = new ArrayList<String>();
|
||||
try
|
||||
{
|
||||
CronTriggerImpl cronTriggerImpl = new CronTriggerImpl();
|
||||
cronTriggerImpl.setCronExpression(cron);
|
||||
List<Date> dates = TriggerUtils.computeFireTimes(cronTriggerImpl, null, 10);
|
||||
for (Date date : dates)
|
||||
{
|
||||
list.add(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, date));
|
||||
}
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 任务执行工具
|
||||
*
|
||||
* @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().getMethod(methodName, getMethodParamsType(methodParams));
|
||||
method.invoke(bean, getMethodParamsValue(methodParams));
|
||||
}
|
||||
else
|
||||
{
|
||||
Method method = bean.getClass().getMethod(methodName);
|
||||
method.invoke(bean);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验是否为为class包名
|
||||
*
|
||||
* @param invokeTarget 名称
|
||||
* @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.startsWithAny(str, "'", "\""))
|
||||
{
|
||||
classs.add(new Object[] { StringUtils.substring(str, 1, str.length() - 1), String.class });
|
||||
}
|
||||
// boolean布尔类型,等于true或者false
|
||||
else if ("true".equalsIgnoreCase(str) || "false".equalsIgnoreCase(str))
|
||||
{
|
||||
classs.add(new Object[] { Boolean.valueOf(str), Boolean.class });
|
||||
}
|
||||
// long长整形,以L结尾
|
||||
else if (StringUtils.endsWith(str, "L"))
|
||||
{
|
||||
classs.add(new Object[] { Long.valueOf(StringUtils.substring(str, 0, str.length() - 1)), Long.class });
|
||||
}
|
||||
// double浮点类型,以D结尾
|
||||
else if (StringUtils.endsWith(str, "D"))
|
||||
{
|
||||
classs.add(new Object[] { Double.valueOf(StringUtils.substring(str, 0, str.length() - 1)), 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.ruoyi.quartz.util;
|
||||
|
||||
import org.quartz.DisallowConcurrentExecution;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import com.ruoyi.quartz.domain.SysJob;
|
||||
|
||||
/**
|
||||
* 定时任务处理(禁止并发执行)
|
||||
*
|
||||
* @author ruoyi
|
||||
*
|
||||
*/
|
||||
@DisallowConcurrentExecution
|
||||
public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob
|
||||
{
|
||||
@Override
|
||||
protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception
|
||||
{
|
||||
JobInvokeUtil.invokeMethod(sysJob);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.ruoyi.quartz.util;
|
||||
|
||||
import org.quartz.JobExecutionContext;
|
||||
import com.ruoyi.quartz.domain.SysJob;
|
||||
|
||||
/**
|
||||
* 定时任务处理(允许并发执行)
|
||||
*
|
||||
* @author ruoyi
|
||||
*
|
||||
*/
|
||||
public class QuartzJobExecution extends AbstractQuartzJob
|
||||
{
|
||||
@Override
|
||||
protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception
|
||||
{
|
||||
JobInvokeUtil.invokeMethod(sysJob);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
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.Constants;
|
||||
import com.ruoyi.common.constant.ScheduleConstants;
|
||||
import com.ruoyi.common.exception.job.TaskException;
|
||||
import com.ruoyi.common.exception.job.TaskException.Code;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.quartz.domain.SysJob;
|
||||
|
||||
/**
|
||||
* 定时任务工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*
|
||||
*/
|
||||
public class ScheduleUtils
|
||||
{
|
||||
/**
|
||||
* 得到quartz任务类
|
||||
*
|
||||
* @param sysJob 执行计划
|
||||
* @return 具体执行任务类
|
||||
*/
|
||||
private static Class<? extends Job> getQuartzJobClass(SysJob sysJob)
|
||||
{
|
||||
boolean isConcurrent = "0".equals(sysJob.getConcurrent());
|
||||
return isConcurrent ? QuartzJobExecution.class : QuartzDisallowConcurrentExecution.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建任务触发对象
|
||||
*/
|
||||
public static TriggerKey getTriggerKey(Long jobId, String jobGroup)
|
||||
{
|
||||
return TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建任务键对象
|
||||
*/
|
||||
public static JobKey getJobKey(Long jobId, String jobGroup)
|
||||
{
|
||||
return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建定时任务
|
||||
*/
|
||||
public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException
|
||||
{
|
||||
Class<? extends Job> jobClass = getQuartzJobClass(job);
|
||||
// 构建job信息
|
||||
Long jobId = job.getJobId();
|
||||
String jobGroup = job.getJobGroup();
|
||||
JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build();
|
||||
|
||||
// 表达式调度构建器
|
||||
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
|
||||
cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder);
|
||||
|
||||
// 按新的cronExpression表达式构建一个新的trigger
|
||||
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup))
|
||||
.withSchedule(cronScheduleBuilder).build();
|
||||
|
||||
// 放入参数,运行时的方法可以获取
|
||||
jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job);
|
||||
|
||||
// 判断是否存在
|
||||
if (scheduler.checkExists(getJobKey(jobId, jobGroup)))
|
||||
{
|
||||
// 防止创建时存在数据问题 先移除,然后在执行创建操作
|
||||
scheduler.deleteJob(getJobKey(jobId, jobGroup));
|
||||
}
|
||||
|
||||
// 判断任务是否过期
|
||||
if (StringUtils.isNotNull(CronUtils.getNextExecution(job.getCronExpression())))
|
||||
{
|
||||
// 执行调度任务
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查包名是否为白名单配置
|
||||
*
|
||||
* @param invokeTarget 目标字符串
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean whiteList(String invokeTarget)
|
||||
{
|
||||
String packageName = StringUtils.substringBefore(invokeTarget, "(");
|
||||
int count = StringUtils.countMatches(packageName, ".");
|
||||
if (count > 1)
|
||||
{
|
||||
return StringUtils.containsAnyIgnoreCase(invokeTarget, Constants.JOB_WHITELIST_STR);
|
||||
}
|
||||
Object obj = SpringUtils.getBean(StringUtils.split(invokeTarget, ".")[0]);
|
||||
return StringUtils.containsAnyIgnoreCase(obj.getClass().getPackage().getName(), Constants.JOB_WHITELIST_STR);
|
||||
}
|
||||
}
|
||||
101
ruoyi-quartz/src/main/resources/mapper/quartz/PlanNowMapper.xml
Normal file
101
ruoyi-quartz/src/main/resources/mapper/quartz/PlanNowMapper.xml
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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.PlanNowMapper">
|
||||
|
||||
<resultMap type="PlanNow" id="PlanNowResult">
|
||||
<result property="orderId" column="order_id" />
|
||||
<result property="planType" column="plan_type" />
|
||||
<result property="materialCode" column="material_code" />
|
||||
<result property="erpCode" column="erp_code" />
|
||||
<result property="productBatch" column="product_batch" />
|
||||
<result property="planQuantity" column="plan_quantity" />
|
||||
<result property="status" column="status" />
|
||||
<result property="operateType" column="operate_type" />
|
||||
<result property="orderNo" column="order_no" />
|
||||
<result property="message" column="message" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPlanNowVo">
|
||||
select order_id,order_no,message, plan_type, material_code, erp_code, product_batch, plan_quantity, status, operate_type from (select * from plan_now union select * from plan_now_finish ) a
|
||||
|
||||
</sql>
|
||||
<sql id="selectPlanNowVo1">
|
||||
select top(1) order_id,order_no, status from plan_now
|
||||
</sql>
|
||||
|
||||
<select id="selectPlanNowList" parameterType="PlanNow" resultMap="PlanNowResult">
|
||||
<include refid="selectPlanNowVo"/>
|
||||
<where>
|
||||
<if test="orderId != null and orderId != ''"> and order_id = #{orderId}</if>
|
||||
<if test="planType != null and planType != ''"> and plan_type = #{planType}</if>
|
||||
<if test="materialCode != null and materialCode != ''"> and material_code = #{materialCode}</if>
|
||||
<if test="erpCode != null and erpCode != ''"> and erp_code = #{erpCode}</if>
|
||||
<if test="productBatch != null and productBatch != ''"> and product_batch = #{productBatch}</if>
|
||||
<if test="planQuantity != null and planQuantity != ''"> and plan_quantity = #{planQuantity}</if>
|
||||
<if test="status != null "> and status = #{status}</if>
|
||||
<if test="operateType != null and operateType != ''"> and operate_type = #{operateType}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectPlanNowByOrderId" parameterType="String" resultMap="PlanNowResult">
|
||||
<include refid="selectPlanNowVo"/>
|
||||
where order_id = #{orderId}
|
||||
</select>
|
||||
<select id="selectPlanNow" parameterType="Long" resultMap="PlanNowResult">
|
||||
<include refid="selectPlanNowVo1"/>
|
||||
where status = #{status} order by order_no
|
||||
</select>
|
||||
<insert id="insertPlanNow" parameterType="PlanNow">
|
||||
insert into plan_now
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="orderId != null">order_id,</if>
|
||||
<if test="planType != null">plan_type,</if>
|
||||
<if test="materialCode != null">material_code,</if>
|
||||
<if test="erpCode != null">erp_code,</if>
|
||||
<if test="productBatch != null">product_batch,</if>
|
||||
<if test="planQuantity != null">plan_quantity,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="operateType != null">operate_type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="orderId != null">#{orderId},</if>
|
||||
<if test="planType != null">#{planType},</if>
|
||||
<if test="materialCode != null">#{materialCode},</if>
|
||||
<if test="erpCode != null">#{erpCode},</if>
|
||||
<if test="productBatch != null">#{productBatch},</if>
|
||||
<if test="planQuantity != null">#{planQuantity},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="operateType != null">#{operateType},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePlanNow" parameterType="PlanNow">
|
||||
update plan_now
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="planType != null">plan_type = #{planType},</if>
|
||||
<if test="materialCode != null">material_code = #{materialCode},</if>
|
||||
<if test="erpCode != null">erp_code = #{erpCode},</if>
|
||||
<if test="productBatch != null">product_batch = #{productBatch},</if>
|
||||
<if test="planQuantity != null">plan_quantity = #{planQuantity},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="operateType != null">operate_type = #{operateType},</if>
|
||||
<if test="orderNo != null">order_no = #{orderNo},</if>
|
||||
<if test="message != null">message = #{message},</if>
|
||||
</trim>
|
||||
where order_id = #{orderId}
|
||||
</update>
|
||||
|
||||
<delete id="deletePlanNowByOrderId" parameterType="String">
|
||||
delete from plan_now where order_id = #{orderId}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePlanNowByOrderIds" parameterType="String">
|
||||
delete from plan_now where order_id in
|
||||
<foreach item="orderId" collection="array" open="(" separator="," close=")">
|
||||
#{orderId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.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>
|
||||
|
||||
<sql id="selectJobLogVo">
|
||||
select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time
|
||||
from sys_job_log
|
||||
</sql>
|
||||
|
||||
<select id="selectJobLogList" parameterType="SysJobLog" resultMap="SysJobLogResult">
|
||||
<include refid="selectJobLogVo"/>
|
||||
<where>
|
||||
<if test="jobName != null and jobName != ''">
|
||||
AND job_name like concat('%', #{jobName}, '%')
|
||||
</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">
|
||||
AND job_group = #{jobGroup}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="invokeTarget != null and invokeTarget != ''">
|
||||
AND invoke_target like concat('%', #{invokeTarget}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and CONVERT(varchar(10),create_time, 120 ) >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
and CONVERT(varchar(10),create_time, 120 ) <= #{params.endTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectJobLogAll" resultMap="SysJobLogResult">
|
||||
<include refid="selectJobLogVo"/>
|
||||
</select>
|
||||
|
||||
<select id="selectJobLogById" parameterType="Long" resultMap="SysJobLogResult">
|
||||
<include refid="selectJobLogVo"/>
|
||||
where job_log_id = #{jobLogId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteJobLogById" parameterType="Long">
|
||||
delete from sys_job_log where job_log_id = #{jobLogId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteJobLogByIds" parameterType="String">
|
||||
delete from sys_job_log where job_log_id in
|
||||
<foreach collection="array" item="jobLogId" open="(" separator="," close=")">
|
||||
#{jobLogId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="cleanJobLog">
|
||||
truncate table sys_job_log
|
||||
</update>
|
||||
|
||||
<insert id="insertJobLog" parameterType="SysJobLog">
|
||||
insert into sys_job_log(
|
||||
<if test="jobLogId != null and jobLogId != 0">job_log_id,</if>
|
||||
<if test="jobName != null and jobName != ''">job_name,</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">job_group,</if>
|
||||
<if test="invokeTarget != null and invokeTarget != ''">invoke_target,</if>
|
||||
<if test="jobMessage != null and jobMessage != ''">job_message,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="exceptionInfo != null and exceptionInfo != ''">exception_info,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="jobLogId != null and jobLogId != 0">#{jobLogId},</if>
|
||||
<if test="jobName != null and jobName != ''">#{jobName},</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if>
|
||||
<if test="invokeTarget != null and invokeTarget != ''">#{invokeTarget},</if>
|
||||
<if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if>
|
||||
CONVERT(varchar, getdate(), 120 )
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
115
ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml
Normal file
115
ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml
Normal file
@@ -0,0 +1,115 @@
|
||||
<?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>
|
||||
|
||||
<sql id="selectJobVo">
|
||||
select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark
|
||||
from sys_job
|
||||
</sql>
|
||||
|
||||
<select id="selectJobList" parameterType="SysJob" resultMap="SysJobResult">
|
||||
<include refid="selectJobVo"/>
|
||||
<where>
|
||||
<if test="jobName != null and jobName != ''">
|
||||
AND job_name like concat('%', #{jobName}, '%')
|
||||
</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">
|
||||
AND job_group = #{jobGroup}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="invokeTarget != null and invokeTarget != ''">
|
||||
AND invoke_target like concat('%', #{invokeTarget}, '%')
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectJobAll" resultMap="SysJobResult">
|
||||
<include refid="selectJobVo"/>
|
||||
</select>
|
||||
|
||||
<select id="selectJobById" parameterType="Long" resultMap="SysJobResult">
|
||||
<include refid="selectJobVo"/>
|
||||
where job_id = #{jobId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteJobById" parameterType="Long">
|
||||
delete from sys_job where job_id = #{jobId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteJobByIds" parameterType="Long">
|
||||
delete from sys_job where job_id in
|
||||
<foreach collection="array" item="jobId" open="(" separator="," close=")">
|
||||
#{jobId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="updateJob" parameterType="SysJob">
|
||||
update sys_job
|
||||
<set>
|
||||
<if test="jobName != null and jobName != ''">job_name = #{jobName},</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">job_group = #{jobGroup},</if>
|
||||
<if test="invokeTarget != null and invokeTarget != ''">invoke_target = #{invokeTarget},</if>
|
||||
<if test="cronExpression != null and cronExpression != ''">cron_expression = #{cronExpression},</if>
|
||||
<if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy = #{misfirePolicy},</if>
|
||||
<if test="concurrent != null and concurrent != ''">concurrent = #{concurrent},</if>
|
||||
<if test="status !=null">status = #{status},</if>
|
||||
<if test="remark != null and remark != ''">remark = #{remark},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = CONVERT(varchar, getdate(), 120 )
|
||||
</set>
|
||||
where job_id = #{jobId}
|
||||
</update>
|
||||
|
||||
<insert id="insertJob" parameterType="SysJob" useGeneratedKeys="true" keyProperty="jobId">
|
||||
insert into sys_job(
|
||||
<if test="jobId != null and jobId != 0">job_id,</if>
|
||||
<if test="jobName != null and jobName != ''">job_name,</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">job_group,</if>
|
||||
<if test="invokeTarget != null and invokeTarget != ''">invoke_target,</if>
|
||||
<if test="cronExpression != null and cronExpression != ''">cron_expression,</if>
|
||||
<if test="misfirePolicy != null and misfirePolicy != ''">misfire_policy,</if>
|
||||
<if test="concurrent != null and concurrent != ''">concurrent,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="jobId != null and jobId != 0">#{jobId},</if>
|
||||
<if test="jobName != null and jobName != ''">#{jobName},</if>
|
||||
<if test="jobGroup != null and jobGroup != ''">#{jobGroup},</if>
|
||||
<if test="invokeTarget != null and invokeTarget != ''">#{invokeTarget},</if>
|
||||
<if test="cronExpression != null and cronExpression != ''">#{cronExpression},</if>
|
||||
<if test="misfirePolicy != null and misfirePolicy != ''">#{misfirePolicy},</if>
|
||||
<if test="concurrent != null and concurrent != ''">#{concurrent},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
CONVERT(varchar, getdate(), 120 )
|
||||
)
|
||||
</insert>
|
||||
<select id="prepareOut" parameterType="java.util.Map" statementType="CALLABLE">
|
||||
{
|
||||
call stock_hz(#{v_result, mode=OUT,jdbcType=INTEGER})
|
||||
}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?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.sysurl.mapper.SysUrlMapper">
|
||||
|
||||
<resultMap type="SysUrl" id="SysUrlResult">
|
||||
<result property="ip" column="ip" />
|
||||
<result property="port" column="port" />
|
||||
<result property="address" column="address" />
|
||||
<result property="type" column="type" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysUrlVo">
|
||||
select ip, port, address, type from sys_url
|
||||
</sql>
|
||||
|
||||
<select id="selectSysUrlList" parameterType="SysUrl" resultMap="SysUrlResult">
|
||||
<include refid="selectSysUrlVo"/>
|
||||
<where>
|
||||
<if test="ip != null and ip != ''"> and ip = #{ip}</if>
|
||||
<if test="port != null and port != ''"> and port = #{port}</if>
|
||||
<if test="address != null and address != ''"> and address = #{address}</if>
|
||||
<if test="type != null and type != ''"> and type = #{type}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSysUrlByIp" parameterType="String" resultMap="SysUrlResult">
|
||||
<include refid="selectSysUrlVo"/>
|
||||
where ip = #{ip}
|
||||
</select>
|
||||
|
||||
<insert id="insertSysUrl" parameterType="SysUrl">
|
||||
insert into sys_url
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="ip != null">ip,</if>
|
||||
<if test="port != null">port,</if>
|
||||
<if test="address != null">address,</if>
|
||||
<if test="type != null">type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="ip != null">#{ip},</if>
|
||||
<if test="port != null">#{port},</if>
|
||||
<if test="address != null">#{address},</if>
|
||||
<if test="type != null">#{type},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysUrl" parameterType="SysUrl">
|
||||
update sys_url
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="port != null">port = #{port},</if>
|
||||
<if test="address != null">address = #{address},</if>
|
||||
<if test="type != null">type = #{type},</if>
|
||||
</trim>
|
||||
where ip = #{ip}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysUrlByIp" parameterType="String">
|
||||
delete from sys_url where ip = #{ip}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysUrlByIps" parameterType="String">
|
||||
delete from sys_url where ip in
|
||||
<foreach item="ip" collection="array" open="(" separator="," close=")">
|
||||
#{ip}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
109
ruoyi-quartz/src/main/resources/templates/monitor/job/add.html
Normal file
109
ruoyi-quartz/src/main/resources/templates/monitor/job/add.html
Normal file
@@ -0,0 +1,109 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||
<head>
|
||||
<th:block th:include="include :: header('新增定时任务')" />
|
||||
</head>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-job-add">
|
||||
<input type="hidden" name="createBy" th:value="${@permission.getPrincipalProperty('loginName')}">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">任务名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="jobName" id="jobName" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务分组:</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="jobGroup" class="form-control m-b" th:with="type=${@dict.getType('sys_job_group')}">
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">调用目标字符串:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="invokeTarget" id="invokeTarget" required>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Bean调用示例:ryTask.ryParams('ry')</span>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Class类调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry')</span>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 参数说明:支持字符串,布尔类型,长整型,浮点型,整型</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">cron表达式:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="cronExpression" id="cronExpression" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">执行策略:</label>
|
||||
<div class="col-sm-8">
|
||||
<label class="radio-box"> <input type="radio" name="misfirePolicy" value="1" th:checked="true"/> 立即执行 </label>
|
||||
<label class="radio-box"> <input type="radio" name="misfirePolicy" value="2" /> 执行一次 </label>
|
||||
<label class="radio-box"> <input type="radio" name="misfirePolicy" value="3" /> 放弃执行 </label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">并发执行:</label>
|
||||
<div class="col-sm-8">
|
||||
<label class="radio-box"> <input type="radio" name="concurrent" value="0"/> 允许 </label>
|
||||
<label class="radio-box"> <input type="radio" name="concurrent" value="1" th:checked="true"/> 禁止 </label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">状态:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="radio-box" th:each="dict : ${@dict.getType('sys_job_status')}">
|
||||
<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:checked="${dict.default}">
|
||||
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">备注:</label>
|
||||
<div class="col-sm-8">
|
||||
<textarea id="remark" name="remark" class="form-control"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<script type="text/javascript">
|
||||
var prefix = ctx + "monitor/job";
|
||||
|
||||
$("#form-job-add").validate({
|
||||
onkeyup: false,
|
||||
rules:{
|
||||
cronExpression:{
|
||||
remote: {
|
||||
url: prefix + "/checkCronExpressionIsValid",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
"cronExpression": function() {
|
||||
return $.common.trim($("#cronExpression").val());
|
||||
}
|
||||
},
|
||||
dataFilter: function(data, type) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
"cronExpression": {
|
||||
remote: "表达式不正确"
|
||||
}
|
||||
},
|
||||
focusCleanup: true
|
||||
});
|
||||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
$.operate.save(prefix + "/add", $('#form-job-add').serialize());
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
1172
ruoyi-quartz/src/main/resources/templates/monitor/job/cron.html
Normal file
1172
ruoyi-quartz/src/main/resources/templates/monitor/job/cron.html
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,99 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||
<head>
|
||||
<th:block th:include="include :: header('定时任务详细')" />
|
||||
</head>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
|
||||
<form class="form-horizontal m-t" id="jobLogForm" th:if="${name == 'jobLog'}">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">日志序号:</label>
|
||||
<div class="form-control-static" th:text="${jobLog.jobLogId}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务名称:</label>
|
||||
<div class="form-control-static" th:text="${jobLog.jobName}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务分组:</label>
|
||||
<div class="form-control-static" th:text="${@dict.getLabel('sys_job_group', jobLog.jobGroup)}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">调用目标字符串:</label>
|
||||
<div class="form-control-static" th:text="${jobLog.invokeTarget}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">日志信息:</label>
|
||||
<div class="form-control-static" th:text="${jobLog.jobMessage}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">执行状态:</label>
|
||||
<div class="form-control-static" th:class="${jobLog.status == '0' ? 'label label-primary' : 'label label-danger'}" th:text="${jobLog.status == '0' ? '正常' : '失败'}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group" th:style="'display:' + ${jobLog.status == '0' ? 'none' : 'block'}">
|
||||
<label class="col-sm-3 control-label">异常信息:</label>
|
||||
<div class="form-control-static" th:text="${jobLog.exceptionInfo}">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<form class="form-horizontal m-t" id="jobForm" th:if="${name == 'job'}">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务序号:</label>
|
||||
<div class="form-control-static" th:text="${job.jobId}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务名称:</label>
|
||||
<div class="form-control-static" th:text="${job.jobName}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务分组:</label>
|
||||
<div class="form-control-static" th:text="${job.jobGroup}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">调用目标字符串:</label>
|
||||
<div class="form-control-static" th:text="${job.invokeTarget}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">执行表达式:</label>
|
||||
<div class="form-control-static" th:text="${job.cronExpression}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">下次执行时间:</label>
|
||||
<div class="form-control-static" th:text="${#dates.format(job.nextValidTime, 'yyyy-MM-dd HH:mm:ss')}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">执行策略:</label>
|
||||
<div class="form-control-static" th:if="${job.misfirePolicy == '0'}">默认策略</div>
|
||||
<div class="form-control-static" th:if="${job.misfirePolicy == '1'}">立即执行</div>
|
||||
<div class="form-control-static" th:if="${job.misfirePolicy == '2'}">执行一次</div>
|
||||
<div class="form-control-static" th:if="${job.misfirePolicy == '3'}">放弃执行</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">并发执行:</label>
|
||||
<div class="form-control-static" th:class="${job.concurrent == '0' ? 'label label-primary' : 'label label-danger'}" th:text="${job.concurrent == '0' ? '允许' : '禁止'}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">执行状态:</label>
|
||||
<div class="form-control-static" th:class="${job.status == '0' ? 'label label-primary' : 'label label-danger'}" th:text="${job.status == '0' ? '正常' : '暂停'}">
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
111
ruoyi-quartz/src/main/resources/templates/monitor/job/edit.html
Normal file
111
ruoyi-quartz/src/main/resources/templates/monitor/job/edit.html
Normal file
@@ -0,0 +1,111 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||
<head>
|
||||
<th:block th:include="include :: header('修改定时任务')" />
|
||||
</head>
|
||||
<body class="white-bg">
|
||||
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
|
||||
<form class="form-horizontal m" id="form-job-edit" th:object="${job}">
|
||||
<input id="jobId" name="jobId" type="hidden" th:field="*{jobId}"/>
|
||||
<input type="hidden" name="updateBy" th:value="${@permission.getPrincipalProperty('loginName')}">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">任务名称:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="jobName" id="jobName" th:field="*{jobName}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">任务分组:</label>
|
||||
<div class="col-sm-8">
|
||||
<select name="jobGroup" class="form-control m-b" th:with="type=${@dict.getType('sys_job_group')}">
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{jobGroup}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">调用目标字符串:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="invokeTarget" id="invokeTarget" th:field="*{invokeTarget}" required>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Bean调用示例:ryTask.ryParams('ry')</span>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> Class类调用示例:com.ruoyi.quartz.task.RyTask.ryParams('ry')</span>
|
||||
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 参数说明:支持字符串,布尔类型,长整型,浮点型,整型</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label is-required">cron表达式:</label>
|
||||
<div class="col-sm-8">
|
||||
<input class="form-control" type="text" name="cronExpression" id="cronExpression" th:field="*{cronExpression}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">执行策略:</label>
|
||||
<div class="col-sm-8">
|
||||
<label class="radio-box"> <input type="radio" th:field="*{misfirePolicy}" name="misfirePolicy" value="1" /> 立即执行 </label>
|
||||
<label class="radio-box"> <input type="radio" th:field="*{misfirePolicy}" name="misfirePolicy" value="2" /> 执行一次 </label>
|
||||
<label class="radio-box"> <input type="radio" th:field="*{misfirePolicy}" name="misfirePolicy" value="3" /> 放弃执行 </label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">并发执行:</label>
|
||||
<div class="col-sm-8">
|
||||
<label class="radio-box"> <input type="radio" th:field="*{concurrent}" name="concurrent" value="0"/> 允许 </label>
|
||||
<label class="radio-box"> <input type="radio" th:field="*{concurrent}" name="concurrent" value="1"/> 禁止 </label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">状态:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="radio-box" th:each="dict : ${@dict.getType('sys_job_status')}">
|
||||
<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
|
||||
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label">备注:</label>
|
||||
<div class="col-sm-8">
|
||||
<textarea id="remark" name="remark" class="form-control">[[*{remark}]]</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<script type="text/javascript">
|
||||
var prefix = ctx + "monitor/job";
|
||||
|
||||
$("#form-job-edit").validate({
|
||||
onkeyup: false,
|
||||
rules:{
|
||||
cronExpression:{
|
||||
required:true,
|
||||
remote: {
|
||||
url: prefix + "/checkCronExpressionIsValid",
|
||||
type: "post",
|
||||
dataType: "json",
|
||||
data: {
|
||||
"cronExpression": function() {
|
||||
return $.common.trim($("#cronExpression").val());
|
||||
}
|
||||
},
|
||||
dataFilter: function(data, type) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
"cronExpression": {
|
||||
remote: "表达式不正确"
|
||||
}
|
||||
},
|
||||
focusCleanup: true
|
||||
});
|
||||
|
||||
function submitHandler() {
|
||||
if ($.validate.form()) {
|
||||
$.operate.save(prefix + "/edit", $('#form-job-edit').serialize());
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
198
ruoyi-quartz/src/main/resources/templates/monitor/job/job.html
Normal file
198
ruoyi-quartz/src/main/resources/templates/monitor/job/job.html
Normal file
@@ -0,0 +1,198 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<head>
|
||||
<th:block th:include="include :: header('定时任务列表')" />
|
||||
</head>
|
||||
<body class="gray-bg">
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="job-form">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
任务名称:<input type="text" name="jobName"/>
|
||||
</li>
|
||||
<li>
|
||||
任务分组:<select name="jobGroup" th:with="type=${@dict.getType('sys_job_group')}">
|
||||
<option value="">所有</option>
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
任务状态:<select name="status" th:with="type=${@dict.getType('sys_job_status')}">
|
||||
<option value="">所有</option>
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
|
||||
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="monitor:job:add">
|
||||
<i class="fa fa-plus"></i> 新增
|
||||
</a>
|
||||
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="monitor:job:edit">
|
||||
<i class="fa fa-edit"></i> 修改
|
||||
</a>
|
||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="monitor:job:remove">
|
||||
<i class="fa fa-remove"></i> 删除
|
||||
</a>
|
||||
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:job:export">
|
||||
<i class="fa fa-download"></i> 导出
|
||||
</a>
|
||||
<a class="btn btn-primary" onclick="javascript:cron()">
|
||||
<i class="fa fa-code"></i> 生成表达式
|
||||
</a>
|
||||
<a class="btn btn-info" onclick="javascript:jobLog()" shiro:hasPermission="monitor:job:detail">
|
||||
<i class="fa fa-list"></i> 日志
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 select-table table-bordered">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<script th:inline="javascript">
|
||||
var detailFlag = [[${@permission.hasPermi('monitor:job:detail')}]];
|
||||
var editFlag = [[${@permission.hasPermi('monitor:job:edit')}]];
|
||||
var removeFlag = [[${@permission.hasPermi('monitor:job:remove')}]];
|
||||
var statusFlag = [[${@permission.hasPermi('monitor:job:changeStatus')}]];
|
||||
var datas = [[${@dict.getType('sys_job_group')}]];
|
||||
var prefix = ctx + "monitor/job";
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
url: prefix + "/list",
|
||||
detailUrl: prefix + "/detail/{id}",
|
||||
createUrl: prefix + "/add",
|
||||
updateUrl: prefix + "/edit/{id}",
|
||||
removeUrl: prefix + "/remove",
|
||||
exportUrl: prefix + "/export",
|
||||
sortName: "createTime",
|
||||
sortOrder: "desc",
|
||||
modalName: "任务",
|
||||
columns: [{
|
||||
checkbox: true
|
||||
},
|
||||
{
|
||||
field: 'jobId',
|
||||
title: '任务编号'
|
||||
},
|
||||
{
|
||||
field: 'jobName',
|
||||
title: '任务名称',
|
||||
},
|
||||
{
|
||||
field: 'jobGroup',
|
||||
title: '任务分组',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.selectDictLabel(datas, value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'invokeTarget',
|
||||
title: '调用目标字符串',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.tooltip(value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'cronExpression',
|
||||
title: '执行表达式'
|
||||
},
|
||||
{
|
||||
visible: statusFlag == 'hidden' ? false : true,
|
||||
title: '任务状态',
|
||||
align: 'center',
|
||||
formatter: function (value, row, index) {
|
||||
return statusTools(row);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.jobId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.jobId + '\')"><i class="fa fa-remove"></i>删除</a> ');
|
||||
var more = [];
|
||||
more.push("<a class='btn btn-default btn-xs " + statusFlag + "' href='javascript:void(0)' onclick='run(" + row.jobId + ")'><i class='fa fa-play-circle-o'></i> 执行一次</a> ");
|
||||
more.push("<a class='btn btn-default btn-xs " + detailFlag + "' href='javascript:void(0)' onclick='$.operate.detail(" + row.jobId + ")'><i class='fa fa-search'></i>任务详细</a> ");
|
||||
more.push("<a class='btn btn-default btn-xs " + detailFlag + "' href='javascript:void(0)' onclick='jobLog(" + row.jobId + ")'><i class='fa fa-list'></i>调度日志</a>");
|
||||
actions.push('<a class="btn btn-info btn-xs" role="button" data-container="body" data-placement="left" data-toggle="popover" data-html="true" data-trigger="hover" data-content="' + more.join('') + '"><i class="fa fa-chevron-circle-right"></i>更多操作</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
|
||||
/* 调度任务状态显示 */
|
||||
function statusTools(row) {
|
||||
if (row.status == 1) {
|
||||
return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="start(\'' + row.jobId + '\', \'' + row.jobGroup + '\')"></i> ';
|
||||
} else {
|
||||
return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="stop(\'' + row.jobId + '\', \'' + row.jobGroup + '\')"></i> ';
|
||||
}
|
||||
}
|
||||
|
||||
/* 立即执行一次 */
|
||||
function run(jobId) {
|
||||
$.modal.confirm("确认要立即执行一次任务吗?", function() {
|
||||
$.operate.post(prefix + "/run", { "jobId": jobId});
|
||||
})
|
||||
}
|
||||
|
||||
/* 调度任务-停用 */
|
||||
function stop(jobId, jobGroup) {
|
||||
$.modal.confirm("确认要停用任务吗?", function() {
|
||||
$.operate.post(prefix + "/changeStatus", { "jobId": jobId, "jobGroup": jobGroup, "status": 1 });
|
||||
})
|
||||
}
|
||||
|
||||
/* 调度任务-启用 */
|
||||
function start(jobId, jobGroup) {
|
||||
$.modal.confirm("确认要启用任务吗?", function() {
|
||||
$.operate.post(prefix + "/changeStatus", { "jobId": jobId, "jobGroup": jobGroup, "status": 0 });
|
||||
})
|
||||
}
|
||||
|
||||
/* 调度日志查询 */
|
||||
function jobLog(jobId) {
|
||||
var url = ctx + 'monitor/jobLog';
|
||||
if ($.common.isNotEmpty(jobId)) {
|
||||
url += '?jobId=' + jobId;
|
||||
}
|
||||
$.modal.openTab("调度日志", url);
|
||||
}
|
||||
|
||||
/* cron表达式生成 */
|
||||
function cron() {
|
||||
var url = prefix + '/cron';
|
||||
var height = $(window).height() - 50;
|
||||
top.layer.open({
|
||||
maxmin: true,
|
||||
title: "Cron表达式生成器",
|
||||
type: 2,
|
||||
area: ['800px', height + "px" ], //宽高
|
||||
shadeClose: true,
|
||||
content: url
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,138 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
|
||||
<head>
|
||||
<th:block th:include="include :: header('定时任务日志列表')" />
|
||||
</head>
|
||||
<body class="gray-bg">
|
||||
|
||||
<div class="container-div">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 search-collapse">
|
||||
<form id="jobLog-form">
|
||||
<div class="select-list">
|
||||
<ul>
|
||||
<li>
|
||||
任务名称:<input type="text" name="jobName" th:value="${job!=null?job.jobName:''}"/>
|
||||
</li>
|
||||
<li>
|
||||
任务分组:<select name="jobGroup" th:with="type=${@dict.getType('sys_job_group')}">
|
||||
<option value="">所有</option>
|
||||
<th:block th:if="${job==null}"><option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option></th:block>
|
||||
<th:block th:if="${job!=null}"><option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{job.jobGroup}"></option></th:block>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
执行状态:<select name="status" th:with="type=${@dict.getType('sys_common_status')}">
|
||||
<option value="">所有</option>
|
||||
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
|
||||
</select>
|
||||
</li>
|
||||
<li class="select-time">
|
||||
<label>执行时间: </label>
|
||||
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
|
||||
<span>-</span>
|
||||
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
|
||||
</li>
|
||||
<li>
|
||||
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
|
||||
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="monitor:job:remove">
|
||||
<i class="fa fa-remove"></i> 删除
|
||||
</a>
|
||||
<a class="btn btn-danger" onclick="$.operate.clean()" shiro:hasPermission="monitor:job:remove">
|
||||
<i class="fa fa-trash"></i> 清空
|
||||
</a>
|
||||
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:job:export">
|
||||
<i class="fa fa-download"></i> 导出
|
||||
</a>
|
||||
<a class="btn btn-danger" onclick="closeItem()">
|
||||
<i class="fa fa-reply-all"></i> 关闭
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 select-table table-bordered">
|
||||
<table id="bootstrap-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<th:block th:include="include :: footer" />
|
||||
<script th:inline="javascript">
|
||||
var detailFlag = [[${@permission.hasPermi('monitor:job:detail')}]];
|
||||
var statusDatas = [[${@dict.getType('sys_common_status')}]];
|
||||
var groupDatas = [[${@dict.getType('sys_job_group')}]];
|
||||
var prefix = ctx + "monitor/jobLog";
|
||||
|
||||
$(function() {
|
||||
var options = {
|
||||
url: prefix + "/list",
|
||||
cleanUrl: prefix + "/clean",
|
||||
detailUrl: prefix + "/detail/{id}",
|
||||
removeUrl: prefix + "/remove",
|
||||
exportUrl: prefix + "/export",
|
||||
sortName: "createTime",
|
||||
sortOrder: "desc",
|
||||
modalName: "调度日志",
|
||||
columns: [{
|
||||
checkbox: true
|
||||
},
|
||||
{
|
||||
field: 'jobLogId',
|
||||
title: '日志编号'
|
||||
},
|
||||
{
|
||||
field: 'jobName',
|
||||
title: '任务名称'
|
||||
},
|
||||
{
|
||||
field: 'jobGroup',
|
||||
title: '任务分组',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.selectDictLabel(groupDatas, value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'invokeTarget',
|
||||
title: '调用目标字符串',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.tooltip(value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'jobMessage',
|
||||
title: '日志信息'
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
return $.table.selectDictLabel(statusDatas, value);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
formatter: function(value, row, index) {
|
||||
var actions = [];
|
||||
actions.push('<a class="btn btn-warning btn-xs ' + detailFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.jobLogId + '\')"><i class="fa fa-search"></i>详细</a>');
|
||||
return actions.join('');
|
||||
}
|
||||
}]
|
||||
};
|
||||
$.table.init(options);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user