From f08b7e95bc941a72d4a7b7bc64c2086ed53f1565 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期一, 21 十月 2024 15:48:27 +0800 Subject: [PATCH] 修改2.0 bug --- DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java | 131 ++++++++++++++++++++++++++++++++----------- 1 files changed, 97 insertions(+), 34 deletions(-) diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java index c7413bf..736a375 100644 --- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java +++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java @@ -254,27 +254,63 @@ } new Thread(()->{ - try { - Car car = carService.selectById(orderLogistics.getCarId()); - if(!StringUtils.hasLength(car.getVehicleId())){ - car.setVehicleId(UUIDUtil.getRandomCode()); - carService.updateById(car); - } - String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); - if(ToolUtil.isEmpty(trip)){ - String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); - if(ToolUtil.isEmpty(vehicles)){ - CarModel carModel = carModelMapper.selectById(car.getCarModelId()); - fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); + Car car = carService.selectById(orderLogistics.getCarId()); + if(!StringUtils.hasLength(car.getVehicleId())){ + car.setVehicleId(UUIDUtil.getRandomCode()); + carService.updateById(car); + } + String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); + if(ToolUtil.isEmpty(trip)){ + String vehicles = fleetEngineUtil.getVehicles(car.getVehicleId()); + if(ToolUtil.isEmpty(vehicles)){ + CarModel carModel = carModelMapper.selectById(car.getCarModelId()); + boolean createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); + if(!createVehicles){ + for (int i = 0; i < 5; i++) { + createVehicles = fleetEngineUtil.createVehicles(carModel.getSeat() - 1, car.getCarLicensePlate(), car.getVehicleId()); + if(createVehicles){ + break; + } + try { + Thread.sleep(5000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } } - fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), - orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); - }else{ - //开始修改行程数据 - fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); } - }catch (Exception e){ - e.printStackTrace(); + boolean createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), + orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); + if(!createTrip){ + for (int i = 0; i < 5; i++) { + createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), + orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); + if(createTrip){ + break; + } + try { + Thread.sleep(5000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } + }else{ + //开始修改行程数据 + boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); + if(!updateTrip){ + for (int i = 0; i < 5; i++) { + updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); + if(updateTrip){ + break; + } + try { + Thread.sleep(5000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } } }).start(); @@ -417,10 +453,19 @@ new Thread(()->{ Car car = carMapper.selectById(driver.getCarId()); //修改行程数据 - try { - fleetEngineUtil.updateTrip(finalTripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); - } catch (Exception e) { - throw new RuntimeException(e); + boolean updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); + if(!updateTrip){ + for (int i = 0; i < 5; i++) { + updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); + if(updateTrip){ + break; + } + try { + Thread.sleep(5000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } } }).start(); @@ -731,12 +776,21 @@ orderLogistics.setEndLat(Double.valueOf(orderLogistics.getDestinationLat())); orderLogistics.setEndAddress(orderLogistics.getDestination()); //修改google地图行程终点 - try { - fleetEngineUtil.updateTrip(null, null, null, orderLogistics.getTripId(), - null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); - } catch (Exception e) { - e.printStackTrace(); - throw new RuntimeException(e); + boolean updateTrip = fleetEngineUtil.updateTrip(null, null, null, orderLogistics.getTripId(), + null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); + if(!updateTrip){ + for (int i = 0; i < 5; i++) { + updateTrip = fleetEngineUtil.updateTrip(null, null, null, orderLogistics.getTripId(), + null, null, orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); + if(updateTrip){ + break; + } + try { + Thread.sleep(5000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } } } orderLogistics.setDestinationLon(""); @@ -1098,11 +1152,20 @@ //上报google OrderLogistics finalOrderLogistics = orderLogistics; new Thread(()->{ - try { - fleetEngineUtil.reportBillableEvent(finalOrderLogistics.getTripId()); - log.warn("行程结束:{} {}", System.currentTimeMillis(), finalOrderLogistics.getTripId()); - }catch (Exception e){ - e.printStackTrace(); + log.warn("行程结束:{} {}", System.currentTimeMillis(), finalOrderLogistics.getTripId()); + boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderLogistics.getTripId()); + if(!reportBillableEvent){ + for (int i = 0; i < 5; i++) { + reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderLogistics.getTripId()); + if(reportBillableEvent){ + break; + } + try { + Thread.sleep(5000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } } }).start(); return ResultUtil.success(); -- Gitblit v1.7.1