Commit a4921aba by tiger

sql

1 parent b8bd7677
...@@ -19,7 +19,6 @@ import cn.com.glsx.process.modules.entity.SopInstNodeBatch; ...@@ -19,7 +19,6 @@ import cn.com.glsx.process.modules.entity.SopInstNodeBatch;
import cn.com.glsx.process.modules.model.SopStruct; import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService; import cn.com.glsx.process.modules.service.SopService;
import cn.com.glsx.process.modules.sop.SopHelper; import cn.com.glsx.process.modules.sop.SopHelper;
import cn.com.glsx.process.modules.sop.execute.RunResult;
import cn.com.glsx.process.modules.sop.execute.SnapshotStruct; import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor; import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutorFactory; import cn.com.glsx.process.modules.sop.execute.SopNodeExecutorFactory;
...@@ -111,13 +110,13 @@ public class SopInstNodeExecuteJobHandler { ...@@ -111,13 +110,13 @@ public class SopInstNodeExecuteJobHandler {
try { try {
if (node.getNodeSkip() != 1) { if (node.getNodeSkip() != 1) {
// 重新加载sop // 重新加载sop
sop = reloadAndCreateBatch(sop, node); sop = reloadAndCreateNodeBatch(sop, node);
// 预备执行参数 // 预备执行参数
SnapshotStruct snapshotStruct = instance.prepare(sop, node); SnapshotStruct snapshotStruct = instance.prepare(sop, node);
// 执行sop节点 // 执行sop节点
RunResult result = instance.execute(sop, node, snapshotStruct); Object result = instance.execute(sop, node, snapshotStruct);
// 处理执行结果 // 处理执行结果
snapshotStruct = instance.handleResult(sop, node, snapshotStruct, result); snapshotStruct = instance.handleResult(sop, node, snapshotStruct, result);
...@@ -164,7 +163,7 @@ public class SopInstNodeExecuteJobHandler { ...@@ -164,7 +163,7 @@ public class SopInstNodeExecuteJobHandler {
sopService.updateNodeBatch(inst, batch, nodeBatch); sopService.updateNodeBatch(inst, batch, nodeBatch);
} }
private SopStruct reloadAndCreateBatch(SopStruct sop, SopInstNode node) { private SopStruct reloadAndCreateNodeBatch(SopStruct sop, SopInstNode node) {
sop = sopService.loadSop(sop.getInst().getInstId()); sop = sopService.loadSop(sop.getInst().getInstId());
// 创建节点执行批次 // 创建节点执行批次
SopInstNodeBatch curBatch = sopService.createNodeBatch(sop.getInst(), node.getInstNodeId()); SopInstNodeBatch curBatch = sopService.createNodeBatch(sop.getInst(), node.getInstNodeId());
......
package cn.com.glsx.process.modules.sop.execute;
import lombok.Data;
/**
* <code>
{
"paramName": "merchantId",
"paramDesc": "门店id,分配给门店时需要赋值",
"valueType": "String",
"defaultValue": "",
"required": true
}
* </code>
*
* @author kome
* @date 2023年9月19日 下午5:20:39
* @param <T> String / Map / List
*/
@Data
public class Param<T> {
private String paramName;
private String paramDesc;
/**
* String / Map / List
*/
private String valueType;
private T defaultValue;
private boolean required;
}
/*
* @Copyright (c) 2018 缪聪(mcg-helper@qq.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;
/**
* 单节点单次执行结果
*
* @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();
}
...@@ -18,7 +18,7 @@ import lombok.Getter; ...@@ -18,7 +18,7 @@ import lombok.Getter;
public class SnapshotStruct implements Serializable, Cloneable { public class SnapshotStruct implements Serializable, Cloneable {
private static final long serialVersionUID = -1413400196758036960L; private static final long serialVersionUID = -1413400196758036960L;
//
/** /**
* Sop批次初始化参数表 * Sop批次初始化参数表
*/ */
......
...@@ -50,6 +50,8 @@ public interface SopNodeExecutor { ...@@ -50,6 +50,8 @@ public interface SopNodeExecutor {
} }
} }
es.getInitMap().put("instId", sop.getInst().getInstId());
// 当前节点需要的参数 // 当前节点需要的参数
if (StrUtil.isNotEmpty(node.getNodeParam())) { if (StrUtil.isNotEmpty(node.getNodeParam())) {
// 节点入参按freemarker语法替换 // 节点入参按freemarker语法替换
...@@ -74,7 +76,7 @@ public interface SopNodeExecutor { ...@@ -74,7 +76,7 @@ public interface SopNodeExecutor {
* @return 输出参数 * @return 输出参数
* @throws Exception * @throws Exception
*/ */
RunResult execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception; Object execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception;
/** /**
* 合并本节点执行结果到快照体中 * 合并本节点执行结果到快照体中
...@@ -85,14 +87,14 @@ public interface SopNodeExecutor { ...@@ -85,14 +87,14 @@ public interface SopNodeExecutor {
* @param result * @param result
* @return * @return
*/ */
default SnapshotStruct handleResult(SopStruct sop, SopInstNode node, SnapshotStruct es, RunResult result) { default SnapshotStruct handleResult(SopStruct sop, SopInstNode node, SnapshotStruct es, Object result) {
if (result == null) { if (result == null) {
return es; return es;
} }
// 当前节点需要的参数 // 当前节点需要的参数
if (StrUtil.isNotEmpty(node.getNodeKey())) { if (StrUtil.isNotEmpty(node.getNodeKey())) {
es.getParamMap().put(node.getNodeKey(), result); es.getResultMap().put(node.getNodeKey(), result);
} else { } else {
log.warn("【{}】nodeKey 为空!!!", node.getInstId() + "-" + node.getNodeId()); log.warn("【{}】nodeKey 为空!!!", node.getInstId() + "-" + node.getNodeId());
} }
......
...@@ -8,7 +8,6 @@ import cn.com.glsx.process.common.constant.Constants; ...@@ -8,7 +8,6 @@ import cn.com.glsx.process.common.constant.Constants;
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.modules.sop.execute.SnapshotStruct; import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.modules.sop.execute.RunResult;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor; import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -17,7 +16,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -17,7 +16,7 @@ import lombok.extern.slf4j.Slf4j;
public class EndExecutor implements SopNodeExecutor { public class EndExecutor implements SopNodeExecutor {
@Override @Override
public RunResult execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception { public Object execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception {
Map<String, Object> resultMap = executeStruct.getResultMap(); Map<String, Object> resultMap = executeStruct.getResultMap();
resultMap.put(Constants.RES_KEY, Constants.RES_SUCCESS); resultMap.put(Constants.RES_KEY, Constants.RES_SUCCESS);
......
...@@ -12,7 +12,6 @@ import cn.com.glsx.process.modules.entity.SopInst; ...@@ -12,7 +12,6 @@ import cn.com.glsx.process.modules.entity.SopInst;
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.modules.sop.execute.SnapshotStruct; import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.modules.sop.execute.RunResult;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor; import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
import cn.com.glsx.process.modules.sop.execute.plugin.java.DynamicEngine; import cn.com.glsx.process.modules.sop.execute.plugin.java.DynamicEngine;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -22,7 +21,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -22,7 +21,7 @@ import lombok.extern.slf4j.Slf4j;
public class JavaExecutor implements SopNodeExecutor { public class JavaExecutor implements SopNodeExecutor {
@Override @Override
public RunResult execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception { public Object execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception {
Map<String, Object> resultMap = executeStruct.getResultMap(); Map<String, Object> resultMap = executeStruct.getResultMap();
try { try {
// 处理开始节点 // 处理开始节点
......
...@@ -14,7 +14,6 @@ import cn.com.glsx.process.modules.entity.SopDataSource; ...@@ -14,7 +14,6 @@ import cn.com.glsx.process.modules.entity.SopDataSource;
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.modules.service.SopDataSourceService; import cn.com.glsx.process.modules.service.SopDataSourceService;
import cn.com.glsx.process.modules.sop.execute.RunResult;
import cn.com.glsx.process.modules.sop.execute.SnapshotStruct; import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor; import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.FlowDataAdapterImpl; import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.FlowDataAdapterImpl;
...@@ -30,7 +29,7 @@ public class SqlExecutor implements SopNodeExecutor { ...@@ -30,7 +29,7 @@ public class SqlExecutor implements SopNodeExecutor {
private SopDataSourceService sopDataSourceService; private SopDataSourceService sopDataSourceService;
@Override @Override
public RunResult execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception { public Object execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception {
Map<String, Object> resultMap = executeStruct.getResultMap(); Map<String, Object> resultMap = executeStruct.getResultMap();
try { try {
// 获取配置参数信息 // 获取配置参数信息
......
...@@ -10,12 +10,10 @@ import org.springframework.stereotype.Service; ...@@ -10,12 +10,10 @@ import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import cn.com.glsx.process.common.constant.Constants;
import cn.com.glsx.process.modules.entity.SopDataSource; import cn.com.glsx.process.modules.entity.SopDataSource;
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.modules.service.SopDataSourceService; import cn.com.glsx.process.modules.service.SopDataSourceService;
import cn.com.glsx.process.modules.sop.execute.RunResult;
import cn.com.glsx.process.modules.sop.execute.SnapshotStruct; import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor; import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.FlowDataAdapterImpl; import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.FlowDataAdapterImpl;
...@@ -27,37 +25,32 @@ import lombok.extern.slf4j.Slf4j; ...@@ -27,37 +25,32 @@ import lombok.extern.slf4j.Slf4j;
@Service @Service
public class SqlQueryExecutor implements SopNodeExecutor { public class SqlQueryExecutor implements SopNodeExecutor {
@Autowired @Autowired
private SopDataSourceService sopDataSourceService; private SopDataSourceService sopDataSourceService;
@Override @Override
public RunResult execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception { public Object execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception {
Map<String, Object> resultMap = executeStruct.getResultMap(); try {
try { // 获取配置参数信息
// 获取配置参数信息 String nodeContent = node.getNodeContent();
String nodeContent = node.getNodeContent(); JSONObject paramMap = JSON.parseObject(nodeContent);
JSONObject paramMap = JSON.parseObject(nodeContent);
String sqlTemplate = paramMap.get("source") + ""; String sqlTemplate = paramMap.get("source") + "";
String dataSourceId = paramMap.get("dataSourceId") + ""; String dataSourceId = paramMap.get("dataSourceId") + "";
// 执行sql插件 // 执行sql插件
SopDataSource byId = sopDataSourceService.findByName(dataSourceId); SopDataSource byId = sopDataSourceService.findByName(dataSourceId);
SopBizAdapter mcgBizAdapter = new FlowDataAdapterImpl(byId); SopBizAdapter mcgBizAdapter = new FlowDataAdapterImpl(byId);
String sql = FreemarkerUtil.processContent(sqlTemplate, executeStruct.toMap()); String sql = FreemarkerUtil.processContent(sqlTemplate, executeStruct.toMap());
List<Map<String, Object>> maps = mcgBizAdapter.tableQuery(sql); List<Map<String, Object>> maps = mcgBizAdapter.tableQuery(sql);
// 处理执行结果 // 处理执行结果
resultMap.put(Constants.RES_DATE_KEY, maps); return maps;
resultMap.put(Constants.RES_KEY, Constants.RES_SUCCESS); } catch (Exception e) {
} catch (Exception e) { e.printStackTrace();
String message = e.getMessage(); }
resultMap.put(Constants.RES_FAIL_MESSAGE, message);
resultMap.put(Constants.RES_KEY, Constants.RES_FAIL);
}
return null; return null;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -8,7 +8,6 @@ import org.springframework.stereotype.Service; ...@@ -8,7 +8,6 @@ import org.springframework.stereotype.Service;
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.modules.service.SopService; import cn.com.glsx.process.modules.service.SopService;
import cn.com.glsx.process.modules.sop.execute.RunResult;
import cn.com.glsx.process.modules.sop.execute.SnapshotStruct; import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor; import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
import cn.hutool.json.JSONObject; import cn.hutool.json.JSONObject;
...@@ -32,7 +31,7 @@ public class StartExecutor implements SopNodeExecutor { ...@@ -32,7 +31,7 @@ public class StartExecutor implements SopNodeExecutor {
private SopService sopService; private SopService sopService;
@Override @Override
public RunResult execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception { public Object execute(SopStruct sop, SopInstNode node, SnapshotStruct executeStruct) throws Exception {
return null; return null;
} }
......
...@@ -108,7 +108,6 @@ public class FlowDataAdapterImpl implements SopBizAdapter { ...@@ -108,7 +108,6 @@ public class FlowDataAdapterImpl implements SopBizAdapter {
@Override @Override
public List<Map<String, Object>> tableQuery(String sql, Object... para) throws SQLException { public List<Map<String, Object>> tableQuery(String sql, Object... para) throws SQLException {
return mcgConnect.querySql(sql, para); return mcgConnect.querySql(sql, para);
} }
......
...@@ -34,6 +34,7 @@ public class ControllerXblcCustomerQuery { ...@@ -34,6 +34,7 @@ public class ControllerXblcCustomerQuery {
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
Object o = restTemplate.postForObject(baseurl + "?busKey=" + 11, param, Object.class); Object o = restTemplate.postForObject(baseurl + "?busKey=" + 11, param, Object.class);
return (JSONObject) JSONObject.toJSON(o); return (JSONObject) JSONObject.toJSON(o);
} }
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!