Commit a0fd5f51 by tiger

快照参数标记

1 parent d7a5ea54
......@@ -9,3 +9,4 @@
*.container
*.name
/platform-process-api/*.factorypath
/platform-process/*.path_IS_UNDEFINED
......@@ -14,31 +14,31 @@ import cn.com.glsx.process.modules.model.SopInstSearch;
@Mapper
public interface SopInstMapper extends CommonBaseMapper<SopInst> {
List<SopInst> selectByGroupId(SopInstSearch search);
/**
* 通过门店模板实例初始参数查询
*
* @param customData
* @return
*/
List<SopInst> selectByCustomData(@Param("customData") Map<String, Object> customData);
/**
* 更新门店模板实例默认参数的自定义参数
*
* @param instId
* @param customData
*/
void updateInstParamCustomData(@Param("instId") String instId, @Param("customData") Map<String, Object> customData);
/**
* 更新门店模板实例的状态
*
* @param instId
* @param status
*/
void updateInstStatus(@Param("instId") String instId, @Param("status") Byte status);
List<SopInst> selectByGroupId(SopInstSearch search);
/**
* 通过门店模板实例初始参数查询
*
* @param customData
* @return
*/
List<SopInst> selectByCustomData(@Param("customData") Map<String, Object> customData);
/**
* 更新门店模板实例默认参数的自定义参数
*
* @param instId
* @param customData
*/
void updateInstParamCustomData(@Param("instId") String instId, @Param("customData") Map<String, Object> customData);
/**
* 更新门店模板实例的状态
*
* @param instId
* @param status
*/
void updateInstStatus(@Param("instId") String instId, @Param("status") Byte status);
void updateInstBatchNo(@Param("instId") String instId, @Param("batchNo") String batchNo);
}
\ No newline at end of file
......@@ -31,7 +31,7 @@ public class SopInstExecuteJobHandler {
SopStruct sop = sopService.loadSop(instId);
// 创建执行批次
SopInstBatch batch = sopService.createBatch(instId);
SopInstBatch batch = sopService.createBatch(sop.getInst());
sop.setBatch(batch);
sop.getInst().setBatchNo(batch.getBatchNo());
......
......@@ -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.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.SopInstNodeBatch;
import cn.com.glsx.process.modules.model.SopStruct;
......@@ -109,6 +110,7 @@ public class SopInstNodeExecuteJobHandler {
// 重新加载sop
sop = reloadAndCreateBatch(sop, node);
// 预备执行参数
SnapshotStruct snapshotStruct = instance.prepare(sop, node);
// 执行sop节点
......@@ -137,8 +139,15 @@ public class SopInstNodeExecuteJobHandler {
}
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();
nodeBatch.setSnapshot(JSONUtil.toJsonStr(result));// TODO 这里需要考虑合并结果
nodeBatch.setSnapshot(JSONUtil.toJsonStr(result));
nodeBatch.setUpdateTime(new Date());
sopService.updateInstNodeBatch(nodeBatch);
}
......@@ -146,7 +155,7 @@ public class SopInstNodeExecuteJobHandler {
private SopStruct reloadAndCreateBatch(SopStruct sop, SopInstNode node) {
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);
return sop;
}
......
......@@ -197,28 +197,29 @@ public class SopService {
// }
}
public SopInstBatch createBatch(String instId) {
public SopInstBatch createBatch(SopInst sopInst) {
SopInstBatch batch = new SopInstBatch();
batch.setBatchNo(SnowFlake.nextSerialNumber());
batch.setCreateTime(new Date());
batch.setUpdateTime(new Date());
batch.setInstId(instId);
batch.setSnapshot("");
batch.setInstId(sopInst.getInstId());
batch.setSnapshot(sopInst.getInstSnapshot());
instBatchMapper.insert(batch);
instMapper.updateInstBatchNo(instId, batch.getBatchNo());
instMapper.updateInstBatchNo(sopInst.getInstId(), batch.getBatchNo());
return batch;
}
public SopInstNodeBatch createNodeBatch(String batchNo, Integer instNodeId) {
public SopInstNodeBatch createNodeBatch(SopInst sopInst, Integer instNodeId) {
SopInstNodeBatch curBatch = new SopInstNodeBatch();
curBatch.setBatchNo(batchNo);
curBatch.setBatchNo(sopInst.getBatchNo());
curBatch.setNodeBatchNo(SnowFlake.nextSerialNumber());
curBatch.setCreateTime(new Date());
curBatch.setUpdateTime(new Date());
curBatch.setInstNodeId(instNodeId);
curBatch.setSnapshot("");
curBatch.setSnapshot(sopInst.getInstSnapshot());
instNodeBatchMapper.insert(curBatch);
......@@ -229,4 +230,10 @@ public class SopService {
instNodeBatchMapper.updateByPrimaryKey(nodeBatch);
}
public void updateInstBatch(SopInst sopInst, SopInstBatch batch) {
instMapper.updateByPrimaryKey(sopInst);
instBatchMapper.updateByPrimaryKey(batch);
}
}
......@@ -17,6 +17,11 @@
package cn.com.glsx.process.modules.sop.execute;
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;
* @author kome
* @date 2023年9月20日 下午6:02:22
*/
@Data
public class RunResult implements Serializable {
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 {
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();
......
......@@ -16,14 +16,20 @@
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.model.SopStruct;
import cn.com.glsx.process.util.JacksonUtils;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
public interface SopNodeExecutor {
Logger log = LoggerFactory.getLogger(SopNodeExecutor.class);
/**
* 通过sop模板+sop实例输入参数+sop跑批快照,获得本节点执行的输入参数
*
......@@ -32,17 +38,25 @@ public interface SopNodeExecutor {
*/
default SnapshotStruct prepare(SopStruct sop, SopInstNode node) {
SnapshotStruct es = new SnapshotStruct();
// 启动参数
if (StrUtil.isNotEmpty(sop.getInst().getInstParam())) {
JSONObject paramObj = JSONUtil.parseObj(sop.getInst().getInstParam());
es.getParamMap().putAll(paramObj);
if (StrUtil.length(sop.getBatch().getSnapshot()) > 3) {
// 继承参数
es = JacksonUtils.fromJson(sop.getBatch().getSnapshot(), SnapshotStruct.class);
} else {
// 启动参数
if (StrUtil.isNotEmpty(sop.getInst().getInstParam())) {
JSONObject paramObj = JSONUtil.parseObj(sop.getInst().getInstParam());
es.getInitMap().putAll(paramObj);
}
}
// 当前节点需要的参数
if (StrUtil.isNotEmpty(node.getNodeParam())) {
JSONObject nodeParamObj = JSONUtil.parseObj(node.getNodeParam());
es.getExecuteMap().putAll(nodeParamObj);
if (StrUtil.isNotEmpty(node.getNodeKey())) {
JSONObject nodeParamObj = JSONUtil.parseObj(node.getNodeParam());
es.getParamMap().put(node.getNodeKey(), nodeParamObj);
} else {
log.warn("【{}】nodeKey 为空!!!", node.getInstId() + "-" + node.getNodeId());
}
}
return es;
......@@ -71,13 +85,13 @@ public interface SopNodeExecutor {
// 启动参数
if (StrUtil.isNotEmpty(sop.getInst().getInstParam())) {
JSONObject paramObj = JSONUtil.parseObj(sop.getInst().getInstParam());
es.getParamMap().putAll(paramObj);
es.getInitMap().putAll(paramObj);
}
// 当前节点需要的参数
if (StrUtil.isNotEmpty(node.getNodeParam())) {
JSONObject nodeParamObj = JSONUtil.parseObj(node.getNodeParam());
es.getExecuteMap().putAll(nodeParamObj);
es.getParamMap().putAll(nodeParamObj);
}
return es;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!