diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java index 63c4cd69..c1a1a086 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java @@ -3,6 +3,7 @@ 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.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; @@ -44,10 +45,12 @@ public class SysJobLog extends BaseEntity private String exceptionInfo; /** 开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date startTime; - /** 停止时间 */ - private Date stopTime; + /** 结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date endTime; public Long getJobLogId() { @@ -129,14 +132,14 @@ public class SysJobLog extends BaseEntity this.startTime = startTime; } - public Date getStopTime() + public Date getEndTime() { - return stopTime; + return endTime; } - public void setStopTime(Date stopTime) + public void setEndTime(Date endTime) { - this.stopTime = stopTime; + this.endTime = endTime; } @Override @@ -149,7 +152,7 @@ public class SysJobLog extends BaseEntity .append("status", getStatus()) .append("exceptionInfo", getExceptionInfo()) .append("startTime", getStartTime()) - .append("stopTime", getStopTime()) + .append("stopTime", getEndTime()) .toString(); } } diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java index 39eddcb2..a3f51627 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java @@ -65,7 +65,7 @@ public abstract class AbstractQuartzJob implements Job * 执行后 * * @param context 工作执行上下文对象 - * @param sysJob 系统计划任务 + * @param sysScheduleJob 系统计划任务 */ protected void after(JobExecutionContext context, SysJob sysJob, Exception e) { @@ -77,8 +77,8 @@ public abstract class AbstractQuartzJob implements Job sysJobLog.setJobGroup(sysJob.getJobGroup()); sysJobLog.setInvokeTarget(sysJob.getInvokeTarget()); sysJobLog.setStartTime(startTime); - sysJobLog.setStopTime(new Date()); - long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime(); + sysJobLog.setEndTime(new Date()); + long runMs = sysJobLog.getEndTime().getTime() - sysJobLog.getStartTime().getTime(); sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒"); if (e != null) { diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml index 5ed72647..9864be77 100644 --- a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml @@ -12,11 +12,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + - select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time + select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, start_time, end_time, create_time from sys_job_log @@ -78,6 +80,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" job_message, status, exception_info, + start_time, + end_time, create_time )values( #{jobLogId}, @@ -87,6 +91,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{jobMessage}, #{status}, #{exceptionInfo}, + #{startTime}, + #{endTime}, sysdate() ) diff --git a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml index 69233bdf..e13034da 100644 --- a/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml @@ -21,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark + select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, update_by, update_time, remark from sys_job diff --git a/ruoyi-ui/src/assets/styles/ruoyi.scss b/ruoyi-ui/src/assets/styles/ruoyi.scss index 19e463d4..3d873135 100644 --- a/ruoyi-ui/src/assets/styles/ruoyi.scss +++ b/ruoyi-ui/src/assets/styles/ruoyi.scss @@ -81,6 +81,10 @@ margin-top: 6vh !important; } +.el-dialog__body { + padding: 8px 20px !important; +} + .el-dialog__wrapper.scrollbar .el-dialog .el-dialog__body { overflow: auto; overflow-x: hidden; @@ -268,6 +272,74 @@ .detail-value { color: #303133; flex: 1; word-break: break-all; } .detail-location { color: #999; font-size: 12px; } +.method-tag { + display: inline-block; + padding: 1px 7px; + border-radius: 3px; + font-size: 11px; + font-weight: 700; + margin-right: 6px; + vertical-align: middle; +} +.mono { font-family: Consolas, 'SFMono-Regular', monospace; font-size: 12px; } +.code-body { padding: 14px; } +.code-wrap { + background: #f7f9fb; + border: 1px solid #e8ecf0; + border-radius: 4px; + overflow: hidden; + max-height: 260px; + position: relative; +} +.code-action { + position: absolute; + top: 8px; + right: 8px; + z-index: 10; + margin: 0; + padding: 0; +} +.code-action .el-button { + height: 24px; + font-size: 12px; + padding: 4px 8px; + background: rgba(255, 255, 255, 0.9); + border: 1px solid #dcdcdc; +} +.code-action .el-button:hover { + background: #ffffff; + border-color: #409EFF; +} +.code-pre { + margin: 0; + padding: 12px 14px; + font-size: 12px; + line-height: 1.6; + font-family: Consolas, 'SFMono-Regular', monospace; + color: #444; + white-space: pre-wrap; + word-break: break-all; + overflow: auto; + max-height: 240px; + display: block; +} + +/* error */ +.error-title { color: #c0392b !important; } +.error-title i { color: #c0392b !important; } +.error-body { padding: 12px 16px; } +.error-msg { + background: #fff8f8; + border-left: 3px solid #e74c3c; + border-radius: 3px; + padding: 8px 12px; + color: #c0392b; + font-size: 12px; + line-height: 1.7; + word-break: break-all; + white-space: pre-wrap; +} + /* http method */ .method-GET { background: #e8f5e9; color: #27ae60; } .method-POST { background: #e3f2fd; color: #1565c0; } diff --git a/ruoyi-ui/src/views/monitor/job/detail.vue b/ruoyi-ui/src/views/monitor/job/detail.vue new file mode 100644 index 00000000..6ddca242 --- /dev/null +++ b/ruoyi-ui/src/views/monitor/job/detail.vue @@ -0,0 +1,197 @@ + + + + + + + + 基本信息 + + + 日志编号{{ form.jobLogId }} + + + + 执行状态 + 正常 + 失败 + + + + + + 开始时间{{ form.startTime }} + + + 结束时间{{ form.endTime }} + + + + + 记录时间{{ form.createTime }} + + + 执行耗时{{ costTime }} 毫秒 + + + + + + + 任务信息 + + + 任务名称{{ form.jobName }} + + + + 任务分组 + + + + + + + 日志信息{{ form.jobMessage }} + + + + + + + 调用目标 + + {{ form.invokeTarget || '(无)' }} + + + + + + 异常信息 + {{ form.exceptionInfo }} + + + + + + + + 任务配置 + + + 任务编号{{ form.jobId }} + + + 任务名称{{ form.jobName }} + + + + + + 任务分组 + + + + + + 执行状态 + 正常 + 暂停 + + + + + + + + 调度信息 + + + cron 表达式{{ form.cronExpression }} + + + 下次执行时间{{ parseTime(form.nextValidTime) }} + + + + + + 执行策略 + 默认策略 + 立即执行 + 执行一次 + 放弃执行 + + + + + 并发执行 + 允许 + 禁止 + + + + + + + + 执行方法 + + {{ form.invokeTarget || '(无)' }} + + + + + + 元信息 + + + 创建人{{ form.createBy || '-' }} + + + 创建时间{{ form.createTime }} + + + + + 更新人{{ form.updateBy || '-' }} + + + 更新时间{{ form.updateTime || '-' }} + + + + + 备注{{ form.remark }} + + + + + + + + + + + diff --git a/ruoyi-ui/src/views/monitor/job/index.vue b/ruoyi-ui/src/views/monitor/job/index.vue index 093e41b4..92b8bb69 100644 --- a/ruoyi-ui/src/views/monitor/job/index.vue +++ b/ruoyi-ui/src/views/monitor/job/index.vue @@ -241,61 +241,17 @@ - - - - - {{ form.jobId }} - {{ form.jobName }} - - - {{ jobGroupFormat(form) }} - {{ form.createTime }} - - - {{ form.cronExpression }} - - - {{ parseTime(form.nextValidTime) }} - - - {{ form.invokeTarget }} - - - - 正常 - 暂停 - - - - - 允许 - 禁止 - - - - - 默认策略 - 立即执行 - 执行一次 - 放弃执行 - - - - - - + - - \ No newline at end of file diff --git a/sql/ry_20260320.sql b/sql/ry_20260320.sql index 0084d674..b191e7cf 100644 --- a/sql/ry_20260320.sql +++ b/sql/ry_20260320.sql @@ -613,6 +613,8 @@ create table sys_job_log ( job_message varchar(500) comment '日志信息', status char(1) default '0' comment '执行状态(0正常 1失败)', exception_info varchar(2000) default '' comment '异常信息', + start_time datetime comment '执行开始时间', + end_time datetime comment '执行结束时间', create_time datetime comment '创建时间', primary key (job_log_id) ) engine=innodb comment = '定时任务调度日志表';
{{ form.invokeTarget || '(无)' }}