Commit 63e9902b by guo_minglei@163.com

修改杀死工作流接口

parent a83d1383
...@@ -70,8 +70,8 @@ public class ApiFlowController { ...@@ -70,8 +70,8 @@ public class ApiFlowController {
@PostMapping("killFlow") @PostMapping("killFlow")
@ApiOperation("杀死工作流") @ApiOperation("杀死工作流")
public ResponseResult killFlow(String runId) throws InterruptedException { public ResponseResult killFlow(String param) throws InterruptedException {
Boolean result = flowService.killFlow(runId); Boolean result = flowService.killFlow(param);
return ResponseResult.ok(result); return ResponseResult.ok(result);
} }
......
...@@ -118,11 +118,11 @@ public interface RunRecordingMapper { ...@@ -118,11 +118,11 @@ public interface RunRecordingMapper {
List<RunRecording> findStopRunCordByRunId(String runId); List<RunRecording> findStopRunCordByRunId(String runId);
/** /**
* 杀死整个runid * 根据runid和flowid杀死运行实例
* @param runId * @param runId
* @return * @return
*/ */
int killUnFinshFlow(String runId); int killUnFinshFlow(@Param("runId")String runId, @Param("flowId")Integer flowId);
/** /**
* 杀死工作流内的某个内嵌工作流 * 杀死工作流内的某个内嵌工作流
...@@ -137,7 +137,7 @@ public interface RunRecordingMapper { ...@@ -137,7 +137,7 @@ public interface RunRecordingMapper {
* @param runId * @param runId
* @return * @return
*/ */
List<RunRecording> findUnFinishByRunId(String runId); RunRecording findUnFinishByRunId(@Param("runId")String runId, @Param("flowId")Integer flowId);
List<RunRecording> findByStartAndEndTime(@Param("startDate")Date startDate, List<RunRecording> findByStartAndEndTime(@Param("startDate")Date startDate,
@Param("endDate")Date endDate, @Param("endDate")Date endDate,
......
...@@ -93,8 +93,8 @@ public interface FlowService { ...@@ -93,8 +93,8 @@ public interface FlowService {
/** /**
* 杀死一个工作流 * 杀死一个工作流
* @param runId * @param param
* @return * @return
*/ */
Boolean killFlow(String runId) throws InterruptedException; Boolean killFlow(String param) throws InterruptedException;
} }
...@@ -4,14 +4,12 @@ import cn.hutool.http.HttpUtil; ...@@ -4,14 +4,12 @@ import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.byit.dto.web.ResponseResult; import com.byit.dto.web.ResponseResult;
import com.byit.enums.ExecuteStatusEnum;
import com.byit.enums.FlowPropertyEnum; import com.byit.enums.FlowPropertyEnum;
import com.byit.enums.NodePropertyEnum; import com.byit.enums.NodePropertyEnum;
import com.byit.job.utils.CronExpression; import com.byit.job.utils.CronExpression;
import com.byit.mapper.*; import com.byit.mapper.*;
import com.byit.model.Flow; import com.byit.model.*;
import com.byit.model.JobTaskRunLog;
import com.byit.model.Node;
import com.byit.model.RunRecording;
import com.byit.model.vo.FlowVo; import com.byit.model.vo.FlowVo;
import com.byit.model.vo.NodeVo; import com.byit.model.vo.NodeVo;
import com.byit.service.FlowService; import com.byit.service.FlowService;
...@@ -48,6 +46,8 @@ public class FlowServiceImpl implements FlowService { ...@@ -48,6 +46,8 @@ public class FlowServiceImpl implements FlowService {
private JobTaskRunLogMapper jobTaskRunLogMapper; private JobTaskRunLogMapper jobTaskRunLogMapper;
@Resource @Resource
private RunRecordingMapper runRecordingMapper; private RunRecordingMapper runRecordingMapper;
@Resource
private WorkspaceMapper workspaceMapper;
@Override @Override
public Flow findFlowById(Integer id) { public Flow findFlowById(Integer id) {
...@@ -351,17 +351,30 @@ public class FlowServiceImpl implements FlowService { ...@@ -351,17 +351,30 @@ public class FlowServiceImpl implements FlowService {
} }
@Override @Override
public Boolean killFlow(String runId) throws InterruptedException { public Boolean killFlow(String param) throws InterruptedException {
ValidationUtil.dataNotBank(runId, "运行实例不允许为空!"); 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); RunRecording runRecording = runRecordingMapper.findUnFinishByRunId(runId, flow.getFlowId());
ValidationUtil.dataNotNull(runRecordings, "该运行id未找到或已经运行完成无需杀死!"); ValidationUtil.dataNotNull(runRecording, "该运行id未找到或已经运行完成无需杀死!");
Boolean result = true; Boolean result = true;
//杀死未完成的运行实例 //将未完成的运行实例设置为完成且杀死
runRecordingMapper.killUnFinshFlow(runId); runRecording.setFlowStatus("4");
runRecording.setFlowRunResult("5");
runRecordingMapper.updateRunRecordingById(runRecording);
//杀死所有的任务 //杀死所有的任务
List<JobTaskRunLog> jobTaskRunLogList = jobTaskRunLogMapper.findByRunId(runId); List<JobTaskRunLogWithBLOBs> jobTaskRunLogList = jobTaskRunLogMapper.findJobTaskRunLogWithBLOBsByFlowIdAndRunId(flow.getFlowId(), runId);
for (JobTaskRunLog jobTaskRunLog : jobTaskRunLogList){ for (JobTaskRunLogWithBLOBs jobTaskRunLog : jobTaskRunLogList){
if ("0".equals(jobTaskRunLog.getRunCode())){ if ("0".equals(jobTaskRunLog.getRunCode())){
if (StringUtils.isEmpty(jobTaskRunLog.getJobGroupIp())){ if (StringUtils.isEmpty(jobTaskRunLog.getJobGroupIp())){
log.warn("已经调度成功但是还未返回具体的调用机器的ip地址"); log.warn("已经调度成功但是还未返回具体的调用机器的ip地址");
......
...@@ -98,12 +98,13 @@ ...@@ -98,12 +98,13 @@
and flow_status = '3' and flow_status = '3'
</select> </select>
<select id="findUnFinishByRunId" parameterType="string" resultMap="BaseResultMap"> <select id="findUnFinishByRunId" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from run_recording from run_recording
where run_id = #{runId,jdbcType=VARCHAR} where run_id = #{runId,jdbcType=VARCHAR}
and flow_status != '4' and flow_id = #{flowId,jdbcType=INTEGER}
and flow_status != '4'
</select> </select>
<select id="findByStartAndEndTime" resultMap="BaseResultMap"> <select id="findByStartAndEndTime" resultMap="BaseResultMap">
select select
...@@ -504,7 +505,7 @@ ...@@ -504,7 +505,7 @@
<update id="killUnFinshFlow" parameterType="string"> <update id="killUnFinshFlow" parameterType="string">
update run_recording set flow_status = '4',flow_run_result = '5' 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' and flow_status != '4'
</update> </update>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment