优化定时任务详情页展示&补充执行时间字段

This commit is contained in:
RuoYi
2026-03-21 22:23:32 +08:00
parent af2d446a5f
commit 784fe5c399
8 changed files with 332 additions and 196 deletions

View File

@@ -3,6 +3,7 @@ package com.ruoyi.job.domain;
import java.util.Date; import java.util.Date;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.annotation.Excel; import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity; import com.ruoyi.common.core.web.domain.BaseEntity;
@@ -44,10 +45,12 @@ public class SysJobLog extends BaseEntity
private String exceptionInfo; private String exceptionInfo;
/** 开始时间 */ /** 开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime; private Date startTime;
/** 停止时间 */ /** 结束时间 */
private Date stopTime; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
public Long getJobLogId() public Long getJobLogId()
{ {
@@ -129,14 +132,14 @@ public class SysJobLog extends BaseEntity
this.startTime = startTime; 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 @Override
@@ -149,7 +152,7 @@ public class SysJobLog extends BaseEntity
.append("status", getStatus()) .append("status", getStatus())
.append("exceptionInfo", getExceptionInfo()) .append("exceptionInfo", getExceptionInfo())
.append("startTime", getStartTime()) .append("startTime", getStartTime())
.append("stopTime", getStopTime()) .append("stopTime", getEndTime())
.toString(); .toString();
} }
} }

View File

@@ -76,8 +76,8 @@ public abstract class AbstractQuartzJob implements Job
sysJobLog.setJobGroup(sysJob.getJobGroup()); sysJobLog.setJobGroup(sysJob.getJobGroup());
sysJobLog.setInvokeTarget(sysJob.getInvokeTarget()); sysJobLog.setInvokeTarget(sysJob.getInvokeTarget());
sysJobLog.setStartTime(startTime); sysJobLog.setStartTime(startTime);
sysJobLog.setStopTime(new Date()); sysJobLog.setEndTime(new Date());
long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime(); long runMs = sysJobLog.getEndTime().getTime() - sysJobLog.getStartTime().getTime();
sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒"); sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
if (e != null) if (e != null)
{ {

View File

@@ -12,11 +12,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="jobMessage" column="job_message" /> <result property="jobMessage" column="job_message" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="exceptionInfo" column="exception_info" /> <result property="exceptionInfo" column="exception_info" />
<result property="startTime" column="start_time" />
<result property="endTime" column="end_time" />
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time" />
</resultMap> </resultMap>
<sql id="selectJobLogVo"> <sql id="selectJobLogVo">
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 from sys_job_log
</sql> </sql>
@@ -78,6 +80,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="jobMessage != null and jobMessage != ''">job_message,</if> <if test="jobMessage != null and jobMessage != ''">job_message,</if>
<if test="status != null and status != ''">status,</if> <if test="status != null and status != ''">status,</if>
<if test="exceptionInfo != null and exceptionInfo != ''">exception_info,</if> <if test="exceptionInfo != null and exceptionInfo != ''">exception_info,</if>
<if test="startTime != null">start_time,</if>
<if test="endTime != null">end_time,</if>
create_time create_time
)values( )values(
<if test="jobLogId != null and jobLogId != 0">#{jobLogId},</if> <if test="jobLogId != null and jobLogId != 0">#{jobLogId},</if>
@@ -87,6 +91,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if> <if test="jobMessage != null and jobMessage != ''">#{jobMessage},</if>
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if> <if test="exceptionInfo != null and exceptionInfo != ''">#{exceptionInfo},</if>
<if test="startTime != null">#{startTime},</if>
<if test="endTime != null">#{endTime},</if>
sysdate() sysdate()
) )
</insert> </insert>

View File

@@ -21,7 +21,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectJobVo"> <sql id="selectJobVo">
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 from sys_job
</sql> </sql>

View File

