Commit b297e9c6 by huangfusuper

增加暂停计数

parent b19ac36a
......@@ -2,6 +2,7 @@ package com.byit.api;
import com.byit.dto.executor.KillDto;
import com.byit.dto.plugin.CollectData;
import com.byit.dto.plugin.StopFlowParam;
import com.byit.dto.web.ResponseResult;
import com.byit.model.RunRecording;
import com.byit.model.vo.RunRecordingVo;
......@@ -10,6 +11,7 @@ import com.byit.service.FlowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -105,8 +107,8 @@ public class ApiFlowController {
@PostMapping("reStartSchedule")
@ApiOperation("重新开始某次调度")
public ResponseResult reStartSchedule(String runIds) {
apiFlowService.reStartSchedule(runIds);
public ResponseResult reStartSchedule(@RequestBody StopFlowParam stopFlowParam) {
apiFlowService.reStartSchedule(stopFlowParam);
return ResponseResult.ok("SUCCESS");
}
......
......@@ -2,6 +2,7 @@ package com.byit.service;
import com.byit.dto.plugin.CollectData;
import com.byit.dto.plugin.PluginFlow;
import com.byit.dto.plugin.StopFlowParam;
import com.byit.model.RunRecording;
import com.byit.model.vo.RunRecordingVo;
......@@ -28,7 +29,8 @@ public interface ApiFlowService {
String stopSchedule(String param);
void reStartSchedule(String runIds);
void reStartSchedule(StopFlowParam stopFlowParam);
void publishFlow(String param) throws Exception;
......
......@@ -1525,7 +1525,10 @@ public class ApiFlowServiceImpl implements ApiFlowService {
RunRecording runRecording = runRecordingMapper.runIngRunRecording(flowName, byName.getWorkspaceId());
ValidationUtil.isTrueValidation(runRecording == null, "没有正在运行中的实例!");
if ("3".equals(runRecording.getFlowStatus())) {
reStartSchedule(runRecording.getRunId());
StopFlowParam stopFlowParam = new StopFlowParam();
stopFlowParam.setRunIds(runRecording.getRunId());
stopFlowParam.setAllStartFlow("1");
reStartSchedule(stopFlowParam);
} else {
log.warn("{},不是出于暂停状态", runRecording);
}
......@@ -1668,7 +1671,9 @@ public class ApiFlowServiceImpl implements ApiFlowService {
@Override
@Transactional(rollbackFor = Exception.class)
public void reStartSchedule(String runIds) {
public void reStartSchedule(StopFlowParam stopFlowParam) {
ValidationUtil.dataNotNull(stopFlowParam, "执行参数不允许为空!");
String runIds = stopFlowParam.getRunIds();
ValidationUtil.dataNotBank(runIds, "运行id不允许为空!");
List<String> runIdList = Arrays.asList(runIds.split(","));
......@@ -1681,7 +1686,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
if (mainRunRecording != null) {
stopCount = mainRunRecording.getStopCount();
}
if(stopCount !=null && stopCount > 0){
if(stopCount !=null && stopCount > 0 && "1".equals(stopFlowParam.getAllStartFlow())){
mainRunRecording.setStopCount(--stopCount);
runRecordingMapper.updateRunRecordingById(mainRunRecording);
}else{
......
......@@ -670,7 +670,7 @@
</update>
<update id="startByRunId" parameterType="string">
update run_recording set flow_status = '2'
update run_recording set flow_status = '2', stop_count = 0
where run_id = #{runId,jdbcType=VARCHAR}
and flow_status = '3'
</update>
......
package com.byit.dto.plugin;
import lombok.Data;
/**
* 暂停工作流参数
*
* @author huangfu
*/
@Data
public class StopFlowParam {
private String runIds;
private String allStartFlow = "0";
private String allStartFlowExplanation = "0:全部释放;1:单个释放";
}
......@@ -389,10 +389,10 @@ public class JobUtils {
* @param runIds
* @return
*/
public static ResponseResult startSchedule(String runIds) {
log.debug("重新开始调度接口 runids:{}", runIds);
public static ResponseResult startSchedule(StopFlowParam stopFlowParam) {
log.debug("重新开始调度接口 stopFlowParam:{}", stopFlowParam);
//发送请求 添加任务
String response = createHttpRequest(REQUEST_FLOW_REREPEAL, "runIds=" + runIds);
String response = createHttpRequest(REQUEST_FLOW_REREPEAL, JSON.toJSONString(stopFlowParam, WriteClassName));
log.debug("--------------------重新开始调度接口调用成功,结果为:{}------------------------", response);
return JSON.parseObject(response, ResponseResult.class);
}
......
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