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); /** 当前观测快照;updatedAt 为毫秒时间戳,不代表历史数据已完整接收。 */ record LiveState(Long testId, String testStatus, String receptionStatus, long updatedAt, List sources, List> exceptions, TestPlanSnapshot testPlan) { public LiveState(Long testId, String testStatus, String receptionStatus, Instant updatedAt, List sources, List> exceptions) { this(testId, testStatus, receptionStatus, updatedAt.toEpochMilli(), sources, exceptions, null); } } record TestPlanSnapshot(int currentCycleNo, int currentStepNo, int plannedCycleCount, List 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 latestSnapshot) { } }