添加网络类型
This commit is contained in:
parent
68cdcd4c9a
commit
833c8e5cec
|
|
@ -89,6 +89,23 @@ public class DeviceTelemetry {
|
|||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* 网络速率 {"unit_name":"千字节每秒 / KB/s"}
|
||||
*/
|
||||
// 温度 - Double
|
||||
public static final TelemetryKey<Double> Network_State_Rate = TelemetryKey.of(
|
||||
"network_state.rate",
|
||||
Double.class,
|
||||
value -> {
|
||||
if (value == null) return null;
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).doubleValue();
|
||||
}
|
||||
return Double.parseDouble(value.toString());
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* 运行时长 {"unit_name":"秒 / s"}
|
||||
*/
|
||||
|
|
@ -106,6 +123,8 @@ public class DeviceTelemetry {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 舱内温度 temperature
|
||||
*/
|
||||
|
|
@ -446,7 +465,8 @@ public class DeviceTelemetry {
|
|||
Distance_Limit_Status_Distance_Limit,
|
||||
Alternate_land_point_Latitude,
|
||||
Alternate_land_point_Longitude,
|
||||
Environment_Temperature
|
||||
Environment_Temperature,
|
||||
Network_State_Rate
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.ruoyi.device.service.dto.AircraftDetailDTO;
|
|||
import com.ruoyi.device.service.dto.DockDetailDTO;
|
||||
import com.ruoyi.device.api.enums.AircraftStatusEnum;
|
||||
import com.ruoyi.device.api.enums.DockStatusEnum;
|
||||
import com.ruoyi.device.api.enums.NetworkTypeEnum;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -192,6 +193,26 @@ public class BufferDeviceImpl implements IBufferDeviceService
|
|||
telemetryMap.get(DeviceTelemetry.Environment_Temperature)
|
||||
.ifPresent(telemetryValue -> dto.setEnvironmentTemperature(telemetryValue.getValue()));
|
||||
|
||||
// 设置网络类型和网络速率
|
||||
// 网络类型(枚举值:1-4G,2-以太网)
|
||||
telemetryMap.get(DeviceTelemetry.Network_State_Type)
|
||||
.ifPresent(telemetryValue -> {
|
||||
Integer networkTypeCode = telemetryValue.getValue();
|
||||
String networkType = mapNetworkTypeCodeToEnum(networkTypeCode);
|
||||
dto.setNetworkType(networkType);
|
||||
});
|
||||
|
||||
// 网络速率(单位:千字节每秒 KB/s)
|
||||
telemetryMap.get(DeviceTelemetry.Network_State_Rate)
|
||||
.ifPresent(telemetryValue -> {
|
||||
Double rate = telemetryValue.getValue();
|
||||
if (rate != null) {
|
||||
// 将速率转换为网络延迟(假设延迟与速率成反比)
|
||||
// 这里可以根据实际业务逻辑调整
|
||||
dto.setNetworkDelay(rate.intValue());
|
||||
}
|
||||
});
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
|
@ -217,6 +238,26 @@ public class BufferDeviceImpl implements IBufferDeviceService
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将网络类型代码映射到 NetworkTypeEnum
|
||||
* @param networkTypeCode 网络类型代码(1-4G,2-以太网)
|
||||
* @return 网络类型枚举的 code
|
||||
*/
|
||||
private String mapNetworkTypeCodeToEnum(Integer networkTypeCode) {
|
||||
if (networkTypeCode == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (networkTypeCode) {
|
||||
case 1:
|
||||
return NetworkTypeEnum.FOUR_G.getCode();
|
||||
case 2:
|
||||
return NetworkTypeEnum.ETHERNET.getCode();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private AircraftDetailDTO getChangeAbleAirDetailDTO(String deviceIotId)
|
||||
{
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue