电单车发送停止充电指令 处理异常

This commit is contained in:
Guoqs
2025-08-25 16:32:50 +08:00
parent 545a7fe65f
commit 9180778947

View File

@@ -125,9 +125,15 @@ public class EBikeSendCommandServiceImpl implements EBikeSendCommandService {
message.setForceAutoStopWhenFull(1);
message.setFullChargePower(0);
message.setMaxFullChargePowerCheckTime(0);
byte[] response = this.send(message);
log.info("电单车发送停止充电指令response:{}", BytesUtil.binary(response, 16));
return new ChargingOperationResponse(response);
// send方法有可能抛异常所以这里用try-catch, 避免异常
try {
byte[] response = this.send(message);
log.info("电单车发送停止充电指令response:{}", BytesUtil.binary(response, 16));
return new ChargingOperationResponse(response);
} catch (Exception e) {
log.error("电单车发送停止充电指令异常:{}", e.getMessage());
return null;
}
}
/**