mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-18 21:15:06 +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 {
|
||||
|
Reference in New Issue
Block a user