diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/EBikeSendCommandServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/EBikeSendCommandServiceImpl.java index be8996b98..2e19d0b12 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/EBikeSendCommandServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/EBikeSendCommandServiceImpl.java @@ -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; + } } /**