| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- package com.cyksj.xxljob;
- import cn.hutool.core.net.URLEncoder;
- import com.cyksj.common.exception.BusinessRuntimeException;
- import lombok.Data;
- import lombok.Getter;
- import org.apache.commons.lang3.StringUtils;
- import java.nio.charset.Charset;
- /**
- * @ClassName XxlJobInfo
- * @Description TODO
- * @Author Huang yuanzhi
- * @Date 2023/6/12 16:11
- * @Version 1.0.0
- **/
- @Data
- public class XxlJobInfo {
- public XxlJobInfo() {
- }
- public XxlJobInfo(int id, String jobDesc, String jobCron, int jobGroup, String author, String alarmEmail, String executorHandler, String executorParam) {
- this.id = id;
- this.jobGroup = jobGroup;
- this.jobDesc = jobDesc;
- this.jobCron = jobCron;
- this.author = author;
- this.alarmEmail = alarmEmail;
- this.executorHandler = executorHandler;
- this.executorParam = executorParam;
- this.triggerStatus = 1;
- }
- private int id;
- /**
- * 执行器主键ID
- */
- private int jobGroup = 5;
- /**
- * 备注
- */
- private String jobDesc;
- /**
- * 表达式
- */
- private String jobCron;
- private String glueType = "BEAN";
- /**
- * 负责人
- */
- private String author;
- /**
- * 报警邮件
- */
- private String alarmEmail;
- /**
- * 执行器路由策略
- */
- private String executorRouteStrategy = "FIRST";
- /**
- * 执行器,任务Handler名称
- */
- private String executorHandler;
- /**
- * 执行器,任务参数
- */
- private String executorParam;
- /**
- * 阻塞处理策略
- */
- private String executorBlockStrategy = "SERIAL_EXECUTION";
- /**
- * 任务执行超时时间,单位秒
- */
- private int executorTimeout;
- private String glueRemark = "GLUE代码初始化";
- /**
- * 失败重试次数
- */
- private int executorFailRetryCount;
- /**
- * 子任务ID,多个逗号分隔
- */
- private String childJobId;
- /**
- * 调度状态:0-停止,1-运行
- */
- private int triggerStatus;
- /**
- * 上次调度时间
- */
- private long triggerLastTime;
- /**
- * 下次调度时间
- */
- private long triggerNextTime;
- //银河执行器 id
- private static int jobGroups = 10;
- /**
- * 创建执行器
- *
- * @param author
- * @param jobDesc 任务秒速
- * @param corn 表达式
- * @param executorHandler executorHandler
- * @param executorParam 参数
- * @return
- */
- public static XxlJobInfo getInstance(AUTHOR author, String jobDesc, String corn, int jopGroup, String executorHandler, String executorParam) {
- return new XxlJobInfo(0, jobDesc, URLEncoder.createQuery().encode(corn, Charset.defaultCharset()), jopGroup, author.getName(), author.email, executorHandler, executorParam);
- }
- public static XxlJobInfo getUpdateInstance(int id, AUTHOR author, String jobDesc, String corn, int jopGroup, String executorHandler, String executorParam) {
- return new XxlJobInfo(id, jobDesc, URLEncoder.createQuery().encode(corn, Charset.defaultCharset()), jopGroup, author.getName(), author.email, executorHandler, executorParam);
- }
- public static XxlJobInfo getTaskInstance(int id, String corn, String executorParam) {
- AUTHOR author = AUTHOR.Zou;
- if (StringUtils.isBlank(corn)) {
- throw BusinessRuntimeException.getInstance("任务运行周期不能为空");
- }
- return new XxlJobInfo(id, "周期群发任务", URLEncoder.createQuery().encode(corn, Charset.defaultCharset()), jobGroups, author.getName(), author.email, "yh_corp_msg_bulk_task_cycle_job", executorParam);
- }
- @Getter
- public enum AUTHOR {
- Zou("zou", "1091496505@qq.com");
- AUTHOR(String name, String email) {
- this.name = name;
- this.email = email;
- }
- private String name;
- private String email;
- }
- @Override
- public String toString() {
- return
- "?id=" + id +
- "&jobDesc=" + jobDesc +
- "&jobCron=" + jobCron +
- "&jobGroup=" + jobGroup +
- "&glueType=" + glueType +
- "&author=" + author +
- "&alarmEmail=" + alarmEmail +
- "&executorRouteStrategy=" + executorRouteStrategy +
- "&executorHandler=" + executorHandler +
- "&executorParam=" + executorParam +
- "&executorBlockStrategy=" + executorBlockStrategy +
- "&executorTimeout=" + executorTimeout +
- "&glueRemark=" + glueRemark +
- "&executorFailRetryCount=" + executorFailRetryCount +
- "&triggerStatus=" + triggerStatus +
- "&triggerLastTime=" + triggerLastTime +
- "&triggerNextTime=" + triggerNextTime;
- }
- }
|