209 lines
4.3 KiB
Java
209 lines
4.3 KiB
Java
package com.syzb.common.entity;
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.baomidou.mybatisplus.annotation.IdType;
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
import com.baomidou.mybatisplus.annotation.TableId;
|
|
import com.syzb.common.constant.ScheduleLogResult;
|
|
|
|
import java.io.Serializable;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
|
|
/**
|
|
* <p>
|
|
*
|
|
* </p>
|
|
*
|
|
* @author helloSyzb
|
|
* @since 2022-11-09
|
|
*/
|
|
public class ScheduleLog implements Serializable {
|
|
|
|
|
|
/**
|
|
* 同步记录ID
|
|
*/
|
|
@TableId(value = "id", type = IdType.AUTO)
|
|
private Integer id;
|
|
|
|
/**
|
|
* 服务名
|
|
*/
|
|
@TableField("server_name")
|
|
private String serverName;
|
|
|
|
/**
|
|
* 定时任务名称
|
|
*/
|
|
@TableField("schedule_name")
|
|
private String scheduleName;
|
|
|
|
/**
|
|
* 执行时间
|
|
*/
|
|
private LocalDate date;
|
|
|
|
/**
|
|
* 实际开始时间
|
|
*/
|
|
@TableField("start_time")
|
|
private LocalDateTime startTime;
|
|
|
|
/**
|
|
* 实际结束时间
|
|
*/
|
|
@TableField("end_time")
|
|
private LocalDateTime endTime;
|
|
|
|
/**
|
|
* 执行结果:1:执行中 2:成功 3:失败
|
|
*/
|
|
private Integer result;
|
|
|
|
/**
|
|
* 附加信息json
|
|
*/
|
|
private String ext;
|
|
|
|
/**
|
|
* 异常信息
|
|
*/
|
|
private String error;
|
|
|
|
/**
|
|
* 执行机器IP
|
|
*/
|
|
private String ip;
|
|
|
|
public static ScheduleLog start(String scheduleName, String ip) {
|
|
String server = System.getProperty("server.server");
|
|
ScheduleLog log = new ScheduleLog();
|
|
log.setServerName(server);
|
|
log.setScheduleName(scheduleName);
|
|
log.setDate(LocalDate.now());
|
|
log.setStartTime(LocalDateTime.now());
|
|
log.setResult(ScheduleLogResult.RUNNING.value);
|
|
log.setIp(ip);
|
|
return log;
|
|
}
|
|
|
|
public static ScheduleLog success(Integer id, String ext) {
|
|
ScheduleLog log = new ScheduleLog();
|
|
log.setId(id);
|
|
log.setEndTime(LocalDateTime.now());
|
|
log.setResult(ScheduleLogResult.SUCCESS.value);
|
|
if (StrUtil.isNotEmpty(ext)) {
|
|
log.setExt(ext);
|
|
}
|
|
return log;
|
|
}
|
|
|
|
public static ScheduleLog error(Integer id, String error) {
|
|
ScheduleLog log = new ScheduleLog();
|
|
log.setId(id);
|
|
log.setEndTime(LocalDateTime.now());
|
|
log.setResult(ScheduleLogResult.FAILURE.value);
|
|
if (StrUtil.isNotEmpty(error)) {
|
|
log.setError(error);
|
|
}
|
|
return log;
|
|
}
|
|
|
|
public Integer getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(Integer id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getServerName() {
|
|
return serverName;
|
|
}
|
|
|
|
public void setServerName(String serverName) {
|
|
this.serverName = serverName;
|
|
}
|
|
|
|
public String getScheduleName() {
|
|
return scheduleName;
|
|
}
|
|
|
|
public void setScheduleName(String scheduleName) {
|
|
this.scheduleName = scheduleName;
|
|
}
|
|
|
|
public LocalDate getDate() {
|
|
return date;
|
|
}
|
|
|
|
public void setDate(LocalDate date) {
|
|
this.date = date;
|
|
}
|
|
|
|
public LocalDateTime getStartTime() {
|
|
return startTime;
|
|
}
|
|
|
|
public void setStartTime(LocalDateTime startTime) {
|
|
this.startTime = startTime;
|
|
}
|
|
|
|
public LocalDateTime getEndTime() {
|
|
return endTime;
|
|
}
|
|
|
|
public void setEndTime(LocalDateTime endTime) {
|
|
this.endTime = endTime;
|
|
}
|
|
|
|
public Integer getResult() {
|
|
return result;
|
|
}
|
|
|
|
public void setResult(Integer result) {
|
|
this.result = result;
|
|
}
|
|
|
|
public String getExt() {
|
|
return ext;
|
|
}
|
|
|
|
public void setExt(String ext) {
|
|
this.ext = ext;
|
|
}
|
|
|
|
public String getError() {
|
|
return error;
|
|
}
|
|
|
|
public void setError(String error) {
|
|
this.error = error;
|
|
}
|
|
|
|
public String getIp() {
|
|
return ip;
|
|
}
|
|
|
|
public void setIp(String ip) {
|
|
this.ip = ip;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "ScheduleLog{" +
|
|
"id=" + id +
|
|
", serverName=" + serverName +
|
|
", scheduleName=" + scheduleName +
|
|
", date=" + date +
|
|
", startTime=" + startTime +
|
|
", endTime=" + endTime +
|
|
", result=" + result +
|
|
", ext=" + ext +
|
|
", error=" + error +
|
|
", ip=" + ip +
|
|
"}";
|
|
}
|
|
}
|