Commit 9f31706a by guo_minglei@163.com

Merge remote-tracking branch 'origin/developer' into developer

parents be7f205a 65b5ae9a
...@@ -22,6 +22,13 @@ public interface RunRecordingMapper { ...@@ -22,6 +22,13 @@ public interface RunRecordingMapper {
* @return * @return
*/ */
List<RunRecording> findRunningRunRecording(); List<RunRecording> findRunningRunRecording();
/**
* 根据工作流查询对应的实例
* @param flowId
* @return
*/
List<RunRecording> findRunRecordingByFlowId(Integer flowId);
/** /**
* 这个方法是会根据任务流的id和运行标识找到唯一对应的一个任务流,这个任务流就是一个虚拟节点 * 这个方法是会根据任务流的id和运行标识找到唯一对应的一个任务流,这个任务流就是一个虚拟节点
* @param flowId * @param flowId
......
...@@ -22,6 +22,13 @@ public interface RunRecordingService { ...@@ -22,6 +22,13 @@ public interface RunRecordingService {
List<RunRecording> findRunningRunRecording(); List<RunRecording> findRunningRunRecording();
/** /**
* 根据工作流ID查询 是否有正在运行中的实例
* @param flowId
* @return
*/
boolean findRunRecordingIsRunning(Integer flowId);
/**
* 这个方法是会根据任务流的id和运行标识找到唯一对应的一个任务流,这个任务流就是一个虚拟节点 * 这个方法是会根据任务流的id和运行标识找到唯一对应的一个任务流,这个任务流就是一个虚拟节点
* @param flowId * @param flowId
* @param runId * @param runId
......
package com.byit.service.impl; package com.byit.service.impl;
import com.byit.enums.RunRecordingEnum;
import com.byit.mapper.RunRecordingMapper; import com.byit.mapper.RunRecordingMapper;
import com.byit.model.RunRecording; import com.byit.model.RunRecording;
import com.byit.service.RunRecordingService; import com.byit.service.RunRecordingService;
...@@ -33,6 +34,22 @@ public class RunRecordingServiceImpl implements RunRecordingService { ...@@ -33,6 +34,22 @@ public class RunRecordingServiceImpl implements RunRecordingService {
return runRecordingMapper.findRunningRunRecording(); return runRecordingMapper.findRunningRunRecording();
} }
/**
* 是否存在运行的工作流实例
* @param flowId 工作流ID
* @return 是否在正在运行中
*/
@Override
public boolean findRunRecordingIsRunning(Integer flowId) {
List<RunRecording> runRecordings = runRecordingMapper.findRunRecordingByFlowId(flowId);
for (RunRecording runRecording : runRecordings) {
if (!RunRecordingEnum.FLOW_STATUS_IS_END.getCode().equals(runRecording.getFlowStatus())) {
return true;
}
}
return false;
}
@Override @Override
public RunRecording findRunRecordingByFlowIdAndRunId(Integer flowId, String runId) { public RunRecording findRunRecordingByFlowIdAndRunId(Integer flowId, String runId) {
return runRecordingMapper.findRunRecordingByFlowIdAndRunId(flowId,runId); return runRecordingMapper.findRunRecordingByFlowIdAndRunId(flowId,runId);
......
...@@ -7,6 +7,7 @@ import com.byit.model.Node; ...@@ -7,6 +7,7 @@ import com.byit.model.Node;
import com.byit.service.FlowService; import com.byit.service.FlowService;
import com.byit.service.NodeService; import com.byit.service.NodeService;
import com.byit.service.RunNodeServer; import com.byit.service.RunNodeServer;
import com.byit.service.RunRecordingService;
import com.byit.thread.BaseThreadRunHelper; import com.byit.thread.BaseThreadRunHelper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -30,12 +31,15 @@ public class FlowThreadRunHelper extends BaseThreadRunHelper { ...@@ -30,12 +31,15 @@ public class FlowThreadRunHelper extends BaseThreadRunHelper {
private final FlowService flowService; private final FlowService flowService;
private final NodeService nodeService; private final NodeService nodeService;
private final RunNodeServer runNodeServer; private final RunNodeServer runNodeServer;
private final RunRecordingService runRecordingService;
public FlowThreadRunHelper(DataSource dataSource, FlowService flowService, NodeService nodeService, RunNodeServer runNodeServer) { public FlowThreadRunHelper(DataSource dataSource, FlowService flowService, NodeService nodeService,
RunNodeServer runNodeServer, RunRecordingService runRecordingService) {
this.dataSource = dataSource; this.dataSource = dataSource;
this.flowService = flowService; this.flowService = flowService;
this.nodeService = nodeService; this.nodeService = nodeService;
this.runNodeServer = runNodeServer; this.runNodeServer = runNodeServer;
this.runRecordingService = runRecordingService;
} }
@Override @Override
...@@ -45,7 +49,12 @@ public class FlowThreadRunHelper extends BaseThreadRunHelper { ...@@ -45,7 +49,12 @@ public class FlowThreadRunHelper extends BaseThreadRunHelper {
List<Flow> halfAnHourFlow = flowService.findHalfAnHourFlow(preTestTime); List<Flow> halfAnHourFlow = flowService.findHalfAnHourFlow(preTestTime);
if (CollectionUtil.isNotEmpty(halfAnHourFlow)) { if (CollectionUtil.isNotEmpty(halfAnHourFlow)) {
for(Flow flow : halfAnHourFlow ){ for(Flow flow : halfAnHourFlow ){
log.debug("-----------------【工作流{}的执行次数大于0,放行】-------------------------",flow.getFlowName()); log.debug("-----------------【工作流{}的执行次数不等于0,放行】-------------------------",flow.getFlowName());
if (runRecordingService.findRunRecordingIsRunning(flow.getFlowId())) {
//TODO 是否可以使用事件通知机制,由完结的工作流实例通知通过流可以运行了
log.info("-----工作流{},有正在运行中的实例,跳过等待------",flow);
continue;
}
//String versionName = flow.getVersionName() //String versionName = flow.getVersionName()
Integer flowId = flow.getFlowId(); Integer flowId = flow.getFlowId();
//根据工作流查询工作流下所有的节点 //根据工作流查询工作流下所有的节点
......
...@@ -46,6 +46,12 @@ ...@@ -46,6 +46,12 @@
where flow_status = '2' where flow_status = '2'
</select> </select>
<select id="findRunRecordingByFlowId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from run_recording where flow_id = #{flowId,jdbcType=INTEGER}
</select>
<select id="findRunRecordingByFlowIdAndRunId" resultMap="BaseResultMap" > <select id="findRunRecordingByFlowIdAndRunId" resultMap="BaseResultMap" >
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
......
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