@@ -0,0 +1,197 @@
<template>
<el-dialog :title="type === 'log' ? '调度日志详细' : '任务详细'" :visible.sync="visible" width="780px" append-to-body @close="$emit('update:visible', false)">
<div class="detail-wrap">
<template v-if="type === 'log'">
<!-- 基本信息 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-info"></i> 基本信息</div>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">日志编号</span><span class="detail-value">{{ form.jobLogId }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">执行状态</span>
<el-tag v-if="form.status == 0" type="success" size="small">正常</el-tag>
<el-tag v-else type="danger" size="small">失败</el-tag>
</div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">开始时间</span><span class="detail-value">{{ form.startTime }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item"><span class="detail-label">结束时间</span><span class="detail-value">{{ form.endTime }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">记录时间</span><span class="detail-value">{{ form.createTime }}</span></div>
</el-col>
<el-col :span="12" v-if="form.status == 0 && form.startTime && form.endTime">
<div class="detail-item"><span class="detail-label">执行耗时</span><span class="detail-value">{{ costTime }} 毫秒</span></div>
</el-col>
</el-row>
</div>
<!-- 任务信息 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-time"></i> 任务信息</div>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">任务名称</span><span class="detail-value">{{ form.jobName }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">任务分组</span>
<dict-tag :options="dict.type.sys_job_group" :value="form.jobGroup" />
</div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="24">
<div class="detail-item"><span class="detail-label">日志信息</span><span class="detail-value">{{ form.jobMessage }}</span></div>
</el-col>
</el-row>
</div>
<!-- 调用目标 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-s-operation"></i> 调用目标</div>
<div class="code-body">
<div class="code-wrap"><pre class="code-pre">{{ form.invokeTarget || '(无)' }}</pre></div>
</div>
</div>
<!-- 异常信息 -->
<div class="detail-card" v-if="form.status == 1">
<div class="detail-card-title error-title"><i class="el-icon-warning"></i> 异常信息</div>
<div class="error-body"><div class="error-msg">{{ form.exceptionInfo }}</div></div>
</div>
</template>
<template v-else>
<!-- 任务配置 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-setting"></i> 任务配置</div>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">任务编号</span><span class="detail-value">{{ form.jobId }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item"><span class="detail-label">任务名称</span><span class="detail-value">{{ form.jobName }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">任务分组</span>
<dict-tag :options="dict.type.sys_job_group" :value="form.jobGroup" />
</div>
</el-col>
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">执行状态</span>
<el-tag v-if="form.status == 0" type="success" size="small">正常</el-tag>
<el-tag v-else type="info" size="small">暂停</el-tag>
</div>
</el-col>
</el-row>
</div>
<!-- 调度信息 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-date"></i> 调度信息</div>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">cron 表达式</span><span class="detail-value mono">{{ form.cronExpression }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item"><span class="detail-label">下次执行时间</span><span class="detail-value">{{ parseTime(form.nextValidTime) }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">执行策略</span>
<el-tag v-if="form.misfirePolicy == 0" type="info" size="small">默认策略</el-tag>
<el-tag v-else-if="form.misfirePolicy == 1" type="warning" size="small">立即执行</el-tag>
<el-tag v-else-if="form.misfirePolicy == 2" type="primary" size="small">执行一次</el-tag>
<el-tag v-else-if="form.misfirePolicy == 3" type="danger" size="small">放弃执行</el-tag>
</div>
</el-col>
<el-col :span="12">
<div class="detail-item">
<span class="detail-label">并发执行</span>
<el-tag v-if="form.concurrent == 0" type="success" size="small">允许</el-tag>
<el-tag v-else type="danger" size="small">禁止</el-tag>
</div>
</el-col>
</el-row>
</div>
<!-- 执行方法 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-s-operation"></i> 执行方法</div>
<div class="code-body">
<div class="code-wrap"><pre class="code-pre">{{ form.invokeTarget || '(无)' }}</pre></div>
</div>
</div>
<!-- 元信息 -->
<div class="detail-card">
<div class="detail-card-title"><i class="el-icon-document"></i> 元信息</div>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">创建人</span><span class="detail-value">{{ form.createBy || '-' }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item"><span class="detail-label">创建时间</span><span class="detail-value">{{ form.createTime }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row">
<el-col :span="12">
<div class="detail-item"><span class="detail-label">更新人</span><span class="detail-value">{{ form.updateBy || '-' }}</span></div>
</el-col>
<el-col :span="12">
<div class="detail-item"><span class="detail-label">更新时间</span><span class="detail-value">{{ form.updateTime || '-' }}</span></div>
</el-col>
</el-row>
<el-row class="detail-row" v-if="form.remark">
<el-col :span="24">
<div class="detail-item"><span class="detail-label">备注</span><span class="detail-value">{{ form.remark }}</span></div>
</el-col>
</el-row>
</div>
</template>
</div>
</el-dialog>
</template>
<script>
export default {
dicts: ['sys_job_group'],
props: {
visible: { type: Boolean, default: false },
row: { type: Object, default: () => ({}) },
// 'job' 任务详细 | 'log' 调度日志详细
type: { type: String, default: 'job' }
},
computed: {
form() { return this.row || {} },
costTime() {
if (!this.form.startTime || !this.form.endTime) return 0
return new Date(this.form.endTime).getTime() - new Date(this.form.startTime).getTime()
}
}
}
</script>
<style scoped>
.detail-label {
width: 80px;
}
</style>

View File

@@ -94,7 +94,11 @@
<el-table v-loading="loading" :data="jobList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="jobList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="任务编号" width="100" align="center" prop="jobId" /> <el-table-column label="任务编号" width="100" align="center" prop="jobId" />
<el-table-column label="任务名称" align="center" prop="jobName" :show-overflow-tooltip="true" /> <el-table-column label="任务名称" align="center" :show-overflow-tooltip="true">
<template slot-scope="scope">
<a class="link-type" style="cursor:pointer" @click="handleView(scope.row)">{{ scope.row.jobName }}</a>
</template>
</el-table-column>
<el-table-column label="任务组名" align="center" prop="jobGroup"> <el-table-column label="任务组名" align="center" prop="jobGroup">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.sys_job_group" :value="scope.row.jobGroup"/> <dict-tag :options="dict.type.sys_job_group" :value="scope.row.jobGroup"/>
@@ -133,8 +137,6 @@
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleRun" icon="el-icon-caret-right" <el-dropdown-item command="handleRun" icon="el-icon-caret-right"
v-hasPermi="['monitor:job:changeStatus']">执行一次</el-dropdown-item> v-hasPermi="['monitor:job:changeStatus']">执行一次</el-dropdown-item>
<el-dropdown-item command="handleView" icon="el-icon-view"
v-hasPermi="['monitor:job:query']">任务详细</el-dropdown-item>
<el-dropdown-item command="handleJobLog" icon="el-icon-s-operation" <el-dropdown-item command="handleJobLog" icon="el-icon-s-operation"
v-hasPermi="['monitor:job:query']">调度日志</el-dropdown-item> v-hasPermi="['monitor:job:query']">调度日志</el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
@@ -241,61 +243,17 @@
</el-dialog> </el-dialog>
<!-- 任务日志详细 --> <!-- 任务日志详细 -->
<el-dialog title="任务详细" :visible.sync="openView" width="700px" append-to-body> <job-detail :visible.sync="openView" :row="form" type="job" />
<el-form ref="form" :model="form" label-width="120px" size="mini">
<el-row>
<el-col :span="12">
<el-form-item label="任务编号:">{{ form.jobId }}</el-form-item>
<el-form-item label="任务名称:">{{ form.jobName }}</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="任务分组:">{{ jobGroupFormat(form) }}</el-form-item>
<el-form-item label="创建时间:">{{ form.createTime }}</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="cron表达式">{{ form.cronExpression }}</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="下次执行时间:">{{ parseTime(form.nextValidTime) }}</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="调用目标方法:">{{ form.invokeTarget }}</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="任务状态:">
<div v-if="form.status == 0">正常</div>
<div v-else-if="form.status == 1">暂停</div>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="是否并发:">
<div v-if="form.concurrent == 0">允许</div>
<div v-else-if="form.concurrent == 1">禁止</div>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="执行策略:">
<div v-if="form.misfirePolicy == 0">默认策略</div>
<div v-else-if="form.misfirePolicy == 1">立即执行</div>
<div v-else-if="form.misfirePolicy == 2">执行一次</div>
<div v-else-if="form.misfirePolicy == 3">放弃执行</div>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="openView = false"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listJob, getJob, delJob, addJob, updateJob, runJob, changeJobStatus } from "@/api/monitor/job"; import { listJob, getJob, delJob, addJob, updateJob, runJob, changeJobStatus } from "@/api/monitor/job"
import JobDetail from './detail'
import Crontab from '@/components/Crontab' import Crontab from '@/components/Crontab'
export default { export default {
components: { Crontab }, components: { Crontab, JobDetail },
name: "Job", name: "Job",
dicts: ['sys_job_group', 'sys_job_status'], dicts: ['sys_job_group', 'sys_job_status'],
data() { data() {
@@ -346,29 +304,29 @@ export default {
{ required: true, message: "cron执行表达式不能为空", trigger: "blur" } { required: true, message: "cron执行表达式不能为空", trigger: "blur" }
] ]
} }
}; }
}, },
created() { created() {
this.getList(); this.getList()
}, },
methods: { methods: {
/** 查询定时任务列表 */ /** 查询定时任务列表 */
getList() { getList() {
this.loading = true; this.loading = true
listJob(this.queryParams).then(response => { listJob(this.queryParams).then(response => {
this.jobList = response.rows; this.jobList = response.rows
this.total = response.total; this.total = response.total
this.loading = false; this.loading = false
}); })
}, },
// 任务组名字典翻译 // 任务组名字典翻译
jobGroupFormat(row, column) { jobGroupFormat(row, column) {
return this.selectDictLabel(this.dict.type.sys_job_group, row.jobGroup); return this.selectDictLabel(this.dict.type.sys_job_group, row.jobGroup)
}, },
// 取消按钮 // 取消按钮
cancel() { cancel() {
this.open = false; this.open = false
this.reset(); this.reset()
}, },
// 表单重置 // 表单重置
reset() { reset() {
@@ -381,96 +339,96 @@ export default {
misfirePolicy: 1, misfirePolicy: 1,
concurrent: 1, concurrent: 1,
status: "0" status: "0"
}; }
this.resetForm("form"); this.resetForm("form")
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1
this.getList(); this.getList()
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm"); this.resetForm("queryForm")
this.handleQuery(); this.handleQuery()
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.jobId); this.ids = selection.map(item => item.jobId)
this.single = selection.length != 1; this.single = selection.length != 1
this.multiple = !selection.length; this.multiple = !selection.length
}, },
// 更多操作触发 // 更多操作触发
handleCommand(command, row) { handleCommand(command, row) {
switch (command) { switch (command) {
case "handleRun": case "handleRun":
this.handleRun(row); this.handleRun(row)
break; break
case "handleView": case "handleView":
this.handleView(row); this.handleView(row)
break; break
case "handleJobLog": case "handleJobLog":
this.handleJobLog(row); this.handleJobLog(row)
break; break
default: default:
break; break
} }
}, },
// 任务状态修改 // 任务状态修改
handleStatusChange(row) { handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用"; let text = row.status === "0" ? "启用" : "停用"
this.$modal.confirm('确认要"' + text + '""' + row.jobName + '"任务吗?').then(function() { this.$modal.confirm('确认要"' + text + '""' + row.jobName + '"任务吗?').then(function() {
return changeJobStatus(row.jobId, row.status); return changeJobStatus(row.jobId, row.status)
}).then(() => { }).then(() => {
this.$modal.msgSuccess(text + "成功"); this.$modal.msgSuccess(text + "成功")
}).catch(function() { }).catch(function() {
row.status = row.status === "0" ? "1" : "0"; row.status = row.status === "0" ? "1" : "0"
}); })
}, },
/* 立即执行一次 */ /* 立即执行一次 */
handleRun(row) { handleRun(row) {
this.$modal.confirm('确认要立即执行一次"' + row.jobName + '"任务吗?').then(function() { this.$modal.confirm('确认要立即执行一次"' + row.jobName + '"任务吗?').then(function() {
return runJob(row.jobId, row.jobGroup); return runJob(row.jobId, row.jobGroup)
}).then(() => { }).then(() => {
this.$modal.msgSuccess("执行成功"); this.$modal.msgSuccess("执行成功")
}).catch(() => {}); }).catch(() => {})
}, },
/** 任务详细信息 */ /** 任务详细信息 */
handleView(row) { handleView(row) {
getJob(row.jobId).then(response => { getJob(row.jobId).then(response => {
this.form = response.data; this.form = response.data
this.openView = true; this.openView = true
}); })
}, },
/** cron表达式按钮操作 */ /** cron表达式按钮操作 */
handleShowCron() { handleShowCron() {
this.expression = this.form.cronExpression; this.expression = this.form.cronExpression
this.openCron = true; this.openCron = true
}, },
/** 确定后回传值 */ /** 确定后回传值 */
crontabFill(value) { crontabFill(value) {
this.form.cronExpression = value; this.form.cronExpression = value
}, },
/** 任务日志列表查询 */ /** 任务日志列表查询 */
handleJobLog(row) { handleJobLog(row) {
const jobId = row.jobId || 0; const jobId = row.jobId || 0
this.$router.push('/monitor/job-log/index/' + jobId) this.$router.push('/monitor/job-log/index/' + jobId)
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset(); this.reset()
this.open = true; this.open = true
this.title = "添加任务"; this.title = "添加任务"
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset()
const jobId = row.jobId || this.ids; const jobId = row.jobId || this.ids
getJob(jobId).then(response => { getJob(jobId).then(response => {
this.form = response.data; this.form = response.data
this.open = true; this.open = true
this.title = "修改任务"; this.title = "修改任务"
}); })
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm: function() { submitForm: function() {
@@ -478,29 +436,29 @@ export default {
if (valid) { if (valid) {
if (this.form.jobId != undefined) { if (this.form.jobId != undefined) {
updateJob(this.form).then(() => { updateJob(this.form).then(() => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功")
this.open = false; this.open = false
this.getList(); this.getList()
}); })
} else { } else {
addJob(this.form).then(() => { addJob(this.form).then(() => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功")
this.open = false; this.open = false
this.getList(); this.getList()
}); })
} }
} }
}); })
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const jobIds = row.jobId || this.ids; const jobIds = row.jobId || this.ids
this.$modal.confirm('是否确认删除定时任务编号为"' + jobIds + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除定时任务编号为"' + jobIds + '"的数据项?').then(function() {
return delJob(jobIds); return delJob(jobIds)
}).then(() => { }).then(() => {
this.getList(); this.getList()
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功")
}).catch(() => {}); }).catch(() => {})
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
@@ -509,5 +467,5 @@ export default {
}, `job_${new Date().getTime()}.xlsx`) }, `job_${new Date().getTime()}.xlsx`)
} }
} }
}; }
</script> </script>

