yeg
2026-09-05 07d3e4aa6478fe61edb271d80cbc61d037e6f409
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
package com.ruoyi.system.service;
 
import java.time.Instant;
import java.util.List;
import java.util.Map;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
 
/** 提供测试控制台的双状态实时事实与鉴权 SSE。 */
public interface ITestLiveService
{
    /** 返回指定测试及其绑定来源的最新设备、接收和测试状态。 */
    LiveState current(Long testId);
 
    /** 打开实时 SSE;连接初次发送当前事实,后续只推送最新快照。 */
    SseEmitter stream(Long testId);
    record LiveState(Long testId, String testStatus, String receptionStatus, long updatedAt,
            List<LiveSource> sources, List<Map<String, Object>> exceptions, TestPlanSnapshot testPlan)
    {
        public LiveState(Long testId, String testStatus, String receptionStatus, Instant updatedAt,
                List<LiveSource> sources, List<Map<String, Object>> exceptions)
        { this(testId, testStatus, receptionStatus, updatedAt.toEpochMilli(), sources, exceptions, null); }
    }
    record TestPlanSnapshot(int currentCycleNo, int currentStepNo, int plannedCycleCount,
            List<TestPlanRow> rows) { }
    record TestPlanRow(String rowType, int stepNo, Integer cyclePosition, String stepName, double durationSeconds,
            Double voltageV, String executionStatus, Integer cycleCount, Long recordCount) { }
    record LiveSource(String sourceType, Long sourceId, String batteryNo, String deviceStatus,
            Map<String, Object> latestSnapshot) { }
}