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 a0fd5f51
authored
Sep 21, 2023
by
tiger
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
快照参数标记
1 parent
d7a5ea54
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
89 additions
and
49 deletions
.gitignore
platform-process-api/src/main/java/cn/com/glsx/process/modules/mapper/SopInstMapper.java
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/impl/SopInstExecuteJobHandler.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/service/SopService.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/RunResult.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/SnapshotStruct.java
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/SopNodeExecutor.java
platform-process/src/main/java/cn/com/glsx/process/util/JacksonUtils.java
.gitignore
View file @
a0fd5f5
...
@@ -9,3 +9,4 @@
...
@@ -9,3 +9,4 @@
*.container
*.container
*.name
*.name
/platform-process-api/*.factorypath
/platform-process-api/*.factorypath
/platform-process/*.path_IS_UNDEFINED
platform-process-api/src/main/java/cn/com/glsx/process/modules/mapper/SopInstMapper.java
View file @
a0fd5f5
...
@@ -14,31 +14,31 @@ import cn.com.glsx.process.modules.model.SopInstSearch;
...
@@ -14,31 +14,31 @@ import cn.com.glsx.process.modules.model.SopInstSearch;
@Mapper
@Mapper
public
interface
SopInstMapper
extends
CommonBaseMapper
<
SopInst
>
{
public
interface
SopInstMapper
extends
CommonBaseMapper
<
SopInst
>
{
List
<
SopInst
>
selectByGroupId
(
SopInstSearch
search
);
List
<
SopInst
>
selectByGroupId
(
SopInstSearch
search
);
/**
/**
* 通过门店模板实例初始参数查询
* 通过门店模板实例初始参数查询
*
*
* @param customData
* @param customData
* @return
* @return
*/
*/
List
<
SopInst
>
selectByCustomData
(
@Param
(
"customData"
)
Map
<
String
,
Object
>
customData
);
List
<
SopInst
>
selectByCustomData
(
@Param
(
"customData"
)
Map
<
String
,
Object
>
customData
);
/**
/**
* 更新门店模板实例默认参数的自定义参数
* 更新门店模板实例默认参数的自定义参数
*
*
* @param instId
* @param instId
* @param customData
* @param customData
*/
*/
void
updateInstParamCustomData
(
@Param
(
"instId"
)
String
instId
,
@Param
(
"customData"
)
Map
<
String
,
Object
>
customData
);
void
updateInstParamCustomData
(
@Param
(
"instId"
)
String
instId
,
@Param
(
"customData"
)
Map
<
String
,
Object
>
customData
);
/**
/**
* 更新门店模板实例的状态
* 更新门店模板实例的状态
*
*
* @param instId
* @param instId
* @param status
* @param status
*/
*/
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
);
}
}
\ No newline at end of file
\ No newline at end of file
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/impl/SopInstExecuteJobHandler.java
View file @
a0fd5f5
...
@@ -31,7 +31,7 @@ public class SopInstExecuteJobHandler {
...
@@ -31,7 +31,7 @@ public class SopInstExecuteJobHandler {
SopStruct
sop
=
sopService
.
loadSop
(
instId
);
SopStruct
sop
=
sopService
.
loadSop
(
instId
);
// 创建执行批次
// 创建执行批次
SopInstBatch
batch
=
sopService
.
createBatch
(
instId
);
SopInstBatch
batch
=
sopService
.
createBatch
(
sop
.
getInst
()
);
sop
.
setBatch
(
batch
);
sop
.
setBatch
(
batch
);
sop
.
getInst
().
setBatchNo
(
batch
.
getBatchNo
());
sop
.
getInst
().
setBatchNo
(
batch
.
getBatchNo
());
...
...
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/impl/SopInstNodeExecuteJobHandler.java
View file @
a0fd5f5
...
@@ -12,6 +12,7 @@ import com.xxl.job.core.handler.annotation.XxlJob;
...
@@ -12,6 +12,7 @@ import com.xxl.job.core.handler.annotation.XxlJob;
import
cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil
;
import
cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil
;
import
cn.com.glsx.process.job.xxljob.param.SopInstNodeParam
;
import
cn.com.glsx.process.job.xxljob.param.SopInstNodeParam
;
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.model.SopStruct
;
import
cn.com.glsx.process.modules.model.SopStruct
;
...
@@ -109,6 +110,7 @@ public class SopInstNodeExecuteJobHandler {
...
@@ -109,6 +110,7 @@ public class SopInstNodeExecuteJobHandler {
// 重新加载sop
// 重新加载sop
sop
=
reloadAndCreateBatch
(
sop
,
node
);
sop
=
reloadAndCreateBatch
(
sop
,
node
);
// 预备执行参数
SnapshotStruct
snapshotStruct
=
instance
.
prepare
(
sop
,
node
);
SnapshotStruct
snapshotStruct
=
instance
.
prepare
(
sop
,
node
);
// 执行sop节点
// 执行sop节点
...
@@ -137,8 +139,15 @@ public class SopInstNodeExecuteJobHandler {
...
@@ -137,8 +139,15 @@ public class SopInstNodeExecuteJobHandler {
}
}
private
void
updateBatch
(
SopStruct
sop
,
SopInstNode
node
,
SnapshotStruct
result
)
{
private
void
updateBatch
(
SopStruct
sop
,
SopInstNode
node
,
SnapshotStruct
result
)
{
// TODO 这里需要考虑合并结果
SopInstBatch
batch
=
sop
.
getBatch
();
batch
.
setSnapshot
(
JSONUtil
.
toJsonStr
(
result
));
sop
.
getInst
().
setInstSnapshot
(
batch
.
getSnapshot
());
sopService
.
updateInstBatch
(
sop
.
getInst
(),
batch
);
SopInstNodeBatch
nodeBatch
=
sop
.
getNodeBatch
();
SopInstNodeBatch
nodeBatch
=
sop
.
getNodeBatch
();
nodeBatch
.
setSnapshot
(
JSONUtil
.
toJsonStr
(
result
));
// TODO 这里需要考虑合并结果
nodeBatch
.
setSnapshot
(
JSONUtil
.
toJsonStr
(
result
));
nodeBatch
.
setUpdateTime
(
new
Date
());
nodeBatch
.
setUpdateTime
(
new
Date
());
sopService
.
updateInstNodeBatch
(
nodeBatch
);
sopService
.
updateInstNodeBatch
(
nodeBatch
);
}
}
...
@@ -146,7 +155,7 @@ public class SopInstNodeExecuteJobHandler {
...
@@ -146,7 +155,7 @@ public class SopInstNodeExecuteJobHandler {
private
SopStruct
reloadAndCreateBatch
(
SopStruct
sop
,
SopInstNode
node
)
{
private
SopStruct
reloadAndCreateBatch
(
SopStruct
sop
,
SopInstNode
node
)
{
sop
=
sopService
.
loadSop
(
sop
.
getInst
().
getInstId
());
sop
=
sopService
.
loadSop
(
sop
.
getInst
().
getInstId
());
// 创建节点执行批次
// 创建节点执行批次
SopInstNodeBatch
curBatch
=
sopService
.
createNodeBatch
(
sop
.
getInst
()
.
getBatchNo
()
,
node
.
getInstNodeId
());
SopInstNodeBatch
curBatch
=
sopService
.
createNodeBatch
(
sop
.
getInst
(),
node
.
getInstNodeId
());
sop
.
setNodeBatch
(
curBatch
);
sop
.
setNodeBatch
(
curBatch
);
return
sop
;
return
sop
;
}
}
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopService.java
View file @
a0fd5f5
...
@@ -197,28 +197,29 @@ public class SopService {
...
@@ -197,28 +197,29 @@ public class SopService {
// }
// }
}
}
public
SopInstBatch
createBatch
(
S
tring
instId
)
{
public
SopInstBatch
createBatch
(
S
opInst
sopInst
)
{
SopInstBatch
batch
=
new
SopInstBatch
();
SopInstBatch
batch
=
new
SopInstBatch
();
batch
.
setBatchNo
(
SnowFlake
.
nextSerialNumber
());
batch
.
setBatchNo
(
SnowFlake
.
nextSerialNumber
());
batch
.
setCreateTime
(
new
Date
());
batch
.
setCreateTime
(
new
Date
());
batch
.
setUpdateTime
(
new
Date
());
batch
.
setUpdateTime
(
new
Date
());
batch
.
setInstId
(
instId
);
batch
.
setInstId
(
sopInst
.
getInstId
()
);
batch
.
setSnapshot
(
""
);
batch
.
setSnapshot
(
sopInst
.
getInstSnapshot
()
);
instBatchMapper
.
insert
(
batch
);
instBatchMapper
.
insert
(
batch
);
instMapper
.
updateInstBatchNo
(
instId
,
batch
.
getBatchNo
());
instMapper
.
updateInstBatchNo
(
sopInst
.
getInstId
(),
batch
.
getBatchNo
());
return
batch
;
return
batch
;
}
}
public
SopInstNodeBatch
createNodeBatch
(
S
tring
batchNo
,
Integer
instNodeId
)
{
public
SopInstNodeBatch
createNodeBatch
(
S
opInst
sopInst
,
Integer
instNodeId
)
{
SopInstNodeBatch
curBatch
=
new
SopInstNodeBatch
();
SopInstNodeBatch
curBatch
=
new
SopInstNodeBatch
();
curBatch
.
setBatchNo
(
batchNo
);
curBatch
.
setBatchNo
(
sopInst
.
getBatchNo
()
);
curBatch
.
setNodeBatchNo
(
SnowFlake
.
nextSerialNumber
());
curBatch
.
setNodeBatchNo
(
SnowFlake
.
nextSerialNumber
());
curBatch
.
setCreateTime
(
new
Date
());
curBatch
.
setCreateTime
(
new
Date
());
curBatch
.
setUpdateTime
(
new
Date
());
curBatch
.
setUpdateTime
(
new
Date
());
curBatch
.
setInstNodeId
(
instNodeId
);
curBatch
.
setInstNodeId
(
instNodeId
);
curBatch
.
setSnapshot
(
""
);
curBatch
.
setSnapshot
(
sopInst
.
getInstSnapshot
()
);
instNodeBatchMapper
.
insert
(
curBatch
);
instNodeBatchMapper
.
insert
(
curBatch
);
...
@@ -229,4 +230,10 @@ public class SopService {
...
@@ -229,4 +230,10 @@ public class SopService {
instNodeBatchMapper
.
updateByPrimaryKey
(
nodeBatch
);
instNodeBatchMapper
.
updateByPrimaryKey
(
nodeBatch
);
}
}
public
void
updateInstBatch
(
SopInst
sopInst
,
SopInstBatch
batch
)
{
instMapper
.
updateByPrimaryKey
(
sopInst
);
instBatchMapper
.
updateByPrimaryKey
(
batch
);
}
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/RunResult.java
View file @
a0fd5f5
...
@@ -17,6 +17,11 @@
...
@@ -17,6 +17,11 @@
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
.
execute
;
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
.
execute
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.util.Map
;
import
com.google.common.collect.Maps
;
import
lombok.Data
;
/**
/**
* 单节点单次执行结果
* 单节点单次执行结果
...
@@ -24,8 +29,12 @@ import java.io.Serializable;
...
@@ -24,8 +29,12 @@ import java.io.Serializable;
* @author kome
* @author kome
* @date 2023年9月20日 下午6:02:22
* @date 2023年9月20日 下午6:02:22
*/
*/
@Data
public
class
RunResult
implements
Serializable
{
public
class
RunResult
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1321328867544959522L
;
private
static
final
long
serialVersionUID
=
-
1321328867544959522L
;
private
String
key
;
private
Map
<
String
,
Object
>
map
=
Maps
.
newHashMap
();
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/SnapshotStruct.java
View file @
a0fd5f5
...
@@ -20,15 +20,15 @@ public class SnapshotStruct implements Serializable, Cloneable {
...
@@ -20,15 +20,15 @@ public class SnapshotStruct implements Serializable, Cloneable {
private
static
final
long
serialVersionUID
=
-
1413400196758036960L
;
private
static
final
long
serialVersionUID
=
-
1413400196758036960L
;
//
//
/**
/**
*
各节点的
初始化参数表
*
Sop批次
初始化参数表
*/
*/
private
Map
<
String
,
Object
>
param
Map
=
Maps
.
newHashMap
();
private
Map
<
String
,
Object
>
init
Map
=
Maps
.
newHashMap
();
/**
/**
* 各节点的输入参数表
*
Sop
各节点的输入参数表
*/
*/
private
Map
<
String
,
Object
>
execute
Map
=
Maps
.
newHashMap
();
private
Map
<
String
,
Object
>
param
Map
=
Maps
.
newHashMap
();
/**
/**
* 各节点的执行结果表
*
Sop
各节点的执行结果表
*/
*/
private
Map
<
String
,
Object
>
resultMap
=
Maps
.
newHashMap
();
private
Map
<
String
,
Object
>
resultMap
=
Maps
.
newHashMap
();
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/SopNodeExecutor.java
View file @
a0fd5f5
...
@@ -16,14 +16,20 @@
...
@@ -16,14 +16,20 @@
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
.
execute
;
package
cn
.
com
.
glsx
.
process
.
modules
.
sop
.
execute
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
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.util.JacksonUtils
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
public
interface
SopNodeExecutor
{
public
interface
SopNodeExecutor
{
Logger
log
=
LoggerFactory
.
getLogger
(
SopNodeExecutor
.
class
);
/**
/**
* 通过sop模板+sop实例输入参数+sop跑批快照,获得本节点执行的输入参数
* 通过sop模板+sop实例输入参数+sop跑批快照,获得本节点执行的输入参数
*
*
...
@@ -32,17 +38,25 @@ public interface SopNodeExecutor {
...
@@ -32,17 +38,25 @@ public interface SopNodeExecutor {
*/
*/
default
SnapshotStruct
prepare
(
SopStruct
sop
,
SopInstNode
node
)
{
default
SnapshotStruct
prepare
(
SopStruct
sop
,
SopInstNode
node
)
{
SnapshotStruct
es
=
new
SnapshotStruct
();
SnapshotStruct
es
=
new
SnapshotStruct
();
if
(
StrUtil
.
length
(
sop
.
getBatch
().
getSnapshot
())
>
3
)
{
// 启动参数
// 继承参数
if
(
StrUtil
.
isNotEmpty
(
sop
.
getInst
().
getInstParam
()))
{
es
=
JacksonUtils
.
fromJson
(
sop
.
getBatch
().
getSnapshot
(),
SnapshotStruct
.
class
);
JSONObject
paramObj
=
JSONUtil
.
parseObj
(
sop
.
getInst
().
getInstParam
());
}
else
{
es
.
getParamMap
().
putAll
(
paramObj
);
// 启动参数
if
(
StrUtil
.
isNotEmpty
(
sop
.
getInst
().
getInstParam
()))
{
JSONObject
paramObj
=
JSONUtil
.
parseObj
(
sop
.
getInst
().
getInstParam
());
es
.
getInitMap
().
putAll
(
paramObj
);
}
}
}
// 当前节点需要的参数
// 当前节点需要的参数
if
(
StrUtil
.
isNotEmpty
(
node
.
getNodeParam
()))
{
if
(
StrUtil
.
isNotEmpty
(
node
.
getNodeParam
()))
{
JSONObject
nodeParamObj
=
JSONUtil
.
parseObj
(
node
.
getNodeParam
());
if
(
StrUtil
.
isNotEmpty
(
node
.
getNodeKey
()))
{
es
.
getExecuteMap
().
putAll
(
nodeParamObj
);
JSONObject
nodeParamObj
=
JSONUtil
.
parseObj
(
node
.
getNodeParam
());
es
.
getParamMap
().
put
(
node
.
getNodeKey
(),
nodeParamObj
);
}
else
{
log
.
warn
(
"【{}】nodeKey 为空!!!"
,
node
.
getInstId
()
+
"-"
+
node
.
getNodeId
());
}
}
}
return
es
;
return
es
;
...
@@ -71,13 +85,13 @@ public interface SopNodeExecutor {
...
@@ -71,13 +85,13 @@ public interface SopNodeExecutor {
// 启动参数
// 启动参数
if
(
StrUtil
.
isNotEmpty
(
sop
.
getInst
().
getInstParam
()))
{
if
(
StrUtil
.
isNotEmpty
(
sop
.
getInst
().
getInstParam
()))
{
JSONObject
paramObj
=
JSONUtil
.
parseObj
(
sop
.
getInst
().
getInstParam
());
JSONObject
paramObj
=
JSONUtil
.
parseObj
(
sop
.
getInst
().
getInstParam
());
es
.
get
Param
Map
().
putAll
(
paramObj
);
es
.
get
Init
Map
().
putAll
(
paramObj
);
}
}
// 当前节点需要的参数
// 当前节点需要的参数
if
(
StrUtil
.
isNotEmpty
(
node
.
getNodeParam
()))
{
if
(
StrUtil
.
isNotEmpty
(
node
.
getNodeParam
()))
{
JSONObject
nodeParamObj
=
JSONUtil
.
parseObj
(
node
.
getNodeParam
());
JSONObject
nodeParamObj
=
JSONUtil
.
parseObj
(
node
.
getNodeParam
());
es
.
get
Execute
Map
().
putAll
(
nodeParamObj
);
es
.
get
Param
Map
().
putAll
(
nodeParamObj
);
}
}
return
es
;
return
es
;
...
...
platform-process/src/main/java/cn/com/glsx/process/util/JacksonUtils.java
0 → 100644
View file @
a0fd5f5
This diff is collapsed.
Click to expand it.
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