Commit 6b3ed7aa by huangfusuper

暂停BUG

parent 76f97ef7
...@@ -1536,6 +1536,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -1536,6 +1536,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
if ("3".equals(runRecording.getFlowStatus())) { if ("3".equals(runRecording.getFlowStatus())) {
StopFlowParam stopFlowParam = new StopFlowParam(); StopFlowParam stopFlowParam = new StopFlowParam();
stopFlowParam.setRunIds(runRecording.getRunId()); stopFlowParam.setRunIds(runRecording.getRunId());
stopFlowParam.setFlowName(flowName);
stopFlowParam.setAllStartFlow("1"); stopFlowParam.setAllStartFlow("1");
reStartSchedule(stopFlowParam); reStartSchedule(stopFlowParam);
} else { } else {
...@@ -1672,7 +1673,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -1672,7 +1673,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
//暂停工作流调度 //暂停工作流调度
recordingList.forEach(runRecording -> { recordingList.forEach(runRecording -> {
//runRecordingMapper.stopByRunIdAndFlowId(runRecording.getRunId(), runRecording.getFlowId()); //runRecordingMapper.stopByRunIdAndFlowId(runRecording.getRunId(), runRecording.getFlowId());
runRecordingMapper.stopByRunId(runRecording.getRunId()); runRecordingMapper.stopByRunIdAndFlowId(runRecording.getRunId(), runRecording.getFlowId());
jobTaskMapper.stopByRunIdAndFlowId(runRecording.getRunId(), runRecording.getFlowId()); jobTaskMapper.stopByRunIdAndFlowId(runRecording.getRunId(), runRecording.getFlowId());
runids.append(runRecording.getRunId() + ","); runids.append(runRecording.getRunId() + ",");
}); });
...@@ -1685,13 +1686,19 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -1685,13 +1686,19 @@ public class ApiFlowServiceImpl implements ApiFlowService {
ValidationUtil.dataNotNull(stopFlowParam, "执行参数不允许为空!"); ValidationUtil.dataNotNull(stopFlowParam, "执行参数不允许为空!");
String runIds = stopFlowParam.getRunIds(); String runIds = stopFlowParam.getRunIds();
ValidationUtil.dataNotBank(runIds, "运行id不允许为空!"); ValidationUtil.dataNotBank(runIds, "运行id不允许为空!");
String flowName = stopFlowParam.getFlowName();
ValidationUtil.dataNotBank(flowName, "工作流名称不允许为空!");
List<String> runIdList = Arrays.asList(runIds.split(",")); List<String> runIdList = Arrays.asList(runIds.split(","));
runIdList.forEach(runId -> { for (String runId : runIdList) {
List<RunRecording> runRecordList = runRecordingMapper.findStopRunCordByRunId(runId); List<RunRecording> runRecordList = runRecordingMapper.findStopRunCordByRunId(runId);
log.warn("---------运行记录{},不存在暂停记录中!---", runId);
ValidationUtil.isTrueValidation(CollectionUtil.isEmpty(runRecordList), "该工作流不是暂停状态!"); //ValidationUtil.isTrueValidation(CollectionUtil.isEmpty(runRecordList), "该工作流不是暂停状态!");
RunRecording mainRunRecording = runRecordList.stream().filter(runRecording -> "1".equals(runRecording.getIsInner())).findFirst().orElse(null); if(CollectionUtil.isEmpty(runRecordList)){
log.warn("---------运行记录{},不存在暂停记录中!---", runId);
return;
}
RunRecording mainRunRecording = runRecordList.stream().filter(runRecording -> flowName.equals(runRecording.getFlowName())).findFirst().orElse(null);
Integer stopCount = 0; Integer stopCount = 0;
if (mainRunRecording != null) { if (mainRunRecording != null) {
stopCount = mainRunRecording.getStopCount(); stopCount = mainRunRecording.getStopCount();
...@@ -1701,11 +1708,11 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -1701,11 +1708,11 @@ public class ApiFlowServiceImpl implements ApiFlowService {
mainRunRecording.setStopCount(stopCount); mainRunRecording.setStopCount(stopCount);
runRecordingMapper.updateRunRecordingById(mainRunRecording); runRecordingMapper.updateRunRecordingById(mainRunRecording);
} else { } else {
runRecordingMapper.startByRunId(runId); runRecordingMapper.startByRunIdAndFlowId(runId, mainRunRecording.getFlowId());
jobTaskMapper.startByRunId(runId); jobTaskMapper.startByRunIdAndFlowId(runId, mainRunRecording.getFlowId());
} }
}); }
} }
} }
...@@ -104,7 +104,15 @@ public interface JobTaskMapper { ...@@ -104,7 +104,15 @@ public interface JobTaskMapper {
* @param runId * @param runId
* @return * @return
*/ */
int startByRunId(String runId); int startByRunId(@Param("runId")String runId);
/**
* 根据runid开始调度
* @param runId
* @param flowId
* @return
*/
int startByRunIdAndFlowId(@Param("runId")String runId, @Param("flowId") Integer flowId);
int stopJobTask(@Param("runId") String runId, @Param("nodeIds")List<Integer> nodeIds); int stopJobTask(@Param("runId") String runId, @Param("nodeIds")List<Integer> nodeIds);
......
...@@ -163,6 +163,14 @@ public interface RunRecordingMapper { ...@@ -163,6 +163,14 @@ public interface RunRecordingMapper {
int startByRunId(String runId); int startByRunId(String runId);
/** /**
* 开始实例 基于runid和工作流名称
* @param runId
* @param flowId
* @return
*/
int startByRunIdAndFlowId(@Param("runId") String runId, @Param("flowId")Integer flowId);
/**
* 根据runid查找停止的运行记录 * 根据runid查找停止的运行记录
* @param runId * @param runId
* @return * @return
......
...@@ -473,6 +473,11 @@ ...@@ -473,6 +473,11 @@
where run_id = #{runId,jdbcType=VARCHAR} where run_id = #{runId,jdbcType=VARCHAR}
</update> </update>
<update id="startByRunIdAndFlowId" parameterType="string">
update job_task set trigger_status = '1'
where run_id = #{runId,jdbcType=VARCHAR} and flow_id = #{flowId,jdbcType=INTEGER}
</update>
<!--多个删除--> <!--多个删除-->
<delete id="deleteInId" parameterType="com.byit.model.JobTaskSchedule"> <delete id="deleteInId" parameterType="com.byit.model.JobTaskSchedule">
delete from job_task delete from job_task
......
...@@ -695,6 +695,12 @@ ...@@ -695,6 +695,12 @@
and flow_status = '3' and flow_status = '3'
</update> </update>
<update id="startByRunIdAndFlowId">
update run_recording set flow_status = '2', stop_count = 0
where run_id = #{runId,jdbcType=VARCHAR}
and flow_status = '3' and flow_id = #{flowId,jdbcType=INTEGER}
</update>
<update id="killUnFinshFlow"> <update id="killUnFinshFlow">
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}
......
...@@ -9,6 +9,8 @@ import lombok.Data; ...@@ -9,6 +9,8 @@ import lombok.Data;
*/ */
@Data @Data
public class StopFlowParam { public class StopFlowParam {
private String flowName;
private String runIds; private String runIds;
private String allStartFlow = "0"; private String allStartFlow = "0";
......
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