Commit a0fd5f51 by tiger

快照参数标记

1 parent d7a5ea54
...@@ -9,3 +9,4 @@ ...@@ -9,3 +9,4 @@
*.container *.container
*.name *.name
/platform-process-api/*.factorypath /platform-process-api/*.factorypath
/platform-process/*.path_IS_UNDEFINED
...@@ -31,7 +31,7 @@ public class SopInstExecuteJobHandler { ...@@ -31,7 +31,7 @@ public class SopInstExecuteJobHandler {
SopStruct sop = sopService.loadSop(instId); SopStruct sop = sopService.loadSop(instId);
// 创建执行批次 // 创建执行批次
SopInstBatch batch = sopService.createBatch(instId); SopInstBatch batch = sopService.createBatch(sop.getInst());
sop.setBatch(batch); sop.setBatch(batch);
sop.getInst().setBatchNo(batch.getBatchNo()); sop.getInst().setBatchNo(batch.getBatchNo());
......
...@@ -12,6 +12,7 @@ import com.xxl.job.core.handler.annotation.XxlJob; ...@@ -12,6 +12,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.core.SopXxlJobUtil;
import cn.com.glsx.process.job.xxljob.param.SopInstNodeParam; import cn.com.glsx.process.job.xxljob.param.SopInstNodeParam;
import cn.com.glsx.process.modules.entity.SopInstBatch;
import cn.com.glsx.process.modules.entity.SopInstNode; import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.entity.SopInstNodeBatch; import cn.com.glsx.process.modules.entity.SopInstNodeBatch;
import cn.com.glsx.process.modules.model.SopStruct; import cn.com.glsx.process.modules.model.SopStruct;
...@@ -109,6 +110,7 @@ public class SopInstNodeExecuteJobHandler { ...@@ -109,6 +110,7 @@ public class SopInstNodeExecuteJobHandler {
// 重新加载sop // 重新加载sop
sop = reloadAndCreateBatch(sop, node); sop = reloadAndCreateBatch(sop, node);
// 预备执行参数
SnapshotStruct snapshotStruct = instance.prepare(sop, node); SnapshotStruct snapshotStruct = instance.prepare(sop, node);
// 执行sop节点 // 执行sop节点
...@@ -137,8 +139,15 @@ public class SopInstNodeExecuteJobHandler { ...@@ -137,8 +139,15 @@ public class SopInstNodeExecuteJobHandler {
} }
private void updateBatch(SopStruct sop, SopInstNode node, SnapshotStruct result) { private void updateBatch(SopStruct sop, SopInstNode node, SnapshotStruct result) {
// TODO 这里需要考虑合并结果
SopInstBatch batch = sop.getBatch();
batch.setSnapshot(JSONUtil.toJsonStr(result));
sop.getInst().setInstSnapshot(batch.getSnapshot());
sopService.updateInstBatch(sop.getInst(), batch);
SopInstNodeBatch nodeBatch = sop.getNodeBatch(); SopInstNodeBatch nodeBatch = sop.getNodeBatch();
nodeBatch.setSnapshot(JSONUtil.toJsonStr(result));// TODO 这里需要考虑合并结果 nodeBatch.setSnapshot(JSONUtil.toJsonStr(result));
nodeBatch.setUpdateTime(new Date()); nodeBatch.setUpdateTime(new Date());
sopService.updateInstNodeBatch(nodeBatch); sopService.updateInstNodeBatch(nodeBatch);
} }
...@@ -146,7 +155,7 @@ public class SopInstNodeExecuteJobHandler { ...@@ -146,7 +155,7 @@ public class SopInstNodeExecuteJobHandler {
private SopStruct reloadAndCreateBatch(SopStruct sop, SopInstNode node) { private SopStruct reloadAndCreateBatch(SopStruct sop, SopInstNode node) {
sop = sopService.loadSop(sop.getInst().getInstId()); sop = sopService.loadSop(sop.getInst().getInstId());
// 创建节点执行批次 // 创建节点执行批次
SopInstNodeBatch curBatch = sopService.createNodeBatch(sop.getInst().getBatchNo(), node.getInstNodeId()); SopInstNodeBatch curBatch = sopService.createNodeBatch(sop.getInst(), node.getInstNodeId());
sop.setNodeBatch(curBatch); sop.setNodeBatch(curBatch);
return sop; return sop;
} }
......
...@@ -197,28 +197,29 @@ public class SopService { ...@@ -197,28 +197,29 @@ public class SopService {
// } // }
} }
public SopInstBatch createBatch(String instId) { public SopInstBatch createBatch(SopInst sopInst) {
SopInstBatch batch = new SopInstBatch(); SopInstBatch batch = new SopInstBatch();
batch.setBatchNo(SnowFlake.nextSerialNumber()); batch.setBatchNo(SnowFlake.nextSerialNumber());
batch.setCreateTime(new Date()); batch.setCreateTime(new Date());
batch.setUpdateTime(new Date()); batch.setUpdateTime(new Date());
batch.setInstId(instId); batch.setInstId(sopInst.getInstId());
batch.setSnapshot(""); batch.setSnapshot(sopInst.getInstSnapshot());
instBatchMapper.insert(batch); instBatchMapper.insert(batch);
instMapper.updateInstBatchNo(instId, batch.getBatchNo());
instMapper.updateInstBatchNo(sopInst.getInstId(), batch.getBatchNo());
return batch; return batch;
} }
public SopInstNodeBatch createNodeBatch(String batchNo, Integer instNodeId) { public SopInstNodeBatch createNodeBatch(SopInst sopInst, Integer instNodeId) {
SopInstNodeBatch curBatch = new SopInstNodeBatch(); SopInstNodeBatch curBatch = new SopInstNodeBatch();
curBatch.setBatchNo(batchNo); curBatch.setBatchNo(sopInst.getBatchNo());
curBatch.setNodeBatchNo(SnowFlake.nextSerialNumber()); curBatch.setNodeBatchNo(SnowFlake.nextSerialNumber());
curBatch.setCreateTime(new Date()); curBatch.setCreateTime(new Date());
curBatch.setUpdateTime(new Date()); curBatch.setUpdateTime(new Date());
curBatch.setInstNodeId(instNodeId); curBatch.setInstNodeId(instNodeId);
curBatch.setSnapshot(""); curBatch.setSnapshot(sopInst.getInstSnapshot());
instNodeBatchMapper.insert(curBatch); instNodeBatchMapper.insert(curBatch);
...@@ -229,4 +230,10 @@ public class SopService { ...@@ -229,4 +230,10 @@ public class SopService {
instNodeBatchMapper.updateByPrimaryKey(nodeBatch); instNodeBatchMapper.updateByPrimaryKey(nodeBatch);
} }
public void updateInstBatch(SopInst sopInst, SopInstBatch batch) {
instMapper.updateByPrimaryKey(sopInst);
instBatchMapper.updateByPrimaryKey(batch);
}
} }
...@@ -17,6 +17,11 @@ ...@@ -17,6 +17,11 @@
package cn.com.glsx.process.modules.sop.execute; package cn.com.glsx.process.modules.sop.execute;
import java.io.Serializable; import java.io.Serializable;
import java.util.Map;
import com.google.common.collect.Maps;
import lombok.Data;
/** /**
* 单节点单次执行结果 * 单节点单次执行结果
...@@ -24,8 +29,12 @@ import java.io.Serializable; ...@@ -24,8 +29,12 @@ import java.io.Serializable;
* @author kome * @author kome
* @date 2023年9月20日 下午6:02:22 * @date 2023年9月20日 下午6:02:22
*/ */
@Data
public class RunResult implements Serializable { public class RunResult implements Serializable {
private static final long serialVersionUID = -1321328867544959522L; private static final long serialVersionUID = -1321328867544959522L;
private String key;
private Map<String, Object> map = Maps.newHashMap();
} }
...@@ -20,15 +20,15 @@ public class SnapshotStruct implements Serializable, Cloneable { ...@@ -20,15 +20,15 @@ public class SnapshotStruct implements Serializable, Cloneable {
private static final long serialVersionUID = -1413400196758036960L; private static final long serialVersionUID = -1413400196758036960L;
// //
/** /**
* 各节点的初始化参数表 * Sop批次初始化参数表
*/ */
private Map<String, Object> paramMap = Maps.newHashMap(); private Map<String, Object> initMap = Maps.newHashMap();
/** /**
* 各节点的输入参数表 * Sop各节点的输入参数表
*/ */
private Map<String, Object> executeMap = Maps.newHashMap(); private Map<String, Object> paramMap = Maps.newHashMap();
/** /**
* 各节点的执行结果表 * Sop各节点的执行结果表
*/ */
private Map<String, Object> resultMap = Maps.newHashMap(); private Map<String, Object> resultMap = Maps.newHashMap();
......
...@@ -16,14 +16,20 @@ ...@@ -16,14 +16,20 @@
package cn.com.glsx.process.modules.sop.execute; package cn.com.glsx.process.modules.sop.execute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.com.glsx.process.modules.entity.SopInstNode; import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.model.SopStruct; import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.util.JacksonUtils;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
public interface SopNodeExecutor { public interface SopNodeExecutor {
Logger log = LoggerFactory.getLogger(SopNodeExecutor.class);
/** /**
* 通过sop模板+sop实例输入参数+sop跑批快照,获得本节点执行的输入参数 * 通过sop模板+sop实例输入参数+sop跑批快照,获得本节点执行的输入参数
* *
...@@ -32,17 +38,25 @@ public interface SopNodeExecutor { ...@@ -32,17 +38,25 @@ public interface SopNodeExecutor {
*/ */
default SnapshotStruct prepare(SopStruct sop, SopInstNode node) { default SnapshotStruct prepare(SopStruct sop, SopInstNode node) {
SnapshotStruct es = new SnapshotStruct(); SnapshotStruct es = new SnapshotStruct();
if (StrUtil.length(sop.getBatch().getSnapshot()) > 3) {
// 继承参数
es = JacksonUtils.fromJson(sop.getBatch().getSnapshot(), SnapshotStruct.class);
} else {
// 启动参数 // 启动参数
if (StrUtil.isNotEmpty(sop.getInst().getInstParam())) { if (StrUtil.isNotEmpty(sop.getInst().getInstParam())) {
JSONObject paramObj = JSONUtil.parseObj(sop.getInst().getInstParam()); JSONObject paramObj = JSONUtil.parseObj(sop.getInst().getInstParam());
es.getParamMap().putAll(paramObj); es.getInitMap().putAll(paramObj);
}
} }
// 当前节点需要的参数 // 当前节点需要的参数
if (StrUtil.isNotEmpty(node.getNodeParam())) { if (StrUtil.isNotEmpty(node.getNodeParam())) {
if (StrUtil.isNotEmpty(node.getNodeKey())) {
JSONObject nodeParamObj = JSONUtil.parseObj(node.getNodeParam()); JSONObject nodeParamObj = JSONUtil.parseObj(node.getNodeParam());
es.getExecuteMap().putAll(nodeParamObj); es.getParamMap().put(node.getNodeKey(), nodeParamObj);
} else {
log.warn("【{}】nodeKey 为空!!!", node.getInstId() + "-" + node.getNodeId());
}
} }
return es; return es;
...@@ -71,13 +85,13 @@ public interface SopNodeExecutor { ...@@ -71,13 +85,13 @@ public interface SopNodeExecutor {
// 启动参数 // 启动参数
if (StrUtil.isNotEmpty(sop.getInst().getInstParam())) { if (StrUtil.isNotEmpty(sop.getInst().getInstParam())) {
JSONObject paramObj = JSONUtil.parseObj(sop.getInst().getInstParam()); JSONObject paramObj = JSONUtil.parseObj(sop.getInst().getInstParam());
es.getParamMap().putAll(paramObj); es.getInitMap().putAll(paramObj);
} }
// 当前节点需要的参数 // 当前节点需要的参数
if (StrUtil.isNotEmpty(node.getNodeParam())) { if (StrUtil.isNotEmpty(node.getNodeParam())) {
JSONObject nodeParamObj = JSONUtil.parseObj(node.getNodeParam()); JSONObject nodeParamObj = JSONUtil.parseObj(node.getNodeParam());
es.getExecuteMap().putAll(nodeParamObj); es.getParamMap().putAll(nodeParamObj);
} }
return es; return es;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!