diff --git a/cloud-manage-server/src/main/java/com/evotech/hd/cloud/mqtt/message/processor/impl/request/MqttRequestPushCarCreateMakeAppointmentExchangeProcessorImpl.java b/cloud-manage-server/src/main/java/com/evotech/hd/cloud/mqtt/message/processor/impl/request/MqttRequestPushCarCreateMakeAppointmentExchangeProcessorImpl.java index bff3253..59e1820 100644 --- a/cloud-manage-server/src/main/java/com/evotech/hd/cloud/mqtt/message/processor/impl/request/MqttRequestPushCarCreateMakeAppointmentExchangeProcessorImpl.java +++ b/cloud-manage-server/src/main/java/com/evotech/hd/cloud/mqtt/message/processor/impl/request/MqttRequestPushCarCreateMakeAppointmentExchangeProcessorImpl.java @@ -46,23 +46,46 @@ public class MqttRequestPushCarCreateMakeAppointmentExchangeProcessorImpl implem Assert.hasText(plateNum, "licensePlateNumber is null"); MqttResponse response = null; if(StringUtils.isNotEmpty(plateNum)){ - if (vehicleService.existsVehicleByPlateNum(plateNum)){ - response = new MqttResponse().success("车辆已存在, 无需创建"); - }else{ - //没有车辆信息, 开始创建 - if(vehicleService.createVehicleByPlateNum(plateNum, topic.getStationCode())){ - //创建预约订单 - if (orderSwapBatteryService.addPreByPlanNum(plateNum, topic.getStationCode())){ - //返回状态信息 - response = new MqttResponse().success("车辆初始化完成"); - }else{ - response = new MqttResponse().error("车辆初始化完成, 但是预约单创建失败了"); - } - }else{ - response = new MqttResponse().error("创建车辆信息失败了"); - } - + //如果不存在车辆信息 + if (!vehicleService.existsVehicleByPlateNum(plateNum)){ + //创建车辆信息 + if(!vehicleService.createVehicleByPlateNum(plateNum, topic.getStationCode())){ + response = new MqttResponse().error("创建车辆信息失败了"); + } } + //如果response == null 则证明 车辆创建成功了 + if(response == null){ + //创建预约订单 + if (orderSwapBatteryService.addPreByPlanNum(plateNum, topic.getStationCode())){ + //返回状态信息 + response = new MqttResponse().success("预约单初始化完成"); + }else{ + response = new MqttResponse().error("车辆初始化完成, 但是预约单创建失败了"); + } + } +// if (vehicleService.existsVehicleByPlateNum(plateNum)){ +// //创建预约订单 +// if (orderSwapBatteryService.addPreByPlanNum(plateNum, topic.getStationCode())){ +// //返回状态信息 +// response = new MqttResponse().success("预约单初始化完成"); +// }else{ +// response = new MqttResponse().error("车辆初始化完成, 但是预约单创建失败了"); +// } +// }else{ +// //没有车辆信息, 开始创建 +// if(vehicleService.createVehicleByPlateNum(plateNum, topic.getStationCode())){ +// //创建预约订单 +// if (orderSwapBatteryService.addPreByPlanNum(plateNum, topic.getStationCode())){ +// //返回状态信息 +// response = new MqttResponse().success("预约单初始化完成"); +// }else{ +// response = new MqttResponse().error("车辆初始化完成, 但是预约单创建失败了"); +// } +// }else{ +// response = new MqttResponse().error("创建车辆信息失败了"); +// } +// +// } }else{ response = new MqttResponse().error("参数不全, 没有车牌号信息"); }