任务调度修改

This commit is contained in:
Jerry Yan 2025-03-23 17:45:38 +08:00
parent a8601548c6
commit a5f67b1eac
3 changed files with 14 additions and 2 deletions

View File

@ -53,4 +53,6 @@ public interface TaskMapper {
TaskEntity get(Long taskId);
List<TaskEntity> listEntity(TaskReqQuery taskReqQuery);
List<TaskRespVO> selectNotRunningByScenicId(Long scenicOnly);
}

View File

@ -185,7 +185,12 @@ public class TaskTaskServiceImpl implements TaskService {
try {
if (lock.tryLock(2, TimeUnit.SECONDS)) {
try {
List<TaskRespVO> taskList = taskMapper.selectNotRunning();
List<TaskRespVO> taskList;
if (worker.getScenicOnly() != null) {
taskList = taskMapper.selectNotRunningByScenicId(worker.getScenicOnly());
} else {
taskList = taskMapper.selectNotRunning();
}
resp.setTasks(taskList);
resp.setTemplates(updTemplateList);
taskList.forEach(task -> {

View File

@ -82,7 +82,7 @@
<select id="selectNotRunning" resultType="com.ycwl.basic.model.pc.task.resp.TaskRespVO">
select id, worker_id, member_id, template_id, scenic_id, task_params, video_url, `status`, result, create_time, update_time
from task
where status = 0 and worker_id is null
where status = 0 and worker_id is null and scenic_id not in (select scenic_only from render_worker where scenic_only is not null and status = 1)
limit 1
</select>
<select id="selectAllNotRunning" resultType="com.ycwl.basic.model.pc.task.entity.TaskEntity">
@ -133,4 +133,9 @@
from task
where status = 2
</select>
<select id="selectNotRunningByScenicId" resultType="com.ycwl.basic.model.pc.task.resp.TaskRespVO">
select id, worker_id, member_id, template_id, scenic_id, task_params, video_url, `status`, result, create_time, update_time
from task
where status = 0 and worker_id is null and scenic_id = #{scenicId}
</select>
</mapper>