package com.battery.device.model; import java.math.BigDecimal; import java.time.Instant; import java.util.List; import java.util.Map; public record RealtimeSnapshot( ChannelIdentity channel, DeviceWorkStatus workStatus, Integer cycleNo, Integer stepNo, String stepType, String barcode, BigDecimal currentA, BigDecimal voltageV, BigDecimal capacityAh, BigDecimal energyWh, Long totalTimeSeconds, Long relativeTimeSeconds, String logCode, Instant receivedAt, Map measurements, DeviceConnectionStatus connectionStatus, Instant deviceTime, List plannedSteps, String failureReason) { /** 兼容已有适配器调用的实时快照构造方式。 */ public RealtimeSnapshot(ChannelIdentity channel, DeviceWorkStatus workStatus, Integer cycleNo, Integer stepNo, String stepType, String barcode, BigDecimal currentA, BigDecimal voltageV, BigDecimal capacityAh, BigDecimal energyWh, Long totalTimeSeconds, Long relativeTimeSeconds, String logCode, Instant receivedAt, Map measurements) { this(channel, workStatus, cycleNo, stepNo, stepType, barcode, currentA, voltageV, capacityAh, energyWh, totalTimeSeconds, relativeTimeSeconds, logCode, receivedAt, measurements, DeviceConnectionStatus.ONLINE, null, List.of(), null); } public RealtimeSnapshot { measurements = measurements == null ? Map.of() : Map.copyOf(measurements); plannedSteps = plannedSteps == null ? List.of() : List.copyOf(plannedSteps); connectionStatus = connectionStatus == null ? DeviceConnectionStatus.ONLINE : connectionStatus; failureReason = failureReason == null || failureReason.isBlank() ? null : failureReason.trim(); } }