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 b68032e5
authored
Sep 23, 2023
by
zhouhaibao
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
[+]流程节点处理
1 parent
d5d03470
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
87 additions
and
29 deletions
platform-process/src/main/java/cn/com/glsx/process/modules/sop/CustomerInfo.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/SopHelper.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/java/example/ControllerDisTasksDemo.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/java/example/ControllerFoundInsDemo.java
platform-process/src/test/java/cn/com/glsx/test/JavaNodeTestApplication.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/CustomerInfo.java
View file @
b68032e
...
...
@@ -32,4 +32,6 @@ public class CustomerInfo {
private
String
talkId
;
private
String
vin
;
private
String
arrivalDate
;
}
platform-process/src/main/java/cn/com/glsx/process/modules/sop/SopHelper.java
View file @
b68032e
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
;
import
java.io.IOException
;
import
java.lang.reflect.Field
;
import
java.security.GeneralSecurityException
;
import
java.security.MessageDigest
;
import
java.text.DateFormat
;
...
...
@@ -112,6 +113,26 @@ public class SopHelper {
return
null
;
}
public
static
Map
<
String
,
Object
>
objectToMap
(
Object
obj
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Class
<?>
clazz
=
obj
.
getClass
();
Field
[]
fields
=
clazz
.
getDeclaredFields
();
for
(
Field
field
:
fields
)
{
field
.
setAccessible
(
true
);
String
fieldName
=
field
.
getName
();
Object
fieldValue
=
null
;
try
{
fieldValue
=
field
.
get
(
obj
);
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
map
.
put
(
fieldName
,
fieldValue
);
}
return
map
;
}
public
static
String
getValueFromJsonString
(
String
jsonString
,
String
objectName
,
String
fieldName
)
{
try
{
ObjectMapper
objectMapper
=
new
ObjectMapper
();
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/sop/java/example/ControllerDisTasksDemo.java
View file @
b68032e
...
...
@@ -56,15 +56,17 @@ public class ControllerDisTasksDemo {
for
(
int
i
=
0
;
i
<
customerInfoList
.
size
();
i
++)
{
CustomerInfo
customerInfo
=
customerInfoList
.
get
(
i
);
multiValueMap
.
add
(
"requestList["
+
i
+
"].customerId"
,
customerInfo
.
getOneId
());
multiValueMap
.
add
(
"requestList["
+
i
+
"].followStaffUuid"
,
customerInfo
.
getFollowStaffUuid
());
multiValueMap
.
add
(
"requestList["
+
i
+
"].messageContent"
,
customerInfo
.
getMessageContent
());
multiValueMap
.
add
(
"requestList["
+
i
+
"].messageId"
,
customerInfo
.
getMessageId
());
multiValueMap
.
add
(
"requestList["
+
i
+
"].talkId"
,
customerInfo
.
getTalkId
());
multiValueMap
.
add
(
"requestList[
0].customerList[
"
+
i
+
"].customerId"
,
customerInfo
.
getOneId
());
multiValueMap
.
add
(
"requestList[
0].customerList[
"
+
i
+
"].followStaffUuid"
,
customerInfo
.
getFollowStaffUuid
());
multiValueMap
.
add
(
"requestList[
0].customerList[
"
+
i
+
"].messageContent"
,
customerInfo
.
getMessageContent
());
multiValueMap
.
add
(
"requestList[
0].customerList[
"
+
i
+
"].messageId"
,
customerInfo
.
getMessageId
());
multiValueMap
.
add
(
"requestList[
0].customerList[
"
+
i
+
"].talkId"
,
customerInfo
.
getTalkId
());
}
try
{
System
.
out
.
println
(
"入参"
+
JSONObject
.
toJSONString
(
multiValueMap
));
post
=
SopHelper
.
post
(
multiValueMap
,
Object
.
class
,
baseurl
,
method
);
System
.
out
.
println
(
"返回"
+
JSONObject
.
toJSONString
(
post
));
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/sop/java/example/ControllerFoundInsDemo.java
View file @
b68032e
...
...
@@ -10,9 +10,12 @@ import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.time.DateFormatUtils
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
...
...
@@ -24,15 +27,15 @@ import java.util.stream.Collectors;
*/
public
class
ControllerFoundInsDemo
{
private
final
static
String
baseurl
=
"http://scrm.dev.glsx.com.cn/rop-scrm-
stoassistant
/router"
;
private
final
static
String
baseurl
=
"http://scrm.dev.glsx.com.cn/rop-scrm-
marketing
/router"
;
private
final
static
String
method
=
"marketing.api.supermarket.
customers.page
"
;
private
final
static
String
method
=
"marketing.api.supermarket.
renewal.queryByVins
"
;
public
static
JSON
execute
(
JSON
param
)
{
// 将JSON字符串转换为Map
// 将Map中的数据放入MultiValueMap中
Object
post
=
null
;
List
<
CustomerInfo
>
result
=
new
ArrayList
<>()
;
MultiValueMap
<
String
,
String
>
multiValueMap
=
new
LinkedMultiValueMap
<>();
SopExecutorResult
excustorParam
=
SopHelper
.
getExcustorParam
(
param
);
Map
<
String
,
Object
>
resultData
=
excustorParam
.
getResultData
();
...
...
@@ -42,11 +45,24 @@ public class ControllerFoundInsDemo {
List
<
String
>
collect
=
customerInfoList
.
stream
().
filter
(
index
->
StringUtils
.
isNotEmpty
(
index
.
getVin
())).
map
(
CustomerInfo:
:
getVin
).
collect
(
Collectors
.
toList
());
try
{
multiValueMap
.
put
(
"vins"
,
collect
);
post
=
SopHelper
.
post
(
multiValueMap
,
Object
.
class
,
baseurl
,
method
);
Object
post
=
SopHelper
.
post
(
multiValueMap
,
Object
.
class
,
baseurl
,
method
);
JSONObject
json
=
(
JSONObject
)
JSONObject
.
toJSON
(
post
);
Object
data
=
json
.
get
(
"data"
);
Map
<
String
,
Object
>
stringObjectMap
=
(
Map
<
String
,
Object
>)
(
data
);
if
(!
stringObjectMap
.
isEmpty
())
{
for
(
String
key
:
stringObjectMap
.
keySet
())
{
String
s
=
stringObjectMap
.
get
(
key
)
+
""
;
CustomerInfo
customerInfo
=
new
CustomerInfo
();
customerInfo
.
setVin
(
key
);
customerInfo
.
setArrivalDate
(
DateFormatUtils
.
formatUTC
(
Long
.
parseLong
(
s
),
"yyyy-mm-dd mm:ss"
));
result
.
add
(
customerInfo
);
}
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
return
(
JSONObject
)
JSONObject
.
toJSON
(
post
);
return
JSONArray
.
parseArray
(
JSONObject
.
toJSONString
(
result
));
}
}
\ No newline at end of file
platform-process/src/test/java/cn/com/glsx/test/JavaNodeTestApplication.java
View file @
b68032e
package
cn
.
com
.
glsx
.
test
;
import
cn.com.glsx.Application
;
import
cn.com.glsx.process.job.xxljob.impl.SopInstNodeExecuteJobHandler
;
import
cn.com.glsx.process.modules.entity.SopDataSource
;
import
cn.com.glsx.process.modules.entity.SopInst
;
import
cn.com.glsx.process.modules.entity.SopInstNode
;
import
cn.com.glsx.process.modules.entity.User
;
import
cn.com.glsx.process.modules.model.SopStruct
;
import
cn.com.glsx.process.modules.service.SopDataSourceService
;
import
cn.com.glsx.process.modules.service.SopService
;
import
cn.com.glsx.process.modules.service.UserDemoService
;
import
cn.com.glsx.process.modules.sop.CustomerInfo
;
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.java.DynamicEngine
;
import
cn.com.glsx.process.modules.sop.java.example.ControllerDisTasksDemo
;
import
cn.com.glsx.process.modules.sop.java.example.Controller
Http
Demo
;
import
cn.com.glsx.process.modules.sop.java.example.Controller
FoundIns
Demo
;
import
cn.com.glsx.process.modules.sop.java.example.ControllerScreenPersonDemo
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.glsx.plat.common.utils.DateUtils
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
javax.annotation.Resource
;
import
java.sql.SQLException
;
import
java.util.*
;
import
java.util.concurrent.CyclicBarrier
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 测试spring cloud 服务调用方式
...
...
@@ -76,13 +66,13 @@ public class JavaNodeTestApplication {
customerInfo
.
setCustomerPhone
(
"13476670746"
);
customerInfo
.
setOrgId
(
"123456"
);
customerInfo
.
setVin
(
"ceshi"
);
customerInfo
.
setMessageId
(
"
ceshi
"
);
customerInfo
.
setMessageId
(
"
1
"
);
customerInfo
.
setMessageContent
(
"ceshi"
);
customerInfo
.
setSopJourneyId
(
"xblc7"
);
customerInfo
.
setSopJourneyEnterTime
(
new
Date
());
customerInfo
.
setCustomerPhone
(
"13476670746"
);
customerInfo
.
setSop_journey_stage
(
"潜客"
);
customerInfo
.
setSopJourneyStageEnterTime
(
new
Date
(
));
customerInfo
.
setSopJourneyStageEnterTime
(
DateUtils
.
parse
(
"2023-09-22"
));
resultData
.
put
(
"user1"
,
Arrays
.
asList
(
customerInfo
));
SopStruct
sopStruct
=
sopService
.
loadSop
(
"xblc7"
);
SopInstNode
sopInstNode
=
sopStruct
.
getInstNodeMap
().
get
(
3
);
...
...
@@ -94,5 +84,32 @@ public class JavaNodeTestApplication {
System
.
out
.
println
(
execute
);
}
String
aa
=
"\timport cn.com.glsx.process.modules.entity.SopInstNode;\n"
+
"import cn.com.glsx.process.modules.sop.CustomerInfo;\n"
+
"import cn.com.glsx.process.modules.sop.SopExecutorResult;\n"
+
"import cn.com.glsx.process.modules.sop.SopHelper;\n"
+
"import com.alibaba.fastjson.JSON;\n"
+
"import com.alibaba.fastjson.JSONArray;\n"
+
"import com.alibaba.fastjson.JSONObject;\n"
+
"import org.apache.commons.collections.CollectionUtils;\n"
+
"\n"
+
"import java.util.List;\n"
+
"import java.util.Map;\n"
+
"import java.util.stream.Collectors;\n"
+
"\n"
+
"/**\n"
+
" * java执行器使用demo,http请求,类名Controller,方法名execute\n"
+
" * 筛选客户\n"
+
" */\n"
+
"public class ControllerScreenPersonDemo {\n"
+
"\n"
+
"\n"
+
" public static JSON execute(JSON param) {\n"
+
"\n"
+
" SopExecutorResult excustorParam = SopHelper.getExcustorParam(param);\n"
+
" SopInstNode sopInstNode = excustorParam.getSopInstNode();\n"
+
" String nodeParam = sopInstNode.getNodeParam();\n"
+
" String stage = SopHelper.getValueFromJsonString(nodeParam, \"stage\");\n"
+
"\n"
+
" Map<String, Object> resultData = excustorParam.getResultData();\n"
+
"\n"
+
" List<CustomerInfo> customerInfoList = JSON.parseArray(JSON.toJSONString(resultData.get(\"users\")), CustomerInfo.class);\n"
+
" if (CollectionUtils.isNotEmpty(customerInfoList)) {\n"
+
" List<CustomerInfo> collect = customerInfoList.stream().filter(index -> stage.equals(index.getSop_journey_stage())).collect(Collectors.toList());\n"
+
" return (JSONArray) JSONObject.toJSON(collect);\n"
+
" }\n"
+
" return null;\n"
+
" }\n"
+
"}"
;
@Test
public
void
ControllerFoundInsDemo
()
{
Map
<
String
,
Object
>
resultData
=
new
HashMap
<>();
CustomerInfo
customerInfo
=
new
CustomerInfo
();
customerInfo
.
setOneId
(
"123456"
);
customerInfo
.
setCustomerPhone
(
"13476670746"
);
customerInfo
.
setOrgId
(
"123456"
);
customerInfo
.
setVin
(
"ceshi"
);
customerInfo
.
setMessageId
(
"ceshi"
);
customerInfo
.
setMessageContent
(
"ceshi"
);
customerInfo
.
setSopJourneyId
(
"xblc7"
);
customerInfo
.
setSopJourneyEnterTime
(
new
Date
());
customerInfo
.
setCustomerPhone
(
"13476670746"
);
customerInfo
.
setSop_journey_stage
(
"潜在客户"
);
customerInfo
.
setSopJourneyStageEnterTime
(
DateUtils
.
parse
(
"2023-09-22"
));
customerInfo
.
setVin
(
"WAURFCF24MN013761"
);
resultData
.
put
(
"user1"
,
Arrays
.
asList
(
customerInfo
));
SopStruct
sopStruct
=
sopService
.
loadSop
(
"xblc7"
);
SopInstNode
sopInstNode
=
sopStruct
.
getInstNodeMap
().
get
(
3
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"sopInst"
,
sopStruct
.
getInst
());
jsonObject
.
put
(
"sopInstNode"
,
sopInstNode
);
jsonObject
.
put
(
"instSnapshot"
,
resultData
);
JSON
execute
=
ControllerFoundInsDemo
.
execute
(
jsonObject
);
System
.
out
.
println
(
execute
);
}
}
\ 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