Commit 70be1540 by huangfusuper

Merge remote-tracking branch 'origin/developer' into developer

parents 55058733 970c873b
......@@ -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);
}
......
......@@ -118,11 +118,11 @@ public interface RunRecordingMapper {
List<RunRecording> findStopRunCordByRunId(String runId);
/**
* 杀死整个runid
* 根据runid和flowid杀死运行实例
* @param runId
* @return
*/
int killUnFinshFlow(String runId);
int killUnFinshFlow(@Param("runId")String runId, @Param("flowId")Integer flowId);
/**
* 杀死工作流内的某个内嵌工作流
......@@ -137,7 +137,7 @@ public interface RunRecordingMapper {
* @param runId
* @return
*/
List<RunRecording> findUnFinishByRunId(String runId);
RunRecording findUnFinishByRunId(@Param("runId")String runId, @Param("flowId")Integer flowId);
List<RunRecording> findByStartAndEndTime(@Param("startDate")Date startDate,
@Param("endDate")Date endDate,
......
......@@ -93,8 +93,8 @@ public interface FlowService {
/**
* 杀死一个工作流
* @param runId
* @param param
* @return
*/
Boolean killFlow(String runId) throws InterruptedException;
Boolean killFlow(String param) throws InterruptedException;
}
......@@ -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(runRecordings, "该运行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<JobTaskRunLogWithBLOBs> jobTaskRunLogList = jobTaskRunLogMapper.findJobTaskRunLogWithBLOBsByFlowIdAndRunId(flow.getFlowId(), runId);
for (JobTaskRunLogWithBLOBs jobTaskRunLog : jobTaskRunLogList){
if ("0".equals(jobTaskRunLog.getRunCode())){
if (StringUtils.isEmpty(jobTaskRunLog.getJobGroupIp())){
log.warn("已经调度成功但是还未返回具体的调用机器的ip地址");
......
......@@ -98,11 +98,12 @@
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_id = #{flowId,jdbcType=INTEGER}
and flow_status != '4'
</select>
<select id="findByStartAndEndTime" resultMap="BaseResultMap">
......@@ -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>
......
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