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 f87321bc
authored
Sep 21, 2023
by
tiger
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
快照状态梳理
1 parent
a0fd5f51
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
79 deletions
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/SopNodeExecutor.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/job/xxljob/impl/SopInstExecuteJobHandler.java
View file @
f87321b
...
@@ -32,9 +32,7 @@ public class SopInstExecuteJobHandler {
...
@@ -32,9 +32,7 @@ public class SopInstExecuteJobHandler {
// 创建执行批次
// 创建执行批次
SopInstBatch
batch
=
sopService
.
createBatch
(
sop
.
getInst
());
SopInstBatch
batch
=
sopService
.
createBatch
(
sop
.
getInst
());
sop
.
setBatch
(
batch
);
sop
.
setBatch
(
batch
);
sop
.
getInst
().
setBatchNo
(
batch
.
getBatchNo
());
// 创建所有节点任务
// 创建所有节点任务
SopXxlJobUtil
.
initSopNodesJob
(
sop
);
SopXxlJobUtil
.
initSopNodesJob
(
sop
);
...
...
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/impl/SopInstNodeExecuteJobHandler.java
View file @
f87321b
...
@@ -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.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
;
...
@@ -23,6 +24,7 @@ import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
...
@@ -23,6 +24,7 @@ import cn.com.glsx.process.modules.sop.execute.SnapshotStruct;
import
cn.com.glsx.process.modules.sop.execute.SopNodeExecutor
;
import
cn.com.glsx.process.modules.sop.execute.SopNodeExecutor
;
import
cn.com.glsx.process.modules.sop.execute.SopNodeExecutorFactory
;
import
cn.com.glsx.process.modules.sop.execute.SopNodeExecutorFactory
;
import
cn.com.glsx.process.modules.sop.execute.SopNodeType
;
import
cn.com.glsx.process.modules.sop.execute.SopNodeType
;
import
cn.com.glsx.process.util.JacksonUtils
;
import
cn.hutool.core.lang.Pair
;
import
cn.hutool.core.lang.Pair
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -67,8 +69,8 @@ public class SopInstNodeExecuteJobHandler {
...
@@ -67,8 +69,8 @@ public class SopInstNodeExecuteJobHandler {
* @return
* @return
*/
*/
private
boolean
checkPreIds
(
SopStruct
sop
,
SopInstNode
node
,
SopInstNodeParam
param
)
{
private
boolean
checkPreIds
(
SopStruct
sop
,
SopInstNode
node
,
SopInstNodeParam
param
)
{
log
.
info
(
"sop:{}"
,
sop
);
log
.
info
(
"sop:{}"
,
JacksonUtils
.
nodefaultMapper
.
toJson
(
sop
)
);
log
.
info
(
"node:{}"
,
node
);
log
.
info
(
"node:{}"
,
JacksonUtils
.
nodefaultMapper
.
toJson
(
node
)
);
Pair
<
Set
<
Integer
>,
Set
<
Integer
>>
pair
=
sop
.
getInstLinkMap
().
get
(
node
.
getNodeId
());
Pair
<
Set
<
Integer
>,
Set
<
Integer
>>
pair
=
sop
.
getInstLinkMap
().
get
(
node
.
getNodeId
());
// 前置任务为空,直接执行
// 前置任务为空,直接执行
...
@@ -139,17 +141,23 @@ public class SopInstNodeExecuteJobHandler {
...
@@ -139,17 +141,23 @@ public class SopInstNodeExecuteJobHandler {
}
}
private
void
updateBatch
(
SopStruct
sop
,
SopInstNode
node
,
SnapshotStruct
result
)
{
private
void
updateBatch
(
SopStruct
sop
,
SopInstNode
node
,
SnapshotStruct
result
)
{
// TODO 这里需要考虑合并结果
String
snapshot
=
JacksonUtils
.
nodefaultMapper
.
toJson
(
result
);
// 刷新实例快照
SopInst
inst
=
sop
.
getInst
();
inst
.
setInstSnapshot
(
snapshot
);
// 刷新实例批次快照
SopInstBatch
batch
=
sop
.
getBatch
();
SopInstBatch
batch
=
sop
.
getBatch
();
batch
.
setSnapshot
(
JSONUtil
.
toJsonStr
(
result
));
batch
.
setSnapshot
(
snapshot
);
sop
.
getInst
().
setInstSnapshot
(
batch
.
getSnapshot
());
batch
.
setUpdateTime
(
new
Date
());
sopService
.
updateInstBatch
(
sop
.
getInst
(),
batch
);
// 刷新实例节点批次快照
SopInstNodeBatch
nodeBatch
=
sop
.
getNodeBatch
();
SopInstNodeBatch
nodeBatch
=
sop
.
getNodeBatch
();
nodeBatch
.
setSnapshot
(
JSONUtil
.
toJsonStr
(
result
)
);
nodeBatch
.
setSnapshot
(
snapshot
);
nodeBatch
.
setUpdateTime
(
new
Date
());
nodeBatch
.
setUpdateTime
(
new
Date
());
sopService
.
updateInstNodeBatch
(
nodeBatch
);
sopService
.
updateNodeBatch
(
inst
,
batch
,
nodeBatch
);
}
}
private
SopStruct
reloadAndCreateBatch
(
SopStruct
sop
,
SopInstNode
node
)
{
private
SopStruct
reloadAndCreateBatch
(
SopStruct
sop
,
SopInstNode
node
)
{
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopService.java
View file @
f87321b
...
@@ -148,62 +148,13 @@ public class SopService {
...
@@ -148,62 +148,13 @@ public class SopService {
return
sop
;
return
sop
;
}
}
public
void
execute
()
{
// String flowInstanceId = Tools.genFlowInstanceId(session.getId(), webStruct.getFlowId());
//
// ConcurrentHashMap<String, RunResult> runResultMap = new ConcurrentHashMap<String, RunResult>();
// FlowRunSort flowRunSort = new FlowRunSort();
// ExecuteStruct executeStruct = new ExecuteStruct();
// executeStruct.setMcgWebScoketCode(webStruct.getMcgWebScoketCode());
// executeStruct.setFlowId(webStruct.getFlowId());
// executeStruct.setFlowInstanceId(flowInstanceId);
// executeStruct.setDataMap(flowRunSort.init(flowStruct));
// executeStruct.setOrders(flowRunSort.getFlowSort());
// executeStruct.setRunResultMap(runResultMap);
// executeStruct.setSession(session);
// executeStruct.setTopology(curTopology);
// executeStruct.setSubFlag(subFlag);
// executeStruct.setRunStatus(runStatus);
//
// notifyBody.setContent("【" + curTopology.getName() + "】流程执行开始!");
// notifyBody.setType(LogTypeEnum.INFO.getValue());
// message.setBody(notifyBody);
// MessagePlugin.push(webStruct.getMcgWebScoketCode(), session.getId(), message);
//
// try {
// FlowTask flowTask = new FlowTask(webStruct.getMcgWebScoketCode(), session.getId(), executeStruct, subFlag);
//
// FlowInstancesUtils.executeStructMap.put(flowInstanceId, executeStruct);
// Future<RunStatus> future = ThreadPoolUtils.FLOW_WORK_EXECUTOR.submit(flowTask);
//
// FlowInstancesUtils.executeStructMap.get(flowInstanceId).getFlowTaskFutureList().add(future);
// if(subFlag) {
//
// String subFlowInstanceId = Tools.genFlowInstanceId(session.getId(), parentFlowId);
// ExecuteStruct parentExecuteStruct = FlowInstancesUtils.executeStructMap.get(subFlowInstanceId);
// executeStruct.setParentParam(parentParam);
// parentExecuteStruct.setChildExecuteStruct(executeStruct);
// }
// runStatus = future.get();
// logger.debug("流程:{}, 执行结果:{}", JSON.toJSONString(curTopology), JSON.toJSONString(runStatus));
// return runStatus;
//
// } catch(CancellationException e) {
// executeStruct.getRunStatus().setInterrupt(true);
// logger.error("流程执行中断,抛出CancellationException,异常信息:", e);
// } catch (InterruptedException e) {
// executeStruct.getRunStatus().setInterrupt(true);
// logger.error("流程执行中断,抛出InterruptedException,异常信息:", e);
// }
}
public
SopInstBatch
createBatch
(
SopInst
sopInst
)
{
public
SopInstBatch
createBatch
(
SopInst
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
(
sopInst
.
getInstId
());
batch
.
setInstId
(
sopInst
.
getInstId
());
batch
.
setSnapshot
(
sopInst
.
getInstSnapshot
(
));
batch
.
setSnapshot
(
StrUtil
.
blankToDefault
(
sopInst
.
getInstSnapshot
(),
"{}"
));
instBatchMapper
.
insert
(
batch
);
instBatchMapper
.
insert
(
batch
);
...
@@ -219,21 +170,20 @@ public class SopService {
...
@@ -219,21 +170,20 @@ public class SopService {
curBatch
.
setCreateTime
(
new
Date
());
curBatch
.
setCreateTime
(
new
Date
());
curBatch
.
setUpdateTime
(
new
Date
());
curBatch
.
setUpdateTime
(
new
Date
());
curBatch
.
setInstNodeId
(
instNodeId
);
curBatch
.
setInstNodeId
(
instNodeId
);
curBatch
.
setSnapshot
(
sopInst
.
getInstSnapshot
(
));
curBatch
.
setSnapshot
(
StrUtil
.
blankToDefault
(
sopInst
.
getInstSnapshot
(),
"{}"
));
instNodeBatchMapper
.
insert
(
curBatch
);
instNodeBatchMapper
.
insert
(
curBatch
);
return
curBatch
;
return
curBatch
;
}
}
public
void
updateInstNodeBatch
(
SopInstNodeBatch
nodeBatch
)
{
instNodeBatchMapper
.
updateByPrimaryKey
(
nodeBatch
);
}
public
void
update
InstBatch
(
SopInst
sopInst
,
SopInstBatch
b
atch
)
{
public
void
update
NodeBatch
(
SopInst
sopInst
,
SopInstBatch
batch
,
SopInstNodeBatch
nodeB
atch
)
{
inst
Mapper
.
updateByPrimaryKey
(
sopInst
);
inst
NodeBatchMapper
.
updateByPrimaryKey
(
nodeBatch
);
instBatchMapper
.
updateByPrimaryKey
(
batch
);
instBatchMapper
.
updateByPrimaryKey
(
batch
);
instMapper
.
updateByPrimaryKey
(
sopInst
);
}
}
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/SopNodeExecutor.java
View file @
f87321b
...
@@ -38,9 +38,9 @@ public interface SopNodeExecutor {
...
@@ -38,9 +38,9 @@ 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
.
get
Batch
().
ge
tSnapshot
())
>
3
)
{
if
(
StrUtil
.
length
(
sop
.
get
Inst
().
getIns
tSnapshot
())
>
3
)
{
// 继承参数
// 继承参数
es
=
JacksonUtils
.
fromJson
(
sop
.
get
Batch
().
ge
tSnapshot
(),
SnapshotStruct
.
class
);
es
=
JacksonUtils
.
fromJson
(
sop
.
get
Inst
().
getIns
tSnapshot
(),
SnapshotStruct
.
class
);
}
else
{
}
else
{
// 启动参数
// 启动参数
if
(
StrUtil
.
isNotEmpty
(
sop
.
getInst
().
getInstParam
()))
{
if
(
StrUtil
.
isNotEmpty
(
sop
.
getInst
().
getInstParam
()))
{
...
@@ -82,18 +82,16 @@ public interface SopNodeExecutor {
...
@@ -82,18 +82,16 @@ public interface SopNodeExecutor {
* @return
* @return
*/
*/
default
SnapshotStruct
handleResult
(
SopStruct
sop
,
SopInstNode
node
,
SnapshotStruct
es
,
RunResult
result
)
{
default
SnapshotStruct
handleResult
(
SopStruct
sop
,
SopInstNode
node
,
SnapshotStruct
es
,
RunResult
result
)
{
// 启动参数
if
(
result
==
null
)
{
if
(
StrUtil
.
isNotEmpty
(
sop
.
getInst
().
getInstParam
()))
{
return
es
;
JSONObject
paramObj
=
JSONUtil
.
parseObj
(
sop
.
getInst
().
getInstParam
());
es
.
getInitMap
().
putAll
(
paramObj
);
}
}
// 当前节点需要的参数
// 当前节点需要的参数
if
(
StrUtil
.
isNotEmpty
(
node
.
getNodeParam
()))
{
if
(
StrUtil
.
isNotEmpty
(
node
.
getNodeKey
()))
{
JSONObject
nodeParamObj
=
JSONUtil
.
parseObj
(
node
.
getNodeParam
());
es
.
getParamMap
().
put
(
node
.
getNodeKey
(),
result
);
es
.
getParamMap
().
putAll
(
nodeParamObj
);
}
else
{
log
.
warn
(
"【{}】nodeKey 为空!!!"
,
node
.
getInstId
()
+
"-"
+
node
.
getNodeId
());
}
}
return
es
;
return
es
;
}
}
}
}
platform-process/src/main/java/cn/com/glsx/process/modules/sop/execute/executor/StartExecutor.java
View file @
f87321b
...
@@ -8,8 +8,8 @@ import org.springframework.stereotype.Service;
...
@@ -8,8 +8,8 @@ import org.springframework.stereotype.Service;
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.modules.service.SopService
;
import
cn.com.glsx.process.modules.service.SopService
;
import
cn.com.glsx.process.modules.sop.execute.SnapshotStruct
;
import
cn.com.glsx.process.modules.sop.execute.RunResult
;
import
cn.com.glsx.process.modules.sop.execute.RunResult
;
import
cn.com.glsx.process.modules.sop.execute.SnapshotStruct
;
import
cn.com.glsx.process.modules.sop.execute.SopNodeExecutor
;
import
cn.com.glsx.process.modules.sop.execute.SopNodeExecutor
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
...
@@ -26,14 +26,13 @@ import lombok.extern.slf4j.Slf4j;
...
@@ -26,14 +26,13 @@ import lombok.extern.slf4j.Slf4j;
*/
*/
@Slf4j
@Slf4j
@Service
@Service
public
class
StartExecutor
extends
JavaExecutor
implements
SopNodeExecutor
{
public
class
StartExecutor
implements
SopNodeExecutor
{
@Resource
@Resource
private
SopService
sopService
;
private
SopService
sopService
;
@Override
@Override
public
RunResult
execute
(
SopStruct
sop
,
SopInstNode
node
,
SnapshotStruct
executeStruct
)
throws
Exception
{
public
RunResult
execute
(
SopStruct
sop
,
SopInstNode
node
,
SnapshotStruct
executeStruct
)
throws
Exception
{
super
.
execute
(
sop
,
node
,
executeStruct
);
return
null
;
return
null
;
}
}
...
...
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