1. 完成 Job 的 CRUD 功能
parent
bc1504d991
commit
f60855faa0
@ -1,85 +1,64 @@
|
|||||||
package com.ruoyi.quartz.controller;
|
package com.ruoyi.quartz.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.quartz.domain.SysJobLog;
|
import com.ruoyi.quartz.domain.SysJobLog;
|
||||||
import com.ruoyi.quartz.service.ISysJobLogService;
|
import com.ruoyi.quartz.service.ISysJobLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调度日志操作处理
|
* 调度日志操作处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/jobLog")
|
@RequestMapping("/monitor/jobLog")
|
||||||
public class SysJobLogController extends BaseController {
|
public class SysJobLogController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysJobLogService jobLogService;
|
private ISysJobLogService jobLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询定时任务调度日志列表
|
* 查询定时任务调度日志列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:list')")
|
@PreAuthorize("@ss.hasPermi('monitor:job:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(SysJobLog sysJobLog) {
|
public TableDataInfo list(SysJobLog sysJobLog) {
|
||||||
startPage();
|
startPage();
|
||||||
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
|
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出定时任务调度日志列表
|
* 导出定时任务调度日志列表
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
@PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
||||||
@Log(title = "任务调度日志", businessType = BusinessType.EXPORT)
|
@Log(title = "任务调度日志", businessType = BusinessType.EXPORT)
|
||||||
@GetMapping("/export")
|
@GetMapping("/export")
|
||||||
public AjaxResult export(SysJobLog sysJobLog) {
|
public AjaxResult export(SysJobLog sysJobLog) {
|
||||||
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
|
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
|
||||||
ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
|
ExcelUtil<SysJobLog> util = new ExcelUtil<SysJobLog>(SysJobLog.class);
|
||||||
return util.exportExcel(list, "调度日志");
|
return util.exportExcel(list, "调度日志");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据调度编号获取详细信息
|
* 根据调度编号获取详细信息
|
||||||
*/
|
*/
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:query')")
|
@PreAuthorize("@ss.hasPermi('monitor:job:query')")
|
||||||
@GetMapping(value = "/{configId}")
|
@GetMapping(value = "/{configId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long jobLogId) {
|
public AjaxResult getInfo(@PathVariable Long jobLogId) {
|
||||||
return AjaxResult.success(jobLogService.selectJobLogById(jobLogId));
|
return AjaxResult.success(jobLogService.selectJobLogById(jobLogId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 删除定时任务调度日志
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
|
||||||
@Log(title = "定时任务调度日志", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{jobLogIds}")
|
|
||||||
public AjaxResult remove(@PathVariable Long[] jobLogIds) {
|
|
||||||
return toAjax(jobLogService.deleteJobLogByIds(jobLogIds));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 清空定时任务调度日志
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
|
||||||
@Log(title = "调度日志", businessType = BusinessType.CLEAN)
|
|
||||||
@DeleteMapping("/clean")
|
|
||||||
public AjaxResult clean() {
|
|
||||||
jobLogService.cleanJobLog();
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,81 +1,54 @@
|
|||||||
package com.ruoyi.quartz.service.impl;
|
package com.ruoyi.quartz.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.quartz.domain.SysJobLog;
|
import com.ruoyi.quartz.domain.SysJobLog;
|
||||||
import com.ruoyi.quartz.mapper.SysJobLogMapper;
|
import com.ruoyi.quartz.mapper.SysJobLogMapper;
|
||||||
import com.ruoyi.quartz.service.ISysJobLogService;
|
import com.ruoyi.quartz.service.ISysJobLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时任务调度日志信息 服务层
|
* 定时任务调度日志信息 服务层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SysJobLogServiceImpl implements ISysJobLogService {
|
public class SysJobLogServiceImpl implements ISysJobLogService {
|
||||||
@Autowired
|
|
||||||
private SysJobLogMapper jobLogMapper;
|
@Autowired
|
||||||
|
private SysJobLogMapper jobLogMapper;
|
||||||
/**
|
|
||||||
* 获取quartz调度器日志的计划任务
|
/**
|
||||||
*
|
* 获取quartz调度器日志的计划任务
|
||||||
* @param jobLog 调度日志信息
|
*
|
||||||
* @return 调度任务日志集合
|
* @param jobLog 调度日志信息
|
||||||
*/
|
* @return 调度任务日志集合
|
||||||
@Override
|
*/
|
||||||
public List<SysJobLog> selectJobLogList(SysJobLog jobLog) {
|
@Override
|
||||||
return jobLogMapper.selectJobLogList(jobLog);
|
public List<SysJobLog> selectJobLogList(SysJobLog jobLog) {
|
||||||
}
|
return jobLogMapper.selectJobLogList(jobLog);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 通过调度任务日志ID查询调度信息
|
/**
|
||||||
*
|
* 通过调度任务日志ID查询调度信息
|
||||||
* @param jobLogId 调度任务日志ID
|
*
|
||||||
* @return 调度任务日志对象信息
|
* @param jobLogId 调度任务日志ID
|
||||||
*/
|
* @return 调度任务日志对象信息
|
||||||
@Override
|
*/
|
||||||
public SysJobLog selectJobLogById(Long jobLogId) {
|
@Override
|
||||||
return jobLogMapper.selectJobLogById(jobLogId);
|
public SysJobLog selectJobLogById(Long jobLogId) {
|
||||||
}
|
return jobLogMapper.selectJobLogById(jobLogId);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 新增任务日志
|
/**
|
||||||
*
|
* 新增任务日志
|
||||||
* @param jobLog 调度日志信息
|
*
|
||||||
*/
|
* @param jobLog 调度日志信息
|
||||||
@Override
|
*/
|
||||||
public void addJobLog(SysJobLog jobLog) {
|
@Override
|
||||||
jobLogMapper.insertJobLog(jobLog);
|
public void addJobLog(SysJobLog jobLog) {
|
||||||
}
|
jobLogMapper.insertJobLog(jobLog);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* 批量删除调度日志信息
|
}
|
||||||
*
|
|
||||||
* @param logIds 需要删除的数据ID
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int deleteJobLogByIds(Long[] logIds) {
|
|
||||||
return jobLogMapper.deleteJobLogByIds(logIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除任务日志
|
|
||||||
*
|
|
||||||
* @param jobId 调度日志ID
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int deleteJobLogById(Long jobId) {
|
|
||||||
return jobLogMapper.deleteJobLogById(jobId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 清空任务日志
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void cleanJobLog() {
|
|
||||||
jobLogMapper.cleanJobLog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,44 +1,44 @@
|
|||||||
package com.ruoyi.quartz.util;
|
package com.ruoyi.quartz.util;
|
||||||
|
|
||||||
import org.quartz.CronScheduleBuilder;
|
import org.quartz.CronScheduleBuilder;
|
||||||
import org.quartz.CronTrigger;
|
import org.quartz.CronTrigger;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobBuilder;
|
import org.quartz.JobBuilder;
|
||||||
import org.quartz.JobDetail;
|
import org.quartz.JobDetail;
|
||||||
import org.quartz.JobKey;
|
import org.quartz.JobKey;
|
||||||
import org.quartz.Scheduler;
|
import org.quartz.Scheduler;
|
||||||
import org.quartz.SchedulerException;
|
import org.quartz.SchedulerException;
|
||||||
import org.quartz.TriggerBuilder;
|
import org.quartz.TriggerBuilder;
|
||||||
import org.quartz.TriggerKey;
|
import org.quartz.TriggerKey;
|
||||||
import com.ruoyi.common.constant.ScheduleConstants;
|
import com.ruoyi.common.constant.ScheduleConstants;
|
||||||
import com.ruoyi.common.exception.job.TaskException;
|
import com.ruoyi.common.exception.job.TaskException;
|
||||||
import com.ruoyi.common.exception.job.TaskException.Code;
|
import com.ruoyi.common.exception.job.TaskException.Code;
|
||||||
import com.ruoyi.quartz.domain.SysJob;
|
import com.ruoyi.quartz.domain.SysJob;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 定时任务工具类
|
* 定时任务工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class ScheduleUtils {
|
public class ScheduleUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置定时任务策略
|
* 设置定时任务策略
|
||||||
*/
|
*/
|
||||||
public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb)
|
public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb)
|
||||||
throws TaskException {
|
throws TaskException {
|
||||||
switch (job.getMisfirePolicy()) {
|
switch (job.getMisfirePolicy()) {
|
||||||
case ScheduleConstants.MISFIRE_DEFAULT:
|
case ScheduleConstants.MISFIRE_DEFAULT:
|
||||||
return cb;
|
return cb;
|
||||||
case ScheduleConstants.MISFIRE_IGNORE_MISFIRES:
|
case ScheduleConstants.MISFIRE_IGNORE_MISFIRES:
|
||||||
return cb.withMisfireHandlingInstructionIgnoreMisfires();
|
return cb.withMisfireHandlingInstructionIgnoreMisfires();
|
||||||
case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED:
|
case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED:
|
||||||
return cb.withMisfireHandlingInstructionFireAndProceed();
|
return cb.withMisfireHandlingInstructionFireAndProceed();
|
||||||
case ScheduleConstants.MISFIRE_DO_NOTHING:
|
case ScheduleConstants.MISFIRE_DO_NOTHING:
|
||||||
return cb.withMisfireHandlingInstructionDoNothing();
|
return cb.withMisfireHandlingInstructionDoNothing();
|
||||||
default:
|
default:
|
||||||
throw new TaskException("The task misfire policy '" + job.getMisfirePolicy()
|
throw new TaskException("The task misfire policy '" + job.getMisfirePolicy()
|
||||||
+ "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR);
|
+ "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,132 +0,0 @@
|
|||||||
package com.ruoyi.quartz.controller;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.quartz.SchedulerException;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ruoyi.common.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.exception.job.TaskException;
|
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 调度任务信息操作处理
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/monitor/job")
|
|
||||||
public class SysJobController extends BaseController {
|
|
||||||
@Autowired
|
|
||||||
private ISysJobService jobService;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询定时任务列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:list')")
|
|
||||||
@GetMapping("/list")
|
|
||||||
public TableDataInfo list(SysJob sysJob) {
|
|
||||||
startPage();
|
|
||||||
List<SysJob> list = jobService.selectJobList(sysJob);
|
|
||||||
return getDataTable(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 导出定时任务列表
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:export')")
|
|
||||||
@Log(title = "定时任务", businessType = BusinessType.EXPORT)
|
|
||||||
@GetMapping("/export")
|
|
||||||
public AjaxResult export(SysJob sysJob) {
|
|
||||||
List<SysJob> list = jobService.selectJobList(sysJob);
|
|
||||||
ExcelUtil<SysJob> util = new ExcelUtil<SysJob>(SysJob.class);
|
|
||||||
return util.exportExcel(list, "定时任务");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取定时任务详细信息
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:query')")
|
|
||||||
@GetMapping(value = "/{jobId}")
|
|
||||||
public AjaxResult getInfo(@PathVariable("jobId") Long jobId) {
|
|
||||||
return AjaxResult.success(jobService.selectJobById(jobId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增定时任务
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:add')")
|
|
||||||
@Log(title = "定时任务", businessType = BusinessType.INSERT)
|
|
||||||
@PostMapping
|
|
||||||
public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException {
|
|
||||||
if (!CronUtils.isValid(sysJob.getCronExpression())) {
|
|
||||||
return AjaxResult.error("cron表达式不正确");
|
|
||||||
}
|
|
||||||
sysJob.setCreateBy(SecurityUtils.getUsername());
|
|
||||||
return toAjax(jobService.insertJob(sysJob));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改定时任务
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:edit')")
|
|
||||||
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping
|
|
||||||
public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException {
|
|
||||||
if (!CronUtils.isValid(sysJob.getCronExpression())) {
|
|
||||||
return AjaxResult.error("cron表达式不正确");
|
|
||||||
}
|
|
||||||
sysJob.setUpdateBy(SecurityUtils.getUsername());
|
|
||||||
return toAjax(jobService.updateJob(sysJob));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务状态修改
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
|
|
||||||
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping("/changeStatus")
|
|
||||||
public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException {
|
|
||||||
SysJob newJob = jobService.selectJobById(job.getJobId());
|
|
||||||
newJob.setStatus(job.getStatus());
|
|
||||||
return toAjax(jobService.changeStatus(newJob));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 定时任务立即执行一次
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')")
|
|
||||||
@Log(title = "定时任务", businessType = BusinessType.UPDATE)
|
|
||||||
@PutMapping("/run")
|
|
||||||
public AjaxResult run(@RequestBody SysJob job) throws SchedulerException {
|
|
||||||
jobService.run(job);
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除定时任务
|
|
||||||
*/
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:job:remove')")
|
|
||||||
@Log(title = "定时任务", businessType = BusinessType.DELETE)
|
|
||||||
@DeleteMapping("/{jobIds}")
|
|
||||||
public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException {
|
|
||||||
jobService.deleteJobByIds(jobIds);
|
|
||||||
return AjaxResult.success();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
package com.ruoyi.quartz.util;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import org.quartz.CronExpression;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* cron表达式工具类
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
*/
|
|
||||||
public class CronUtils {
|
|
||||||
/**
|
|
||||||
* 返回一个布尔值代表一个给定的Cron表达式的有效性
|
|
||||||
*
|
|
||||||
* @param cronExpression Cron表达式
|
|
||||||
* @return boolean 表达式是否有效
|
|
||||||
*/
|
|
||||||
public static boolean isValid(String cronExpression) {
|
|
||||||
return CronExpression.isValidExpression(cronExpression);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回一个字符串值,表示该消息无效Cron表达式给出有效性
|
|
||||||
*
|
|
||||||
* @param cronExpression Cron表达式
|
|
||||||
* @return String 无效时返回表达式错误描述,如果有效返回null
|
|
||||||
*/
|
|
||||||
public static String getInvalidMessage(String cronExpression) {
|
|
||||||
try {
|
|
||||||
new CronExpression(cronExpression);
|
|
||||||
return null;
|
|
||||||
} catch (ParseException pe) {
|
|
||||||
return pe.getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回下一个执行时间根据给定的Cron表达式
|
|
||||||
*
|
|
||||||
* @param cronExpression Cron表达式
|
|
||||||
* @return Date 下次Cron表达式执行时间
|
|
||||||
*/
|
|
||||||
public static Date getNextExecution(String cronExpression) {
|
|
||||||
try {
|
|
||||||
CronExpression cron = new CronExpression(cronExpression);
|
|
||||||
return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis()));
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new IllegalArgumentException(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,26 +1,26 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-loading="loading" :style="'height:'+ height">
|
<div v-loading="loading" :style="'height:'+ height">
|
||||||
<iframe :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" />
|
<iframe :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "Druid",
|
name: "Druid",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
src: process.env.VUE_APP_BASE_API + "/druid/index.html",
|
src: process.env.VUE_APP_BASE_API + "/druid/index.html",
|
||||||
height: document.documentElement.clientHeight - 94.5 + "px;",
|
height: document.documentElement.clientHeight - 94.5 + "px;",
|
||||||
loading: true
|
loading: true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}, 230);
|
}, 230);
|
||||||
const that = this;
|
const that = this;
|
||||||
window.onresize = function temp() {
|
window.onresize = function temp() {
|
||||||
that.height = document.documentElement.clientHeight - 94.5 + "px;";
|
that.height = document.documentElement.clientHeight - 94.5 + "px;";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -1,210 +1,210 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12" class="card-box">
|
<el-col :span="12" class="card-box">
|
||||||
<el-card>
|
<el-card>
|
||||||
<div slot="header"><span>CPU</span></div>
|
<div slot="header"><span>CPU</span></div>
|
||||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
<div class="el-table el-table--enable-row-hover el-table--medium">
|
||||||
<table cellspacing="0" style="width: 100%;">
|
<table cellspacing="0" style="width: 100%;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="is-leaf"><div class="cell">属性</div></th>
|
<th class="is-leaf"><div class="cell">属性</div></th>
|
||||||
<th class="is-leaf"><div class="cell">值</div></th>
|
<th class="is-leaf"><div class="cell">值</div></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="cell">核心数</div></td>
|
<td><div class="cell">核心数</div></td>
|
||||||
<td><div class="cell" v-if="server.cpu">{{ server.cpu.cpuNum }}</div></td>
|
<td><div class="cell" v-if="server.cpu">{{ server.cpu.cpuNum }}</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="cell">用户使用率</div></td>
|
<td><div class="cell">用户使用率</div></td>
|
||||||
<td><div class="cell" v-if="server.cpu">{{ server.cpu.used }}%</div></td>
|
<td><div class="cell" v-if="server.cpu">{{ server.cpu.used }}%</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="cell">系统使用率</div></td>
|
<td><div class="cell">系统使用率</div></td>
|
||||||
<td><div class="cell" v-if="server.cpu">{{ server.cpu.sys }}%</div></td>
|
<td><div class="cell" v-if="server.cpu">{{ server.cpu.sys }}%</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="cell">当前空闲率</div></td>
|
<td><div class="cell">当前空闲率</div></td>
|
||||||
<td><div class="cell" v-if="server.cpu">{{ server.cpu.free }}%</div></td>
|
<td><div class="cell" v-if="server.cpu">{{ server.cpu.free }}%</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="12" class="card-box">
|
<el-col :span="12" class="card-box">
|
||||||
<el-card>
|
<el-card>
|
||||||
<div slot="header"><span>内存</span></div>
|
<div slot="header"><span>内存</span></div>
|
||||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
<div class="el-table el-table--enable-row-hover el-table--medium">
|
||||||
<table cellspacing="0" style="width: 100%;">
|
<table cellspacing="0" style="width: 100%;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="is-leaf"><div class="cell">属性</div></th>
|
<th class="is-leaf"><div class="cell">属性</div></th>
|
||||||
<th class="is-leaf"><div class="cell">内存</div></th>
|
<th class="is-leaf"><div class="cell">内存</div></th>
|
||||||
<th class="is-leaf"><div class="cell">JVM</div></th>
|
<th class="is-leaf"><div class="cell">JVM</div></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="cell">总内存</div></td>
|
<td><div class="cell">总内存</div></td>
|
||||||
<td><div class="cell" v-if="server.mem">{{ server.mem.total }}G</div></td>
|
<td><div class="cell" v-if="server.mem">{{ server.mem.total }}G</div></td>
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.total }}M</div></td>
|
<td><div class="cell" v-if="server.jvm">{{ server.jvm.total }}M</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="cell">已用内存</div></td>
|
<td><div class="cell">已用内存</div></td>
|
||||||
<td><div class="cell" v-if="server.mem">{{ server.mem.used}}G</div></td>
|
<td><div class="cell" v-if="server.mem">{{ server.mem.used}}G</div></td>
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.used}}M</div></td>
|
<td><div class="cell" v-if="server.jvm">{{ server.jvm.used}}M</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="cell">剩余内存</div></td>
|
<td><div class="cell">剩余内存</div></td>
|
||||||
<td><div class="cell" v-if="server.mem">{{ server.mem.free }}G</div></td>
|
<td><div class="cell" v-if="server.mem">{{ server.mem.free }}G</div></td>
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.free }}M</div></td>
|
<td><div class="cell" v-if="server.jvm">{{ server.jvm.free }}M</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="cell">使用率</div></td>
|
<td><div class="cell">使用率</div></td>
|
||||||
<td><div class="cell" v-if="server.mem" :class="{'text-danger': server.mem.usage > 80}">{{ server.mem.usage }}%</div></td>
|
<td><div class="cell" v-if="server.mem" :class="{'text-danger': server.mem.usage > 80}">{{ server.mem.usage }}%</div></td>
|
||||||
<td><div class="cell" v-if="server.jvm" :class="{'text-danger': server.jvm.usage > 80}">{{ server.jvm.usage }}%</div></td>
|
<td><div class="cell" v-if="server.jvm" :class="{'text-danger': server.jvm.usage > 80}">{{ server.jvm.usage }}%</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="24" class="card-box">
|
<el-col :span="24" class="card-box">
|
||||||
<el-card>
|
<el-card>
|
||||||
<div slot="header">
|
<div slot="header">
|
||||||
<span>服务器信息</span>
|
<span>服务器信息</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
<div class="el-table el-table--enable-row-hover el-table--medium">
|
||||||
<table cellspacing="0" style="width: 100%;">
|
<table cellspacing="0" style="width: 100%;">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="cell">服务器名称</div></td>
|
<td><div class="cell">服务器名称</div></td>
|
||||||
<td><div class="cell" v-if="server.sys">{{ server.sys.computerName }}</div></td>
|
<td><div class="cell" v-if="server.sys">{{ server.sys.computerName }}</div></td>
|
||||||
<td><div class="cell">操作系统</div></td>
|
<td><div class="cell">操作系统</div></td>
|
||||||
<td><div class="cell" v-if="server.sys">{{ server.sys.osName }}</div></td>
|
<td><div class="cell" v-if="server.sys">{{ server.sys.osName }}</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="cell">服务器IP</div></td>
|
<td><div class="cell">服务器IP</div></td>
|
||||||
<td><div class="cell" v-if="server.sys">{{ server.sys.computerIp }}</div></td>
|
<td><div class="cell" v-if="server.sys">{{ server.sys.computerIp }}</div></td>
|
||||||
<td><div class="cell">系统架构</div></td>
|
<td><div class="cell">系统架构</div></td>
|
||||||
<td><div class="cell" v-if="server.sys">{{ server.sys.osArch }}</div></td>
|
<td><div class="cell" v-if="server.sys">{{ server.sys.osArch }}</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="24" class="card-box">
|
<el-col :span="24" class="card-box">
|
||||||
<el-card>
|
<el-card>
|
||||||
<div slot="header">
|
<div slot="header">
|
||||||
<span>Java虚拟机信息</span>
|
<span>Java虚拟机信息</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
<div class="el-table el-table--enable-row-hover el-table--medium">
|
||||||
<table cellspacing="0" style="width: 100%;">
|
<table cellspacing="0" style="width: 100%;">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="cell">Java名称</div></td>
|
<td><div class="cell">Java名称</div></td>
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.name }}</div></td>
|
<td><div class="cell" v-if="server.jvm">{{ server.jvm.name }}</div></td>
|
||||||
<td><div class="cell">Java版本</div></td>
|
<td><div class="cell">Java版本</div></td>
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.version }}</div></td>
|
<td><div class="cell" v-if="server.jvm">{{ server.jvm.version }}</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><div class="cell">启动时间</div></td>
|
<td><div class="cell">启动时间</div></td>
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.startTime }}</div></td>
|
<td><div class="cell" v-if="server.jvm">{{ server.jvm.startTime }}</div></td>
|
||||||
<td><div class="cell">运行时长</div></td>
|
<td><div class="cell">运行时长</div></td>
|
||||||
<td><div class="cell" v-if="server.jvm">{{ server.jvm.runTime }}</div></td>
|
<td><div class="cell" v-if="server.jvm">{{ server.jvm.runTime }}</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1"><div class="cell">安装路径</div></td>
|
<td colspan="1"><div class="cell">安装路径</div></td>
|
||||||
<td colspan="3"><div class="cell" v-if="server.jvm">{{ server.jvm.home }}</div></td>
|
<td colspan="3"><div class="cell" v-if="server.jvm">{{ server.jvm.home }}</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="1"><div class="cell">项目路径</div></td>
|
<td colspan="1"><div class="cell">项目路径</div></td>
|
||||||
<td colspan="3"><div class="cell" v-if="server.sys">{{ server.sys.userDir }}</div></td>
|
<td colspan="3"><div class="cell" v-if="server.sys">{{ server.sys.userDir }}</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="24" class="card-box">
|
<el-col :span="24" class="card-box">
|
||||||
<el-card>
|
<el-card>
|
||||||
<div slot="header">
|
<div slot="header">
|
||||||
<span>磁盘状态</span>
|
<span>磁盘状态</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="el-table el-table--enable-row-hover el-table--medium">
|
<div class="el-table el-table--enable-row-hover el-table--medium">
|
||||||
<table cellspacing="0" style="width: 100%;">
|
<table cellspacing="0" style="width: 100%;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="is-leaf"><div class="cell">盘符路径</div></th>
|
<th class="is-leaf"><div class="cell">盘符路径</div></th>
|
||||||
<th class="is-leaf"><div class="cell">文件系统</div></th>
|
<th class="is-leaf"><div class="cell">文件系统</div></th>
|
||||||
<th class="is-leaf"><div class="cell">盘符类型</div></th>
|
<th class="is-leaf"><div class="cell">盘符类型</div></th>
|
||||||
<th class="is-leaf"><div class="cell">总大小</div></th>
|
<th class="is-leaf"><div class="cell">总大小</div></th>
|
||||||
<th class="is-leaf"><div class="cell">可用大小</div></th>
|
<th class="is-leaf"><div class="cell">可用大小</div></th>
|
||||||
<th class="is-leaf"><div class="cell">已用大小</div></th>
|
<th class="is-leaf"><div class="cell">已用大小</div></th>
|
||||||
<th class="is-leaf"><div class="cell">已用百分比</div></th>
|
<th class="is-leaf"><div class="cell">已用百分比</div></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody v-if="server.sysFiles">
|
<tbody v-if="server.sysFiles">
|
||||||
<tr v-for="sysFile in server.sysFiles">
|
<tr v-for="sysFile in server.sysFiles">
|
||||||
<td><div class="cell">{{ sysFile.dirName }}</div></td>
|
<td><div class="cell">{{ sysFile.dirName }}</div></td>
|
||||||
<td><div class="cell">{{ sysFile.sysTypeName }}</div></td>
|
<td><div class="cell">{{ sysFile.sysTypeName }}</div></td>
|
||||||
<td><div class="cell">{{ sysFile.typeName }}</div></td>
|
<td><div class="cell">{{ sysFile.typeName }}</div></td>
|
||||||
<td><div class="cell">{{ sysFile.total }}</div></td>
|
<td><div class="cell">{{ sysFile.total }}</div></td>
|
||||||
<td><div class="cell">{{ sysFile.free }}</div></td>
|
<td><div class="cell">{{ sysFile.free }}</div></td>
|
||||||
<td><div class="cell">{{ sysFile.used }}</div></td>
|
<td><div class="cell">{{ sysFile.used }}</div></td>
|
||||||
<td><div class="cell" :class="{'text-danger': sysFile.usage > 80}">{{ sysFile.usage }}%</div></td>
|
<td><div class="cell" :class="{'text-danger': sysFile.usage > 80}">{{ sysFile.usage }}%</div></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getServer } from "@/api/monitor/server";
|
import { getServer } from "@/api/monitor/server";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Server",
|
name: "Server",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
// 加载层信息
|
// 加载层信息
|
||||||
loading: [],
|
loading: [],
|
||||||
// 服务器信息
|
// 服务器信息
|
||||||
server: []
|
server: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList();
|
this.getList();
|
||||||
this.openLoading();
|
this.openLoading();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/** 查询服务器信息 */
|
/** 查询服务器信息 */
|
||||||
getList() {
|
getList() {
|
||||||
getServer().then(response => {
|
getServer().then(response => {
|
||||||
this.server = response.data;
|
this.server = response.data;
|
||||||
this.loading.close();
|
this.loading.close();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 打开加载层
|
// 打开加载层
|
||||||
openLoading() {
|
openLoading() {
|
||||||
this.loading = this.$loading({
|
this.loading = this.$loading({
|
||||||
lock: true,
|
lock: true,
|
||||||
text: "拼命读取中",
|
text: "拼命读取中",
|
||||||
spinner: "el-icon-loading",
|
spinner: "el-icon-loading",
|
||||||
background: "rgba(0, 0, 0, 0.7)"
|
background: "rgba(0, 0, 0, 0.7)"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
File diff suppressed because one or more lines are too long
@ -0,0 +1,22 @@
|
|||||||
|
package cn.iocoder.dashboard.framework.quartz.core.util;
|
||||||
|
|
||||||
|
import org.quartz.CronExpression;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quartz Cron 表达式的工具类
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public class CronUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验 CRON 表达式是否有效
|
||||||
|
*
|
||||||
|
* @param cronExpression CRON 表达式
|
||||||
|
* @return 是否有效
|
||||||
|
*/
|
||||||
|
public static boolean isValid(String cronExpression) {
|
||||||
|
return CronExpression.isValidExpression(cronExpression);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue