Commit 1764602d by tiger

updateJob without date

1 parent 3bd38d56
......@@ -55,15 +55,12 @@ public class SopXxlJobUtil {
public static void initLoadJob() {
XxlJobInfo job = XxlJobUtil.findByBusKey(SOP_LOAD_JOB_ID);
if (job != null) {
if (job.getTriggerStatus() == 1) {
return;
} else {
XxlJobUtil.remove(SOP_LOAD_JOB_ID);
}
}
boolean exists = job != null;
if (job == null) {
job = new XxlJobInfo();
}
job.setExecutorParam("");
job.setJobDesc("加载所有SOP实例任务");
job.setAuthor("admin");
......@@ -71,20 +68,27 @@ public class SopXxlJobUtil {
job.setExecutorHandler(SOP_LOAD_JOB_ID);
job.setBusKey(SOP_LOAD_JOB_ID);
job.setTriggerStatus(1);
String add = XxlJobUtil.add(job);
if (exists) {
String update = XxlJobUtil.update(job);
SopXxlJobUtil.log(log, "【{}】任务更新,cron:{},result:{}", SOP_LOAD_JOB_ID, job.getScheduleConf(), update);
} else {
String add = XxlJobUtil.add(job);
SopXxlJobUtil.log(log, "【{}】任务启动,cron:{},result:{}", SOP_LOAD_JOB_ID, job.getScheduleConf(), add);
}
}
public static void initSopJob(SopInst inst) {
String jobBusId = jobBusId(inst);
XxlJobInfo job = XxlJobUtil.findByBusKey(jobBusId);
if (job != null) {
XxlJobUtil.remove(jobBusId);
boolean exists = job != null;
if (job == null) {
job = new XxlJobInfo();
}
// 重建job
job = new XxlJobInfo();
job.setExecutorParam(inst.getInstId());
job.setJobDesc(inst.getInstName());
job.setAuthor("admin");
......@@ -92,9 +96,14 @@ public class SopXxlJobUtil {
job.setExecutorHandler(SopXxlJobUtil.SOP_EXECUTE_JOB_ID);
job.setBusKey(jobBusId);
job.setTriggerStatus(1);
String add = XxlJobUtil.add(job);
SopXxlJobUtil.log(log, "【{}】Sop任务启动,cron:{},result:{}", inst.getInstId(), job.getScheduleConf(), add);
if (exists) {
String update = XxlJobUtil.update(job);
SopXxlJobUtil.log(log, "【{}】Sop任务更新,cron:{},result:{}", jobBusId, job.getScheduleConf(), update);
} else {
String add = XxlJobUtil.add(job);
SopXxlJobUtil.log(log, "【{}】Sop任务启动,cron:{},result:{}", jobBusId, job.getScheduleConf(), add);
}
}
public static void initSopNodesJob(SopStruct sop) {
......@@ -115,8 +124,10 @@ public class SopXxlJobUtil {
public static void initSopNodeJob(SopStruct sop, SopInstNode node) {
String jobBusId = jobBusId(sop.getInst(), node);
XxlJobInfo job = XxlJobUtil.findByBusKey(jobBusId);
if (job != null) {
XxlJobUtil.remove(jobBusId);
boolean exists = job != null;
if (job == null) {
job = new XxlJobInfo();
}
// 15 2/3 * * * ?
......@@ -128,7 +139,6 @@ public class SopXxlJobUtil {
// 前置节点,后置节点
Pair<Set<Integer>, Set<Integer>> linkPair = sop.getInstLinkMap().get(node.getNodeId());
boolean enabled = linkPair == null || linkPair.getKey().isEmpty();
SopInstNodeParam params = new SopInstNodeParam();
params.setInstNodeId(node.getInstNodeId());
params.setPreIds(linkPair.getKey());
......@@ -136,7 +146,6 @@ public class SopXxlJobUtil {
String paramJson = JSONUtil.toJsonStr(params);
// 重建job
job = new XxlJobInfo();
job.setExecutorParam(paramJson);
job.setJobDesc(sop.getInst().getInstName() + "-" + node.getNodeName());
job.setAuthor("admin");
......@@ -144,10 +153,17 @@ public class SopXxlJobUtil {
job.setExecutorHandler(SopXxlJobUtil.SOP_NODE_EXECUTE_JOB_ID);
job.setBusKey(jobBusId);
job.setTriggerStatus(1);
if (exists) {
String update = XxlJobUtil.update(job);
SopXxlJobUtil.log(log, "【{}】Sop节点任务更新,cron:{},result:{}", jobBusId, job.getScheduleConf(), update);
} else {
String add = XxlJobUtil.add(job);
SopXxlJobUtil.log(log, "【{}】Sop节点任务启动,cron:{},result:{}", jobBusId, job.getScheduleConf(), add);
}
}
public static String jobBusId(SopInst inst) {
return inst.getInstId();
}
......
package cn.com.glsx.process.job.xxljob.core;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
public class XxlJobInfo {
......@@ -12,12 +9,8 @@ public class XxlJobInfo {
private int jobGroup; // 执行器主键ID
private String jobDesc;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+08:00")
private Date addTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+08:00")
private Date updateTime;
private String author; // 负责人
......@@ -38,8 +31,6 @@ public class XxlJobInfo {
private String glueSource; // GLUE源代码
private String glueRemark; // GLUE备注
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+08:00")
private Date glueUpdatetime; // GLUE更新时间
private String childJobId; // 子任务ID,多个逗号分隔
......@@ -48,8 +39,7 @@ public class XxlJobInfo {
private long triggerLastTime; // 上次调度时间
private long triggerNextTime; // 下次调度时间
private String busKey; //业务标识
private String busKey; // 业务标识
public int getId() {
return id;
......
......@@ -9,8 +9,8 @@ import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSONObject;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.util.GsonTool;
import com.xxl.job.core.util.XxlJobRemotingUtil;
import cn.hutool.http.HttpResponse;
......@@ -84,6 +84,11 @@ public class XxlJobUtil {
XxlJobInfo byBusKey = findByBusKey(busKey);
if (byBusKey != null) {
jobInfo.setId(byBusKey.getId());
jobInfo.setAddTime(null);
jobInfo.setUpdateTime(null);
jobInfo.setGlueUpdatetime(null);
return doPost(adminAddresses + UPDATE_URL, jobInfo, String.class);
}
return null;
......@@ -179,7 +184,7 @@ public class XxlJobUtil {
}
public static <T> T doPost(String url, Object json, Class<T> clazz) {
log.info("请求url{},请求参数{} {}:{}", url, JSONObject.toJSONString(json), XxlJobRemotingUtil.XXL_JOB_ACCESS_TOKEN, accessToken);
log.info("请求url{},请求参数{} {}:{}", url, GsonTool.toJson(json), XxlJobRemotingUtil.XXL_JOB_ACCESS_TOKEN, accessToken);
ReturnT<T> returnT = XxlJobRemotingUtil.postBody(url, accessToken, 30, json, clazz);
if (returnT.getCode() != SUCCESS_CODE) {
log.info(String.format("【xxl-job】接口调用失败,错误码:%s,原因:%s", returnT.getCode(), returnT.getMsg()));
......
......@@ -9,6 +9,7 @@ import com.xxl.job.core.handler.annotation.XxlJob;
import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
import cn.com.glsx.process.job.xxljob.param.SopInstNodeParam;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService;
import cn.hutool.json.JSONUtil;
......@@ -18,7 +19,6 @@ import lombok.extern.slf4j.Slf4j;
@Component
public class SopInstNodeExecuteJobHandler {
@Resource
private SopService sopService;
......@@ -30,8 +30,16 @@ public class SopInstNodeExecuteJobHandler {
SopXxlJobUtil.log(log, "【执行Sop节点】{}", param);
SopStruct sop = sopService.loadSopByInstNodeId(param.getInstNodeId());
// TODO 执行sop里面的instNodeId节点。
SopInstNode node = sop.getInstNodeMap().get(param.getInstNodeId());
{
// 节点执行
}
// TODO 处理节点流程
// 创建所有节点任务
// SopXxlJobUtil.initSopNodeJob(sop);
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!