Commit 05ca36fe by guo_minglei@163.com

将工作流的内嵌工作流也设置为杀死

parent 970c873b
...@@ -125,4 +125,12 @@ public interface JobTaskRunLogMapper { ...@@ -125,4 +125,12 @@ public interface JobTaskRunLogMapper {
@Param("flowIdList")List<Integer> flowIdList); @Param("flowIdList")List<Integer> flowIdList);
StatisticData findStatisticDataByRunIdAndFlowId(@Param("runId")String runId, @Param("flowId")Integer flowId); StatisticData findStatisticDataByRunIdAndFlowId(@Param("runId")String runId, @Param("flowId")Integer flowId);
/**
* 根据runid和flowidlist获取运行日志
* @param runId
* @param flowIdList
* @return
*/
List<JobTaskRunLog> findbyRunIdAndFlowIdList(@Param("runId")String runId, @Param("flowIdList")List<Integer> flowIdList);
} }
\ No newline at end of file
...@@ -137,7 +137,7 @@ public interface RunRecordingMapper { ...@@ -137,7 +137,7 @@ public interface RunRecordingMapper {
* @param runId * @param runId
* @return * @return
*/ */
RunRecording findUnFinishByRunId(@Param("runId")String runId, @Param("flowId")Integer flowId); List<RunRecording> findUnFinishByRunId(@Param("runId")String runId, @Param("flowIdList")List<Integer> flowIdList);
List<RunRecording> findByStartAndEndTime(@Param("startDate")Date startDate, List<RunRecording> findByStartAndEndTime(@Param("startDate")Date startDate,
@Param("endDate")Date endDate, @Param("endDate")Date endDate,
......
...@@ -364,27 +364,45 @@ public class FlowServiceImpl implements FlowService { ...@@ -364,27 +364,45 @@ public class FlowServiceImpl implements FlowService {
ValidationUtil.dataNotBank(flowName, "工作流名称不允许为空!"); ValidationUtil.dataNotBank(flowName, "工作流名称不允许为空!");
Flow flow = flowMapper.getByWorkSpaceAndName(workspace.getWorkspaceId(), flowName); Flow flow = flowMapper.getByWorkSpaceAndName(workspace.getWorkspaceId(), flowName);
ValidationUtil.dataNotNull(flow, flowName + "工作流不存在"); ValidationUtil.dataNotNull(flow, flowName + "工作流不存在");
List<Integer> flowIdList = new ArrayList<>();
Queue<Integer> queue = new LinkedList<>();
flowIdList.add(flow.getFlowId());
queue.offer(flow.getFlowId());
while(!queue.isEmpty()){
List<Node> innerFlowList = nodeMapper.findVirtualByFlowId(queue.poll());
if (null != innerFlowList && innerFlowList.size() > 0){
innerFlowList.forEach(node -> {
flowIdList.add(node.getMapFlowId());
queue.offer(node.getMapFlowId());
});
}
}
//杀死运行实例 //杀死运行实例
RunRecording runRecording = runRecordingMapper.findUnFinishByRunId(runId, flow.getFlowId()); List<RunRecording> runRecordingList = runRecordingMapper.findUnFinishByRunId(runId, flowIdList);
ValidationUtil.dataNotNull(runRecording, "该运行id未找到或已经运行完成无需杀死!"); ValidationUtil.dataNotNull(runRecordingList, "该运行id未找到或已经运行完成无需杀死!");
Boolean result = true; Boolean result = true;
//将未完成的运行实例设置为完成且杀死 runRecordingList.forEach(runRecording -> {
runRecording.setFlowStatus("4"); //将未完成的运行实例设置为完成且杀死
runRecording.setFlowRunResult("5"); runRecording.setFlowStatus("4");
runRecordingMapper.updateRunRecordingById(runRecording); runRecording.setFlowRunResult("5");
runRecordingMapper.updateRunRecordingById(runRecording);
});
//杀死所有的任务 //杀死所有的任务
List<JobTaskRunLogWithBLOBs> jobTaskRunLogList = jobTaskRunLogMapper.findJobTaskRunLogWithBLOBsByFlowIdAndRunId(flow.getFlowId(), runId); List<JobTaskRunLog> jobTaskRunLogList = jobTaskRunLogMapper.findbyRunIdAndFlowIdList(runId, flowIdList);
for (JobTaskRunLogWithBLOBs jobTaskRunLog : jobTaskRunLogList){ if (null != jobTaskRunLogList && jobTaskRunLogList.size() > 0){
if ("0".equals(jobTaskRunLog.getRunCode())){ for (JobTaskRunLog jobTaskRunLog : jobTaskRunLogList){
if (StringUtils.isEmpty(jobTaskRunLog.getJobGroupIp())){ if ("0".equals(jobTaskRunLog.getRunCode())){
log.warn("已经调度成功但是还未返回具体的调用机器的ip地址"); if (StringUtils.isEmpty(jobTaskRunLog.getJobGroupIp())){
Thread.sleep(3000); log.warn("已经调度成功但是还未返回具体的调用机器的ip地址");
jobTaskRunLog = jobTaskRunLogMapper.findJobTaskRunLogByLogId(jobTaskRunLog.getLogId()); Thread.sleep(3000);
ValidationUtil.isTrueValidation(!"0".equals(jobTaskRunLog.getRunCode()), "该任务已经运行结束!"); jobTaskRunLog = jobTaskRunLogMapper.findJobTaskRunLogByLogId(jobTaskRunLog.getLogId());
ValidationUtil.dataNotBank(jobTaskRunLog.getJobGroupIp(), "尚未分配执行机请稍后再试"); ValidationUtil.isTrueValidation(!"0".equals(jobTaskRunLog.getRunCode()), "该任务已经运行结束!");
} ValidationUtil.dataNotBank(jobTaskRunLog.getJobGroupIp(), "尚未分配执行机请稍后再试");
if (! killJob(jobTaskRunLog.getLogId(), jobTaskRunLog.getJobGroupIp())){ }
result = false; if (! killJob(jobTaskRunLog.getLogId(), jobTaskRunLog.getJobGroupIp())){
result = false;
}
} }
} }
} }
......
...@@ -148,8 +148,20 @@ ...@@ -148,8 +148,20 @@
where run_id = #{runId} where run_id = #{runId}
and flow_id = #{flowId} and flow_id = #{flowId}
</select> </select>
<select id="findbyRunIdAndFlowIdList" resultType="com.byit.model.JobTaskRunLog">
select <include refid="Base_Column_List" />
from job_task_run_log
where run_id = #{runId}
<if test="flowIdList != null">
and flow_id in (
<foreach collection="flowIdList" item="flowId" separator=",">
#{flowId}
</foreach>
)
</if>
</select>
<delete id="deleteById" parameterType="java.lang.Integer"> <delete id="deleteById" parameterType="java.lang.Integer">
delete from job_task_run_log delete from job_task_run_log
where log_id = #{logId,jdbcType=INTEGER} where log_id = #{logId,jdbcType=INTEGER}
</delete> </delete>
......
...@@ -103,8 +103,14 @@ ...@@ -103,8 +103,14 @@
<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_id = #{flowId,jdbcType=INTEGER}
and flow_status != '4' and flow_status != '4'
<if test="flowIdList != null">
and flow_id in (
<foreach collection="flowIdList" item="flowId" separator=",">
#{flowId}
</foreach>
)
</if>
</select> </select>
<select id="findByStartAndEndTime" resultMap="BaseResultMap"> <select id="findByStartAndEndTime" resultMap="BaseResultMap">
select select
......
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