View File

@@ -143,48 +143,18 @@
@pagination="getList" @pagination="getList"
/> />
<!-- 调度日志详细 --> <job-log-detail :visible.sync="open" :row="form" type="log" />
<el-dialog title="调度日志详细" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" label-width="100px" size="mini">
<el-row>
<el-col :span="12">
<el-form-item label="日志序号:">{{ form.jobLogId }}</el-form-item>
<el-form-item label="任务名称:">{{ form.jobName }}</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="任务分组:">{{ form.jobGroup }}</el-form-item>
<el-form-item label="执行时间:">{{ form.createTime }}</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="调用方法:">{{ form.invokeTarget }}</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="日志信息:">{{ form.jobMessage }}</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="执行状态:">
<div v-if="form.status == 0">正常</div>
<div v-else-if="form.status == 1">失败</div>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="异常信息:" v-if="form.status == 1">{{ form.exceptionInfo }}</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="open = false"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { getJob} from "@/api/monitor/job"; import { getJob} from "@/api/monitor/job"
import { listJobLog, delJobLog, cleanJobLog } from "@/api/monitor/jobLog"; import { listJobLog, delJobLog, cleanJobLog } from "@/api/monitor/jobLog"
import JobLogDetail from './detail'
export default { export default {
name: "JobLog", name: "JobLog",
components: { JobLogDetail },
dicts: ['sys_common_status', 'sys_job_group'], dicts: ['sys_common_status', 'sys_job_group'],
data() { data() {
return { return {
@@ -214,75 +184,75 @@ export default {
jobGroup: undefined, jobGroup: undefined,
status: undefined status: undefined
} }
}; }
}, },
created() { created() {
const jobId = this.$route.params && this.$route.params.jobId; const jobId = this.$route.params && this.$route.params.jobId
if (jobId !== undefined && jobId != 0) { if (jobId !== undefined && jobId != 0) {
getJob(jobId).then(response => { getJob(jobId).then(response => {
this.queryParams.jobName = response.data.jobName; this.queryParams.jobName = response.data.jobName
this.queryParams.jobGroup = response.data.jobGroup; this.queryParams.jobGroup = response.data.jobGroup
this.getList(); this.getList()
}); })
} else { } else {
this.getList(); this.getList()
} }
}, },
methods: { methods: {
/** 查询调度日志列表 */ /** 查询调度日志列表 */
getList() { getList() {
this.loading = true; this.loading = true
listJobLog(this.addDateRange(this.queryParams, this.dateRange)).then(response => { listJobLog(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.jobLogList = response.rows; this.jobLogList = response.rows
this.total = response.total; this.total = response.total
this.loading = false; this.loading = false
} }
); )
}, },
// 返回按钮 // 返回按钮
handleClose() { handleClose() {
const obj = { path: "/monitor/job" }; const obj = { path: "/monitor/job" }
this.$tab.closeOpenPage(obj); this.$tab.closeOpenPage(obj)
}, },
/** 搜索按钮操作 */ /** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1; this.queryParams.pageNum = 1
this.getList(); this.getList()
}, },
/** 重置按钮操作 */ /** 重置按钮操作 */
resetQuery() { resetQuery() {
this.dateRange = []; this.dateRange = []
this.resetForm("queryForm"); this.resetForm("queryForm")
this.handleQuery(); this.handleQuery()
}, },
// 多选框选中数据 // 多选框选中数据
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.jobLogId); this.ids = selection.map(item => item.jobLogId)
this.multiple = !selection.length; this.multiple = !selection.length
}, },
/** 详细按钮操作 */ /** 详细按钮操作 */
handleView(row) { handleView(row) {
this.open = true; this.open = true
this.form = row; this.form = row
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const jobLogIds = this.ids; const jobLogIds = this.ids
this.$modal.confirm('是否确认删除调度日志编号为"' + jobLogIds + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除调度日志编号为"' + jobLogIds + '"的数据项?').then(function() {
return delJobLog(jobLogIds); return delJobLog(jobLogIds)
}).then(() => { }).then(() => {
this.getList(); this.getList()
this.$modal.msgSuccess("删除成功"); this.$modal.msgSuccess("删除成功")
}).catch(() => {}); }).catch(() => {})
}, },
/** 清空按钮操作 */ /** 清空按钮操作 */
handleClean() { handleClean() {
this.$modal.confirm('是否确认清空所有调度日志数据项?').then(function() { this.$modal.confirm('是否确认清空所有调度日志数据项?').then(function() {
return cleanJobLog(); return cleanJobLog()
}).then(() => { }).then(() => {
this.getList(); this.getList()
this.$modal.msgSuccess("清空成功"); this.$modal.msgSuccess("清空成功")
}).catch(() => {}); }).catch(() => {})
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
@@ -291,5 +261,5 @@ export default {
}, `log_${new Date().getTime()}.xlsx`) }, `log_${new Date().getTime()}.xlsx`)
} }
} }
}; }
</script> </script>

View File

@@ -609,6 +609,8 @@ create table sys_job_log (
job_message varchar(500) comment '日志信息', job_message varchar(500) comment '日志信息',
status char(1) default '0' comment '执行状态0正常 1失败', status char(1) default '0' comment '执行状态0正常 1失败',
exception_info varchar(2000) default '' comment '异常信息', exception_info varchar(2000) default '' comment '异常信息',
start_time datetime comment '执行开始时间',
end_time datetime comment '执行结束时间',
create_time datetime comment '创建时间', create_time datetime comment '创建时间',
primary key (job_log_id) primary key (job_log_id)
) engine=innodb comment = '定时任务调度日志表'; ) engine=innodb comment = '定时任务调度日志表';