Commit b19ac36a by huangfusuper

增加暂停计数

parent b16b345a
......@@ -1222,8 +1222,9 @@ public class ApiFlowServiceImpl implements ApiFlowService {
List<RunRecording> recordingList = runRecordingMapper.findByRunID(runId);
ValidationUtil.dataNotNull(recordingList, "查无此运行实例!");
AtomicReference<Boolean> result = new AtomicReference<>(true);
//"3".equals(runRecording.getFlowStatus()) ||
recordingList.forEach(runRecording -> {
if (("3".equals(runRecording.getFlowStatus()) || "4".equals(runRecording.getFlowStatus())) //如果不是正在运行
if (("4".equals(runRecording.getFlowStatus())) //如果不是正在运行
&& FlowPropertyEnum.ISNOT_INNER.getCode().equals(runRecording.getIsInner())) { //并且不是内嵌工作流
result.set(false);
}
......@@ -1674,9 +1675,20 @@ public class ApiFlowServiceImpl implements ApiFlowService {
runIdList.forEach(runId -> {
List<RunRecording> runRecordList = runRecordingMapper.findStopRunCordByRunId(runId);
log.warn("---------运行记录{},不存在暂停记录中!---", runId);
ValidationUtil.isTrueValidation(null == runRecordList || runRecordList.size() == 0, "该工作流不是暂停状态!");
ValidationUtil.isTrueValidation(CollectionUtil.isEmpty(runRecordList), "该工作流不是暂停状态!");
RunRecording mainRunRecording = runRecordList.stream().filter(runRecording -> "1".equals(runRecording.getIsInner())).findFirst().orElse(null);
Integer stopCount = 0;
if (mainRunRecording != null) {
stopCount = mainRunRecording.getStopCount();
}
if(stopCount !=null && stopCount > 0){
mainRunRecording.setStopCount(--stopCount);
runRecordingMapper.updateRunRecordingById(mainRunRecording);
}else{
runRecordingMapper.startByRunId(runId);
jobTaskMapper.startByRunId(runId);
}
});
}
}
......
......@@ -166,6 +166,12 @@ public class RunRecording implements Serializable {
private String repeatTime;
/**
* 暂停计数
*/
@ApiModelProperty("暂停计数")
private Integer stopCount;
/**
*/
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -27,12 +27,13 @@
<result column="re_run_id" jdbcType="VARCHAR" property="reRunId" />
<result column="workspace_id" jdbcType="INTEGER" property="workspaceId" />
<result column="repeat_time" jdbcType="VARCHAR" property="repeatTime" />
<result column="stop_count" jdbcType="INTEGER" property="stopCount" />
</resultMap>
<sql id="Base_Column_List">
recording_id, run_id, alarm_email, dispatch_ip, flow_name, flow_run_result, flow_status,
flow_timeout, flow_version_name, alarml_action, priority, trigger_time, principal,
flow_id, start_time, end_time, is_alarm,is_inner,fail_fast, flow_node_count, schedule_type, operator, re_run_id
,workspace_id, repeat_time
,workspace_id, repeat_time, stop_count
</sql>
<select id="findThisDayRunRecording" resultMap="BaseResultMap" parameterType="com.byit.dto.StatisticsConditionDto">
......@@ -413,6 +414,9 @@
<if test="repeatTime != null">
repeat_time,
</if>
<if test="stopCount != null">
stop_count,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="recordingId != null">
......@@ -490,6 +494,9 @@
<if test="repeatTime != null">
#{repeatTime,jdbcType=VARCHAR},
</if>
<if test="stopCount != null">
#{stopCount,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateRunRecordingById" parameterType="com.byit.model.RunRecording">
......@@ -567,6 +574,9 @@
<if test="repeatTime != null">
repeat_time = #{repeatTime,jdbcType=VARCHAR},
</if>
<if test="stopCount != null">
stop_count = #{stopCount,jdbcType=VARCHAR},
</if>
</set>
where recording_id = #{recordingId,jdbcType=INTEGER}
</update>
......@@ -646,14 +656,17 @@
<if test="repeatTime != null">
repeat_time = #{repeatTime,jdbcType=VARCHAR},
</if>
<if test="stopCount != null">
stop_count = #{stopCount,jdbcType=VARCHAR},
</if>
</set>
where flow_id = #{flowId,jdbcType=INTEGER} and run_id = #{runId,jdbcType=VARCHAR}
</update>
<update id="stopByRunId" parameterType="string">
update run_recording set flow_status = '3'
update run_recording set flow_status = '3', stop_count = (stop_count+1)
where run_id = #{runId,jdbcType=VARCHAR}
and flow_status in ('1', '2')
and flow_status != '4'
</update>
<update id="startByRunId" parameterType="string">
......
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