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 26ce1011
authored
Sep 20, 2023
by
tiger
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
instId 调整String
1 parent
d53a104d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
20 deletions
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/core/SopXxlJobUtil.java
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/core/XxlJobUtil.java
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/impl/SopInstNodeExecuteJobHandler.java
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/param/SopInstNodeParam.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/resources/mapper/SopInstBatchMapper.xml
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/core/SopXxlJobUtil.java
View file @
26ce101
...
...
@@ -116,12 +116,13 @@ public class SopXxlJobUtil {
return
;
}
int
i
=
0
;
for
(
SopInstNode
node
:
sop
.
getInstNodeMap
().
values
())
{
initSopNodeJob
(
sop
,
node
);
initSopNodeJob
(
sop
,
node
,
i
++
);
}
}
public
static
void
initSopNodeJob
(
SopStruct
sop
,
SopInstNode
node
)
{
public
static
void
initSopNodeJob
(
SopStruct
sop
,
SopInstNode
node
,
int
i
)
{
String
jobBusId
=
jobBusId
(
sop
.
getInst
(),
node
);
XxlJobInfo
job
=
XxlJobUtil
.
findByBusKey
(
jobBusId
);
...
...
@@ -131,7 +132,7 @@ public class SopXxlJobUtil {
}
// 15 2/3 * * * ?
String
cron
=
DateUtil
.
format
(
org
.
apache
.
commons
.
lang
.
time
.
DateUtils
.
add
Minutes
(
new
Date
(),
1
),
"s m H d M ?"
);
String
cron
=
DateUtil
.
format
(
org
.
apache
.
commons
.
lang
.
time
.
DateUtils
.
add
Seconds
(
new
Date
(),
20
+
i
*
6
),
"s m H d M ?"
);
if
(
StrUtil
.
isNotBlank
(
node
.
getNodeCron
()))
{
cron
=
node
.
getNodeCron
();
}
...
...
@@ -140,7 +141,8 @@ public class SopXxlJobUtil {
Pair
<
Set
<
Integer
>,
Set
<
Integer
>>
linkPair
=
sop
.
getInstLinkMap
().
get
(
node
.
getNodeId
());
SopInstNodeParam
params
=
new
SopInstNodeParam
();
params
.
setInstNodeId
(
node
.
getInstNodeId
());
params
.
setInstId
(
node
.
getInstId
());
params
.
setNodeId
(
node
.
getNodeId
());
params
.
setPreIds
(
linkPair
.
getKey
());
params
.
setNextIds
(
linkPair
.
getValue
());
String
paramJson
=
JSONUtil
.
toJsonStr
(
params
);
...
...
@@ -153,6 +155,7 @@ public class SopXxlJobUtil {
job
.
setExecutorHandler
(
SopXxlJobUtil
.
SOP_NODE_EXECUTE_JOB_ID
);
job
.
setBusKey
(
jobBusId
);
job
.
setTriggerStatus
(
1
);
job
.
setExecutorRouteStrategy
(
"RANDOM"
);
if
(
exists
)
{
String
update
=
XxlJobUtil
.
update
(
job
);
...
...
@@ -169,16 +172,21 @@ public class SopXxlJobUtil {
Pair
<
Set
<
Integer
>,
Set
<
Integer
>>
linkPair
=
sop
.
getInstLinkMap
().
get
(
node
.
getNodeId
());
for
(
Integer
nextId
:
linkPair
.
getValue
())
{
String
jobBusId
=
jobBusId
(
sop
.
getInst
(),
sop
.
getInstNodeMap
().
get
(
nextId
));
XxlJobInfo
job
=
XxlJobUtil
.
findByBusKey
(
jobBusId
);
if
(
job
!=
null
)
{
SopInstNodeParam
params
=
JSONUtil
.
toBean
(
job
.
getExecutorParam
(),
SopInstNodeParam
.
class
);
if
(
params
!=
null
)
{
params
.
getFinishedIds
().
add
(
node
.
getNodeId
());
String
update
=
XxlJobUtil
.
update
(
job
);
SopXxlJobUtil
.
log
(
log
,
"【{}】Sop任务节点更新,params:{},result:{}"
,
jobBusId
,
params
,
update
);
try
{
String
jobBusId
=
jobBusId
(
sop
.
getInst
(),
sop
.
getInstNodeMap
().
get
(
nextId
));
XxlJobInfo
job
=
XxlJobUtil
.
findByBusKey
(
jobBusId
);
if
(
job
!=
null
)
{
SopInstNodeParam
params
=
JSONUtil
.
toBean
(
job
.
getExecutorParam
(),
SopInstNodeParam
.
class
);
if
(
params
!=
null
)
{
params
.
getFinishedIds
().
add
(
node
.
getNodeId
());
String
update
=
XxlJobUtil
.
update
(
job
);
SopXxlJobUtil
.
log
(
log
,
"【{}】Sop任务节点更新,params:{},result:{}"
,
jobBusId
,
params
,
update
);
}
}
}
catch
(
Exception
e
)
{
log
.
warn
(
"linkPair:{}"
,
linkPair
,
e
);
}
}
}
...
...
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/core/XxlJobUtil.java
View file @
26ce101
...
...
@@ -68,7 +68,7 @@ public class XxlJobUtil {
jobInfo
.
setJobGroup
(
groupId
);
jobInfo
.
setGlueType
(
"BEAN"
);
jobInfo
.
setExecutorBlockStrategy
(
"SERIAL_EXECUTION"
);
jobInfo
.
setExecutorRouteStrategy
(
"
FIRST
"
);
jobInfo
.
setExecutorRouteStrategy
(
"
RANDOM
"
);
jobInfo
.
setMisfireStrategy
(
"DO_NOTHING"
);
jobInfo
.
setScheduleType
(
ScheduleTypeEnum
.
CRON
.
name
());
return
doPost
(
adminAddresses
+
ADD_URL
,
jobInfo
,
String
.
class
);
...
...
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/impl/SopInstNodeExecuteJobHandler.java
View file @
26ce101
...
...
@@ -39,10 +39,10 @@ public class SopInstNodeExecuteJobHandler {
SopXxlJobUtil
.
log
(
log
,
"【执行Sop节点】{}"
,
param
);
SopStruct
sop
=
sopService
.
loadSop
ByInstNodeId
(
param
.
getInstNode
Id
());
SopStruct
sop
=
sopService
.
loadSop
(
param
.
getInst
Id
());
// 执行sop里面的instNodeId节点。
SopInstNode
node
=
sop
.
getInstNodeMap
().
get
(
param
.
get
Inst
NodeId
());
SopInstNode
node
=
sop
.
getInstNodeMap
().
get
(
param
.
getNodeId
());
boolean
avaliable
=
checkPreIds
(
sop
,
node
,
param
);
if
(!
avaliable
)
{
return
;
...
...
@@ -65,6 +65,8 @@ public class SopInstNodeExecuteJobHandler {
* @return
*/
private
boolean
checkPreIds
(
SopStruct
sop
,
SopInstNode
node
,
SopInstNodeParam
param
)
{
log
.
info
(
"sop:{}"
,
sop
);
log
.
info
(
"node:{}"
,
node
);
Pair
<
Set
<
Integer
>,
Set
<
Integer
>>
pair
=
sop
.
getInstLinkMap
().
get
(
node
.
getNodeId
());
// 前置任务为空,直接执行
...
...
platform-process/src/main/java/cn/com/glsx/process/job/xxljob/param/SopInstNodeParam.java
View file @
26ce101
...
...
@@ -9,8 +9,11 @@ import lombok.Data;
@Data
public
class
SopInstNodeParam
{
/** 实例id */
private
String
instId
;
/** 实例节点id */
private
Integer
instN
odeId
;
private
Integer
n
odeId
;
/** 实例节点前置节点id */
private
Set
<
Integer
>
preIds
=
Sets
.
newHashSet
();
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopInstService.java
View file @
26ce101
...
...
@@ -76,7 +76,7 @@ public class SopInstService {
* @param instId
* @return
*/
public
boolean
delete
(
Integer
instId
)
{
public
boolean
delete
(
String
instId
)
{
int
i
=
sopInstMapper
.
deleteByPrimaryKey
(
instId
);
if
(
i
>
0
)
{
return
true
;
...
...
platform-process/src/main/java/cn/com/glsx/process/modules/service/SopService.java
View file @
26ce101
...
...
@@ -119,7 +119,7 @@ public class SopService {
List
<
SopInstNode
>
instNodes
=
instNodeMapper
.
selectByExample
(
Example
.
builder
(
SopInstNode
.
class
).
where
(
Sqls
.
custom
().
andEqualTo
(
"instId"
,
inst
.
getInstId
())).
build
());
Map
<
Integer
,
SopInstNode
>
instNodeMap
=
instNodes
.
stream
()
.
collect
(
Collectors
.
toMap
(
SopInstNode:
:
get
Inst
NodeId
,
obj
->
obj
,
(
key1
,
key2
)
->
key1
));
.
collect
(
Collectors
.
toMap
(
SopInstNode:
:
getNodeId
,
obj
->
obj
,
(
key1
,
key2
)
->
key1
));
sop
.
setInstNodeMap
(
instNodeMap
);
List
<
SopInstLink
>
instLinks
=
instLinkMapper
...
...
platform-process/src/main/resources/mapper/SopInstBatchMapper.xml
View file @
26ce101
...
...
@@ -6,7 +6,7 @@
WARNING - @mbg.generated
-->
<id
column=
"batch_no"
jdbcType=
"VARCHAR"
property=
"batchNo"
/>
<result
column=
"inst_id"
jdbcType=
"
INTEGE
R"
property=
"instId"
/>
<result
column=
"inst_id"
jdbcType=
"
VARCHA
R"
property=
"instId"
/>
<result
column=
"snapshot"
jdbcType=
"VARCHAR"
property=
"snapshot"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
...
...
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