package com.ruoyi.inspect.service.impl; import com.ruoyi.common.utils.spring.SpringUtils; import lombok.extern.slf4j.Slf4j; /** * @Description: 巡检任务类 * @ClassName: InspectionTaskImpl * @Author: 刘苏义 * @Date: 2023年06月01日8:57 * @Version: 1.0 **/ @Slf4j(topic = "patrolInspectionTask") class InspectionTask implements Runnable { private String taskId; private boolean isRunning; public InspectionTask(String taskId) { this.taskId = taskId; this.isRunning = false; } public void start() { isRunning = true; Thread thread = new Thread(this); thread.start(); } public void stop() { isRunning = false; } @Override public void run() { while (isRunning) { // 巡检任务的具体逻辑 log.debug("手动巡检任务执行中:" + taskId); ArdVideoInspectTaskServiceImpl ardVideoInspectTaskService = SpringUtils.getBean(ArdVideoInspectTaskServiceImpl.class); ardVideoInspectTaskService.manualTaskRun(taskId); try { Thread.sleep(5000); } catch (InterruptedException e) { e.printStackTrace(); } } } }