Junjie
2026-04-25 ee53cfaffb30751dbade9008d482269d62147917
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
package com.zy.asrs.domain.replay;
 
import com.zy.asrs.entity.DeviceDataLog;
import lombok.Data;
 
import java.io.Serializable;
import java.util.Objects;
 
@Data
public class DeviceReplayStreamKey implements Serializable {
 
    private String day;
    private String type;
    private Integer deviceNo;
    private Integer stationId;
 
    public static DeviceReplayStreamKey of(String day, String type, Integer deviceNo, Integer stationId) {
        DeviceReplayStreamKey key = new DeviceReplayStreamKey();
        key.setDay(day);
        key.setType(type);
        key.setDeviceNo(deviceNo);
        key.setStationId(stationId);
        return key;
    }
 
    public static DeviceReplayStreamKey fromLog(String day, DeviceDataLog logItem) {
        if (logItem == null) {
            return null;
        }
        return of(day, logItem.getType(), logItem.getDeviceNo(), logItem.getStationId());
    }
 
    public String streamId() {
        StringBuilder builder = new StringBuilder();
        builder.append(Objects.toString(day, ""))
                .append('|')
                .append(Objects.toString(type, ""))
                .append('|')
                .append(Objects.toString(deviceNo, ""));
        if (stationId != null) {
            builder.append('|').append(stationId);
        }
        return builder.toString();
    }
}