Commit e08ba1e0 by guo_minglei@163.com

添加获取当前工作流状态接口

parent a32245c5
...@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException; import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @description: 工作流操作的API接口 * @description: 工作流操作的API接口
...@@ -185,4 +186,11 @@ public class ApiFlowController { ...@@ -185,4 +186,11 @@ public class ApiFlowController {
return ResponseResult.ok(collectData); return ResponseResult.ok(collectData);
} }
@PostMapping("/loadCurrentStatus")
@ApiOperation("获取当前的工作流运行状态")
public ResponseResult loadCurrentStatus(String param){
Map<String, RunRecording> statusMap = apiFlowService.loadCurrentStatus(param);
return ResponseResult.ok(statusMap);
}
} }
...@@ -7,6 +7,7 @@ import com.byit.model.vo.RunRecordingVo; ...@@ -7,6 +7,7 @@ import com.byit.model.vo.RunRecordingVo;
import java.text.ParseException; import java.text.ParseException;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @description: 工作流的api请求业务处理接口 * @description: 工作流的api请求业务处理接口
...@@ -95,4 +96,11 @@ public interface ApiFlowService { ...@@ -95,4 +96,11 @@ public interface ApiFlowService {
* @return * @return
*/ */
CollectData loadNodeStatisticData(String param); CollectData loadNodeStatisticData(String param);
/**
* 获取工作流的当前状态
* @param param
* @return
*/
Map<String, RunRecording> loadCurrentStatus(String param);
} }
...@@ -893,6 +893,36 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -893,6 +893,36 @@ public class ApiFlowServiceImpl implements ApiFlowService {
return collectData; return collectData;
} }
@Override
public Map<String, RunRecording> loadCurrentStatus(String param) {
ValidationUtil.dataNotBank(param, "请求参数不允许为空!");
JSONObject jsonObject = JSON.parseObject(param);
//获取工作空间名称
String workspaceName = jsonObject.getString("workspaceName");
ValidationUtil.dataNotBank(workspaceName, "工作空间名称不允许为空!");
Workspace workspace = workspaceMapper.getByName(workspaceName);
ValidationUtil.dataNotNull(workspace, workspaceName + "工作空间不存在");
//获取工作流名称
String flowNames = jsonObject.getString("flowNames");
ValidationUtil.dataNotBank(flowNames, "工作流名称不允许为空!");
List<String> flowNameList = Arrays.asList(flowNames.split(","));
List<Flow> flowList = new ArrayList<>();
flowNameList.forEach(flowName->{
Flow flow = flowMapper.getByWorkSpaceAndName(workspace.getWorkspaceId(), flowName);
ValidationUtil.dataNotNull(flow, flowName + "工作流不存在");
flowList.add(flow);
});
Map<String, RunRecording> statusMap = new HashMap<>();
flowList.forEach(flow -> {
RunRecording runRecording = runRecordingMapper.findNewStatus(flow.getFlowId());
statusMap.put(flow.getFlowName(), runRecording);
});
return statusMap;
}
/** /**
* runState 补批机制 1 补批当前节点 2 补批当前节点及以下节点 * runState 补批机制 1 补批当前节点 2 补批当前节点及以下节点
* @param param * @param param
......
...@@ -54,4 +54,5 @@ public interface FlowMapper { ...@@ -54,4 +54,5 @@ public interface FlowMapper {
* @return * @return
*/ */
List<Flow> findAll(); List<Flow> findAll();
} }
\ No newline at end of file
...@@ -180,4 +180,11 @@ public interface RunRecordingMapper { ...@@ -180,4 +180,11 @@ public interface RunRecordingMapper {
* @return * @return
*/ */
List<RunRecording> findByPreTime(@Param("preHourDate")Date preHourDate, @Param("flowId")Integer flowId); List<RunRecording> findByPreTime(@Param("preHourDate")Date preHourDate, @Param("flowId")Integer flowId);
/**
* 根据flowid获取最新的运行实例
* @param flowId
* @return
*/
RunRecording findNewStatus(Integer flowId);
} }
\ No newline at end of file
...@@ -194,6 +194,18 @@ ...@@ -194,6 +194,18 @@
) )
</select> </select>
<select id="findNewStatus" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from run_recording
where flow_id = #{flowId}
and trigger_time = (
select max(trigger_time)
from run_recording
where flow_id = #{flowId}
)
</select>
<delete id="deleteById" parameterType="java.lang.Integer"> <delete id="deleteById" parameterType="java.lang.Integer">
<!-- generated @mbg.generated date: 2019-12-25 --> <!-- generated @mbg.generated date: 2019-12-25 -->
delete from run_recording delete from run_recording
......
...@@ -101,6 +101,10 @@ public class JobUtils { ...@@ -101,6 +101,10 @@ public class JobUtils {
*/ */
public static final String REQUEST_LOADNODESTATISTICDATA = "/api/flow/loadNodeStatisticData"; public static final String REQUEST_LOADNODESTATISTICDATA = "/api/flow/loadNodeStatisticData";
/** /**
* 获取当前的工作流运行状态
*/
public static final String REQUEST_LOADCURRENTSTATUS = "/api/flow/loadCurrentStatus";
/**
* 补批工作流 * 补批工作流
*/ */
public static final String REQUEST_REPAIRFLOW = "/api/flow/repairFlow"; public static final String REQUEST_REPAIRFLOW = "/api/flow/repairFlow";
...@@ -424,6 +428,21 @@ public class JobUtils { ...@@ -424,6 +428,21 @@ public class JobUtils {
} }
/** /**
* 获取当前的工作流运行状态
* @param workspaceName 工作空间名称
* @param flowNames 工作流名称,多个以","分割
* @return
*/
public static ResponseResult loadCurrentStatus(String workspaceName, String flowNames){
Map<String, Object> param = new HashMap<>();
param.put("workspaceName", workspaceName);
param.put("flowNames", flowNames);
String response = createHttpRequest(REQUEST_LOADCURRENTSTATUS, "param=" + JSON.toJSONString(param));
log.info("--------------------获取当前的工作流运行状态接口调用成功,结果为:{}------------------------",response);
return JSON.parseObject(response, ResponseResult.class);
}
/**
* 补批工作流 * 补批工作流
* @param workspaceName 工作空间名称 * @param workspaceName 工作空间名称
* @param flowName 工作流名称 * @param flowName 工作流名称
......
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