Commit 05ca36fe by guo_minglei@163.com

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

parent 970c873b
......@@ -125,4 +125,12 @@ public interface JobTaskRunLogMapper {
@Param("flowIdList")List<Integer> flowIdList);
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 {
* @param runId
* @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,
@Param("endDate")Date endDate,
......
......@@ -364,17 +364,34 @@ public class FlowServiceImpl implements FlowService {
ValidationUtil.dataNotBank(flowName, "工作流名称不允许为空!");
Flow flow = flowMapper.getByWorkSpaceAndName(workspace.getWorkspaceId(), 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());
ValidationUtil.dataNotNull(runRecording, "该运行id未找到或已经运行完成无需杀死!");
List<RunRecording> runRecordingList = runRecordingMapper.findUnFinishByRunId(runId, flowIdList);
ValidationUtil.dataNotNull(runRecordingList, "该运行id未找到或已经运行完成无需杀死!");
Boolean result = true;
runRecordingList.forEach(runRecording -> {
//将未完成的运行实例设置为完成且杀死
runRecording.setFlowStatus("4");
runRecording.setFlowRunResult("5");
runRecordingMapper.updateRunRecordingById(runRecording);
});
//杀死所有的任务
List<JobTaskRunLogWithBLOBs> jobTaskRunLogList = jobTaskRunLogMapper.findJobTaskRunLogWithBLOBsByFlowIdAndRunId(flow.getFlowId(), runId);
for (JobTaskRunLogWithBLOBs jobTaskRunLog : jobTaskRunLogList){
List<JobTaskRunLog> jobTaskRunLogList = jobTaskRunLogMapper.findbyRunIdAndFlowIdList(runId, flowIdList);
if (null != jobTaskRunLogList && jobTaskRunLogList.size() > 0){
for (JobTaskRunLog jobTaskRunLog : jobTaskRunLogList){
if ("0".equals(jobTaskRunLog.getRunCode())){
if (StringUtils.isEmpty(jobTaskRunLog.getJobGroupIp())){
log.warn("已经调度成功但是还未返回具体的调用机器的ip地址");
......@@ -388,6 +405,7 @@ public class FlowServiceImpl implements FlowService {
}
}
}
}
return result;
}
......
......@@ -148,6 +148,18 @@
where run_id = #{runId}
and flow_id = #{flowId}
</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 from job_task_run_log
......
......@@ -103,8 +103,14 @@
<include refid="Base_Column_List" />
from run_recording
where run_id = #{runId,jdbcType=VARCHAR}
and flow_id = #{flowId,jdbcType=INTEGER}
and flow_status != '4'
<if test="flowIdList != null">
and flow_id in (
<foreach collection="flowIdList" item="flowId" separator=",">
#{flowId}
</foreach>
)
</if>
</select>
<select id="findByStartAndEndTime" resultMap="BaseResultMap">
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