添加充放电状态
This commit is contained in:
parent
dfc5033eab
commit
a636c9a858
|
|
@ -240,6 +240,20 @@ public class DeviceTelemetry {
|
|||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* 电量百分比
|
||||
*/
|
||||
public static final TelemetryKey<Integer> Drone_Charge_State_Capacity_Percent = TelemetryKey.of(
|
||||
"drone_charge_state.capacity_percent",
|
||||
Integer.class,
|
||||
value -> {
|
||||
if (value == null) return null;
|
||||
if (value instanceof Number) {
|
||||
return ((Number) value).intValue();
|
||||
}
|
||||
return Integer.parseInt(value.toString());
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -499,7 +513,8 @@ public class DeviceTelemetry {
|
|||
Alternate_land_point_Longitude,
|
||||
Environment_Temperature,
|
||||
Network_State_Rate,
|
||||
Cover_State
|
||||
Cover_State,
|
||||
Drone_Charge_State_Capacity_Percent
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,6 +125,11 @@ public class DockDetailDTO implements Serializable
|
|||
/** 充放电状态 */
|
||||
private String chargingStatus;
|
||||
|
||||
/**
|
||||
* 电量百分比
|
||||
*/
|
||||
private Integer capacity_percent;
|
||||
|
||||
/** 舱内温度 */
|
||||
private Double cabinTemperature;
|
||||
|
||||
|
|
|
|||
|
|
@ -340,6 +340,23 @@ public class BufferDeviceImpl implements IBufferDeviceService
|
|||
() -> log.warn("未获取到经度数据,dockerDeviceIotId: {}", dockerDeviceIotId)
|
||||
);
|
||||
|
||||
// 无人机充电状态(枚举值:0-空闲,1-充电中)
|
||||
telemetryMap.get(DeviceTelemetry.Drone_Charge_State_State)
|
||||
.ifPresent(telemetryValue -> {
|
||||
Integer chargeState = telemetryValue.getValue();
|
||||
if (chargeState != null) {
|
||||
String chargingStatus = mapChargeStateToStatus(chargeState);
|
||||
dto.setChargingStatus(chargingStatus);
|
||||
}
|
||||
});
|
||||
|
||||
// 电量百分比
|
||||
telemetryMap.get(DeviceTelemetry.Drone_Charge_State_Capacity_Percent)
|
||||
.ifPresent(telemetryValue -> {
|
||||
Integer capacityPercent = telemetryValue.getValue();
|
||||
dto.setCapacity_percent(capacityPercent);
|
||||
});
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
|
@ -385,6 +402,26 @@ public class BufferDeviceImpl implements IBufferDeviceService
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将充电状态代码映射到充电状态字符串
|
||||
* @param chargeState 充电状态代码(0-空闲,1-充电中)
|
||||
* @return 充电状态字符串
|
||||
*/
|
||||
private String mapChargeStateToStatus(Integer chargeState) {
|
||||
if (chargeState == null) {
|
||||
return "未知";
|
||||
}
|
||||
|
||||
switch (chargeState) {
|
||||
case 0:
|
||||
return "FREE";
|
||||
case 1:
|
||||
return "CHARGING";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将空调状态代码映射到 AirConditionerStatusEnum
|
||||
* @param stateCode 空调状态代码
|
||||
|
|
|
|||
Loading…
Reference in New Issue