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
24cd6ee5
Commit
24cd6ee5
authored
Nov 30, 2020
by
huangfusuper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加实例结束回调
parent
4037ac2c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
30 deletions
+46
-30
EndFlowEvent.java
...admin-core/src/main/java/com/byit/event/EndFlowEvent.java
+7
-6
FlowScanEndEvent.java
...n-core/src/main/java/com/byit/event/FlowScanEndEvent.java
+9
-6
FlowEventListener.java
...re/src/main/java/com/byit/listener/FlowEventListener.java
+4
-2
RunNodeServiceImpl.java
...c/main/java/com/byit/service/impl/RunNodeServiceImpl.java
+1
-1
RunRecordingAndLogServiceImpl.java
...ervice/mapservice/impl/RunRecordingAndLogServiceImpl.java
+13
-4
ClosingExampleThreadRunHelper.java
...com/byit/thread/helper/ClosingExampleThreadRunHelper.java
+12
-11
No files found.
byit-myth-core/myth-admin-core/src/main/java/com/byit/event/EndFlowEvent.java
View file @
24cd6ee5
package
com
.
byit
.
event
;
import
com.byit.model.RunRecording
;
import
org.springframework.context.ApplicationEvent
;
/**
...
...
@@ -9,20 +10,20 @@ import org.springframework.context.ApplicationEvent;
public
class
EndFlowEvent
extends
ApplicationEvent
{
private
static
final
long
serialVersionUID
=
2874836396737756384L
;
private
Integer
flowId
;
private
final
RunRecording
runRecording
;
/**
* 创建工作流完结的事件
*
* @param source the object on which the event initially occurred (never {@code null})
* @param
flowId 工作流id
* @param
runRecording 工作流实例
*/
public
EndFlowEvent
(
Object
source
,
Integer
flowId
)
{
public
EndFlowEvent
(
Object
source
,
RunRecording
runRecording
)
{
super
(
source
);
this
.
flowId
=
flowId
;
this
.
runRecording
=
runRecording
;
}
public
Integer
getFlowId
()
{
return
flowId
;
public
RunRecording
getRunRecording
()
{
return
runRecording
;
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/event/FlowScanEndEvent.java
View file @
24cd6ee5
package
com
.
byit
.
event
;
import
com.byit.model.RunRecording
;
import
org.springframework.context.ApplicationEvent
;
/**
...
...
@@ -9,20 +10,21 @@ import org.springframework.context.ApplicationEvent;
*/
public
class
FlowScanEndEvent
extends
ApplicationEvent
{
private
Integer
flowId
;
private
static
final
long
serialVersionUID
=
-
6549668138353259198L
;
private
final
RunRecording
runRecording
;
/**
* 创建工作流添加进实例表完毕后的事件
*
* @param source the object on which the event initially occurred (never {@code null})
* @param
flowId 工作流id
* @param
runRecording 工作流
*/
public
FlowScanEndEvent
(
Object
source
,
Integer
flowId
)
{
public
FlowScanEndEvent
(
Object
source
,
RunRecording
runRecording
)
{
super
(
source
);
this
.
flowId
=
flowId
;
this
.
runRecording
=
runRecording
;
}
public
Integer
getFlowId
()
{
return
flowId
;
public
RunRecording
getRunRecording
()
{
return
runRecording
;
}
}
\ No newline at end of file
byit-myth-core/myth-admin-core/src/main/java/com/byit/listener/FlowEventListener.java
View file @
24cd6ee5
...
...
@@ -32,7 +32,7 @@ public class FlowEventListener {
public
void
flowScanEndEventListener
(
FlowScanEndEvent
flowScanEndEvent
){
log
.
info
(
"-----------监听到事件{},工作流添加进实例完成事件-------"
,
flowScanEndEvent
);
Flow
flow
=
Flow
.
builder
()
.
flowId
(
flowScanEndEvent
.
getFlowId
())
.
flowId
(
flowScanEndEvent
.
get
RunRecording
().
get
FlowId
())
.
scanMark
(
FlowPropertyEnum
.
NOT_SCAN
.
getCode
())
.
build
();
flowService
.
updateByIdSelective
(
flow
);
...
...
@@ -46,9 +46,11 @@ public class FlowEventListener {
public
void
flowEndEventListener
(
EndFlowEvent
endFlowEvent
){
log
.
info
(
"-----------监听到事件{},工作流实例完成事件-------"
,
endFlowEvent
);
Flow
flow
=
Flow
.
builder
()
.
flowId
(
endFlowEvent
.
getFlowId
())
.
flowId
(
endFlowEvent
.
get
RunRecording
().
get
FlowId
())
.
scanMark
(
FlowPropertyEnum
.
SCAN
.
getCode
())
.
build
();
flowService
.
updateByIdSelective
(
flow
);
}
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/impl/RunNodeServiceImpl.java
View file @
24cd6ee5
...
...
@@ -129,7 +129,7 @@ public class RunNodeServiceImpl implements RunNodeServer, ApplicationEventPublis
e
.
printStackTrace
();
}
updateFlow
(
flow
);
applicationEventPublisher
.
publishEvent
(
new
FlowScanEndEvent
(
this
,
flow
.
getFlowId
()
));
applicationEventPublisher
.
publishEvent
(
new
FlowScanEndEvent
(
this
,
build
));
log
.
info
(
"-------saveRunRecAndTaskAndUpdate end-----------【运行结束】-----------------"
);
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/mapservice/impl/RunRecordingAndLogServiceImpl.java
View file @
24cd6ee5
package
com
.
byit
.
service
.
mapservice
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.byit.dto.RunRecordingWrapped
;
import
com.byit.enums.EmailEnum
;
import
com.byit.enums.FlowPropertyEnum
;
import
com.byit.enums.RunRecordingEnum
;
...
...
@@ -9,6 +10,8 @@ import com.byit.event.EndFlowEvent;
import
com.byit.model.*
;
import
com.byit.service.*
;
import
com.byit.service.mapservice.RunRecordingAndLogService
;
import
com.byit.strategy.InstanceRunTheLifeCycleCallback
;
import
com.byit.util.SpringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.context.ApplicationEventPublisher
;
...
...
@@ -17,9 +20,7 @@ import org.springframework.stereotype.Service;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
...
...
@@ -88,7 +89,7 @@ public class RunRecordingAndLogServiceImpl implements RunRecordingAndLogService,
runRecording
.
setIsAlarm
(
EmailEnum
.
IS_ALARM_NO
.
getCode
());
runRecordingService
.
updateRunRecordingById
(
runRecording
);
//执行工作流的完成事件
applicationEventPublisher
.
publishEvent
(
new
EndFlowEvent
(
this
,
runRecording
.
getFlowId
()
));
applicationEventPublisher
.
publishEvent
(
new
EndFlowEvent
(
this
,
runRecording
));
virtualTasks
.
forEach
(
virtualTask
->
{
Integer
mapFlowId
=
virtualTask
.
getMapFlowId
();
...
...
@@ -150,6 +151,14 @@ public class RunRecordingAndLogServiceImpl implements RunRecordingAndLogService,
runRecordingService
.
updateRunRecordingById
(
virtualRunRecording
);
}
Map
<
String
,
InstanceRunTheLifeCycleCallback
>
beansOfType
=
SpringUtil
.
getBeansOfType
(
InstanceRunTheLifeCycleCallback
.
class
);
Set
<
Map
.
Entry
<
String
,
InstanceRunTheLifeCycleCallback
>>
entries
=
beansOfType
.
entrySet
();
//回调生命周期
for
(
Map
.
Entry
<
String
,
InstanceRunTheLifeCycleCallback
>
entry
:
entries
)
{
log
.
info
(
"-------------【开始回调周期{}后置】---------------"
,
entry
.
getKey
());
entry
.
getValue
().
postProcessBeforeInitialization
(
runRecording
);
}
});
//删除task里面的数据
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/thread/helper/ClosingExampleThreadRunHelper.java
View file @
24cd6ee5
...
...
@@ -10,7 +10,9 @@ import com.byit.model.JobTaskRunLogWithBLOBs;
import
com.byit.model.RunRecording
;
import
com.byit.service.JobTaskRunLogService
;
import
com.byit.service.RunRecordingService
;
import
com.byit.strategy.InstanceRunTheLifeCycleCallback
;
import
com.byit.thread.BaseThreadRunHelper
;
import
com.byit.util.SpringUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.context.ApplicationEventPublisher
;
...
...
@@ -20,6 +22,8 @@ import org.springframework.stereotype.Component;
import
javax.sql.DataSource
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
/**
* 完结实例的线程
...
...
@@ -72,17 +76,14 @@ public class ClosingExampleThreadRunHelper extends BaseThreadRunHelper implement
runRecording
.
setIsAlarm
(
EmailEnum
.
IS_ALARM_NO
.
getCode
());
runRecording
.
setEndTime
(
new
Date
());
runRecordingService
.
updateRunRecordingById
(
runRecording
);
applicationEventPublisher
.
publishEvent
(
new
EndFlowEvent
(
this
,
flowId
));
/*if (StringUtils.isNotBlank(runRecording.getReRunId())) {
String reRunId = runRecording.getReRunId();
Integer flowId1 = runRecording.getFlowId();
RunRecording runRecordingByFlowIdAndRunId = runRecordingService.findRunRecordingByFlowIdAndRunId(flowId1, reRunId);
runRecordingByFlowIdAndRunId.setIsAlarm(EmailEnum.IS_ALARM_NO.getCode());
runRecordingByFlowIdAndRunId.setEndTime(new Date());
runRecordingByFlowIdAndRunId.setFlowStatus(RunRecordingEnum.FLOW_STATUS_IS_END.getCode());
runRecordingService.updateRunRecordingById(runRecordingByFlowIdAndRunId);
}*/
applicationEventPublisher
.
publishEvent
(
new
EndFlowEvent
(
this
,
runRecording
));
Map
<
String
,
InstanceRunTheLifeCycleCallback
>
beansOfType
=
SpringUtil
.
getBeansOfType
(
InstanceRunTheLifeCycleCallback
.
class
);
Set
<
Map
.
Entry
<
String
,
InstanceRunTheLifeCycleCallback
>>
entries
=
beansOfType
.
entrySet
();
//回调生命周期
for
(
Map
.
Entry
<
String
,
InstanceRunTheLifeCycleCallback
>
entry
:
entries
)
{
log
.
info
(
"-------------【开始回调周期{}后置】---------------"
,
entry
.
getKey
());
entry
.
getValue
().
postProcessBeforeInitialization
(
runRecording
);
}
}
});
return
UNIVERSAL_WAIT_TIME
;
...
...
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