Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
byit-myth-job
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liyuan
byit-myth-job
Commits
77c28447
Commit
77c28447
authored
Aug 05, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加节点保存删除已加载实例功能
parent
a2c9fc23
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
53 deletions
+60
-53
ApiNodeCheckService.java
...n/src/main/java/com/byit/service/ApiNodeCheckService.java
+1
-5
ApiFlowServiceImpl.java
...c/main/java/com/byit/service/impl/ApiFlowServiceImpl.java
+1
-1
ApiNodeCheckServiceImpl.java
...n/java/com/byit/service/impl/ApiNodeCheckServiceImpl.java
+32
-44
JobTaskService.java
...n-core/src/main/java/com/byit/service/JobTaskService.java
+1
-1
RunRecordingService.java
...e/src/main/java/com/byit/service/RunRecordingService.java
+10
-0
JobTaskServiceImpl.java
...c/main/java/com/byit/service/impl/JobTaskServiceImpl.java
+2
-2
RunRecordingServiceImpl.java
...n/java/com/byit/service/impl/RunRecordingServiceImpl.java
+13
-0
No files found.
byit-myth-admin/src/main/java/com/byit/service/ApiNodeCheckService.java
View file @
77c28447
...
@@ -9,10 +9,6 @@ public interface ApiNodeCheckService {
...
@@ -9,10 +9,6 @@ public interface ApiNodeCheckService {
* 工作流校验
* 工作流校验
* @param mainFlowId 主工作流的id
* @param mainFlowId 主工作流的id
*/
*/
void
checkFlowNode
(
Integer
mainFlowId
);
int
checkFlowNode
(
Integer
mainFlowId
);
/**
* 工作流节点校验 删除不在调度上的节点
*/
int
checkFlowNode
();
}
}
byit-myth-admin/src/main/java/com/byit/service/impl/ApiFlowServiceImpl.java
View file @
77c28447
...
@@ -133,7 +133,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
...
@@ -133,7 +133,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
log
.
debug
(
"生成版本"
);
log
.
debug
(
"生成版本"
);
FlowVersion
flowVersion
=
saveFlowVersion
(
flow
);
FlowVersion
flowVersion
=
saveFlowVersion
(
flow
);
int
checkFlowNode
=
apiNodeCheckService
.
checkFlowNode
();
int
checkFlowNode
=
apiNodeCheckService
.
checkFlowNode
(
flow
.
getFlowId
()
);
log
.
warn
(
"-------删除错误节点{}个--------"
,
checkFlowNode
);
log
.
warn
(
"-------删除错误节点{}个--------"
,
checkFlowNode
);
log
.
debug
(
"插件端通过API保存成功!"
);
log
.
debug
(
"插件端通过API保存成功!"
);
}
}
...
...
byit-myth-admin/src/main/java/com/byit/service/impl/ApiNodeCheckServiceImpl.java
View file @
77c28447
package
com
.
byit
.
service
.
impl
;
package
com
.
byit
.
service
.
impl
;
import
c
om.byit.model.Node
;
import
c
n.hutool.core.collection.CollectionUtil
;
import
com.byit.
model.vo.FlowVo
;
import
com.byit.
enums.DagCheckEnum
;
import
com.byit.
service.ApiNodeCheckService
;
import
com.byit.
model.RunRecording
;
import
com.byit.service.
FlowService
;
import
com.byit.service.
*
;
import
com.byit.
service.NodeService
;
import
com.byit.
utils.ValidationUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
/**
* @author huangfu
* @author huangfu
...
@@ -21,54 +19,44 @@ import java.util.stream.Collectors;
...
@@ -21,54 +19,44 @@ import java.util.stream.Collectors;
@Slf4j
@Slf4j
public
class
ApiNodeCheckServiceImpl
implements
ApiNodeCheckService
{
public
class
ApiNodeCheckServiceImpl
implements
ApiNodeCheckService
{
private
final
NodeService
nodeService
;
private
final
NodeService
nodeService
;
private
final
FlowService
flowService
;
private
final
JobTaskService
jobTaskService
;
private
final
RunRecordingService
runRecordingService
;
public
ApiNodeCheckServiceImpl
(
NodeService
nodeService
,
FlowService
flow
Service
)
{
public
ApiNodeCheckServiceImpl
(
NodeService
nodeService
,
JobTaskService
jobTaskService
,
RunRecordingService
runRecording
Service
)
{
this
.
nodeService
=
nodeService
;
this
.
nodeService
=
nodeService
;
this
.
flowService
=
flowService
;
this
.
jobTaskService
=
jobTaskService
;
this
.
runRecordingService
=
runRecordingService
;
}
}
/**
/**
* 废弃原因:查询次数多,性能低
* @param mainFlowId 主工作流的id
* @param mainFlowId 主工作流的id
*/
*/
@Override
@Override
@Deprecated
public
int
checkFlowNode
(
Integer
mainFlowId
)
{
public
void
checkFlowNode
(
Integer
mainFlowId
)
{
//查询实例表
//查询工作流
List
<
RunRecording
>
runRecordingByFlowId
=
runRecordingService
.
findRunRecordingByFlowId
(
mainFlowId
);
FlowVo
mainFlow
=
flowService
.
getFlowId
(
mainFlowId
);
log
.
debug
(
"--------{}下有{}个实例------------"
,
mainFlowId
,
runRecordingByFlowId
.
size
());
String
flowVersionName
=
mainFlow
.
getVersionName
();
//检查是否有运行中的
//基于主工作流查询所有的节点
boolean
runRecordingIsRunning
=
runRecordingService
.
findRunRecordingIsRunning
(
mainFlowId
);
List
<
Node
>
mainNode
=
nodeService
.
findNodeByFlowIdAndVersionName
(
mainFlowId
);
ValidationUtil
.
isTrueValidation
(
runRecordingIsRunning
,
"当前工作流正在运行不允许重新发布!"
);
//迭代获取所有的虚节点
if
(
CollectionUtil
.
isNotEmpty
(
runRecordingByFlowId
)){
List
<
Node
>
allNodes
=
new
ArrayList
<>();
RunRecording
runRecording
=
runRecordingByFlowId
.
stream
().
filter
(
recording
->
{
getAllInnerNode
(
mainNode
,
allNodes
);
boolean
isFlow
=
"1"
.
equals
(
recording
.
getFlowStatus
());
//筛选版本号不一致的
boolean
isType
=
1
==
recording
.
getScheduleType
();
List
<
Node
>
errorNode
=
allNodes
.
stream
().
filter
(
node
->
{
return
isFlow
&&
isType
;
String
nodeVersionName
=
node
.
getVersionName
();
}).
findFirst
().
orElse
(
null
);
return
!
flowVersionName
.
equals
(
nodeVersionName
);
if
(
runRecording
!=
null
)
{
}).
collect
(
Collectors
.
toList
());
String
runId
=
runRecording
.
getRunId
();
List
<
Integer
>
collect
=
errorNode
.
stream
().
map
(
Node:
:
getNodeId
).
collect
(
Collectors
.
toList
());
//根据runID删除实例
log
.
warn
(
"-------删除错误节点{}个--------"
,
collect
.
size
());
int
deleteRunId
=
runRecordingService
.
deleteRunId
(
runId
);
nodeService
.
deleteNode
(
collect
);
log
.
info
(
"-----删除已经被加载的实例{}个------"
,
deleteRunId
);
//根据runID删除任务表
int
removeByRunId
=
jobTaskService
.
removeByRunId
(
runId
);
log
.
info
(
"-----删除已经被加载的任务{}个------"
,
removeByRunId
);
}
}
}
/**
* 删除不在调度上的节点
*/
@Override
public
int
checkFlowNode
()
{
return
nodeService
.
deleteNoForkNode
();
return
nodeService
.
deleteNoForkNode
();
}
}
private
void
getAllInnerNode
(
List
<
Node
>
mainNodes
,
List
<
Node
>
candidateNodes
){
for
(
Node
node
:
mainNodes
)
{
if
(
"1"
.
equals
(
node
.
getIsVirtual
()))
{
candidateNodes
.
add
(
node
);
}
else
{
List
<
Node
>
mainNode
=
nodeService
.
findNodeByFlowIdAndVersionName
(
node
.
getMapFlowId
());
getAllInnerNode
(
mainNode
,
candidateNodes
);
}
}
}
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/JobTaskService.java
View file @
77c28447
...
@@ -58,5 +58,5 @@ public interface JobTaskService {
...
@@ -58,5 +58,5 @@ public interface JobTaskService {
void
deleteInIds
(
List
<
Integer
>
ids
);
void
deleteInIds
(
List
<
Integer
>
ids
);
void
removeByRunId
(
String
runId
);
int
removeByRunId
(
String
runId
);
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/RunRecordingService.java
View file @
77c28447
...
@@ -68,6 +68,13 @@ public interface RunRecordingService {
...
@@ -68,6 +68,13 @@ public interface RunRecordingService {
boolean
findRunRecordingIsRunning
(
Integer
flowId
);
boolean
findRunRecordingIsRunning
(
Integer
flowId
);
/**
/**
* 工作流ID
* @param flowId 工作流ID
* @return 该工作流下的所由实例
*/
List
<
RunRecording
>
findRunRecordingByFlowId
(
Integer
flowId
);
/**
* 这个方法是会根据任务流的id和运行标识找到唯一对应的一个任务流,这个任务流就是一个虚拟节点
* 这个方法是会根据任务流的id和运行标识找到唯一对应的一个任务流,这个任务流就是一个虚拟节点
* @param flowId
* @param flowId
* @param runId
* @param runId
...
@@ -108,5 +115,7 @@ public interface RunRecordingService {
...
@@ -108,5 +115,7 @@ public interface RunRecordingService {
*/
*/
int
deleteById
(
Integer
recordingId
);
int
deleteById
(
Integer
recordingId
);
int
deleteRunId
(
String
runId
);
}
}
\ No newline at end of file
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/impl/JobTaskServiceImpl.java
View file @
77c28447
...
@@ -91,7 +91,7 @@ public class JobTaskServiceImpl implements JobTaskService {
...
@@ -91,7 +91,7 @@ public class JobTaskServiceImpl implements JobTaskService {
}
}
@Override
@Override
public
void
removeByRunId
(
String
runId
)
{
public
int
removeByRunId
(
String
runId
)
{
jobTaskMapper
.
deleteByRunId
(
runId
);
return
jobTaskMapper
.
deleteByRunId
(
runId
);
}
}
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/impl/RunRecordingServiceImpl.java
View file @
77c28447
package
com
.
byit
.
service
.
impl
;
package
com
.
byit
.
service
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.byit.dto.FlowConditionDto
;
import
com.byit.dto.FlowConditionDto
;
import
com.byit.dto.StatisticsConditionDto
;
import
com.byit.dto.StatisticsConditionDto
;
import
com.byit.enums.RunRecordingEnum
;
import
com.byit.enums.RunRecordingEnum
;
...
@@ -106,6 +107,7 @@ public class RunRecordingServiceImpl implements RunRecordingService {
...
@@ -106,6 +107,7 @@ public class RunRecordingServiceImpl implements RunRecordingService {
@Override
@Override
public
boolean
findRunRecordingIsRunning
(
Integer
flowId
)
{
public
boolean
findRunRecordingIsRunning
(
Integer
flowId
)
{
List
<
RunRecording
>
runRecordings
=
runRecordingMapper
.
findRunRecordingByFlowId
(
flowId
);
List
<
RunRecording
>
runRecordings
=
runRecordingMapper
.
findRunRecordingByFlowId
(
flowId
);
if
(
CollectionUtil
.
isNotEmpty
(
runRecordings
))
{
for
(
RunRecording
runRecording
:
runRecordings
)
{
for
(
RunRecording
runRecording
:
runRecordings
)
{
//判断当前的实例 中是否有 未完成的
//判断当前的实例 中是否有 未完成的
if
(
RunRecordingEnum
.
FLOW_STATUS_RUN_ING
.
getCode
().
equals
(
runRecording
.
getFlowStatus
())
||
if
(
RunRecordingEnum
.
FLOW_STATUS_RUN_ING
.
getCode
().
equals
(
runRecording
.
getFlowStatus
())
||
...
@@ -114,10 +116,16 @@ public class RunRecordingServiceImpl implements RunRecordingService {
...
@@ -114,10 +116,16 @@ public class RunRecordingServiceImpl implements RunRecordingService {
return
true
;
return
true
;
}
}
}
}
}
return
false
;
return
false
;
}
}
@Override
@Override
public
List
<
RunRecording
>
findRunRecordingByFlowId
(
Integer
flowId
)
{
return
runRecordingMapper
.
findRunRecordingByFlowId
(
flowId
);
}
@Override
public
RunRecording
findRunRecordingByFlowIdAndRunId
(
Integer
flowId
,
String
runId
)
{
public
RunRecording
findRunRecordingByFlowIdAndRunId
(
Integer
flowId
,
String
runId
)
{
return
runRecordingMapper
.
findRunRecordingByFlowIdAndRunId
(
flowId
,
runId
);
return
runRecordingMapper
.
findRunRecordingByFlowIdAndRunId
(
flowId
,
runId
);
}
}
...
@@ -146,4 +154,9 @@ public class RunRecordingServiceImpl implements RunRecordingService {
...
@@ -146,4 +154,9 @@ public class RunRecordingServiceImpl implements RunRecordingService {
public
int
deleteById
(
Integer
recordingId
)
{
public
int
deleteById
(
Integer
recordingId
)
{
return
runRecordingMapper
.
deleteById
(
recordingId
);
return
runRecordingMapper
.
deleteById
(
recordingId
);
}
}
@Override
public
int
deleteRunId
(
String
runId
)
{
return
runRecordingMapper
.
deleteByRunId
(
runId
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment