添加充放电状态

This commit is contained in:
孙小云 2026-01-28 15:52:20 +08:00
parent dfc5033eab
commit a636c9a858
3 changed files with 58 additions and 1 deletions

View File

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

View File

@ -125,6 +125,11 @@ public class DockDetailDTO implements Serializable
/** 充放电状态 */
private String chargingStatus;
/**
* 电量百分比
*/
private Integer capacity_percent;
/** 舱内温度 */
private Double cabinTemperature;

View File

@ -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 空调状态代码