‘liusuyi’
2023-08-22 bbafde6d4aecbbfaa452570faeaa25b4058d3a28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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();
            }
        }
 
    }
}