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();
|
}
|
}
|