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 55ba8505
authored
Sep 25, 2023
by
tiger
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
sop params
1 parent
c66bcbf0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
206 additions
and
62 deletions
platform-process-api/src/main/java/cn/com/glsx/process/modules/mapper/SopInstMapper.java
platform-process-api/src/main/java/cn/com/glsx/process/modules/model/SopStruct.java
platform-process/src/main/java/cn/com/glsx/Application.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/controller/SopController.java
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopInstService.java
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopService.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/execute/SopNodeExecutor.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/resources/mapper/SopInstMapper.xml
platform-process-api/src/main/java/cn/com/glsx/process/modules/mapper/SopInstMapper.java
View file @
55ba850
...
@@ -3,13 +3,13 @@ package cn.com.glsx.process.modules.mapper;
...
@@ -3,13 +3,13 @@ package cn.com.glsx.process.modules.mapper;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
cn.com.glsx.process.modules.model.SopInstDTO
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
com.glsx.plat.mybatis.mapper.CommonBaseMapper
;
import
cn.com.glsx.process.modules.entity.SopInst
;
import
cn.com.glsx.process.modules.entity.SopInst
;
import
cn.com.glsx.process.modules.model.SopInstDTO
;
import
cn.com.glsx.process.modules.model.SopInstSearch
;
import
cn.com.glsx.process.modules.model.SopInstSearch
;
@Mapper
@Mapper
...
@@ -41,7 +41,7 @@ public interface SopInstMapper extends CommonBaseMapper<SopInst> {
...
@@ -41,7 +41,7 @@ public interface SopInstMapper extends CommonBaseMapper<SopInst> {
*/
*/
void
updateInstStatus
(
@Param
(
"instId"
)
String
instId
,
@Param
(
"status"
)
Byte
status
);
void
updateInstStatus
(
@Param
(
"instId"
)
String
instId
,
@Param
(
"status"
)
Byte
status
);
void
updateInstBatchNo
(
@Param
(
"instId"
)
String
instId
,
@Param
(
"batchNo"
)
String
batchNo
);
void
updateInstBatchNo
(
@Param
(
"instId"
)
String
instId
,
@Param
(
"batchNo"
)
String
batchNo
,
@Param
(
"snapshot"
)
String
snapshot
);
/**
/**
* 分页查询模板实例列表
* 分页查询模板实例列表
...
...
platform-process-api/src/main/java/cn/com/glsx/process/modules/model/SopStruct.java
View file @
55ba850
...
@@ -11,25 +11,22 @@ import cn.com.glsx.process.modules.entity.SopInst;
...
@@ -11,25 +11,22 @@ import cn.com.glsx.process.modules.entity.SopInst;
import
cn.com.glsx.process.modules.entity.SopInstBatch
;
import
cn.com.glsx.process.modules.entity.SopInstBatch
;
import
cn.com.glsx.process.modules.entity.SopInstNode
;
import
cn.com.glsx.process.modules.entity.SopInstNode
;
import
cn.com.glsx.process.modules.entity.SopInstNodeBatch
;
import
cn.com.glsx.process.modules.entity.SopInstNodeBatch
;
import
cn.com.glsx.process.modules.entity.SopTpl
;
import
cn.com.glsx.process.modules.entity.SopTplGrant
;
import
cn.com.glsx.process.modules.entity.SopTplNode
;
import
cn.hutool.core.lang.Pair
;
import
cn.hutool.core.lang.Pair
;
import
lombok.Data
;
import
lombok.Data
;
@Data
@Data
public
class
SopStruct
{
public
class
SopStruct
{
/** 模板 */
/** 模板
,暂时不关注
*/
private
SopTpl
tpl
;
//
private SopTpl tpl;
/** 模板节点表 */
/** 模板节点表
,暂时不关注
*/
private
Map
<
Integer
,
SopTplNode
>
tplNodeMap
;
//
private Map<Integer, SopTplNode> tplNodeMap;
/** 模板节点连接关系: fromSet, toSet,暂时不关注 */
/** 模板节点连接关系: fromSet, toSet,暂时不关注 */
// private Map<Integer, Pair<Set<Integer>, Set<Integer>>> tplLinkMap;
// private Map<Integer, Pair<Set<Integer>, Set<Integer>>> tplLinkMap;
/** 模板分配 */
/** 模板分配 */
private
SopTplGrant
grant
;
//
private SopTplGrant grant;
/** 模板实例 */
/** 模板实例 */
private
SopInst
inst
;
private
SopInst
inst
;
...
...
platform-process/src/main/java/cn/com/glsx/Application.java
View file @
55ba850
...
@@ -14,6 +14,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
...
@@ -14,6 +14,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.context.annotation.EnableAspectJAutoProxy
;
import
org.springframework.context.annotation.EnableAspectJAutoProxy
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
import
com.glsx.plat.context.EnableRestAdmin
;
import
com.glsx.plat.context.EnableRestAdmin
;
...
@@ -28,6 +29,7 @@ import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
...
@@ -28,6 +29,7 @@ import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
@EnableFeignClients
(
basePackages
=
{
"cn.com.glsx.*.api"
,
"cn.com.glsx.process.modules.client"
})
@EnableFeignClients
(
basePackages
=
{
"cn.com.glsx.*.api"
,
"cn.com.glsx.process.modules.client"
})
@SpringBootApplication
@SpringBootApplication
@EnableAspectJAutoProxy
@EnableAspectJAutoProxy
@EnableTransactionManagement
public
class
Application
implements
CommandLineRunner
{
public
class
Application
implements
CommandLineRunner
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/impl/SopInstNodeExecuteJobHandler.java
View file @
55ba850
...
@@ -145,6 +145,7 @@ public class SopInstNodeExecuteJobHandler {
...
@@ -145,6 +145,7 @@ public class SopInstNodeExecuteJobHandler {
}
}
private
void
updateNextNodes
(
SopStruct
sop
,
SopInstNode
node
)
{
private
void
updateNextNodes
(
SopStruct
sop
,
SopInstNode
node
)
{
// TODO 是否需要触发后续任务
SopXxlJobUtil
.
finishSopNodeJob
(
sop
,
node
);
SopXxlJobUtil
.
finishSopNodeJob
(
sop
,
node
);
}
}
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/controller/SopController.java
View file @
55ba850
...
@@ -45,4 +45,14 @@ public class SopController {
...
@@ -45,4 +45,14 @@ public class SopController {
return
Result
.
success
(
"已刷新:"
+
rs
);
return
Result
.
success
(
"已刷新:"
+
rs
);
}
}
@Operation
(
summary
=
"从实例反推模板"
,
description
=
"注意先把模板清理掉"
)
@GetMapping
(
value
=
"/inst/to/tpl/{instId}"
)
public
Result
<
String
>
instToTpl
(
@PathVariable
(
"instId"
)
String
instId
)
{
SopStruct
sop
=
sopService
.
loadSop
(
instId
);
sopService
.
generateTplFromInst
(
sop
);
return
Result
.
success
(
"已生成模板!"
);
}
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopInstService.java
View file @
55ba850
...
@@ -63,7 +63,7 @@ public class SopInstService {
...
@@ -63,7 +63,7 @@ public class SopInstService {
private
CustomerSopJourneyFeignClient_T
customerSopJourneyFeignClientT
;
private
CustomerSopJourneyFeignClient_T
customerSopJourneyFeignClientT
;
@Autowired
@Autowired
private
MsgProducer
msgProducer
;
private
MsgProducer
msgProducer
;
/**
/**
* 根据id查询
* 根据id查询
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopService.java
View file @
55ba850
...
@@ -3,6 +3,7 @@ package cn.com.glsx.process.modules.service;
...
@@ -3,6 +3,7 @@ package cn.com.glsx.process.modules.service;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -10,10 +11,12 @@ import javax.annotation.Resource;
...
@@ -10,10 +11,12 @@ import javax.annotation.Resource;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.alibaba.nacos.shaded.com.google.common.collect.Maps
;
import
com.alibaba.nacos.shaded.com.google.common.collect.Maps
;
import
com.alibaba.nacos.shaded.com.google.common.collect.Sets
;
import
com.alibaba.nacos.shaded.com.google.common.collect.Sets
;
import
com.glsx.plat.common.utils.SnowFlake
;
import
com.glsx.plat.common.utils.SnowFlake
;
import
com.google.common.collect.Lists
;
import
cn.com.glsx.process.modules.entity.SopInst
;
import
cn.com.glsx.process.modules.entity.SopInst
;
import
cn.com.glsx.process.modules.entity.SopInstBatch
;
import
cn.com.glsx.process.modules.entity.SopInstBatch
;
...
@@ -21,7 +24,7 @@ import cn.com.glsx.process.modules.entity.SopInstLink;
...
@@ -21,7 +24,7 @@ import cn.com.glsx.process.modules.entity.SopInstLink;
import
cn.com.glsx.process.modules.entity.SopInstNode
;
import
cn.com.glsx.process.modules.entity.SopInstNode
;
import
cn.com.glsx.process.modules.entity.SopInstNodeBatch
;
import
cn.com.glsx.process.modules.entity.SopInstNodeBatch
;
import
cn.com.glsx.process.modules.entity.SopTpl
;
import
cn.com.glsx.process.modules.entity.SopTpl
;
import
cn.com.glsx.process.modules.entity.SopTpl
Grant
;
import
cn.com.glsx.process.modules.entity.SopTpl
Link
;
import
cn.com.glsx.process.modules.entity.SopTplNode
;
import
cn.com.glsx.process.modules.entity.SopTplNode
;
import
cn.com.glsx.process.modules.mapper.SopInstBatchMapper
;
import
cn.com.glsx.process.modules.mapper.SopInstBatchMapper
;
import
cn.com.glsx.process.modules.mapper.SopInstLinkMapper
;
import
cn.com.glsx.process.modules.mapper.SopInstLinkMapper
;
...
@@ -33,8 +36,13 @@ import cn.com.glsx.process.modules.mapper.SopTplLinkMapper;
...
@@ -33,8 +36,13 @@ import cn.com.glsx.process.modules.mapper.SopTplLinkMapper;
import
cn.com.glsx.process.modules.mapper.SopTplMapper
;
import
cn.com.glsx.process.modules.mapper.SopTplMapper
;
import
cn.com.glsx.process.modules.mapper.SopTplNodeMapper
;
import
cn.com.glsx.process.modules.mapper.SopTplNodeMapper
;
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.util.JacksonUtils
;
import
cn.hutool.core.lang.Pair
;
import
cn.hutool.core.lang.Pair
;
import
cn.hutool.core.util.NumberUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
tk.mybatis.mapper.entity.Example
;
import
tk.mybatis.mapper.entity.Example
;
import
tk.mybatis.mapper.util.Sqls
;
import
tk.mybatis.mapper.util.Sqls
;
...
@@ -110,16 +118,16 @@ public class SopService {
...
@@ -110,16 +118,16 @@ public class SopService {
inst
.
setInstStatus
((
byte
)
-
1
);
inst
.
setInstStatus
((
byte
)
-
1
);
}
}
SopTplGrant
grant
=
grantMapper
.
selectByPrimaryKey
(
inst
.
getGrantId
());
//
SopTplGrant grant = grantMapper.selectByPrimaryKey(inst.getGrantId());
sop
.
setGrant
(
grant
);
//
sop.setGrant(grant);
SopTpl
tpl
=
tplMapper
.
selectByPrimaryKey
(
grant
.
getTplId
());
//
SopTpl tpl = tplMapper.selectByPrimaryKey(grant.getTplId());
sop
.
setTpl
(
tpl
);
//
sop.setTpl(tpl);
List
<
SopTplNode
>
tplNodes
=
tplNodeMapper
//
List<SopTplNode> tplNodes = tplNodeMapper
.
selectByExample
(
Example
.
builder
(
SopTplNode
.
class
).
where
(
Sqls
.
custom
().
andEqualTo
(
"tplId"
,
grant
.
getTplId
())).
build
());
//
.selectByExample(Example.builder(SopTplNode.class).where(Sqls.custom().andEqualTo("tplId", grant.getTplId())).build());
Map
<
Integer
,
SopTplNode
>
tplNodeMap
=
tplNodes
.
stream
().
collect
(
Collectors
.
toMap
(
SopTplNode:
:
getNodeId
,
obj
->
obj
,
(
key1
,
key2
)
->
key1
));
//
Map<Integer, SopTplNode> tplNodeMap = tplNodes.stream().collect(Collectors.toMap(SopTplNode::getNodeId, obj -> obj, (key1, key2) -> key1));
sop
.
setTplNodeMap
(
tplNodeMap
);
//
sop.setTplNodeMap(tplNodeMap);
List
<
SopInstNode
>
instNodes
=
instNodeMapper
List
<
SopInstNode
>
instNodes
=
instNodeMapper
.
selectByExample
(
Example
.
builder
(
SopInstNode
.
class
).
where
(
Sqls
.
custom
().
andEqualTo
(
"instId"
,
inst
.
getInstId
())).
build
());
.
selectByExample
(
Example
.
builder
(
SopInstNode
.
class
).
where
(
Sqls
.
custom
().
andEqualTo
(
"instId"
,
inst
.
getInstId
())).
build
());
...
@@ -159,11 +167,14 @@ public class SopService {
...
@@ -159,11 +167,14 @@ public class SopService {
batch
.
setCreateTime
(
new
Date
());
batch
.
setCreateTime
(
new
Date
());
batch
.
setUpdateTime
(
new
Date
());
batch
.
setUpdateTime
(
new
Date
());
batch
.
setInstId
(
sopInst
.
getInstId
());
batch
.
setInstId
(
sopInst
.
getInstId
());
batch
.
setSnapshot
(
StrUtil
.
blankToDefault
(
sopInst
.
getInstSnapshot
(),
"{}"
));
SnapshotStruct
ss
=
JacksonUtils
.
fromJson
(
StrUtil
.
blankToDefault
(
sopInst
.
getInstSnapshot
(),
"{}"
),
SnapshotStruct
.
class
);
ss
.
getResultMap
().
clear
();
batch
.
setSnapshot
(
JacksonUtils
.
toJson
(
ss
));
instBatchMapper
.
insert
(
batch
);
instBatchMapper
.
insert
(
batch
);
instMapper
.
updateInstBatchNo
(
sopInst
.
getInstId
(),
batch
.
getBatchNo
());
instMapper
.
updateInstBatchNo
(
sopInst
.
getInstId
(),
batch
.
getBatchNo
()
,
batch
.
getSnapshot
()
);
return
batch
;
return
batch
;
}
}
...
@@ -199,4 +210,133 @@ public class SopService {
...
@@ -199,4 +210,133 @@ public class SopService {
instNodeMapper
.
resetInstNodeDailyCount
(
sop
.
getInst
().
getInstId
());
instNodeMapper
.
resetInstNodeDailyCount
(
sop
.
getInst
().
getInstId
());
}
}
/** 从实例倒推出模板,主要用于开发阶段 */
@Transactional
public
void
generateTplFromInst
(
SopStruct
sop
)
{
// 预备模板
SopTpl
tpl
=
new
SopTpl
();
tpl
.
setCreateTime
(
new
Date
());
tpl
.
setTplCron
(
sop
.
getInst
().
getInstCron
());
tpl
.
setTplId
(
StrUtil
.
sub
(
SnowFlake
.
nextSerialNumber
(),
0
,
8
));
// 随机生成模板id
tpl
.
setTplName
(
sop
.
getInst
().
getInstName
());
// 生成参数定义
tpl
.
setTplParamDef
(
parseDef
(
sop
.
getInst
().
getInstParam
()));
tpl
.
setTplRemark
(
"从实例自动产生模板:"
+
sop
.
getInst
().
getInstName
());
tpl
.
setTplResultDef
(
sop
.
getInst
().
getInstSnapshot
());
tpl
.
setTplSingleton
((
byte
)
1
);
tpl
.
setTplStatus
((
byte
)
1
);
tpl
.
setUpdateTime
(
new
Date
());
tplMapper
.
insert
(
tpl
);
List
<
SopTplNode
>
nodes
=
Lists
.
newArrayList
();
for
(
SopInstNode
node
:
sop
.
getInstNodeMap
().
values
())
{
SopTplNode
tnode
=
new
SopTplNode
();
tnode
.
setDailyLimit
(
node
.
getDailyLimit
());
tnode
.
setNodeAsync
(
node
.
getNodeAsync
());
tnode
.
setNodeContentDef
(
node
.
getNodeContent
());
tnode
.
setNodeCron
(
node
.
getNodeCron
());
tnode
.
setNodeExpireCron
(
node
.
getNodeExpireCron
());
tnode
.
setNodeId
(
node
.
getNodeId
());
tnode
.
setNodeKey
(
node
.
getNodeKey
());
tnode
.
setNodeLabel
(
node
.
getNodeLabel
());
tnode
.
setNodeName
(
node
.
getNodeName
());
tnode
.
setNodeParamDef
(
parseDef
(
node
.
getNodeParam
()));
tnode
.
setNodeResultDef
(
node
.
getNodeContent
());
tnode
.
setNodeShow
(
node
.
getNodeShow
());
tnode
.
setNodeSkipable
(
node
.
getNodeSkip
());
tnode
.
setNodeType
(
node
.
getNodeType
());
tnode
.
setNodeVisible
(
node
.
getNodeVisible
());
tnode
.
setTplId
(
tpl
.
getTplId
());
nodes
.
add
(
tnode
);
}
tplNodeMapper
.
insertList
(
nodes
);
List
<
SopTplLink
>
links
=
Lists
.
newArrayList
();
for
(
Entry
<
Integer
,
Pair
<
Set
<
Integer
>,
Set
<
Integer
>>>
entry
:
sop
.
getInstLinkMap
().
entrySet
())
{
if
(
entry
.
getValue
().
getValue
().
isEmpty
())
{
continue
;
}
int
sourceId
=
entry
.
getKey
();
for
(
int
targetId
:
entry
.
getValue
().
getValue
())
{
SopTplLink
link
=
new
SopTplLink
();
link
.
setSourceId
(
sourceId
);
link
.
setTargetId
(
targetId
);
link
.
setTplId
(
tpl
.
getTplId
());
links
.
add
(
link
);
}
}
tplLinkMapper
.
insertList
(
links
);
}
/**
* <code>
{
"day": {
"paramName": "day",
"paramDesc": "有意向第?天",
"valueType": "Integer",
"defaultValue": "2",
"required": true
},
"textContent": {
"paramName": "textContent",
"paramDesc": "营销文案",
"valueType": "String",
"defaultValue": "尊敬的${userName},优惠券领取url.cn/c134dqwe",
"required": true
}
}
* </code>
*
* @param json
* @return
*/
private
static
String
parseDef
(
String
json
)
{
if
(
json
==
null
||
json
.
trim
().
length
()
<
1
)
{
return
null
;
}
JSONObject
def
=
new
JSONObject
();
try
{
JSONObject
parse
=
JSONUtil
.
parseObj
(
json
);
for
(
String
key
:
parse
.
keySet
())
{
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
map
.
put
(
"paramKey"
,
key
);
map
.
put
(
"paramDesc"
,
key
);
Object
value
=
parse
.
get
(
key
);
String
type
=
detectType
(
value
);
map
.
put
(
"valueType"
,
type
);
map
.
put
(
"defaultValue"
,
value
);
map
.
put
(
"required"
,
true
);
def
.
set
(
key
,
map
);
}
}
catch
(
Exception
e
)
{
log
.
warn
(
"json:{}"
,
json
,
e
);
}
return
def
.
toString
();
}
private
static
String
detectType
(
Object
value
)
{
String
v
=
value
.
toString
().
trim
();
if
(
NumberUtil
.
isNumber
(
v
))
{
return
"Number"
;
}
if
(
StrUtil
.
startWith
(
v
,
"{"
))
{
return
"Map"
;
}
if
(
StrUtil
.
startWith
(
v
,
"["
))
{
return
"Array"
;
}
return
"String"
;
}
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/sop/SopHelper.java
View file @
55ba850
This diff is collapsed.
Click to expand it.
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/SopNodeExecutor.java
View file @
55ba850
...
@@ -39,16 +39,13 @@ public interface SopNodeExecutor {
...
@@ -39,16 +39,13 @@ public interface SopNodeExecutor {
* @return
* @return
*/
*/
default
SnapshotStruct
prepare
(
SopStruct
sop
,
SopInstNode
node
)
{
default
SnapshotStruct
prepare
(
SopStruct
sop
,
SopInstNode
node
)
{
SnapshotStruct
es
=
new
SnapshotStruct
();
SnapshotStruct
es
=
JacksonUtils
.
fromJson
(
sop
.
getInst
().
getInstSnapshot
(),
SnapshotStruct
.
class
);
if
(
StrUtil
.
length
(
sop
.
getInst
().
getInstSnapshot
())
>
4
)
{
// 启动参数
// 继承参数
if
(
StrUtil
.
isNotEmpty
(
sop
.
getInst
().
getInstParam
()))
{
es
=
JacksonUtils
.
fromJson
(
sop
.
getInst
().
getInstSnapshot
(),
SnapshotStruct
.
class
);
es
.
getInitMap
().
clear
();
}
else
{
// 重新生成初始化参数
// 启动参数
JSONObject
paramObj
=
JSONUtil
.
parseObj
(
sop
.
getInst
().
getInstParam
());
if
(
StrUtil
.
isNotEmpty
(
sop
.
getInst
().
getInstParam
()))
{
es
.
getInitMap
().
putAll
(
paramObj
);
JSONObject
paramObj
=
JSONUtil
.
parseObj
(
sop
.
getInst
().
getInstParam
());
es
.
getInitMap
().
putAll
(
paramObj
);
}
}
}
es
.
getInitMap
().
put
(
"instId"
,
sop
.
getInst
().
getInstId
());
es
.
getInitMap
().
put
(
"instId"
,
sop
.
getInst
().
getInstId
());
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/JavaExecutor.java
View file @
55ba850
...
@@ -7,6 +7,7 @@ import org.springframework.stereotype.Service;
...
@@ -7,6 +7,7 @@ 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.job.xxljob.core.SopXxlJobUtil
;
import
cn.com.glsx.process.modules.entity.SopInst
;
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
;
...
@@ -46,7 +47,7 @@ public class JavaExecutor implements SopNodeExecutor {
...
@@ -46,7 +47,7 @@ public class JavaExecutor implements SopNodeExecutor {
// 处理返回结果
// 处理返回结果
return
instance
;
return
instance
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
SopXxlJobUtil
.
log
(
log
,
"【{}】{}"
,
getClass
().
getSimpleName
(),
e
.
getMessage
(),
e
);
}
}
return
null
;
return
null
;
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/SqlExecutor.java
View file @
55ba850
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
.
execute
.
executor
;
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
.
execute
.
executor
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
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.
job.xxljob.core.SopXxlJobUtil
;
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
;
...
@@ -24,35 +22,32 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -24,35 +22,32 @@ import lombok.extern.slf4j.Slf4j;
@Service
@Service
public
class
SqlExecutor
implements
SopNodeExecutor
{
public
class
SqlExecutor
implements
SopNodeExecutor
{
@Autowired
@Autowired
private
SopDataSourceService
sopDataSourceService
;
private
SopDataSourceService
sopDataSourceService
;
@Override
@Override
public
Object
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
.
findByDataSourceId
(
dataSourceId
);
SopDataSource
byId
=
sopDataSourceService
.
findByDataSourceId
(
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
());
int
i
=
mcgBizAdapter
.
executeUpdate
(
sql
);
int
i
=
mcgBizAdapter
.
executeUpdate
(
sql
);
return
"更新成功条数"
+
i
;
return
"更新成功条数"
+
i
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
String
message
=
e
.
getMessage
();
SopXxlJobUtil
.
log
(
log
,
"【{}】{}"
,
getClass
().
getSimpleName
(),
e
.
getMessage
(),
e
);
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
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/SqlQueryExecutor.java
View file @
55ba850
...
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
...
@@ -10,6 +10,7 @@ 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.job.xxljob.core.SopXxlJobUtil
;
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
;
...
@@ -48,7 +49,7 @@ public class SqlQueryExecutor implements SopNodeExecutor {
...
@@ -48,7 +49,7 @@ public class SqlQueryExecutor implements SopNodeExecutor {
// 处理执行结果
// 处理执行结果
return
maps
;
return
maps
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
(
);
SopXxlJobUtil
.
log
(
log
,
"【{}】{}"
,
getClass
().
getSimpleName
(),
e
.
getMessage
(),
e
);
}
}
return
null
;
return
null
;
}
}
...
...
platform-process/src/main/resources/mapper/SopInstMapper.xml
View file @
55ba850
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
</update>
</update>
<update
id=
"updateInstBatchNo"
>
<update
id=
"updateInstBatchNo"
>
UPDATE sop_inst SET batch_no = #{batchNo} WHERE inst_id = #{instId}
UPDATE sop_inst SET batch_no = #{batchNo}
, inst_snapshot=#{snapshot}
WHERE inst_id = #{instId}
</update>
</update>
<select
id=
"selectByGroupId"
resultMap=
"BaseResultMap"
>
<select
id=
"selectByGroupId"
resultMap=
"BaseResultMap"
>
...
...
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