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 072eb612
authored
Sep 19, 2023
by
zhouhaibao
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]策略代码处理
1 parent
84dcaa58
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
13 deletions
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/modules/sop/java/example/ControllerHttpDemo.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/java/example/ControllerRopHttpDemo.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/JavaExecutor.java
View file @
072eb61
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
cn.com.glsx.process.common.constant.Constants
;
import
cn.com.glsx.process.modules.entity.SopInst
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
...
@@ -31,8 +32,24 @@ public class JavaExecutor implements SopNodeExecutor {
...
@@ -31,8 +32,24 @@ public class JavaExecutor implements SopNodeExecutor {
// java参数处理,执行java
// java参数处理,执行java
DynamicEngine
de
=
DynamicEngine
.
getInstance
();
DynamicEngine
de
=
DynamicEngine
.
getInstance
();
// 获取实例快照,传给处理器
SopInst
inst
=
sop
.
getInst
();
String
instSnapshot
=
inst
.
getInstSnapshot
();
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
22
);
// 节点信息
jsonObject
.
put
(
"sopId"
,
inst
.
getInstId
());
jsonObject
.
put
(
"sopName"
,
inst
.
getInstName
());
jsonObject
.
put
(
"nodeId"
,
node
.
getNodeId
());
jsonObject
.
put
(
"nodeName"
,
node
.
getNodeName
());
// 节点入参
jsonObject
.
put
(
"nodeData"
,
node
.
getNodeParam
());
// 实例快照
jsonObject
.
put
(
"instSnapshot"
,
instSnapshot
);
Object
instance
=
de
.
execute
(
"Controller"
,
javacode
,
"execute"
,
new
Class
[]{
JSON
.
class
},
new
Object
[]{
jsonObject
});
Object
instance
=
de
.
execute
(
"Controller"
,
javacode
,
"execute"
,
new
Class
[]{
JSON
.
class
},
new
Object
[]{
jsonObject
});
// 处理返回结果
// 处理返回结果
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/SqlExecutor.java
View file @
072eb61
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,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
cn.com.glsx.process.common.constant.Constants
;
import
cn.com.glsx.process.modules.entity.SopInst
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -36,12 +37,17 @@ public class SqlExecutor implements SopNodeExecutor {
...
@@ -36,12 +37,17 @@ public class SqlExecutor implements SopNodeExecutor {
// 获取配置参数信息
// 获取配置参数信息
String
nodeContent
=
node
.
getNodeContent
();
String
nodeContent
=
node
.
getNodeContent
();
JSONObject
paramMap
=
JSON
.
parseObject
(
nodeContent
);
JSONObject
paramMap
=
JSON
.
parseObject
(
nodeContent
);
String
sqlcode
=
paramMap
.
get
(
"source"
)
+
""
;
String
sqlcode
=
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
);
codeReplace
(
sqlcode
,
sop
,
node
);
int
i
=
mcgBizAdapter
.
executeUpdate
(
sqlcode
);
int
i
=
mcgBizAdapter
.
executeUpdate
(
sqlcode
);
// 处理执行结果
// 处理执行结果
...
@@ -55,4 +61,34 @@ public class SqlExecutor implements SopNodeExecutor {
...
@@ -55,4 +61,34 @@ public class SqlExecutor implements SopNodeExecutor {
return
executeStruct
;
return
executeStruct
;
}
}
/**
* 替换sql里面的通配符
*
* @param sqlcode sql脚本
* @param sop sop实例
* @param node sop节点
*/
private
void
codeReplace
(
String
sqlcode
,
SopStruct
sop
,
SopInstNode
node
)
{
SopInst
inst
=
sop
.
getInst
();
String
instSnapshot
=
inst
.
getInstSnapshot
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
instSnapshot
);
// 替换关联业务的活动id
String
activityId
=
jsonObject
.
get
(
"activityId"
)
+
""
;
if
(
activityId
!=
null
)
{
sqlcode
.
replace
(
"#{activityId}"
,
activityId
);
}
// 替换关联的instId
if
(
activityId
!=
null
)
{
sqlcode
.
replace
(
"#{instId}"
,
inst
.
getInstId
());
}
String
nodeParam
=
node
.
getNodeParam
();
JSONObject
nodeJsonObject
=
JSONObject
.
parseObject
(
nodeParam
);
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
nodeJsonObject
.
entrySet
())
{
sqlcode
.
replace
(
"#{"
+
entry
.
getKey
()
+
"}"
,
entry
.
getValue
()
+
""
);
}
}
}
}
\ 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 @
072eb61
...
@@ -5,6 +5,7 @@ import java.util.List;
...
@@ -5,6 +5,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
cn.com.glsx.process.common.constant.Constants
;
import
cn.com.glsx.process.common.constant.Constants
;
import
cn.com.glsx.process.modules.entity.SopInst
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -43,6 +44,7 @@ public class SqlQueryExecutor implements SopNodeExecutor {
...
@@ -43,6 +44,7 @@ public class SqlQueryExecutor implements SopNodeExecutor {
SopDataSource
byId
=
sopDataSourceService
.
findByName
(
dataSourceId
);
SopDataSource
byId
=
sopDataSourceService
.
findByName
(
dataSourceId
);
SopBizAdapter
mcgBizAdapter
=
new
FlowDataAdapterImpl
(
byId
);
SopBizAdapter
mcgBizAdapter
=
new
FlowDataAdapterImpl
(
byId
);
List
<
Map
<
String
,
Object
>>
maps
=
mcgBizAdapter
.
tableQuery
(
sqlcode
);
List
<
Map
<
String
,
Object
>>
maps
=
mcgBizAdapter
.
tableQuery
(
sqlcode
);
codeReplace
(
sqlcode
,
sop
,
node
);
// 处理执行结果
// 处理执行结果
resultMap
.
put
(
Constants
.
RES_DATE_KEY
,
maps
);
resultMap
.
put
(
Constants
.
RES_DATE_KEY
,
maps
);
...
@@ -55,4 +57,28 @@ public class SqlQueryExecutor implements SopNodeExecutor {
...
@@ -55,4 +57,28 @@ public class SqlQueryExecutor implements SopNodeExecutor {
return
executeStruct
;
return
executeStruct
;
}
}
private
void
codeReplace
(
String
sqlcode
,
SopStruct
sop
,
SopInstNode
node
)
{
SopInst
inst
=
sop
.
getInst
();
String
instSnapshot
=
inst
.
getInstSnapshot
();
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
instSnapshot
);
// 替换关联业务的活动id
String
activityId
=
jsonObject
.
get
(
"activityId"
)
+
""
;
if
(
activityId
!=
null
)
{
sqlcode
.
replace
(
"#{activityId}"
,
activityId
);
}
// 替换关联的instId
if
(
activityId
!=
null
)
{
sqlcode
.
replace
(
"#{instId}"
,
inst
.
getInstId
());
}
String
nodeParam
=
node
.
getNodeParam
();
JSONObject
nodeJsonObject
=
JSONObject
.
parseObject
(
nodeParam
);
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
nodeJsonObject
.
entrySet
())
{
sqlcode
.
replace
(
"#{"
+
entry
.
getKey
()
+
"}"
,
entry
.
getValue
()
+
""
);
}
}
}
}
\ 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 @
072eb61
...
@@ -43,10 +43,6 @@ public class StartExecutor implements SopNodeExecutor {
...
@@ -43,10 +43,6 @@ public class StartExecutor implements SopNodeExecutor {
return
executeStruct
;
return
executeStruct
;
}
}
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}}"
;
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/sop/java/example/ControllerHttpDemo.java
View file @
072eb61
...
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
/**
/**
* java执行器使用demo,http请求,类名Controller,方法名execute
* java执行器使用demo,http请求,类名Controller,方法名execute
* TODO 1.推送客户行为数据
*/
*/
public
class
ControllerHttpDemo
{
public
class
ControllerHttpDemo
{
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/sop/java/example/ControllerRopHttpDemo.java
View file @
072eb61
...
@@ -23,6 +23,8 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -23,6 +23,8 @@ import com.alibaba.fastjson.JSONObject;
/**
/**
* java执行器使用demo,rop请求,类名Controller,方法名execute
* java执行器使用demo,rop请求,类名Controller,方法名execute
* TODO 1.下发门店助手任务
* TODO 2.查询到保日期
*/
*/
public
class
ControllerRopHttpDemo
{
public
class
ControllerRopHttpDemo
{
...
@@ -36,10 +38,20 @@ public class ControllerRopHttpDemo {
...
@@ -36,10 +38,20 @@ public class ControllerRopHttpDemo {
private
final
static
String
method
=
"merchants.api.open.findStaffListByMerchantNo"
;
private
final
static
String
method
=
"merchants.api.open.findStaffListByMerchantNo"
;
public
static
JSON
execute
(
JSON
param
)
{
public
static
JSON
execute
(
JSON
param
)
{
// 将JSON字符串转换为Map
// 将JSON字符串转换为Map
// 将Map中的数据放入MultiValueMap中
// 将Map中的数据放入MultiValueMap中
Object
post
=
null
;
Object
post
=
null
;
JSONObject
jsonObject
=
(
JSONObject
)
param
;
JSONObject
jsonObject
=
(
JSONObject
)
param
;
String
nodeData
=
jsonObject
.
get
(
"nodeData"
)
+
""
;
String
instSnapshot
=
jsonObject
.
get
(
"instSnapshot"
)
+
""
;
String
sopId
=
jsonObject
.
get
(
"sopId"
)
+
""
;
String
sopName
=
jsonObject
.
get
(
"sopName"
)
+
""
;
String
nodeId
=
jsonObject
.
get
(
"nodeId"
)
+
""
;
String
nodeName
=
jsonObject
.
get
(
"nodeName"
)
+
""
;
// 组装任务需要的参数
MultiValueMap
<
String
,
String
>
multiValueMap
=
new
LinkedMultiValueMap
<>();
MultiValueMap
<
String
,
String
>
multiValueMap
=
new
LinkedMultiValueMap
<>();
for
(
Object
key
:
jsonObject
.
keySet
())
{
for
(
Object
key
:
jsonObject
.
keySet
())
{
String
keyString
=
(
String
)
key
;
String
keyString
=
(
String
)
key
;
...
@@ -100,14 +112,6 @@ public class ControllerRopHttpDemo {
...
@@ -100,14 +112,6 @@ public class ControllerRopHttpDemo {
return
params
;
return
params
;
}
}
public
static
MultiValueMap
<
String
,
String
>
getSysParamsE
()
{
MultiValueMap
<
String
,
String
>
params
=
new
LinkedMultiValueMap
<
String
,
String
>(
16
);
params
.
add
(
"app_key"
,
appKey
);
params
.
add
(
"format"
,
"json"
);
params
.
add
(
"timestamp"
,
System
.
currentTimeMillis
()
+
""
);
return
params
;
}
static
class
RopUriTemplateHandler
extends
DefaultUriBuilderFactory
{
static
class
RopUriTemplateHandler
extends
DefaultUriBuilderFactory
{
public
RopUriTemplateHandler
(
String
baseUriTemplate
)
{
public
RopUriTemplateHandler
(
String
baseUriTemplate
)
{
...
...
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