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
63e9902b
Commit
63e9902b
authored
Apr 10, 2020
by
guo_minglei@163.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改杀死工作流接口
parent
a83d1383
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
22 deletions
+36
-22
ApiFlowController.java
...h-admin/src/main/java/com/byit/api/ApiFlowController.java
+2
-2
RunRecordingMapper.java
...ore/src/main/java/com/byit/mapper/RunRecordingMapper.java
+3
-3
FlowService.java
...dmin-core/src/main/java/com/byit/service/FlowService.java
+2
-2
FlowServiceImpl.java
.../src/main/java/com/byit/service/impl/FlowServiceImpl.java
+25
-12
RunRecordingMapper.xml
...min-core/src/main/resources/mapper/RunRecordingMapper.xml
+4
-3
No files found.
byit-myth-admin/src/main/java/com/byit/api/ApiFlowController.java
View file @
63e9902b
...
...
@@ -70,8 +70,8 @@ public class ApiFlowController {
@PostMapping
(
"killFlow"
)
@ApiOperation
(
"杀死工作流"
)
public
ResponseResult
killFlow
(
String
runId
)
throws
InterruptedException
{
Boolean
result
=
flowService
.
killFlow
(
runId
);
public
ResponseResult
killFlow
(
String
param
)
throws
InterruptedException
{
Boolean
result
=
flowService
.
killFlow
(
param
);
return
ResponseResult
.
ok
(
result
);
}
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/mapper/RunRecordingMapper.java
View file @
63e9902b
...
...
@@ -118,11 +118,11 @@ public interface RunRecordingMapper {
List
<
RunRecording
>
findStopRunCordByRunId
(
String
runId
);
/**
*
杀死整个runid
*
根据runid和flowid杀死运行实例
* @param runId
* @return
*/
int
killUnFinshFlow
(
String
run
Id
);
int
killUnFinshFlow
(
@Param
(
"runId"
)
String
runId
,
@Param
(
"flowId"
)
Integer
flow
Id
);
/**
* 杀死工作流内的某个内嵌工作流
...
...
@@ -137,7 +137,7 @@ public interface RunRecordingMapper {
* @param runId
* @return
*/
List
<
RunRecording
>
findUnFinishByRunId
(
String
run
Id
);
RunRecording
findUnFinishByRunId
(
@Param
(
"runId"
)
String
runId
,
@Param
(
"flowId"
)
Integer
flow
Id
);
List
<
RunRecording
>
findByStartAndEndTime
(
@Param
(
"startDate"
)
Date
startDate
,
@Param
(
"endDate"
)
Date
endDate
,
...
...
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/FlowService.java
View file @
63e9902b
...
...
@@ -93,8 +93,8 @@ public interface FlowService {
/**
* 杀死一个工作流
* @param
runId
* @param
param
* @return
*/
Boolean
killFlow
(
String
runId
)
throws
InterruptedException
;
Boolean
killFlow
(
String
param
)
throws
InterruptedException
;
}
byit-myth-core/myth-admin-core/src/main/java/com/byit/service/impl/FlowServiceImpl.java
View file @
63e9902b
...
...
@@ -4,14 +4,12 @@ import cn.hutool.http.HttpUtil;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.byit.dto.web.ResponseResult
;
import
com.byit.enums.ExecuteStatusEnum
;
import
com.byit.enums.FlowPropertyEnum
;
import
com.byit.enums.NodePropertyEnum
;
import
com.byit.job.utils.CronExpression
;
import
com.byit.mapper.*
;
import
com.byit.model.Flow
;
import
com.byit.model.JobTaskRunLog
;
import
com.byit.model.Node
;
import
com.byit.model.RunRecording
;
import
com.byit.model.*
;
import
com.byit.model.vo.FlowVo
;
import
com.byit.model.vo.NodeVo
;
import
com.byit.service.FlowService
;
...
...
@@ -48,6 +46,8 @@ public class FlowServiceImpl implements FlowService {
private
JobTaskRunLogMapper
jobTaskRunLogMapper
;
@Resource
private
RunRecordingMapper
runRecordingMapper
;
@Resource
private
WorkspaceMapper
workspaceMapper
;
@Override
public
Flow
findFlowById
(
Integer
id
)
{
...
...
@@ -351,17 +351,30 @@ public class FlowServiceImpl implements FlowService {
}
@Override
public
Boolean
killFlow
(
String
runId
)
throws
InterruptedException
{
ValidationUtil
.
dataNotBank
(
runId
,
"运行实例不允许为空!"
);
public
Boolean
killFlow
(
String
param
)
throws
InterruptedException
{
ValidationUtil
.
dataNotBank
(
param
,
"请求参数不允许为空!"
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
param
);
String
runId
=
jsonObject
.
getString
(
"runId"
);
ValidationUtil
.
dataNotBank
(
runId
,
"运行实例id不允许为空!"
);
String
workspaceName
=
jsonObject
.
getString
(
"workspaceName"
);
ValidationUtil
.
dataNotBank
(
workspaceName
,
"工作空间名称不允许为空!"
);
Workspace
workspace
=
workspaceMapper
.
getByName
(
workspaceName
);
ValidationUtil
.
dataNotNull
(
workspace
,
workspaceName
+
"工作空间不存在"
);
String
flowName
=
jsonObject
.
getString
(
"flowName"
);
ValidationUtil
.
dataNotBank
(
flowName
,
"工作流名称不允许为空!"
);
Flow
flow
=
flowMapper
.
getByWorkSpaceAndName
(
workspace
.
getWorkspaceId
(),
flowName
);
ValidationUtil
.
dataNotNull
(
flow
,
flowName
+
"工作流不存在"
);
//杀死运行实例
List
<
RunRecording
>
runRecordings
=
runRecordingMapper
.
findUnFinishByRunId
(
runId
);
ValidationUtil
.
dataNotNull
(
runRecording
s
,
"该运行id未找到或已经运行完成无需杀死!"
);
RunRecording
runRecording
=
runRecordingMapper
.
findUnFinishByRunId
(
runId
,
flow
.
getFlowId
()
);
ValidationUtil
.
dataNotNull
(
runRecording
,
"该运行id未找到或已经运行完成无需杀死!"
);
Boolean
result
=
true
;
//杀死未完成的运行实例
runRecordingMapper
.
killUnFinshFlow
(
runId
);
//将未完成的运行实例设置为完成且杀死
runRecording
.
setFlowStatus
(
"4"
);
runRecording
.
setFlowRunResult
(
"5"
);
runRecordingMapper
.
updateRunRecordingById
(
runRecording
);
//杀死所有的任务
List
<
JobTaskRunLog
>
jobTaskRunLogList
=
jobTaskRunLogMapper
.
findByRunId
(
runId
);
for
(
JobTaskRunLog
jobTaskRunLog
:
jobTaskRunLogList
){
List
<
JobTaskRunLog
WithBLOBs
>
jobTaskRunLogList
=
jobTaskRunLogMapper
.
findJobTaskRunLogWithBLOBsByFlowIdAndRunId
(
flow
.
getFlowId
(),
runId
);
for
(
JobTaskRunLog
WithBLOBs
jobTaskRunLog
:
jobTaskRunLogList
){
if
(
"0"
.
equals
(
jobTaskRunLog
.
getRunCode
())){
if
(
StringUtils
.
isEmpty
(
jobTaskRunLog
.
getJobGroupIp
())){
log
.
warn
(
"已经调度成功但是还未返回具体的调用机器的ip地址"
);
...
...
byit-myth-core/myth-admin-core/src/main/resources/mapper/RunRecordingMapper.xml
View file @
63e9902b
...
...
@@ -98,12 +98,13 @@
and flow_status = '3'
</select>
<select
id=
"findUnFinishByRunId"
parameterType=
"string"
resultMap=
"BaseResultMap"
>
<select
id=
"findUnFinishByRunId"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from run_recording
where run_id = #{runId,jdbcType=VARCHAR}
and flow_status != '4'
and flow_id = #{flowId,jdbcType=INTEGER}
and flow_status != '4'
</select>
<select
id=
"findByStartAndEndTime"
resultMap=
"BaseResultMap"
>
select
...
...
@@ -504,7 +505,7 @@
<update
id=
"killUnFinshFlow"
parameterType=
"string"
>
update run_recording set flow_status = '4',flow_run_result = '5'
where run_id = #{runId,jdbcType=VARCHAR}
where run_id = #{runId,jdbcType=VARCHAR}
and flow_id = #{flowId,jdbcType=INTEGER}
and flow_status != '4'
</update>
...
...
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