Commit 2f91a636 by huangfusuper

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

parents 00765861 c0d36ed8
...@@ -55,6 +55,13 @@ public class ApiFlowController { ...@@ -55,6 +55,13 @@ public class ApiFlowController {
return ResponseResult.ok("SUCCESS"); return ResponseResult.ok("SUCCESS");
} }
@PostMapping("exist")
@ApiOperation("判断工作流是否存在")
public ResponseResult exist(String param) throws ParseException {
Boolean result = apiFlowService.exist(param);
return ResponseResult.ok(result);
}
@PostMapping("repealSchedule") @PostMapping("repealSchedule")
@ApiOperation("撤销工作流调度,只可以撤销总工作流,若为内嵌工作流不允许撤销") @ApiOperation("撤销工作流调度,只可以撤销总工作流,若为内嵌工作流不允许撤销")
public ResponseResult repealSchedule(String param) throws ParseException { public ResponseResult repealSchedule(String param) throws ParseException {
......
...@@ -103,4 +103,13 @@ public interface ApiFlowService { ...@@ -103,4 +103,13 @@ public interface ApiFlowService {
* @return * @return
*/ */
Map<String, RunRecording> loadCurrentStatus(String param); Map<String, RunRecording> loadCurrentStatus(String param);
/**
* 功能描述 判断工作流是否存在
* @author gml
* @date 2020-05-27 10:12
* @param param
* @return java.lang.Boolean
*/
Boolean exist(String param);
} }
...@@ -1090,6 +1090,25 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -1090,6 +1090,25 @@ public class ApiFlowServiceImpl implements ApiFlowService {
return statusMap; return statusMap;
} }
@Override
public Boolean exist(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 flowName = jsonObject.getString("flowName");
ValidationUtil.dataNotBank(flowName, "工作流名称不允许为空!");
Flow flow = flowMapper.getByWorkSpaceAndName(workspace.getWorkspaceId(), flowName);
if (null == flow){
return false;
}
return true;
}
/** /**
* runState 补批机制 1 补批当前节点 2 补批当前节点及以下节点 * runState 补批机制 1 补批当前节点 2 补批当前节点及以下节点
* @param param * @param param
...@@ -1412,12 +1431,15 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -1412,12 +1431,15 @@ public class ApiFlowServiceImpl implements ApiFlowService {
List<RunRecording> recordingList = runRecordingMapper.findOnScheduleByFlowId(flow.getFlowId()); List<RunRecording> recordingList = runRecordingMapper.findOnScheduleByFlowId(flow.getFlowId());
ValidationUtil.isTrueValidation(null != recordingList && recordingList.size() > 0 , "工作流已在调度中不允许撤销调度!"); ValidationUtil.isTrueValidation(null != recordingList && recordingList.size() > 0 , "工作流已在调度中不允许撤销调度!");
List<RunRecording> unStartRecordingList = runRecordingMapper.findUnStartByFlowId(flow.getFlowId()); List<RunRecording> unStartRecordingList = runRecordingMapper.findUnStartByFlowId(flow.getFlowId());
if (null != unStartRecordingList && unStartRecordingList.size() > 0){
//删除对应的task记录 //删除对应的task记录
unStartRecordingList.forEach(runRecording -> { unStartRecordingList.forEach(runRecording -> {
ValidationUtil.isTrueValidation((runRecording.getTriggerTime() - System.currentTimeMillis()) < 10000 , "工作流已在调度中不允许撤销调度"); ValidationUtil.isTrueValidation((runRecording.getTriggerTime() - System.currentTimeMillis()) < 10000 , "工作流已在调度中不允许撤销调度");
runRecordingMapper.deleteByRunId(runRecording.getRunId()); runRecordingMapper.deleteByRunId(runRecording.getRunId());
jobTaskMapper.deleteByRunId(runRecording.getRunId()); jobTaskMapper.deleteByRunId(runRecording.getRunId());
}); });
}
//撤销工作流调度 //撤销工作流调度
updateFlowStart(flow, false); updateFlowStart(flow, false);
...@@ -1434,10 +1456,10 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -1434,10 +1456,10 @@ public class ApiFlowServiceImpl implements ApiFlowService {
flow.setStartUp(FlowPropertyEnum.IS_START.getCode()); flow.setStartUp(FlowPropertyEnum.IS_START.getCode());
//如果是周期调度修改下次执行时间 //如果是周期调度修改下次执行时间
if (FlowPropertyEnum.SCHEDULE_MODE.getCode().equals(flow.getExecType())){ if (FlowPropertyEnum.SCHEDULE_MODE.getCode().equals(flow.getExecType())){
flow.setTriggerNextTime(new CronExpression(flow.getFlowCron()).getNextValidTimeAfter(new Date()).getTime());
} }
}else { }else {
flow.setStartUp(FlowPropertyEnum.NO_START.getCode()); flow.setStartUp(FlowPropertyEnum.NO_START.getCode());
flow.setTriggerNextTime(new CronExpression(flow.getFlowCron()).getNextValidTimeAfter(new Date()).getTime());
} }
flowMapper.updateByIdSelective(flow); flowMapper.updateByIdSelective(flow);
List<Node> nodeList = nodeMapper.findVirtualByFlowId(flow.getFlowId()); List<Node> nodeList = nodeMapper.findVirtualByFlowId(flow.getFlowId());
...@@ -1468,7 +1490,7 @@ public class ApiFlowServiceImpl implements ApiFlowService { ...@@ -1468,7 +1490,7 @@ public class ApiFlowServiceImpl implements ApiFlowService {
ValidationUtil.dataNotNull(flow, flowName + "工作流不存在"); ValidationUtil.dataNotNull(flow, flowName + "工作流不存在");
ValidationUtil.isTrueValidation(FlowPropertyEnum.IS_INNER.getCode().equals(flow.getIsInner()), "内嵌工作流不允许停止调度!"); ValidationUtil.isTrueValidation(FlowPropertyEnum.IS_INNER.getCode().equals(flow.getIsInner()), "内嵌工作流不允许停止调度!");
//判断是否在调度中 //判断是否在调度中
List<RunRecording> recordingList = runRecordingMapper.findOnScheduleByFlowId(flow.getFlowId()); List<RunRecording> recordingList = runRecordingMapper.findUnFinishByFlowId(flow.getFlowId());
ValidationUtil.isTrueValidation(null == recordingList || recordingList.size() == 0 , flowName + "工作流没有正在运行的调度!"); ValidationUtil.isTrueValidation(null == recordingList || recordingList.size() == 0 , flowName + "工作流没有正在运行的调度!");
StringBuffer runids = new StringBuffer(); StringBuffer runids = new StringBuffer();
//暂停工作流调度 //暂停工作流调度
......
...@@ -209,6 +209,7 @@ ...@@ -209,6 +209,7 @@
from run_recording from run_recording
where run_id = #{runId,jdbcType=VARCHAR} and flow_name = #{flowName,jdbcType=VARCHAR} and schedule_type != 4 where run_id = #{runId,jdbcType=VARCHAR} and flow_name = #{flowName,jdbcType=VARCHAR} and schedule_type != 4
</select> </select>
<select id="findUnFinishByFlowId" resultMap="BaseResultMap"> <select id="findUnFinishByFlowId" resultMap="BaseResultMap">
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
...@@ -216,6 +217,7 @@ ...@@ -216,6 +217,7 @@
where flow_id = #{flowId} where flow_id = #{flowId}
and flow_status != '4' and schedule_type != 4 and flow_status != '4' and schedule_type != 4
</select> </select>
<select id="findStatusByStartAndEndTime" resultType="com.byit.dto.plugin.StatisticData" useCache="false" flushCache="true"> <select id="findStatusByStartAndEndTime" resultType="com.byit.dto.plugin.StatisticData" useCache="false" flushCache="true">
select sum(case when flow_status = '1' then 1 else 0 end ) unstart, select sum(case when flow_status = '1' then 1 else 0 end ) unstart,
sum(case when flow_status='2' then 1 else 0 end ) runIng, sum(case when flow_status='2' then 1 else 0 end ) runIng,
...@@ -234,6 +236,7 @@ ...@@ -234,6 +236,7 @@
) )
</if> </if>
</select> </select>
<select id="findMaxByFlowId" resultMap="BaseResultMap"> <select id="findMaxByFlowId" resultMap="BaseResultMap">
select <include refid="Base_Column_List" /> select <include refid="Base_Column_List" />
from run_recording from run_recording
......
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