Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-process-server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 84dcaa58
authored
Sep 19, 2023
by
zhouhaibao
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]执行器处理
1 parent
72bf77e2
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
260 additions
and
203 deletions
platform-process/src/main/java/cn/com/glsx/process/common/constant/Constants.java
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/impl/SopInstNodeExecuteJobHandler.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/ExecuteStruct.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/SopNodeExecutor.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/EndExecutor.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/JavaExecutor.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/SqlExecutor.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/SqlQueryExecutor.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/StartExecutor.java
platform-process/src/main/java/cn/com/glsx/process/common/constant/Constants.java
View file @
84dcaa5
...
@@ -17,4 +17,13 @@ public final class Constants extends BasicConstants {
...
@@ -17,4 +17,13 @@ public final class Constants extends BasicConstants {
public
static
final
Charset
CHARSET
=
Charset
.
forName
(
"utf-8"
);
public
static
final
Charset
CHARSET
=
Charset
.
forName
(
"utf-8"
);
public
static
final
String
RES_SUCCESS
=
"SUCCESS"
;
public
static
final
String
RES_KEY
=
"code"
;
public
static
final
String
RES_DATE_KEY
=
"data"
;
public
static
final
String
RES_FAIL
=
"FAIL"
;
public
static
final
String
RES_FAIL_MESSAGE
=
"FAIL_MESSAGE"
;
}
}
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/impl/SopInstNodeExecuteJobHandler.java
View file @
84dcaa5
...
@@ -29,119 +29,121 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -29,119 +29,121 @@ import lombok.extern.slf4j.Slf4j;
@Component
@Component
public
class
SopInstNodeExecuteJobHandler
{
public
class
SopInstNodeExecuteJobHandler
{
@Resource
@Resource
private
SopService
sopService
;
private
SopService
sopService
;
@XxlJob
(
SopXxlJobUtil
.
SOP_NODE_EXECUTE_JOB_ID
)
@XxlJob
(
SopXxlJobUtil
.
SOP_NODE_EXECUTE_JOB_ID
)
public
void
handler
(
String
param1
)
throws
Exception
{
public
void
handler
(
String
param1
)
throws
Exception
{
String
json
=
XxlJobHelper
.
getJobParam
();
String
json
=
XxlJobHelper
.
getJobParam
();
SopInstNodeParam
param
=
JSONUtil
.
toBean
(
json
,
SopInstNodeParam
.
class
);
SopInstNodeParam
param
=
JSONUtil
.
toBean
(
json
,
SopInstNodeParam
.
class
);
SopXxlJobUtil
.
log
(
log
,
"【执行Sop节点】{}"
,
param
);
SopXxlJobUtil
.
log
(
log
,
"【执行Sop节点】{}"
,
param
);
SopStruct
sop
=
sopService
.
loadSopByInstNodeId
(
param
.
getInstNodeId
());
SopStruct
sop
=
sopService
.
loadSopByInstNodeId
(
param
.
getInstNodeId
());
// 执行sop里面的instNodeId节点。
// 执行sop里面的instNodeId节点。
SopInstNode
node
=
sop
.
getInstNodeMap
().
get
(
param
.
getInstNodeId
());
SopInstNode
node
=
sop
.
getInstNodeMap
().
get
(
param
.
getInstNodeId
());
boolean
avaliable
=
checkPreIds
(
sop
,
node
,
param
);
boolean
avaliable
=
checkPreIds
(
sop
,
node
,
param
);
if
(!
avaliable
)
{
if
(!
avaliable
)
{
return
;
return
;
}
}
SopXxlJobUtil
.
log
(
log
,
"【执行Sop节点】{}【{}:{}】 开始执行......"
,
sop
.
getInst
().
getInstName
(),
node
.
getNodeId
(),
node
.
getNodeName
());
SopXxlJobUtil
.
log
(
log
,
"【执行Sop节点】{}【{}:{}】 开始执行......"
,
sop
.
getInst
().
getInstName
(),
node
.
getNodeId
(),
node
.
getNodeName
());
// 节点执行
// 节点执行
execute
(
sop
,
node
);
execute
(
sop
,
node
);
// 记录节点执行结果
// 记录节点执行结果
}
}
/**
/**
* 检查本节点的前置任务是否完成,如果前置任务是异步任务,则忽略
* 检查本节点的前置任务是否完成,如果前置任务是异步任务,则忽略
*
*
* @param sop
* @param sop
* @param node
* @param node
* @param param
* @param param
* @return
* @return
*/
*/
private
boolean
checkPreIds
(
SopStruct
sop
,
SopInstNode
node
,
SopInstNodeParam
param
)
{
private
boolean
checkPreIds
(
SopStruct
sop
,
SopInstNode
node
,
SopInstNodeParam
param
)
{
Pair
<
Set
<
Integer
>,
Set
<
Integer
>>
pair
=
sop
.
getInstLinkMap
().
get
(
node
.
getNodeId
());
Pair
<
Set
<
Integer
>,
Set
<
Integer
>>
pair
=
sop
.
getInstLinkMap
().
get
(
node
.
getNodeId
());
// 前置任务为空,直接执行
// 前置任务为空,直接执行
if
(
pair
.
getKey
().
isEmpty
())
{
if
(
pair
.
getKey
().
isEmpty
())
{
return
true
;
return
true
;
}
}
// 前置任务已完成,可以执行
// 前置任务已完成,可以执行
if
(
param
.
getFinishedIds
().
containsAll
(
pair
.
getKey
()))
{
if
(
param
.
getFinishedIds
().
containsAll
(
pair
.
getKey
()))
{
return
true
;
return
true
;
}
}
// 前置任务是异步任务,可以执行
// 前置任务是异步任务,可以执行
for
(
Integer
preId
:
pair
.
getKey
())
{
for
(
Integer
preId
:
pair
.
getKey
())
{
SopInstNode
preNode
=
sop
.
getInstNodeMap
().
get
(
preId
);
SopInstNode
preNode
=
sop
.
getInstNodeMap
().
get
(
preId
);
if
(
preNode
!=
null
&&
preNode
.
getNodeAsync
()
!=
1
&&
!
param
.
getFinishedIds
().
contains
(
preId
))
{
if
(
preNode
!=
null
&&
preNode
.
getNodeAsync
()
!=
1
&&
!
param
.
getFinishedIds
().
contains
(
preId
))
{
SopXxlJobUtil
.
log
(
log
,
"【执行Sop节点】【{}:{}】,存在前置任务未完成:【{}:{}】"
,
sop
.
getInst
().
getInstId
(),
sop
.
getInst
().
getInstName
(),
SopXxlJobUtil
.
log
(
log
,
"【执行Sop节点】【{}:{}】,存在前置任务未完成:【{}:{}】"
,
sop
.
getInst
().
getInstId
(),
sop
.
getInst
().
getInstName
(),
preNode
.
getInstId
(),
preNode
.
getNodeName
());
preNode
.
getInstId
(),
preNode
.
getNodeName
());
return
false
;
return
false
;
}
}
}
}
return
true
;
return
true
;
}
}
/**
/**
* 节点执行时,申请sop锁
* 节点执行时,申请sop锁
*
*
* @param node 节点信息
* @param node 节点信息
* @param sop 执行器
* @param sop 执行器
*/
*/
public
void
execute
(
SopStruct
sop
,
SopInstNode
node
)
{
public
void
execute
(
SopStruct
sop
,
SopInstNode
node
)
{
SopNodeType
type
=
SopNodeType
.
fromBusType
(
node
.
getNodeType
());
SopNodeType
type
=
SopNodeType
.
fromBusType
(
node
.
getNodeType
());
SopNodeExecutor
instance
=
SopNodeExecutorFactory
.
getInstance
(
type
.
getHanderImp
(),
SopNodeExecutor
.
class
);
SopNodeExecutor
instance
=
SopNodeExecutorFactory
.
getInstance
(
type
.
getHanderImp
(),
SopNodeExecutor
.
class
);
// 执行sop节点前,锁定sop
// 执行sop节点前,锁定sop
if
(
SopHelper
.
lockInst
(
sop
.
getInst
()))
{
if
(
SopHelper
.
lockInst
(
sop
.
getInst
()))
{
try
{
try
{
// 重新加载sop
// 重新加载sop
sop
=
reloadAndCreateBatch
(
sop
,
node
);
sop
=
reloadAndCreateBatch
(
sop
,
node
);
// 执行sop节点
// 执行sop节点
ExecuteStruct
result
=
instance
.
execute
(
sop
,
node
);
ExecuteStruct
result
=
instance
.
execute
(
sop
,
node
);
updateBatch
(
sop
,
node
,
result
);
//更新节点批次快照信息
updateBatch
(
sop
,
node
,
result
);
updateNextNodes
(
sop
,
node
);
// 更新下个节点信息
}
catch
(
Exception
e
)
{
updateNextNodes
(
sop
,
node
);
throw
new
RuntimeException
(
e
);
}
finally
{
}
catch
(
Exception
e
)
{
SopHelper
.
unlockInst
(
sop
.
getInst
());
throw
new
RuntimeException
(
e
);
}
}
finally
{
SopHelper
.
unlockInst
(
sop
.
getInst
());
}
else
{
}
SopXxlJobUtil
.
log
(
log
,
"【执行Sop节点】【{}:{}】,申请实例锁失败,本次不执行!"
,
sop
.
getInst
().
getInstId
(),
sop
.
getInst
().
getInstName
());
return
;
}
else
{
}
SopXxlJobUtil
.
log
(
log
,
"【执行Sop节点】【{}:{}】,申请实例锁失败,本次不执行!"
,
sop
.
getInst
().
getInstId
(),
sop
.
getInst
().
getInstName
());
}
return
;
}
private
void
updateNextNodes
(
SopStruct
sop
,
SopInstNode
node
)
{
}
SopXxlJobUtil
.
finishSopNodeJob
(
sop
,
node
);
}
private
void
updateNextNodes
(
SopStruct
sop
,
SopInstNode
node
)
{
SopXxlJobUtil
.
finishSopNodeJob
(
sop
,
node
);
private
void
updateBatch
(
SopStruct
sop
,
SopInstNode
node
,
ExecuteStruct
result
)
{
}
SopInstNodeBatch
nodeBatch
=
sop
.
getNodeBatch
();
nodeBatch
.
setSnapshot
(
JSONUtil
.
toJsonStr
(
result
));
private
void
updateBatch
(
SopStruct
sop
,
SopInstNode
node
,
ExecuteStruct
result
)
{
nodeBatch
.
setUpdateTime
(
new
Date
());
SopInstNodeBatch
nodeBatch
=
sop
.
getNodeBatch
();
sopService
.
updateInstNodeBatch
(
nodeBatch
);
nodeBatch
.
setSnapshot
(
JSONUtil
.
toJsonStr
(
result
));
}
nodeBatch
.
setUpdateTime
(
new
Date
());
sopService
.
updateInstNodeBatch
(
nodeBatch
);
private
SopStruct
reloadAndCreateBatch
(
SopStruct
sop
,
SopInstNode
node
)
{
}
sop
=
sopService
.
loadSop
(
sop
.
getInst
().
getInstId
());
// 创建节点执行批次
private
SopStruct
reloadAndCreateBatch
(
SopStruct
sop
,
SopInstNode
node
)
{
SopInstNodeBatch
curBatch
=
sopService
.
createNodeBatch
(
sop
.
getInst
().
getBatchNo
(),
node
.
getInstNodeId
());
sop
=
sopService
.
loadSop
(
sop
.
getInst
().
getInstId
());
sop
.
setNodeBatch
(
curBatch
);
// 创建节点执行批次
return
sop
;
SopInstNodeBatch
curBatch
=
sopService
.
createNodeBatch
(
sop
.
getInst
().
getBatchNo
(),
node
.
getInstNodeId
());
}
sop
.
setNodeBatch
(
curBatch
);
return
sop
;
}
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/ExecuteStruct.java
View file @
84dcaa5
...
@@ -10,23 +10,24 @@ import lombok.Getter;
...
@@ -10,23 +10,24 @@ import lombok.Getter;
/**
/**
* node执行过程管理
* node执行过程管理
*
*
* @author kome
* @author kome
* @date 2023年9月19日 下午5:09:42
* @date 2023年9月19日 下午5:09:42
*/
*/
@Getter
@Getter
public
class
ExecuteStruct
implements
Serializable
,
Cloneable
{
public
class
ExecuteStruct
implements
Serializable
,
Cloneable
{
//
//
/**
/**
* 各节点的初始化参数表
* 各节点的初始化参数表
*/
*/
private
Map
<
String
,
Object
>
paramMap
=
Maps
.
newHashMap
();
private
Map
<
String
,
Object
>
paramMap
=
Maps
.
newHashMap
();
/**
/**
* 各节点的输入参数表
* 各节点的输入参数表
*/
*/
private
Map
<
String
,
Object
>
executeMap
=
Maps
.
newHashMap
();
private
Map
<
String
,
Object
>
executeMap
=
Maps
.
newHashMap
();
/**
/**
* 各节点的执行结果表
* 各节点的执行结果表
*/
*/
private
Map
<
String
,
Object
>
resultMap
=
Maps
.
newHashMap
();
private
Map
<
String
,
Object
>
resultMap
=
Maps
.
newHashMap
();
}
}
\ No newline at end of file
\ No newline at end of file
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/SopNodeExecutor.java
View file @
84dcaa5
...
@@ -27,7 +27,6 @@ public interface SopNodeExecutor {
...
@@ -27,7 +27,6 @@ public interface SopNodeExecutor {
/**
/**
* 通过sop模板+sop实例输入参数+sop跑批快照,获得本节点执行的输入参数
* 通过sop模板+sop实例输入参数+sop跑批快照,获得本节点执行的输入参数
*
*
* @param sopStruct
* @param node
* @param node
* @return
* @return
*/
*/
...
@@ -54,7 +53,6 @@ public interface SopNodeExecutor {
...
@@ -54,7 +53,6 @@ public interface SopNodeExecutor {
*
*
* @param sop SOP
* @param sop SOP
* @param node SOP节点
* @param node SOP节点
* @param executeStruct 输入参数
* @return 输出参数
* @return 输出参数
* @throws Exception
* @throws Exception
*/
*/
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/EndExecutor.java
View file @
84dcaa5
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
.
execute
.
executor
;
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
.
execute
.
executor
;
import
cn.com.glsx.process.common.constant.Constants
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
cn.com.glsx.process.modules.entity.SopInstNode
;
import
cn.com.glsx.process.modules.entity.SopInstNode
;
...
@@ -8,14 +9,20 @@ import cn.com.glsx.process.modules.sop.execute.ExecuteStruct;
...
@@ -8,14 +9,20 @@ import cn.com.glsx.process.modules.sop.execute.ExecuteStruct;
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
;
import
java.util.Map
;
@Slf4j
@Slf4j
@Service
@Service
public
class
EndExecutor
implements
SopNodeExecutor
{
public
class
EndExecutor
implements
SopNodeExecutor
{
@Override
@Override
public
ExecuteStruct
execute
(
SopStruct
sop
,
SopInstNode
node
)
throws
Exception
{
public
ExecuteStruct
execute
(
SopStruct
sop
,
SopInstNode
node
)
throws
Exception
{
// TODO Auto-generated method stub
ExecuteStruct
executeStruct
=
prepare
(
sop
,
node
);
return
null
;
}
Map
<
String
,
Object
>
resultMap
=
executeStruct
.
getResultMap
();
resultMap
.
put
(
Constants
.
RES_KEY
,
Constants
.
RES_SUCCESS
);
return
executeStruct
;
}
}
}
\ No newline at end of file
\ No newline at end of file
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/JavaExecutor.java
View file @
84dcaa5
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
.
execute
.
executor
;
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
.
execute
.
executor
;
import
cn.com.glsx.process.common.constant.Constants
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
...
@@ -12,25 +13,38 @@ import cn.com.glsx.process.modules.sop.execute.SopNodeExecutor;
...
@@ -12,25 +13,38 @@ 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
;
import
java.util.Map
;
@Slf4j
@Slf4j
@Service
@Service
public
class
JavaExecutor
implements
SopNodeExecutor
{
public
class
JavaExecutor
implements
SopNodeExecutor
{
@Override
@Override
public
ExecuteStruct
execute
(
SopStruct
sop
,
SopInstNode
node
)
throws
Exception
{
public
ExecuteStruct
execute
(
SopStruct
sop
,
SopInstNode
node
)
throws
Exception
{
// 处理开始节点
ExecuteStruct
executeStruct
=
prepare
(
sop
,
node
);
String
nodeContent
=
node
.
getNodeContent
();
Map
<
String
,
Object
>
resultMap
=
executeStruct
.
getResultMap
();
JSONObject
paramMap
=
JSON
.
parseObject
(
nodeContent
);
try
{
String
javacode
=
paramMap
.
get
(
"source"
)
+
""
;
// 处理开始节点
String
nodeContent
=
node
.
getNodeContent
();
// java参数处理,执行java
JSONObject
paramMap
=
JSON
.
parseObject
(
nodeContent
);
DynamicEngine
de
=
DynamicEngine
.
getInstance
();
String
javacode
=
paramMap
.
get
(
"source"
)
+
""
;
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
22
);
// java参数处理,执行java
Object
instance
=
de
.
execute
(
"Controller"
,
javacode
,
"execute"
,
new
Class
[]
{
JSON
.
class
},
new
Object
[]
{
jsonObject
});
DynamicEngine
de
=
DynamicEngine
.
getInstance
();
JSONObject
jsonObject
=
new
JSONObject
();
// 处理返回结果
jsonObject
.
put
(
"id"
,
22
);
return
null
;
Object
instance
=
de
.
execute
(
"Controller"
,
javacode
,
"execute"
,
new
Class
[]{
JSON
.
class
},
new
Object
[]{
jsonObject
});
}
// 处理返回结果
resultMap
.
put
(
Constants
.
RES_DATE_KEY
,
instance
);
resultMap
.
put
(
Constants
.
RES_KEY
,
Constants
.
RES_SUCCESS
);
}
catch
(
Exception
e
)
{
String
message
=
e
.
getMessage
();
resultMap
.
put
(
Constants
.
RES_FAIL_MESSAGE
,
message
);
resultMap
.
put
(
Constants
.
RES_KEY
,
Constants
.
RES_FAIL
);
}
return
executeStruct
;
}
}
}
\ No newline at end of file
\ No newline at end of file
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/SqlExecutor.java
View file @
84dcaa5
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
.
execute
.
executor
;
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
.
execute
.
executor
;
import
cn.com.glsx.process.common.constant.Constants
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -18,6 +19,8 @@ import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.FlowDataAdapterImpl
...
@@ -18,6 +19,8 @@ import cn.com.glsx.process.modules.sop.execute.plugin.dbconn.FlowDataAdapterImpl
import
cn.com.glsx.process.modules.sop.execute.plugin.dbconn.SopBizAdapter
;
import
cn.com.glsx.process.modules.sop.execute.plugin.dbconn.SopBizAdapter
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.Map
;
@Slf4j
@Slf4j
@Service
@Service
public
class
SqlExecutor
implements
SopNodeExecutor
{
public
class
SqlExecutor
implements
SopNodeExecutor
{
...
@@ -25,22 +28,31 @@ public class SqlExecutor implements SopNodeExecutor {
...
@@ -25,22 +28,31 @@ public class SqlExecutor implements SopNodeExecutor {
@Autowired
@Autowired
private
SopDataSourceService
sopDataSourceService
;
private
SopDataSourceService
sopDataSourceService
;
@Override
@Override
public
ExecuteStruct
execute
(
SopStruct
sop
,
SopInstNode
node
)
throws
Exception
{
public
ExecuteStruct
execute
(
SopStruct
sop
,
SopInstNode
node
)
throws
Exception
{
// 获取配置参数信息
ExecuteStruct
executeStruct
=
prepare
(
sop
,
node
);
String
nodeContent
=
node
.
getNodeContent
();
Map
<
String
,
Object
>
resultMap
=
executeStruct
.
getResultMap
();
JSONObject
paramMap
=
JSON
.
parseObject
(
nodeContent
);
try
{
String
sqlcode
=
paramMap
.
get
(
"source"
)
+
""
;
// 获取配置参数信息
String
dataSourceId
=
paramMap
.
get
(
"dataSourceId"
)
+
""
;
String
nodeContent
=
node
.
getNodeContent
();
JSONObject
paramMap
=
JSON
.
parseObject
(
nodeContent
);
// 执行sql插件
String
sqlcode
=
paramMap
.
get
(
"source"
)
+
""
;
SopDataSource
byId
=
sopDataSourceService
.
findByName
(
dataSourceId
);
String
dataSourceId
=
paramMap
.
get
(
"dataSourceId"
)
+
""
;
SopBizAdapter
mcgBizAdapter
=
new
FlowDataAdapterImpl
(
byId
);
int
i
=
mcgBizAdapter
.
executeUpdate
(
sqlcode
);
// 执行sql插件
SopDataSource
byId
=
sopDataSourceService
.
findByName
(
dataSourceId
);
// 处理执行结果
SopBizAdapter
mcgBizAdapter
=
new
FlowDataAdapterImpl
(
byId
);
int
i
=
mcgBizAdapter
.
executeUpdate
(
sqlcode
);
return
null
;
// 处理执行结果
resultMap
.
put
(
Constants
.
RES_DATE_KEY
,
i
);
resultMap
.
put
(
Constants
.
RES_KEY
,
Constants
.
RES_SUCCESS
);
}
catch
(
Exception
e
)
{
String
message
=
e
.
getMessage
();
resultMap
.
put
(
Constants
.
RES_FAIL_MESSAGE
,
message
);
resultMap
.
put
(
Constants
.
RES_KEY
,
Constants
.
RES_FAIL
);
}
return
executeStruct
;
}
}
}
}
\ No newline at end of file
\ No newline at end of file
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/SqlQueryExecutor.java
View file @
84dcaa5
...
@@ -4,6 +4,7 @@ package cn.com.glsx.process.modules.sop.execute.executor;
...
@@ -4,6 +4,7 @@ package cn.com.glsx.process.modules.sop.execute.executor;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
cn.com.glsx.process.common.constant.Constants
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -24,24 +25,34 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -24,24 +25,34 @@ 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
ExecuteStruct
execute
(
SopStruct
sop
,
SopInstNode
node
)
throws
Exception
{
public
ExecuteStruct
execute
(
SopStruct
sop
,
SopInstNode
node
)
throws
Exception
{
// 获取配置参数信息
ExecuteStruct
executeStruct
=
prepare
(
sop
,
node
);
String
nodeContent
=
node
.
getNodeContent
();
Map
<
String
,
Object
>
resultMap
=
executeStruct
.
getResultMap
();
JSONObject
paramMap
=
JSON
.
parseObject
(
nodeContent
);
try
{
String
sqlcode
=
paramMap
.
get
(
"source"
)
+
""
;
// 获取配置参数信息
String
dataSourceId
=
paramMap
.
get
(
"dataSourceId"
)
+
""
;
String
nodeContent
=
node
.
getNodeContent
();
JSONObject
paramMap
=
JSON
.
parseObject
(
nodeContent
);
// 执行sql插件
String
sqlcode
=
paramMap
.
get
(
"source"
)
+
""
;
SopDataSource
byId
=
sopDataSourceService
.
findByName
(
dataSourceId
);
String
dataSourceId
=
paramMap
.
get
(
"dataSourceId"
)
+
""
;
SopBizAdapter
mcgBizAdapter
=
new
FlowDataAdapterImpl
(
byId
);
List
<
Map
<
String
,
Object
>>
maps
=
mcgBizAdapter
.
tableQuery
(
sqlcode
);
// 执行sql插件
SopDataSource
byId
=
sopDataSourceService
.
findByName
(
dataSourceId
);
// 处理执行结果
SopBizAdapter
mcgBizAdapter
=
new
FlowDataAdapterImpl
(
byId
);
return
null
;
List
<
Map
<
String
,
Object
>>
maps
=
mcgBizAdapter
.
tableQuery
(
sqlcode
);
}
// 处理执行结果
resultMap
.
put
(
Constants
.
RES_DATE_KEY
,
maps
);
resultMap
.
put
(
Constants
.
RES_KEY
,
Constants
.
RES_SUCCESS
);
}
catch
(
Exception
e
)
{
String
message
=
e
.
getMessage
();
resultMap
.
put
(
Constants
.
RES_FAIL_MESSAGE
,
message
);
resultMap
.
put
(
Constants
.
RES_KEY
,
Constants
.
RES_FAIL
);
}
return
executeStruct
;
}
}
}
\ No newline at end of file
\ No newline at end of file
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/StartExecutor.java
View file @
84dcaa5
...
@@ -3,6 +3,7 @@ package cn.com.glsx.process.modules.sop.execute.executor;
...
@@ -3,6 +3,7 @@ package cn.com.glsx.process.modules.sop.execute.executor;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
cn.com.glsx.process.common.constant.Constants
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
cn.com.glsx.process.modules.entity.SopInstNode
;
import
cn.com.glsx.process.modules.entity.SopInstNode
;
...
@@ -14,12 +15,14 @@ import cn.hutool.json.JSONObject;
...
@@ -14,12 +15,14 @@ import cn.hutool.json.JSONObject;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.Map
;
/**
/**
* 开始节点:
* 开始节点:
* 1.从SopInst提取初始化参数;
* 1.从SopInst提取初始化参数;
* 2.记录开始节点快照,更新Sop快照;
* 2.记录开始节点快照,更新Sop快照;
* 3.更新触发后置任务;
* 3.更新触发后置任务;
*
*
* @author kome
* @author kome
* @date 2023年9月19日 下午5:42:59
* @date 2023年9月19日 下午5:42:59
*/
*/
...
@@ -27,29 +30,29 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -27,29 +30,29 @@ import lombok.extern.slf4j.Slf4j;
@Service
@Service
public
class
StartExecutor
implements
SopNodeExecutor
{
public
class
StartExecutor
implements
SopNodeExecutor
{
@Resource
@Resource
private
SopService
sopService
;
private
SopService
sopService
;
@Override
public
ExecuteStruct
execute
(
SopStruct
sop
,
SopInstNode
node
)
throws
Exception
{
ExecuteStruct
executeStruct
=
prepare
(
sop
,
node
);
@Override
public
ExecuteStruct
execute
(
SopStruct
sop
,
SopInstNode
node
)
throws
Exception
{
ExecuteStruct
executeStruct
=
prepare
(
sop
,
node
);
// 更新节点快照
Map
<
String
,
Object
>
resultMap
=
executeStruct
.
getResultMap
();
resultMap
.
put
(
Constants
.
RES_KEY
,
Constants
.
RES_SUCCESS
);
return
executeStruct
;
return
executeStruct
;
}
}
public
void
updateBatch
()
{
public
void
updateBatch
()
{
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
String
json
=
"{\"merchantId\":{\"paramName\":\"merchantId\",\"paramDesc\":\"门店id,分配给门店时需要赋值\",\"valueType\":\"String\",\"defaultValue\":\"\",\"required\":true},\"stages\":{\"paramName\":\"stages\",\"paramDesc\":\"旅程阶段,值类型为Json\",\"valueType\":\"Json\",\"defaultValue\":{\"stage1\":{\"value\":\"潜客\",\"editable\":false,\"conditions\":[\"链接(#膨胀金活动名称#) 反馈\",\"链接(#膨胀金活动名称#) 反馈\"]},\"stage2\":{\"value\":\"高意向\",\"editable\":true,\"conditions\":[\"链接(#膨胀金活动名称#) 反馈\",\"链接(#膨胀金活动名称#) 反馈\"]},\"stage3\":{\"value\":\"下单\",\"editable\":false,\"conditions\":[\"链接(#膨胀金活动名称#) 反馈\",\"链接(#膨胀金活动名称#) 反馈\"]},\"stage4\":{\"value\":\"战败\",\"editable\":false,\"conditions\":[\"链接(#膨胀金活动名称#) 反馈\",\"链接(#膨胀金活动名称#) 反馈\"]}},\"required\":true},\"users\":{\"paramName\":\"users\",\"paramDesc\":\"通过膨胀金活动导入的用户信息\",\"valueType\":\"Json\",\"defaultValue\":{\"u0001\":{\"userId\":\"u0001\",\"userName\":\"张三\",\"followId\":\"跟进人id1\",\"textContent\":\"文案内容:尊敬的${userName},优惠券领取url.cn/dE32C1Ab7\"},\"u0002\":{\"userId\":\"u0002\",\"userName\":\"李四\",\"followId\":\"跟进人id2\",\"textContent\":\"文案内容:尊敬的${userName},优惠券领取url.cn/dE32C1Ab7\"}},\"required\":true}}"
;
String
json
=
"{\"merchantId\":{\"paramName\":\"merchantId\",\"paramDesc\":\"门店id,分配给门店时需要赋值\",\"valueType\":\"String\",\"defaultValue\":\"\",\"required\":true},\"stages\":{\"paramName\":\"stages\",\"paramDesc\":\"旅程阶段,值类型为Json\",\"valueType\":\"Json\",\"defaultValue\":{\"stage1\":{\"value\":\"潜客\",\"editable\":false,\"conditions\":[\"链接(#膨胀金活动名称#) 反馈\",\"链接(#膨胀金活动名称#) 反馈\"]},\"stage2\":{\"value\":\"高意向\",\"editable\":true,\"conditions\":[\"链接(#膨胀金活动名称#) 反馈\",\"链接(#膨胀金活动名称#) 反馈\"]},\"stage3\":{\"value\":\"下单\",\"editable\":false,\"conditions\":[\"链接(#膨胀金活动名称#) 反馈\",\"链接(#膨胀金活动名称#) 反馈\"]},\"stage4\":{\"value\":\"战败\",\"editable\":false,\"conditions\":[\"链接(#膨胀金活动名称#) 反馈\",\"链接(#膨胀金活动名称#) 反馈\"]}},\"required\":true},\"users\":{\"paramName\":\"users\",\"paramDesc\":\"通过膨胀金活动导入的用户信息\",\"valueType\":\"Json\",\"defaultValue\":{\"u0001\":{\"userId\":\"u0001\",\"userName\":\"张三\",\"followId\":\"跟进人id1\",\"textContent\":\"文案内容:尊敬的${userName},优惠券领取url.cn/dE32C1Ab7\"},\"u0002\":{\"userId\":\"u0002\",\"userName\":\"李四\",\"followId\":\"跟进人id2\",\"textContent\":\"文案内容:尊敬的${userName},优惠券领取url.cn/dE32C1Ab7\"}},\"required\":true}}"
;
JSONObject
paramObj
=
JSONUtil
.
parseObj
(
json
);
JSONObject
paramObj
=
JSONUtil
.
parseObj
(
json
);
System
.
out
.
println
(
paramObj
.
get
(
"merchantId"
));
System
.
out
.
println
(
paramObj
.
get
(
"merchantId"
));
}
}
}
}
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment