更换电池优化

This commit is contained in:
PC 2026-02-06 11:50:48 +08:00
parent ecabdbf5ea
commit b07a1a08eb

View File

@ -428,6 +428,15 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
if (batteryInfo == null) { if (batteryInfo == null) {
throw new EbikeException("电池编号错误"); throw new EbikeException("电池编号错误");
} }
queryWrapper.clear();
queryWrapper.select(EBIKE_BIKE_INFO.ALL_COLUMNS)
.leftJoin(EBIKE_BATTERY_INFO).on(EBIKE_BATTERY_INFO.BATTERY_ID.eq(EBIKE_BIKE_INFO.BATTERY_ID))
.where(EBIKE_BATTERY_INFO.BATTERY_CODE.eq(batteryCode));
EbikeBikeInfo ebikeBikeInfo = bikeInfoMapper.selectOneByQuery(queryWrapper);
if (ebikeBikeInfo != null){
throw new EbikeException("该电池编号已绑定其他车辆");
}
bikeInfo.setBatteryId(batteryInfo.getBatteryId()); bikeInfo.setBatteryId(batteryInfo.getBatteryId());
bikeInfoMapper.update(bikeInfo); bikeInfoMapper.update(bikeInfo);
bikeOrder.setHandleState(OrderHandleState.PROCESSED); bikeOrder.setHandleState(OrderHandleState.PROCESSED);
@ -440,6 +449,15 @@ public class EbikeBikeOrderServiceImpl extends ServiceImpl<EbikeBikeOrderMapper,
if (ecuInfo == null) { if (ecuInfo == null) {
throw new EbikeException("带电池中控编号错误"); throw new EbikeException("带电池中控编号错误");
} }
queryWrapper.clear();
queryWrapper.select(EBIKE_BIKE_INFO.ALL_COLUMNS)
.leftJoin(EBIKE_ECU_INFO).on(EBIKE_ECU_INFO.ECU_ID.eq(EBIKE_BIKE_INFO.ECU_ID))
.where(EBIKE_ECU_INFO.ECU_SN.eq(batteryCode));
EbikeBikeInfo ebikeBikeInfo = bikeInfoMapper.selectOneByQuery(queryWrapper);
if (ebikeBikeInfo != null){
throw new EbikeException("该中控编号已绑定其他车辆");
}
bikeInfo.setEcuId(ecuInfo.getEcuId()); bikeInfo.setEcuId(ecuInfo.getEcuId());
bikeInfo.setBatteryId(null); bikeInfo.setBatteryId(null);
bikeInfoMapper.update(bikeInfo); bikeInfoMapper.update(bikeInfo);