mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-24 16:05:08 +08:00
1. 完成 Job 的新增和修改
2. 优化代码生成器的模板
This commit is contained in:
@ -89,7 +89,7 @@ public class InfJobController {
|
||||
@PreAuthorize("@ss.hasPermission('infra:job:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportJobExcel(@Valid InfJobExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<InfJobDO> list = jobService.getJobList(exportReqVO);
|
||||
// 导出 Excel
|
||||
List<InfJobExcelVO> datas = InfJobConvert.INSTANCE.convertList02(list);
|
||||
|
@ -2,12 +2,8 @@ package cn.iocoder.dashboard.modules.infra.controller.job.vo.job;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
import static cn.iocoder.dashboard.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 定时任务 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
@ -20,14 +16,6 @@ public class InfJobBaseVO {
|
||||
@NotNull(message = "任务名称不能为空")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "任务状态", required = true, example = "1", notes = "参见 InfJobStatusEnum 枚举")
|
||||
@NotNull(message = "任务状态不能为空")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "处理器的名字", required = true, example = "sysUserSessionTimeoutJob")
|
||||
@NotNull(message = "处理器的名字不能为空")
|
||||
private String handlerName;
|
||||
|
||||
@ApiModelProperty(value = "处理器的参数", example = "yudao")
|
||||
private String handlerParam;
|
||||
|
||||
@ -35,22 +23,6 @@ public class InfJobBaseVO {
|
||||
@NotNull(message = "CRON 表达式不能为空")
|
||||
private String cronExpression;
|
||||
|
||||
@ApiModelProperty(value = "最后一次执行的开始时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date executeBeginTime;
|
||||
|
||||
@ApiModelProperty(value = "最后一次执行的结束时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date executeEndTime;
|
||||
|
||||
@ApiModelProperty(value = "上一次触发时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date firePrevTime;
|
||||
|
||||
@ApiModelProperty(value = "下一次触发时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private Date fireNextTime;
|
||||
|
||||
@ApiModelProperty(value = "监控超时时间", example = "1000")
|
||||
private Integer monitorTimeout;
|
||||
|
||||
|
@ -1,14 +1,21 @@
|
||||
package cn.iocoder.dashboard.modules.infra.controller.job.vo.job;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("定时任务创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class InfJobCreateReqVO extends InfJobBaseVO {
|
||||
|
||||
@ApiModelProperty(value = "处理器的名字", required = true, example = "sysUserSessionTimeoutJob")
|
||||
@NotNull(message = "处理器的名字不能为空")
|
||||
private String handlerName;
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("定时任务 Response VO")
|
||||
@ -17,6 +18,25 @@ public class InfJobRespVO extends InfJobBaseVO {
|
||||
@ApiModelProperty(value = "任务编号", required = true, example = "1024")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "任务状态", required = true, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "处理器的名字", required = true, example = "sysUserSessionTimeoutJob")
|
||||
@NotNull(message = "处理器的名字不能为空")
|
||||
private String handlerName;
|
||||
|
||||
@ApiModelProperty(value = "最后一次执行的开始时间")
|
||||
private Date executeBeginTime;
|
||||
|
||||
@ApiModelProperty(value = "最后一次执行的结束时间")
|
||||
private Date executeEndTime;
|
||||
|
||||
@ApiModelProperty(value = "上一次触发时间")
|
||||
private Date firePrevTime;
|
||||
|
||||
@ApiModelProperty(value = "下一次触发时间")
|
||||
private Date fireNextTime;
|
||||
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
|
@ -80,10 +80,10 @@ public class InfJobDO extends BaseDO {
|
||||
// ========== 监控相关字段 ==========
|
||||
/**
|
||||
* 监控超时时间,单位:毫秒
|
||||
* 为空时,表示不监控
|
||||
*
|
||||
* 注意,这里的超时的目的,不是进行任务的取消,而是告警任务的执行时间过长
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private Integer monitorTimeout;
|
||||
|
||||
// TODO misfirePolicy
|
||||
|
@ -35,6 +35,9 @@ public class InfJobServiceImpl implements InfJobService {
|
||||
public Long createJob(InfJobCreateReqVO createReqVO) {
|
||||
// 插入
|
||||
InfJobDO job = InfJobConvert.INSTANCE.convert(createReqVO);
|
||||
if (job.getMonitorTimeout() == null) {
|
||||
job.setMonitorTimeout(0);
|
||||
}
|
||||
jobMapper.insert(job);
|
||||
// 返回
|
||||
return job.getId();
|
||||
@ -46,6 +49,9 @@ public class InfJobServiceImpl implements InfJobService {
|
||||
this.validateJobExists(updateReqVO.getId());
|
||||
// 更新
|
||||
InfJobDO updateObj = InfJobConvert.INSTANCE.convert(updateReqVO);
|
||||
if (updateObj.getMonitorTimeout() == null) {
|
||||
updateObj.setMonitorTimeout(0);
|
||||
}
|
||||
jobMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,11 @@ import cn.iocoder.dashboard.framework.quartz.core.handler.JobHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 用户 Session 超时 Job
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class SysUserSessionTimeoutJob implements JobHandler {
|
||||
|
@ -6,7 +6,7 @@ import io.swagger.annotations.*;
|
||||
import javax.validation.constraints.*;
|
||||
## 处理 Date 字段的引入
|
||||
#foreach ($column in $columns)
|
||||
#if (${column.createOperation} && ${column.updateOperation} && ${column.listOperationResult})##通用操作
|
||||
#if (${column.createOperation} && ${column.updateOperation} && ${column.listOperationResult}
|
||||
&& ${column.javaType} == "Date")## 时间类型
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
|
@ -218,11 +218,13 @@ export default {
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
#foreach ($column in $columns)## 时间范围
|
||||
#if ($column.listOperation)
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
dateRange${AttrName}: [],
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNo: 1,
|
||||
@ -256,11 +258,13 @@ export default {
|
||||
// 处理查询参数
|
||||
let params = {...this.queryParams};
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.listOperation)
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.addBeginAndEndTime(params, this.dateRange${AttrName}, '${column.javaField}');
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
// 执行查询
|
||||
get${simpleClassName}Page(params).then(response => {
|
||||
this.list = response.data.list;
|
||||
@ -277,12 +281,14 @@ export default {
|
||||
reset() {
|
||||
this.form = {
|
||||
#foreach ($column in $columns)
|
||||
#if($column.htmlType == "checkbox")
|
||||
#if ($column.createOperation || $column.updateOperation)
|
||||
#if ($column.htmlType == "checkbox")
|
||||
$column.javaField: [],
|
||||
#else
|
||||
$column.javaField: undefined,
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
@ -294,11 +300,13 @@ export default {
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.listOperation)
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.dateRange${AttrName} = [];
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
@ -372,11 +380,13 @@ export default {
|
||||
params.pageNo = undefined;
|
||||
params.pageSize = undefined;
|
||||
#foreach ($column in $columns)
|
||||
#if ($column.listOperation)
|
||||
#if ($column.htmlType == "datetime" && $column.listOperationCondition == "BETWEEN")
|
||||
#set ($AttrName = $column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||
this.addBeginAndEndTime(params, this.dateRange${AttrName}, '${column.javaField}');
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
// 执行导出
|
||||
this.$confirm('是否确认导出所有${table.classComment}数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
|
Reference in New Issue
Block a user