Commit bfc919f6 by huangfusuper

使用工作流名称开启工作流

parent e5167cde
......@@ -55,6 +55,13 @@ public class ApiFlowController {
return ResponseResult.ok("SUCCESS");
}
@PostMapping("unsuspendFlow")
@ApiOperation("开始工作流的调度,将工作流启用调度")
public ResponseResult unsuspendFlow(String param) throws ParseException {
apiFlowService.unsuspendFlow(param);
return ResponseResult.ok("SUCCESS");
}
@PostMapping("exist")
@ApiOperation("判断工作流是否存在")
public ResponseResult exist(String param) throws ParseException {
......
......@@ -18,6 +18,8 @@ public interface ApiFlowService {
void deleteFlow(String param);
void unsuspendFlow(String param);
void start(String param) throws ParseException;
void repealSchedule(String param) throws ParseException;
......
......@@ -186,7 +186,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
if (StringUtils.isBlank(versionName)) {
String version = oldFlow.getVersionName();
Integer versionTag = JobVersionGenUtil.parsingVersionName(version);
flow.setVersionName(JobVersionGenUtil.generateVersionName(versionTag+1));
flow.setVersionName(JobVersionGenUtil.generateVersionName(versionTag + 1));
} else {
flow.setVersionName(versionName);
......@@ -1509,6 +1509,28 @@ public class ApiFlowServiceImpl implements ApiFlowService {
deleteFlowAndNode(flow);
}
@Override
public void unsuspendFlow(String param) {
ValidationUtil.dataNotBank(param, "请求参数不允许为空!");
JSONObject jsonObject = JSON.parseObject(param);
//获取工作空间名称
String workspaceName = jsonObject.getString("workspaceName");
ValidationUtil.dataNotBank(workspaceName, "工作空间名称不允许为空!");
//获取工作流名称
String flowName = jsonObject.getString("flowName");
ValidationUtil.dataNotBank(flowName, "工作流名称不允许为空!");
Workspace byName = workspaceMapper.getByName(flowName);
ValidationUtil.isTrueValidation(byName == null, "没有此工作空间");
RunRecording runRecording = runRecordingMapper.runIngRunRecording(flowName, byName.getWorkspaceId());
ValidationUtil.isTrueValidation(runRecording == null, "没有正在运行中的实例!");
if ("3".equals(runRecording.getFlowStatus())) {
reStartSchedule(runRecording.getRunId());
} else {
log.warn("{},不是出于暂停状态", runRecording);
}
}
/**
* 删除工作流及下属节点
*
......
......@@ -26,7 +26,7 @@ public interface RunRecordingMapper {
*/
List<RunRecording> findThisDayRunRecording(StatisticsConditionDto statisticsConditionDto);
RunRecording runIngRunRecording(String flowName);
RunRecording runIngRunRecording(@Param("flowName") String flowName, @Param("workspaceId") Integer workspaceId);
/**
* 查询全部的数据
* @return
......
......@@ -12,7 +12,7 @@ import java.util.List;
*/
public interface RunRecordingService {
RunRecording runIngRunRecording(String flowName);
RunRecording runIngRunRecording(String flowName,Integer workspaceId);
/**
* 查询当天的实例 查询一个时间段的范围
......
......@@ -36,8 +36,8 @@ public class RunRecordingServiceImpl implements RunRecordingService {
}
@Override
public RunRecording runIngRunRecording(String flowName) {
return runRecordingMapper.runIngRunRecording(flowName);
public RunRecording runIngRunRecording(String flowName,Integer workspaceId) {
return runRecordingMapper.runIngRunRecording(flowName, workspaceId);
}
/**
......
......@@ -8,9 +8,11 @@ import com.byit.enums.task.RunResultEnum;
import com.byit.filesystem.FileSystem;
import com.byit.model.JobTaskRunLogWithBLOBs;
import com.byit.model.RunRecording;
import com.byit.model.Workspace;
import com.byit.model.vo.RunLogVo;
import com.byit.packet.response.PluginRpcResponsePacket;
import com.byit.service.RunRecordingService;
import com.byit.service.WorkspaceService;
import com.byit.service.impl.JobTaskRunLogServiceImpl;
import com.byit.util.SpringUtil;
import com.byit.utils.ValidationUtil;
......@@ -111,8 +113,14 @@ public class JavaFlowFreeTaskCallbackThread implements Runnable {
RunRecordingService bean = SpringUtil.getBean(RunRecordingService.class);
JobTaskRunLogServiceImpl mythJobTaskRunLogService = SpringUtil.getBean(JobTaskRunLogServiceImpl.class);
String flowName = specialJavaNode.getFlowName();
String workspaceName = specialJavaNode.getWorkspaceName();
WorkspaceService workspaceService = SpringUtil.getBean(WorkspaceService.class);
Workspace byName = workspaceService.getByName(workspaceName);
if(byName == null) {
return null;
}
RunRecording runRecording = bean.runIngRunRecording(flowName);
RunRecording runRecording = bean.runIngRunRecording(flowName,byName.getWorkspaceId());
List<JobTaskRunLogWithBLOBs> jobTaskRunLogWithBLOBsByFlowIdAndRunId = mythJobTaskRunLogService.findJobTaskRunLogWithBLOBsByFlowIdAndRunId(runRecording.getFlowId(), runRecording.getRunId());
JobTaskRunLogWithBLOBs jobTaskRunLogWithBLOBs = jobTaskRunLogWithBLOBsByFlowIdAndRunId.stream().filter(log -> log.getNodeName().equals(specialJavaNode.getNodeName())).findFirst().orElse(null);
if(jobTaskRunLogWithBLOBs != null) {
......
......@@ -320,7 +320,7 @@
select
<include refid="Base_Column_List" />
from run_recording
where (flow_status = '2' or flow_status = '3') and schedule_type != 4 and flow_name = #{flowName}
where (flow_status = '2' or flow_status = '3') and schedule_type != 4 and flow_name = #{flowName} and workspace_id = #{workspaceId}
</select>
<delete id="deleteById">
......
......@@ -30,4 +30,6 @@ public class SpecialJavaNode implements Serializable {
* 当前执行的日志的url
*/
private String thisLogUrlPath;
private String workspaceName;
}
......@@ -55,6 +55,7 @@ public class JobUtils {
* 开始工作流
*/
private static final String REQUEST_FLOW_START = "/api/flow/start";
private static final String REQUEST_FLOW_START_UNSUSPENDFLOW = "/api/flow/unsuspendFlow";
/**
* 校验工作流是否存在
*/
......@@ -287,6 +288,16 @@ public class JobUtils {
return JSON.parseObject(response, ResponseResult.class);
}
public static ResponseResult unsuspendFlow(String flowName, String workspaceName){
Map<String, String> map = new HashMap<>(5);
map.put("flowName", flowName);
map.put("workspaceName", workspaceName);
//发送请求 添加任务
String response = createHttpRequest(REQUEST_FLOW_START_UNSUSPENDFLOW, "param=" + JSON.toJSONString(map, 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