huang
9 天以前 9a9479a5e34324822b223747b7c88ff060466db0
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
52
53
54
55
56
57
58
59
60
package com.mes.task.service;
 
import com.mes.task.entity.MultiDeviceTask;
import com.mes.task.entity.TaskStepDetail;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
 
import java.util.List;
 
/**
 * 任务状态通知服务
 * 用于实时推送任务执行状态
 * 
 * @author mes
 * @since 2025-01-XX
 */
public interface TaskStatusNotificationService {
 
    /**
     * 创建SSE连接
     * 
     * @param taskId 任务ID(可选,如果为null则监听所有任务)
     * @return SSE发射器
     */
    SseEmitter createConnection(String taskId);
 
    /**
     * 发送任务状态更新
     * 
     * @param task 任务实体
     */
    void notifyTaskStatus(MultiDeviceTask task);
 
    /**
     * 发送任务步骤更新
     * 
     * @param taskId 任务ID
     * @param step 步骤详情
     */
    void notifyStepUpdate(String taskId, TaskStepDetail step);
 
    /**
     * 发送任务步骤列表更新
     * 
     * @param taskId 任务ID
     * @param steps 步骤列表
     */
    void notifyStepsUpdate(String taskId, List<TaskStepDetail> steps);
 
    /**
     * 关闭指定任务的连接
     * 
     * @param taskId 任务ID
     */
    void closeConnections(String taskId);
 
    /**
     * 关闭所有连接
     */
    void closeAllConnections();
}