fix:动态调度
This commit is contained in:
@@ -7,7 +7,8 @@ public enum TaskStatusEnum {
|
|||||||
UN_START(1, "未开始"),
|
UN_START(1, "未开始"),
|
||||||
PROCEED(2, "进行中"),
|
PROCEED(2, "进行中"),
|
||||||
FINISHED(3, "已完成"),
|
FINISHED(3, "已完成"),
|
||||||
CANCELED(4, "取消")
|
CANCELED(4, "取消"),
|
||||||
|
ERROR(5, "错误"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final Integer code;
|
private final Integer code;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
@Repository
|
@Repository
|
||||||
public interface ScheduledTaskMapper {
|
public interface ScheduledTaskMapper {
|
||||||
@@ -14,4 +16,6 @@ public interface ScheduledTaskMapper {
|
|||||||
int update(ScheduledTaskEntity entity);
|
int update(ScheduledTaskEntity entity);
|
||||||
|
|
||||||
ScheduledTaskEntity getTask(@Param("id") Long taskId);
|
ScheduledTaskEntity getTask(@Param("id") Long taskId);
|
||||||
|
|
||||||
|
List<ScheduledTaskEntity> getTaskList(ScheduledTaskEntity entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -62,4 +63,20 @@ public class DynamicTaskSchedulerServiceImpl implements IDynamicTaskSchedulerSer
|
|||||||
}
|
}
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean errTask(Long taskId) {
|
||||||
|
ScheduledTaskEntity task = scheduledTaskMapper.getTask(taskId);
|
||||||
|
if (Objects.nonNull(task)) {
|
||||||
|
task.setStatus(TaskStatusEnum.ERROR.getCode());
|
||||||
|
task.setUpdatedTime(LocalDateTime.now());
|
||||||
|
return scheduledTaskMapper.update(task) > 0;
|
||||||
|
}
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ScheduledTaskEntity> getTaskList(ScheduledTaskEntity entity) {
|
||||||
|
return scheduledTaskMapper.getTaskList(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.xiang.xservice.schedule.service;
|
|||||||
|
|
||||||
import com.xiang.xservice.schedule.entity.ScheduledTaskEntity;
|
import com.xiang.xservice.schedule.entity.ScheduledTaskEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
public interface IDynamicTaskSchedulerService {
|
public interface IDynamicTaskSchedulerService {
|
||||||
Boolean saveTask(ScheduledTaskEntity entity);
|
Boolean saveTask(ScheduledTaskEntity entity);
|
||||||
@@ -10,4 +12,6 @@ public interface IDynamicTaskSchedulerService {
|
|||||||
Boolean updateProcess(Long taskId);
|
Boolean updateProcess(Long taskId);
|
||||||
Boolean cancelTask(Long taskId);
|
Boolean cancelTask(Long taskId);
|
||||||
Boolean finishTask(Long taskId);
|
Boolean finishTask(Long taskId);
|
||||||
|
Boolean errTask(Long taskId);
|
||||||
|
List<ScheduledTaskEntity> getTaskList(ScheduledTaskEntity entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
<result column="task_name" property="taskName"/>
|
<result column="task_name" property="taskName"/>
|
||||||
<result column="task_group" property="taskGroup"/>
|
<result column="task_group" property="taskGroup"/>
|
||||||
<result column="run_time" property="runTime"/>
|
<result column="run_time" property="runTime"/>
|
||||||
<result column="parameters" property="status"/>
|
<result column="status" property="status"/>
|
||||||
<result column="create_time" property="parameters"/>
|
<result column="parameters" property="parameters"/>
|
||||||
<result column="update_time" property="createdTime"/>
|
<result column="create_time" property="createdTime"/>
|
||||||
<result column="status" property="updatedTime"/>
|
<result column="update_time" property="updatedTime"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
@@ -41,5 +41,22 @@
|
|||||||
select <include refid="Base_Column_List"/>
|
select <include refid="Base_Column_List"/>
|
||||||
from script_schedule_task where id = #{id}
|
from script_schedule_task where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getTaskList" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from script_schedule_task
|
||||||
|
<where>
|
||||||
|
1=1
|
||||||
|
<if test="taskName != null and taskName != ''">
|
||||||
|
and task_name = #{taskName}
|
||||||
|
</if>
|
||||||
|
<if test="taskGroup != null and taskGroup != ''">
|
||||||
|
and task_group = #{taskGroup}
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
and status = #{status}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user