24 changed files with 2845 additions and 842 deletions
@ -0,0 +1,107 @@ |
|||
package com.ccsens.scheduler.bean.dto; |
|||
|
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.ccsens.scheduler.util.Constant; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
import org.quartz.Job; |
|||
import org.quartz.JobDataMap; |
|||
import org.quartz.JobExecutionContext; |
|||
import org.springframework.util.ClassUtils; |
|||
|
|||
import javax.validation.constraints.NotEmpty; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/6/30 16:00 |
|||
*/ |
|||
@Data |
|||
public class QuartzJob { |
|||
|
|||
@Data |
|||
@ApiModel("任务") |
|||
public static class Job{ |
|||
@NotEmpty |
|||
@ApiModelProperty("job名称") |
|||
private String jobName; |
|||
@ApiModelProperty("job组名") |
|||
private String jobGroupName = Constant.Quartz.QZ_JOB_GROUP_NAME; |
|||
@NotEmpty |
|||
@ApiModelProperty("定时器名称") |
|||
private String triggerName; |
|||
@ApiModelProperty("定时器组名") |
|||
private String triggerGroupName = Constant.Quartz.QZ_TRIGGER_GROUP_NAME; |
|||
@ApiModelProperty("触发器开始时间") |
|||
private long startTime; |
|||
@ApiModelProperty("触发器结束时间") |
|||
private long endTime; |
|||
@ApiModelProperty("执行定时任务的具体操作") |
|||
private byte job = 0; |
|||
@ApiModelProperty("自动迁移 0:不自动迁移 1:自动迁移") |
|||
private byte autoMove = 1; |
|||
@NotEmpty |
|||
@ApiModelProperty("cron表达式") |
|||
private String cron; |
|||
@ApiModelProperty("misfire对应的处理规则") |
|||
private String misfirePolicy = "withMisfireHandlingInstructionDoNothing"; |
|||
@ApiModelProperty("job的附加信息") |
|||
private JobDataMap jobDataMap = new JobDataMap(); |
|||
/** |
|||
* 校验 |
|||
* @return |
|||
*/ |
|||
public boolean verify(){ |
|||
return !(StrUtil.isEmpty(jobName) |
|||
|| StrUtil.isEmpty(jobGroupName) |
|||
|| StrUtil.isEmpty(triggerName) |
|||
|| StrUtil.isEmpty(triggerGroupName) |
|||
|| StrUtil.isEmpty(cron) |
|||
|| !ClassUtils.hasMethod(Job.class, "execute", JobExecutionContext.class) |
|||
); |
|||
} |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("任务名称") |
|||
public static class Update { |
|||
@ApiModelProperty("定时器名称") |
|||
private String triggerName; |
|||
@ApiModelProperty("定时器组名") |
|||
private String triggerGroupName = Constant.Quartz.QZ_TRIGGER_GROUP_NAME; |
|||
@ApiModelProperty("表达式") |
|||
private String cron; |
|||
@ApiModelProperty("misfire对应的处理规则") |
|||
private String misfirePolicy = "withMisfireHandlingInstructionDoNothing"; |
|||
@ApiModelProperty("触发器开始时间") |
|||
private long startTime; |
|||
@ApiModelProperty("触发器结束时间") |
|||
private long endTime; |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("任务名称") |
|||
public static class Name{ |
|||
@ApiModelProperty("任务名") |
|||
private String jobName; |
|||
@ApiModelProperty("job组名") |
|||
private String jobGroupName = Constant.Quartz.QZ_JOB_GROUP_NAME; |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("删除任务") |
|||
public static class Del{ |
|||
@ApiModelProperty("任务名") |
|||
private String jobName; |
|||
@ApiModelProperty("job组名") |
|||
private String jobGroupName = Constant.Quartz.QZ_JOB_GROUP_NAME; |
|||
@ApiModelProperty("定时器名称") |
|||
private String triggerName; |
|||
@ApiModelProperty("定时器组名") |
|||
private String triggerGroupName = Constant.Quartz.QZ_TRIGGER_GROUP_NAME; |
|||
} |
|||
|
|||
} |
@ -1,77 +0,0 @@ |
|||
package com.ccsens.scheduler.bean.dto; |
|||
|
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.ccsens.scheduler.util.Constant; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import lombok.Data; |
|||
import org.quartz.Job; |
|||
import org.quartz.JobDataMap; |
|||
import org.quartz.JobExecutionContext; |
|||
import org.springframework.util.ClassUtils; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/6/30 16:00 |
|||
*/ |
|||
@Data |
|||
public class QuartzJobModule { |
|||
/** |
|||
* 触发器开始时间 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
private Date startTime; |
|||
/** |
|||
* 触发器结束时间 |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
private Date endTime; |
|||
/** |
|||
* job名称 |
|||
*/ |
|||
private String jobName; |
|||
/** |
|||
* job组名 |
|||
*/ |
|||
private String jobGroupName = Constant.Quartz.QZ_JOB_GROUP_NAME; |
|||
/** |
|||
* 定时器名称 |
|||
*/ |
|||
private String triggerName; |
|||
/** |
|||
* 定时器组名 |
|||
*/ |
|||
private String triggerGroupName = Constant.Quartz.QZ_TRIGGER_GROUP_NAME; |
|||
/** |
|||
* 执行定时任务的具体操作 |
|||
*/ |
|||
private String jobClass; |
|||
/** |
|||
* cron表达式 |
|||
*/ |
|||
private String cron; |
|||
/** |
|||
* misfire对应的处理规则 |
|||
*/ |
|||
private String misfirePolicy = "withMisfireHandlingInstructionDoNothing"; |
|||
/** |
|||
* job的附加信息 |
|||
*/ |
|||
private JobDataMap jobDataMap = new JobDataMap(); |
|||
/** |
|||
* 校验 |
|||
* @return |
|||
*/ |
|||
public boolean verify(){ |
|||
return !(StrUtil.isEmpty(jobName) |
|||
|| StrUtil.isEmpty(jobGroupName) |
|||
|| StrUtil.isEmpty(triggerName) |
|||
|| StrUtil.isEmpty(triggerGroupName) |
|||
|| StrUtil.isEmpty(cron) |
|||
|| !ClassUtils.hasMethod(Job.class, "execute", JobExecutionContext.class) |
|||
); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.ccsens.scheduler.bean.dto; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.Valid; |
|||
|
|||
/** |
|||
* @program: ptpro |
|||
* @description: 编辑病人信息 |
|||
* @author: wu huijuan |
|||
* @create: 2019/10/30 14:33 |
|||
*/ |
|||
@ApiModel |
|||
@Data |
|||
public class QueryDto<T> { |
|||
@ApiModelProperty("真正的请求参数") |
|||
@Valid |
|||
private T param; |
|||
@ApiModelProperty("登录用户ID 前端不为userId赋值") |
|||
private Long userId; |
|||
@ApiModelProperty("用户名") |
|||
private String userName; |
|||
@ApiModelProperty("头像") |
|||
private String avatarUrl; |
|||
} |
@ -0,0 +1,216 @@ |
|||
package com.ccsens.scheduler.bean.po; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
public class Task implements Serializable { |
|||
private Long id; |
|||
|
|||
private String jobName; |
|||
|
|||
private String jobGroupName; |
|||
|
|||
private String triggerName; |
|||
|
|||
private String triggerGroupName; |
|||
|
|||
private String cron; |
|||
|
|||
private String misfirePolicy; |
|||
|
|||
private Byte job; |
|||
|
|||
private Long startTime; |
|||
|
|||
private Long endTime; |
|||
|
|||
private Byte autoMove; |
|||
|
|||
private Byte notifyWay; |
|||
|
|||
private String notifyUrl; |
|||
|
|||
private String notifyParam; |
|||
|
|||
private Long appId; |
|||
|
|||
private Date createdAt; |
|||
|
|||
private Date updatedAt; |
|||
|
|||
private Byte recStatus; |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
public Long getId() { |
|||
return id; |
|||
} |
|||
|
|||
public void setId(Long id) { |
|||
this.id = id; |
|||
} |
|||
|
|||
public String getJobName() { |
|||
return jobName; |
|||
} |
|||
|
|||
public void setJobName(String jobName) { |
|||
this.jobName = jobName == null ? null : jobName.trim(); |
|||
} |
|||
|
|||
public String getJobGroupName() { |
|||
return jobGroupName; |
|||
} |
|||
|
|||
public void setJobGroupName(String jobGroupName) { |
|||
this.jobGroupName = jobGroupName == null ? null : jobGroupName.trim(); |
|||
} |
|||
|
|||
public String getTriggerName() { |
|||
return triggerName; |
|||
} |
|||
|
|||
public void setTriggerName(String triggerName) { |
|||
this.triggerName = triggerName == null ? null : triggerName.trim(); |
|||
} |
|||
|
|||
public String getTriggerGroupName() { |
|||
return triggerGroupName; |
|||
} |
|||
|
|||
public void setTriggerGroupName(String triggerGroupName) { |
|||
this.triggerGroupName = triggerGroupName == null ? null : triggerGroupName.trim(); |
|||
} |
|||
|
|||
public String getCron() { |
|||
return cron; |
|||
} |
|||
|
|||
public void setCron(String cron) { |
|||
this.cron = cron == null ? null : cron.trim(); |
|||
} |
|||
|
|||
public String getMisfirePolicy() { |
|||
return misfirePolicy; |
|||
} |
|||
|
|||
public void setMisfirePolicy(String misfirePolicy) { |
|||
this.misfirePolicy = misfirePolicy == null ? null : misfirePolicy.trim(); |
|||
} |
|||
|
|||
public Byte getJob() { |
|||
return job; |
|||
} |
|||
|
|||
public void setJob(Byte job) { |
|||
this.job = job; |
|||
} |
|||
|
|||
public Long getStartTime() { |
|||
return startTime; |
|||
} |
|||
|
|||
public void setStartTime(Long startTime) { |
|||
this.startTime = startTime; |
|||
} |
|||
|
|||
public Long getEndTime() { |
|||
return endTime; |
|||
} |
|||
|
|||
public void setEndTime(Long endTime) { |
|||
this.endTime = endTime; |
|||
} |
|||
|
|||
public Byte getAutoMove() { |
|||
return autoMove; |
|||
} |
|||
|
|||
public void setAutoMove(Byte autoMove) { |
|||
this.autoMove = autoMove; |
|||
} |
|||
|
|||
public Byte getNotifyWay() { |
|||
return notifyWay; |
|||
} |
|||
|
|||
public void setNotifyWay(Byte notifyWay) { |
|||
this.notifyWay = notifyWay; |
|||
} |
|||
|
|||
public String getNotifyUrl() { |
|||
return notifyUrl; |
|||
} |
|||
|
|||
public void setNotifyUrl(String notifyUrl) { |
|||
this.notifyUrl = notifyUrl == null ? null : notifyUrl.trim(); |
|||
} |
|||
|
|||
public String getNotifyParam() { |
|||
return notifyParam; |
|||
} |
|||
|
|||
public void setNotifyParam(String notifyParam) { |
|||
this.notifyParam = notifyParam == null ? null : notifyParam.trim(); |
|||
} |
|||
|
|||
public Long getAppId() { |
|||
return appId; |
|||
} |
|||
|
|||
public void setAppId(Long appId) { |
|||
this.appId = appId; |
|||
} |
|||
|
|||
public Date getCreatedAt() { |
|||
return createdAt; |
|||
} |
|||
|
|||
public void setCreatedAt(Date createdAt) { |
|||
this.createdAt = createdAt; |
|||
} |
|||
|
|||
public Date getUpdatedAt() { |
|||
return updatedAt; |
|||
} |
|||
|
|||
public void setUpdatedAt(Date updatedAt) { |
|||
this.updatedAt = updatedAt; |
|||
} |
|||
|
|||
public Byte getRecStatus() { |
|||
return recStatus; |
|||
} |
|||
|
|||
public void setRecStatus(Byte recStatus) { |
|||
this.recStatus = recStatus; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
StringBuilder sb = new StringBuilder(); |
|||
sb.append(getClass().getSimpleName()); |
|||
sb.append(" ["); |
|||
sb.append("Hash = ").append(hashCode()); |
|||
sb.append(", id=").append(id); |
|||
sb.append(", jobName=").append(jobName); |
|||
sb.append(", jobGroupName=").append(jobGroupName); |
|||
sb.append(", triggerName=").append(triggerName); |
|||
sb.append(", triggerGroupName=").append(triggerGroupName); |
|||
sb.append(", cron=").append(cron); |
|||
sb.append(", misfirePolicy=").append(misfirePolicy); |
|||
sb.append(", job=").append(job); |
|||
sb.append(", startTime=").append(startTime); |
|||
sb.append(", endTime=").append(endTime); |
|||
sb.append(", autoMove=").append(autoMove); |
|||
sb.append(", notifyWay=").append(notifyWay); |
|||
sb.append(", notifyUrl=").append(notifyUrl); |
|||
sb.append(", notifyParam=").append(notifyParam); |
|||
sb.append(", appId=").append(appId); |
|||
sb.append(", createdAt=").append(createdAt); |
|||
sb.append(", updatedAt=").append(updatedAt); |
|||
sb.append(", recStatus=").append(recStatus); |
|||
sb.append("]"); |
|||
return sb.toString(); |
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,9 @@ |
|||
package com.ccsens.scheduler.persist.dao; |
|||
|
|||
import com.ccsens.scheduler.persist.mapper.TaskMapper; |
|||
|
|||
/** |
|||
* @author wu |
|||
*/ |
|||
public interface TaskDao extends TaskMapper { |
|||
} |
@ -0,0 +1,30 @@ |
|||
package com.ccsens.scheduler.persist.mapper; |
|||
|
|||
import com.ccsens.scheduler.bean.po.Task; |
|||
import com.ccsens.scheduler.bean.po.TaskExample; |
|||
import java.util.List; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
public interface TaskMapper { |
|||
long countByExample(TaskExample example); |
|||
|
|||
int deleteByExample(TaskExample example); |
|||
|
|||
int deleteByPrimaryKey(Long id); |
|||
|
|||
int insert(Task record); |
|||
|
|||
int insertSelective(Task record); |
|||
|
|||
List<Task> selectByExample(TaskExample example); |
|||
|
|||
Task selectByPrimaryKey(Long id); |
|||
|
|||
int updateByExampleSelective(@Param("record") Task record, @Param("example") TaskExample example); |
|||
|
|||
int updateByExample(@Param("record") Task record, @Param("example") TaskExample example); |
|||
|
|||
int updateByPrimaryKeySelective(Task record); |
|||
|
|||
int updateByPrimaryKey(Task record); |
|||
} |
@ -0,0 +1,73 @@ |
|||
package com.ccsens.scheduler.service; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import cn.hutool.extra.mail.Mail; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.ccsens.scheduler.bean.po.Task; |
|||
import com.ccsens.scheduler.bean.po.TaskExample; |
|||
import com.ccsens.scheduler.persist.dao.TaskDao; |
|||
import com.ccsens.scheduler.util.Constant; |
|||
import com.ccsens.scheduler.util.RestTemplateUtil; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.quartz.JobExecutionContext; |
|||
import org.quartz.JobExecutionException; |
|||
import org.quartz.JobKey; |
|||
import org.quartz.TriggerKey; |
|||
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|||
import org.springframework.scheduling.quartz.QuartzJobBean; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.annotation.Resource; |
|||
import javax.validation.constraints.Email; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: 任务调度 |
|||
* @author: whj |
|||
* @time: 2021/7/23 10:41 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class CoreJobService extends QuartzJobBean implements ICoreJobService { |
|||
@Resource |
|||
private TaskDao taskDao; |
|||
@Resource |
|||
private RabbitTemplate rabbitTemplate; |
|||
|
|||
|
|||
@Override |
|||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException { |
|||
|
|||
JobKey jobKey = context.getJobDetail().getKey(); |
|||
TriggerKey triggerKey = context.getTrigger().getKey(); |
|||
log.info("【{}】执行任务:{},{}", System.currentTimeMillis(), jobKey.getName(), triggerKey.getName()); |
|||
TaskExample example = new TaskExample(); |
|||
example.createCriteria().andJobNameEqualTo(jobKey.getName()).andJobGroupNameEqualTo(jobKey.getGroup()) |
|||
.andTriggerNameEqualTo(triggerKey.getName()).andTriggerGroupNameEqualTo(triggerKey.getGroup()); |
|||
List<Task> tasks = taskDao.selectByExample(example); |
|||
if (CollectionUtil.isEmpty(tasks)) { |
|||
log.error("未找到调度任务:{},{},{},{}", jobKey.getName(), jobKey.getGroup(), triggerKey.getName(), triggerKey.getGroup()); |
|||
} |
|||
|
|||
Task task = tasks.get(0); |
|||
log.info("task:{}", task); |
|||
switch (task.getNotifyWay()) { |
|||
case Constant.NotifyWay.HTTP: |
|||
RestTemplateUtil.postBody(task.getNotifyUrl(), JSONObject.parse(task.getNotifyParam())); |
|||
break; |
|||
case Constant.NotifyWay.MQ: |
|||
rabbitTemplate.convertAndSend(task.getNotifyUrl(), task.getNotifyParam()); |
|||
break; |
|||
case Constant.NotifyWay.EMAIL: |
|||
Mail.create().setContent() |
|||
break; |
|||
case Constant.NotifyWay.SMS: |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
package com.ccsens.scheduler.service; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/7/23 11:21 |
|||
*/ |
|||
public interface ICoreJobService { |
|||
} |
@ -0,0 +1,46 @@ |
|||
package com.ccsens.scheduler.service; |
|||
|
|||
import com.ccsens.scheduler.bean.dto.QuartzJob; |
|||
import com.ccsens.scheduler.util.CodeEnum; |
|||
|
|||
/** |
|||
* @author whj |
|||
*/ |
|||
public interface IJobService { |
|||
|
|||
/** |
|||
* 添加定时任务 |
|||
* @param job 任务 |
|||
* @param userId 操作人 |
|||
* @return 结果 |
|||
*/ |
|||
CodeEnum add(QuartzJob.Job job, Long userId); |
|||
/** |
|||
* 修改定时任务 |
|||
* @param job 任务 |
|||
* @param userId 操作人 |
|||
* @return 结果 |
|||
*/ |
|||
CodeEnum modify(QuartzJob.Update job, Long userId); |
|||
/** |
|||
* 暂停定时任务 |
|||
* @param job 任务名 |
|||
* @param userId 操作人 |
|||
* @return 结果 |
|||
*/ |
|||
CodeEnum pause(QuartzJob.Name job, Long userId); |
|||
/** |
|||
* 重启定时任务 |
|||
* @param job 任务名 |
|||
* @param userId 操作人 |
|||
* @return 结果 |
|||
*/ |
|||
CodeEnum resume(QuartzJob.Name job, Long userId); |
|||
/** |
|||
* 删除定时任务 |
|||
* @param job 任务名 |
|||
* @param userId 操作人 |
|||
* @return 结果 |
|||
*/ |
|||
CodeEnum remove(QuartzJob.Del job, Long userId); |
|||
} |
@ -0,0 +1,134 @@ |
|||
package com.ccsens.scheduler.service; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.ccsens.scheduler.bean.dto.QuartzJob; |
|||
import com.ccsens.scheduler.bean.po.Task; |
|||
import com.ccsens.scheduler.bean.po.TaskExample; |
|||
import com.ccsens.scheduler.persist.dao.TaskDao; |
|||
import com.ccsens.scheduler.util.CodeEnum; |
|||
import com.ccsens.scheduler.util.Constant; |
|||
import com.ccsens.scheduler.util.QuartzJobUtil; |
|||
import com.ccsens.scheduler.util.RedisUtil; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Propagation; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/7/23 11:53 |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class) |
|||
public class JobService implements IJobService { |
|||
|
|||
@Resource |
|||
private QuartzJobUtil quartzJobUtil; |
|||
@Resource |
|||
private RedisUtil redisUtil; |
|||
@Resource |
|||
private TaskDao taskDao; |
|||
|
|||
|
|||
@Override |
|||
public CodeEnum add(QuartzJob.Job job, Long userId) { |
|||
// 写缓存,防重复
|
|||
boolean writeSuc = redisUtil.setNx(Constant.Quartz.JOB_KEY_PREFIX + job.getJobName() + Constant.Quartz.JOB_KEY_SPLIT + job.getJobGroupName(), "", Constant.Quartz.JOB_KEY_EXPIRE_TIME); |
|||
log.info("缓存{}结果:{}", job.getJobName(), writeSuc); |
|||
if (!writeSuc) { |
|||
return CodeEnum.JOB_EXISTED; |
|||
} |
|||
// 添加任务
|
|||
boolean suc = quartzJobUtil.addJob(job); |
|||
log.info("添加Quartz任务成功:{}", suc); |
|||
if (!suc) { |
|||
return CodeEnum.JOB_ADD_FAIL; |
|||
} |
|||
Task task = new Task(); |
|||
BeanUtils.copyProperties(job, task); |
|||
taskDao.insertSelective(task); |
|||
log.info("添加任务成功"); |
|||
return CodeEnum.SUCCESS; |
|||
} |
|||
|
|||
@Override |
|||
public CodeEnum modify(QuartzJob.Update job, Long userId) { |
|||
// 写缓存,防重复
|
|||
boolean writeSuc = redisUtil.setNx(Constant.Quartz.JOB_KEY_PREFIX + job.getTriggerName() + Constant.Quartz.JOB_KEY_SPLIT + job.getTriggerGroupName(), "", Constant.Quartz.JOB_KEY_EXPIRE_TIME); |
|||
log.info("缓存{}结果:{}", job.getTriggerName() + Constant.Quartz.JOB_KEY_SPLIT + job.getTriggerGroupName(),writeSuc); |
|||
if (!writeSuc) { |
|||
return CodeEnum.JOB_EXISTED; |
|||
} |
|||
// 查询任务
|
|||
TaskExample example = new TaskExample(); |
|||
example.createCriteria().andTriggerNameEqualTo(job.getTriggerName()).andTriggerGroupNameEqualTo(job.getTriggerGroupName()); |
|||
List<Task> tasks = taskDao.selectByExample(example); |
|||
log.info("tasks:{}", tasks); |
|||
if (CollectionUtil.isEmpty(tasks)) { |
|||
return CodeEnum.JOB_NOT_EXISTED; |
|||
} |
|||
Task task = tasks.get(0); |
|||
boolean cronChange = (StrUtil.isNotBlank(job.getCron()) && !job.getCron().equals(task.getCron())) |
|||
|| ((StrUtil.isNotBlank(job.getMisfirePolicy()) && !job.getMisfirePolicy().equals(task.getMisfirePolicy()))); |
|||
if (cronChange) { |
|||
log.info("cron需要变更"); |
|||
boolean modify = quartzJobUtil.modifyJobTime(job); |
|||
if (!modify) { |
|||
return CodeEnum.JOB_MODIFY_FAIL; |
|||
} |
|||
} |
|||
Task updateTask = new Task(); |
|||
BeanUtils.copyProperties(job, updateTask); |
|||
updateTask.setId(task.getId()); |
|||
return CodeEnum.SUCCESS; |
|||
} |
|||
|
|||
@Override |
|||
public CodeEnum pause(QuartzJob.Name job, Long userId) { |
|||
boolean pause = quartzJobUtil.pauseJob(job.getJobName(), job.getJobGroupName()); |
|||
if (!pause) { |
|||
return CodeEnum.JOB_PAUSE_FAIL; |
|||
} |
|||
Task task = new Task(); |
|||
task.setRecStatus(Constant.REC_STATUS.Disabled.value); |
|||
TaskExample example = new TaskExample(); |
|||
example.createCriteria().andJobNameEqualTo(job.getJobName()).andJobGroupNameEqualTo(job.getJobGroupName()); |
|||
taskDao.updateByExampleSelective(task, example); |
|||
return CodeEnum.SUCCESS; |
|||
} |
|||
|
|||
@Override |
|||
public CodeEnum resume(QuartzJob.Name job, Long userId) { |
|||
boolean resume = quartzJobUtil.resumeJob(job.getJobName(), job.getJobGroupName()); |
|||
if (!resume) { |
|||
return CodeEnum.JOB_RESUME_FAIL; |
|||
} |
|||
Task task = new Task(); |
|||
task.setRecStatus(Constant.REC_STATUS.Normal.value); |
|||
TaskExample example = new TaskExample(); |
|||
example.createCriteria().andJobNameEqualTo(job.getJobName()).andJobGroupNameEqualTo(job.getJobGroupName()); |
|||
taskDao.updateByExampleSelective(task, example); |
|||
return CodeEnum.SUCCESS; |
|||
} |
|||
|
|||
@Override |
|||
public CodeEnum remove(QuartzJob.Del job, Long userId) { |
|||
boolean remove = quartzJobUtil.removeJob(job.getJobName(), job.getJobGroupName(), job.getTriggerName(), job.getTriggerGroupName()); |
|||
if (!remove) { |
|||
return CodeEnum.JOB_DEL_FAIL; |
|||
} |
|||
Task task = new Task(); |
|||
task.setRecStatus(Constant.REC_STATUS.Deleted.value); |
|||
TaskExample example = new TaskExample(); |
|||
example.createCriteria().andJobNameEqualTo(job.getJobName()).andJobGroupNameEqualTo(job.getJobGroupName()); |
|||
taskDao.updateByExampleSelective(task, example); |
|||
return CodeEnum.SUCCESS; |
|||
} |
|||
} |
@ -0,0 +1,156 @@ |
|||
package com.ccsens.scheduler.util; |
|||
|
|||
import cn.hutool.core.util.StrUtil; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.ccsens.scheduler.exception.BaseException; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.http.HttpEntity; |
|||
import org.springframework.http.HttpHeaders; |
|||
import org.springframework.http.MediaType; |
|||
import org.springframework.http.ResponseEntity; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.util.LinkedMultiValueMap; |
|||
import org.springframework.util.MultiValueMap; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
import javax.annotation.PostConstruct; |
|||
import javax.annotation.Resource; |
|||
import java.net.URI; |
|||
import java.net.URISyntaxException; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Slf4j |
|||
@Component |
|||
public class RestTemplateUtil { |
|||
|
|||
@Resource |
|||
private RestTemplate restTemplate; |
|||
|
|||
private static RestTemplateUtil util; |
|||
|
|||
@PostConstruct |
|||
public void init(){ |
|||
util = this; |
|||
util.restTemplate = this.restTemplate; |
|||
} |
|||
|
|||
public static Object getForEntity(String url, Map<String, Object> params, Class<?> returnClass) { |
|||
|
|||
if (params != null && !params.isEmpty()) { |
|||
String questionMark = "?"; |
|||
String assignMark = "="; |
|||
String andMark = "&"; |
|||
if (!url.contains(questionMark)) { |
|||
url += questionMark; |
|||
} |
|||
for (String key : params.keySet()) { |
|||
if (url.endsWith(questionMark)) { |
|||
url += key + assignMark +params.get(key); |
|||
} else { |
|||
url += andMark + key + assignMark +params.get(key); |
|||
} |
|||
} |
|||
} |
|||
log.info("url:{}, params:{}", url, params); |
|||
ResponseEntity<String> entity = util.restTemplate.getForEntity(url, String.class); |
|||
log.info("entity:{}",entity); |
|||
return JSONObject.parseObject(entity.getBody(), returnClass); |
|||
} |
|||
|
|||
public static String postBody(String url, Object params) { |
|||
log.info("路径:{}, 参数:{}", url, params); |
|||
HttpHeaders httpHeaders = new HttpHeaders(); |
|||
MediaType type= MediaType.parseMediaType("application/json;charset=UTF-8"); |
|||
httpHeaders.setContentType(type); |
|||
|
|||
JSONObject json = JSON.parseObject(JSON.toJSONString(params)); |
|||
HttpEntity<Map<String, Object>> objectHttpEntity = new HttpEntity<>(json,httpHeaders); |
|||
URI uri; |
|||
try { |
|||
uri = new URI(url); |
|||
}catch (URISyntaxException e) { |
|||
log.error("转换路径异常", e); |
|||
throw new BaseException(CodeEnum.URL_ERROR); |
|||
} |
|||
|
|||
ResponseEntity<String> response = util.restTemplate.postForEntity(uri, objectHttpEntity, String.class); |
|||
log.info("返回:{}", response); |
|||
return response.getBody(); |
|||
} |
|||
|
|||
public static String postBody(String url, List<? extends Object> params) { |
|||
log.info("路径:{}, 参数:{}", url, params); |
|||
HttpHeaders httpHeaders = new HttpHeaders(); |
|||
MediaType type= MediaType.parseMediaType("application/json;charset=UTF-8"); |
|||
httpHeaders.setContentType(type); |
|||
|
|||
HttpEntity<List<? extends Object>> objectHttpEntity = new HttpEntity<>(params,httpHeaders); |
|||
URI uri; |
|||
try { |
|||
uri = new URI(url); |
|||
}catch (URISyntaxException e) { |
|||
log.error("转换路径异常:{}", e); |
|||
throw new BaseException(CodeEnum.URL_ERROR); |
|||
} |
|||
|
|||
ResponseEntity<String> response = util.restTemplate.postForEntity(uri, objectHttpEntity, String.class); |
|||
log.info("返回:{}", response); |
|||
return response.getBody(); |
|||
} |
|||
public static String postUrlEncode(String url, Object params) { |
|||
log.info("请求路径:{},请求参数:{}", url, params); |
|||
MultiValueMap<String, Object> paramMap; |
|||
if (params == null) { |
|||
paramMap = new LinkedMultiValueMap<>(); |
|||
} else { |
|||
JSONObject json = JSON.parseObject(JSON.toJSONString(params)); |
|||
paramMap = transMultiValueMap(json); |
|||
} |
|||
|
|||
HttpHeaders headers = new HttpHeaders(); |
|||
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
|||
HttpEntity<MultiValueMap> formEntity = new HttpEntity<>(paramMap, headers); |
|||
ResponseEntity<String> result = util.restTemplate.postForEntity(url, formEntity, String.class); |
|||
log.info("接口返回结果:{}", result); |
|||
return result.getBody(); |
|||
} |
|||
|
|||
/** |
|||
* 发送multipart/form-data |
|||
* @author whj |
|||
* @date 2019/8/20 |
|||
* @param url 路径 |
|||
* @param params 参数 |
|||
* @return com.alibaba.fastjson.JSONObject |
|||
*/ |
|||
public static JSONObject postImg(String url, JSONObject params) { |
|||
log.info("请求路径:{},请求参数:{}", url, params); |
|||
HttpHeaders headers = new HttpHeaders(); |
|||
headers.add("Accept", MediaType.APPLICATION_JSON.toString()); |
|||
headers.setContentType(MediaType.MULTIPART_FORM_DATA); |
|||
MultiValueMap<String, Object> paramMap = transMultiValueMap(params); |
|||
HttpEntity<MultiValueMap> formEntity = new HttpEntity<>(paramMap, headers); |
|||
JSONObject result = util.restTemplate.postForObject(url, formEntity, JSONObject.class); |
|||
log.info("接口返回结果:{}", result); |
|||
return result; |
|||
} |
|||
|
|||
/** |
|||
* 将参数封装成MultiValueMap对象 |
|||
* @author whj |
|||
* @date 2019/8/20 |
|||
* @param params 参数 |
|||
* @return org.springframework.util.MultiValueMap<java.lang.String,java.lang.Object> |
|||
*/ |
|||
private static MultiValueMap<String, Object> transMultiValueMap(JSONObject params) { |
|||
MultiValueMap<String, Object> paramMap = new LinkedMultiValueMap<>(); |
|||
for (String key: params.keySet()) { |
|||
paramMap.add(key, params.get(key)); |
|||
} |
|||
return paramMap; |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,59 @@ |
|||
package com.ccsens.scheduler.util; |
|||
|
|||
import cn.hutool.core.util.RandomUtil; |
|||
import cn.hutool.json.JSONException; |
|||
import com.github.qcloudsms.SmsSingleSender; |
|||
import com.github.qcloudsms.SmsSingleSenderResult; |
|||
import com.github.qcloudsms.httpclient.HTTPException; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.io.IOException; |
|||
|
|||
@Slf4j |
|||
@Component |
|||
public class SmsUtil { |
|||
// 1400开头
|
|||
private static final int appid = 1400188778; |
|||
private static final String appkey = "c86ca104521ab2e28e1d4b558fdd665e"; |
|||
/** |
|||
* {1} 验证码{1}, 您正在通过{2}登录传控科技“时物链条”会议管理系统,请与{3}分钟内填写,如非本人操作,请忽略本短信。\ |
|||
*/ |
|||
private static final int templateId = 286731; |
|||
/** |
|||
* {1} 您正在通过{2}登录传控科技“时物链条”会议管理系统,请与{2}分钟内填写,如非本人操作,请忽略本短信。 |
|||
*/ |
|||
private static final int templateId1 = 286682; |
|||
/**验证码{1},{2}分钟内有效,如非本人操作请忽略 |
|||
* |
|||
*/ |
|||
private static final int templateId2 = 686476; |
|||
private static final String smsSign = "传控科技"; |
|||
|
|||
public static void sendSms(String phone,String code,String appName,Integer seconds){ |
|||
String phoneNumbers[] = {phone}; |
|||
Integer minutes = (seconds - 1) / 60 + 1; |
|||
try { |
|||
//数组具体的元素个数和模板中变量个数必须一致,例如事例中templateId:5678对应一个变量,参数数组中元素个数也必须是一个
|
|||
String[] params = {code,String.valueOf(minutes)}; |
|||
SmsSingleSender ssender = new SmsSingleSender(appid, appkey); |
|||
// 签名参数未提供或者为空时,会使用默认签名发送短信
|
|||
SmsSingleSenderResult result = ssender.sendWithParam("86", phoneNumbers[0], |
|||
templateId2, params, smsSign, "", ""); |
|||
log.info(String.valueOf(result)); |
|||
} catch (HTTPException e) { |
|||
// HTTP响应码错误
|
|||
e.printStackTrace(); |
|||
} catch (JSONException e) { |
|||
// json解析错误
|
|||
e.printStackTrace(); |
|||
} catch (IOException e) { |
|||
// 网络IO错误
|
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
public static String generateRandomSmsCode(int length){ |
|||
return RandomUtil.randomNumbers(4); |
|||
} |
|||
} |
@ -0,0 +1,4 @@ |
|||
host = smtp.ccsens.com |
|||
port = 25 |
|||
from = admin@ccsens.com |
|||
pass = q1w2e3 |
@ -0,0 +1,5 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.ccsens.scheduler.persist.dao.TaskDao"> |
|||
|
|||
</mapper> |
@ -0,0 +1,418 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.ccsens.scheduler.persist.mapper.TaskMapper"> |
|||
<resultMap id="BaseResultMap" type="com.ccsens.scheduler.bean.po.Task"> |
|||
<id column="id" jdbcType="BIGINT" property="id" /> |
|||
<result column="job_name" jdbcType="VARCHAR" property="jobName" /> |
|||
<result column="job_group_name" jdbcType="VARCHAR" property="jobGroupName" /> |
|||
<result column="trigger_name" jdbcType="VARCHAR" property="triggerName" /> |
|||
<result column="trigger_group_name" jdbcType="VARCHAR" property="triggerGroupName" /> |
|||
<result column="cron" jdbcType="VARCHAR" property="cron" /> |
|||
<result column="misfire_policy" jdbcType="VARCHAR" property="misfirePolicy" /> |
|||
<result column="job" jdbcType="TINYINT" property="job" /> |
|||
<result column="start_time" jdbcType="BIGINT" property="startTime" /> |
|||
<result column="end_time" jdbcType="BIGINT" property="endTime" /> |
|||
<result column="auto_move" jdbcType="TINYINT" property="autoMove" /> |
|||
<result column="notify_way" jdbcType="TINYINT" property="notifyWay" /> |
|||
<result column="notify_url" jdbcType="VARCHAR" property="notifyUrl" /> |
|||
<result column="notify_param" jdbcType="VARCHAR" property="notifyParam" /> |
|||
<result column="app_id" jdbcType="BIGINT" property="appId" /> |
|||
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" /> |
|||
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" /> |
|||
<result column="rec_status" jdbcType="TINYINT" property="recStatus" /> |
|||
</resultMap> |
|||
<sql id="Example_Where_Clause"> |
|||
<where> |
|||
<foreach collection="oredCriteria" item="criteria" separator="or"> |
|||
<if test="criteria.valid"> |
|||
<trim prefix="(" prefixOverrides="and" suffix=")"> |
|||
<foreach collection="criteria.criteria" item="criterion"> |
|||
<choose> |
|||
<when test="criterion.noValue"> |
|||
and ${criterion.condition} |
|||
</when> |
|||
<when test="criterion.singleValue"> |
|||
and ${criterion.condition} #{criterion.value} |
|||
</when> |
|||
<when test="criterion.betweenValue"> |
|||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} |
|||
</when> |
|||
<when test="criterion.listValue"> |
|||
and ${criterion.condition} |
|||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> |
|||
#{listItem} |
|||
</foreach> |
|||
</when> |
|||
</choose> |
|||
</foreach> |
|||
</trim> |
|||
</if> |
|||
</foreach> |
|||
</where> |
|||
</sql> |
|||
<sql id="Update_By_Example_Where_Clause"> |
|||
<where> |
|||
<foreach collection="example.oredCriteria" item="criteria" separator="or"> |
|||
<if test="criteria.valid"> |
|||
<trim prefix="(" prefixOverrides="and" suffix=")"> |
|||
<foreach collection="criteria.criteria" item="criterion"> |
|||
<choose> |
|||
<when test="criterion.noValue"> |
|||
and ${criterion.condition} |
|||
</when> |
|||
<when test="criterion.singleValue"> |
|||
and ${criterion.condition} #{criterion.value} |
|||
</when> |
|||
<when test="criterion.betweenValue"> |
|||
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} |
|||
</when> |
|||
<when test="criterion.listValue"> |
|||
and ${criterion.condition} |
|||
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=","> |
|||
#{listItem} |
|||
</foreach> |
|||
</when> |
|||
</choose> |
|||
</foreach> |
|||
</trim> |
|||
</if> |
|||
</foreach> |
|||
</where> |
|||
</sql> |
|||
<sql id="Base_Column_List"> |
|||
id, job_name, job_group_name, trigger_name, trigger_group_name, cron, misfire_policy, |
|||
job, start_time, end_time, auto_move, notify_way, notify_url, notify_param, app_id, |
|||
created_at, updated_at, rec_status |
|||
</sql> |
|||
<select id="selectByExample" parameterType="com.ccsens.scheduler.bean.po.TaskExample" resultMap="BaseResultMap"> |
|||
select |
|||
<if test="distinct"> |
|||
distinct |
|||
</if> |
|||
<include refid="Base_Column_List" /> |
|||
from t_task |
|||
<if test="_parameter != null"> |
|||
<include refid="Example_Where_Clause" /> |
|||
</if> |
|||
<if test="orderByClause != null"> |
|||
order by ${orderByClause} |
|||
</if> |
|||
</select> |
|||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List" /> |
|||
from t_task |
|||
where id = #{id,jdbcType=BIGINT} |
|||
</select> |
|||
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> |
|||
delete from t_task |
|||
where id = #{id,jdbcType=BIGINT} |
|||
</delete> |
|||
<delete id="deleteByExample" parameterType="com.ccsens.scheduler.bean.po.TaskExample"> |
|||
delete from t_task |
|||
<if test="_parameter != null"> |
|||
<include refid="Example_Where_Clause" /> |
|||
</if> |
|||
</delete> |
|||
<insert id="insert" parameterType="com.ccsens.scheduler.bean.po.Task"> |
|||
insert into t_task (id, job_name, job_group_name, |
|||
trigger_name, trigger_group_name, cron, |
|||
misfire_policy, job, start_time, |
|||
end_time, auto_move, notify_way, |
|||
notify_url, notify_param, app_id, |
|||
created_at, updated_at, rec_status |
|||
) |
|||
values (#{id,jdbcType=BIGINT}, #{jobName,jdbcType=VARCHAR}, #{jobGroupName,jdbcType=VARCHAR}, |
|||
#{triggerName,jdbcType=VARCHAR}, #{triggerGroupName,jdbcType=VARCHAR}, #{cron,jdbcType=VARCHAR}, |
|||
#{misfirePolicy,jdbcType=VARCHAR}, #{job,jdbcType=TINYINT}, #{startTime,jdbcType=BIGINT}, |
|||
#{endTime,jdbcType=BIGINT}, #{autoMove,jdbcType=TINYINT}, #{notifyWay,jdbcType=TINYINT}, |
|||
#{notifyUrl,jdbcType=VARCHAR}, #{notifyParam,jdbcType=VARCHAR}, #{appId,jdbcType=BIGINT}, |
|||
#{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}, #{recStatus,jdbcType=TINYINT} |
|||
) |
|||
</insert> |
|||
<insert id="insertSelective" parameterType="com.ccsens.scheduler.bean.po.Task"> |
|||
insert into t_task |
|||
<trim prefix="(" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
id, |
|||
</if> |
|||
<if test="jobName != null"> |
|||
job_name, |
|||
</if> |
|||
<if test="jobGroupName != null"> |
|||
job_group_name, |
|||
</if> |
|||
<if test="triggerName != null"> |
|||
trigger_name, |
|||
</if> |
|||
<if test="triggerGroupName != null"> |
|||
trigger_group_name, |
|||
</if> |
|||
<if test="cron != null"> |
|||
cron, |
|||
</if> |
|||
<if test="misfirePolicy != null"> |
|||
misfire_policy, |
|||
</if> |
|||
<if test="job != null"> |
|||
job, |
|||
</if> |
|||
<if test="startTime != null"> |
|||
start_time, |
|||
</if> |
|||
<if test="endTime != null"> |
|||
end_time, |
|||
</if> |
|||
<if test="autoMove != null"> |
|||
auto_move, |
|||
</if> |
|||
<if test="notifyWay != null"> |
|||
notify_way, |
|||
</if> |
|||
<if test="notifyUrl != null"> |
|||
notify_url, |
|||
</if> |
|||
<if test="notifyParam != null"> |
|||
notify_param, |
|||
</if> |
|||
<if test="appId != null"> |
|||
app_id, |
|||
</if> |
|||
<if test="createdAt != null"> |
|||
created_at, |
|||
</if> |
|||
<if test="updatedAt != null"> |
|||
updated_at, |
|||
</if> |
|||
<if test="recStatus != null"> |
|||
rec_status, |
|||
</if> |
|||
</trim> |
|||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
|||
<if test="id != null"> |
|||
#{id,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="jobName != null"> |
|||
#{jobName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="jobGroupName != null"> |
|||
#{jobGroupName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="triggerName != null"> |
|||
#{triggerName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="triggerGroupName != null"> |
|||
#{triggerGroupName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="cron != null"> |
|||
#{cron,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="misfirePolicy != null"> |
|||
#{misfirePolicy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="job != null"> |
|||
#{job,jdbcType=TINYINT}, |
|||
</if> |
|||
<if test="startTime != null"> |
|||
#{startTime,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="endTime != null"> |
|||
#{endTime,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="autoMove != null"> |
|||
#{autoMove,jdbcType=TINYINT}, |
|||
</if> |
|||
<if test="notifyWay != null"> |
|||
#{notifyWay,jdbcType=TINYINT}, |
|||
</if> |
|||
<if test="notifyUrl != null"> |
|||
#{notifyUrl,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="notifyParam != null"> |
|||
#{notifyParam,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="appId != null"> |
|||
#{appId,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="createdAt != null"> |
|||
#{createdAt,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="updatedAt != null"> |
|||
#{updatedAt,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="recStatus != null"> |
|||
#{recStatus,jdbcType=TINYINT}, |
|||
</if> |
|||
</trim> |
|||
</insert> |
|||
<select id="countByExample" parameterType="com.ccsens.scheduler.bean.po.TaskExample" resultType="java.lang.Long"> |
|||
select count(*) from t_task |
|||
<if test="_parameter != null"> |
|||
<include refid="Example_Where_Clause" /> |
|||
</if> |
|||
</select> |
|||
<update id="updateByExampleSelective" parameterType="map"> |
|||
update t_task |
|||
<set> |
|||
<if test="record.id != null"> |
|||
id = #{record.id,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="record.jobName != null"> |
|||
job_name = #{record.jobName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="record.jobGroupName != null"> |
|||
job_group_name = #{record.jobGroupName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="record.triggerName != null"> |
|||
trigger_name = #{record.triggerName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="record.triggerGroupName != null"> |
|||
trigger_group_name = #{record.triggerGroupName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="record.cron != null"> |
|||
cron = #{record.cron,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="record.misfirePolicy != null"> |
|||
misfire_policy = #{record.misfirePolicy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="record.job != null"> |
|||
job = #{record.job,jdbcType=TINYINT}, |
|||
</if> |
|||
<if test="record.startTime != null"> |
|||
start_time = #{record.startTime,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="record.endTime != null"> |
|||
end_time = #{record.endTime,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="record.autoMove != null"> |
|||
auto_move = #{record.autoMove,jdbcType=TINYINT}, |
|||
</if> |
|||
<if test="record.notifyWay != null"> |
|||
notify_way = #{record.notifyWay,jdbcType=TINYINT}, |
|||
</if> |
|||
<if test="record.notifyUrl != null"> |
|||
notify_url = #{record.notifyUrl,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="record.notifyParam != null"> |
|||
notify_param = #{record.notifyParam,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="record.appId != null"> |
|||
app_id = #{record.appId,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="record.createdAt != null"> |
|||
created_at = #{record.createdAt,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="record.updatedAt != null"> |
|||
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="record.recStatus != null"> |
|||
rec_status = #{record.recStatus,jdbcType=TINYINT}, |
|||
</if> |
|||
</set> |
|||
<if test="_parameter != null"> |
|||
<include refid="Update_By_Example_Where_Clause" /> |
|||
</if> |
|||
</update> |
|||
<update id="updateByExample" parameterType="map"> |
|||
update t_task |
|||
set id = #{record.id,jdbcType=BIGINT}, |
|||
job_name = #{record.jobName,jdbcType=VARCHAR}, |
|||
job_group_name = #{record.jobGroupName,jdbcType=VARCHAR}, |
|||
trigger_name = #{record.triggerName,jdbcType=VARCHAR}, |
|||
trigger_group_name = #{record.triggerGroupName,jdbcType=VARCHAR}, |
|||
cron = #{record.cron,jdbcType=VARCHAR}, |
|||
misfire_policy = #{record.misfirePolicy,jdbcType=VARCHAR}, |
|||
job = #{record.job,jdbcType=TINYINT}, |
|||
start_time = #{record.startTime,jdbcType=BIGINT}, |
|||
end_time = #{record.endTime,jdbcType=BIGINT}, |
|||
auto_move = #{record.autoMove,jdbcType=TINYINT}, |
|||
notify_way = #{record.notifyWay,jdbcType=TINYINT}, |
|||
notify_url = #{record.notifyUrl,jdbcType=VARCHAR}, |
|||
notify_param = #{record.notifyParam,jdbcType=VARCHAR}, |
|||
app_id = #{record.appId,jdbcType=BIGINT}, |
|||
created_at = #{record.createdAt,jdbcType=TIMESTAMP}, |
|||
updated_at = #{record.updatedAt,jdbcType=TIMESTAMP}, |
|||
rec_status = #{record.recStatus,jdbcType=TINYINT} |
|||
<if test="_parameter != null"> |
|||
<include refid="Update_By_Example_Where_Clause" /> |
|||
</if> |
|||
</update> |
|||
<update id="updateByPrimaryKeySelective" parameterType="com.ccsens.scheduler.bean.po.Task"> |
|||
update t_task |
|||
<set> |
|||
<if test="jobName != null"> |
|||
job_name = #{jobName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="jobGroupName != null"> |
|||
job_group_name = #{jobGroupName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="triggerName != null"> |
|||
trigger_name = #{triggerName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="triggerGroupName != null"> |
|||
trigger_group_name = #{triggerGroupName,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="cron != null"> |
|||
cron = #{cron,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="misfirePolicy != null"> |
|||
misfire_policy = #{misfirePolicy,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="job != null"> |
|||
job = #{job,jdbcType=TINYINT}, |
|||
</if> |
|||
<if test="startTime != null"> |
|||
start_time = #{startTime,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="endTime != null"> |
|||
end_time = #{endTime,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="autoMove != null"> |
|||
auto_move = #{autoMove,jdbcType=TINYINT}, |
|||
</if> |
|||
<if test="notifyWay != null"> |
|||
notify_way = #{notifyWay,jdbcType=TINYINT}, |
|||
</if> |
|||
<if test="notifyUrl != null"> |
|||
notify_url = #{notifyUrl,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="notifyParam != null"> |
|||
notify_param = #{notifyParam,jdbcType=VARCHAR}, |
|||
</if> |
|||
<if test="appId != null"> |
|||
app_id = #{appId,jdbcType=BIGINT}, |
|||
</if> |
|||
<if test="createdAt != null"> |
|||
created_at = #{createdAt,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="updatedAt != null"> |
|||
updated_at = #{updatedAt,jdbcType=TIMESTAMP}, |
|||
</if> |
|||
<if test="recStatus != null"> |
|||
rec_status = #{recStatus,jdbcType=TINYINT}, |
|||
</if> |
|||
</set> |
|||
where id = #{id,jdbcType=BIGINT} |
|||
</update> |
|||
<update id="updateByPrimaryKey" parameterType="com.ccsens.scheduler.bean.po.Task"> |
|||
update t_task |
|||
set job_name = #{jobName,jdbcType=VARCHAR}, |
|||
job_group_name = #{jobGroupName,jdbcType=VARCHAR}, |
|||
trigger_name = #{triggerName,jdbcType=VARCHAR}, |
|||
trigger_group_name = #{triggerGroupName,jdbcType=VARCHAR}, |
|||
cron = #{cron,jdbcType=VARCHAR}, |
|||
misfire_policy = #{misfirePolicy,jdbcType=VARCHAR}, |
|||
job = #{job,jdbcType=TINYINT}, |
|||
start_time = #{startTime,jdbcType=BIGINT}, |
|||
end_time = #{endTime,jdbcType=BIGINT}, |
|||
auto_move = #{autoMove,jdbcType=TINYINT}, |
|||
notify_way = #{notifyWay,jdbcType=TINYINT}, |
|||
notify_url = #{notifyUrl,jdbcType=VARCHAR}, |
|||
notify_param = #{notifyParam,jdbcType=VARCHAR}, |
|||
app_id = #{appId,jdbcType=BIGINT}, |
|||
created_at = #{createdAt,jdbcType=TIMESTAMP}, |
|||
updated_at = #{updatedAt,jdbcType=TIMESTAMP}, |
|||
rec_status = #{recStatus,jdbcType=TINYINT} |
|||
where id = #{id,jdbcType=BIGINT} |
|||
</update> |
|||
</mapper> |
Loading…
Reference in new issue