From 3af9c82375df6bd77ae78a5d900c409a895ecd18 Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期四, 14 十一月 2024 17:10:16 +0800 Subject: [PATCH] Merge branch '2.0' of http://120.76.84.145:10101/gitblit/r/java/IgoTravel into 2.0 --- DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java | 207 +++++++++++++++++++++++++++------------------------ 1 files changed, 110 insertions(+), 97 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 736a375..4cc9d2f 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 @@ -207,6 +207,72 @@ driver.setState(3); driverService.updateById(driver); + //检查google车辆信息或者添加新的车辆信息 + Car car = carService.selectById(orderLogistics.getCarId()); + if(ToolUtil.isEmpty(car.getVehicleId())){ + car.setVehicleId(UUIDUtil.getRandomCode()); + carService.updateById(car); + } + 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(3000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } + } + + //修改google订单信息或者创建新的行程 + String trip = fleetEngineUtil.getTrip(orderLogistics.getTripId()); + if(ToolUtil.isEmpty(trip)){ + JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderLogistics.getTripId(), + orderLogistics.getStartLat().toString(), orderLogistics.getStartLon().toString(), orderLogistics.getEndLat().toString(), orderLogistics.getEndLon().toString()); + JSONObject error = createTrip.getJSONObject("error"); + if(null != error){ + 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()); + error = createTrip.getJSONObject("error"); + String tripStatus = createTrip.getString("tripStatus"); + if(null == error && "NEW".equals(tripStatus)){ + break; + } + try { + Thread.sleep(3000L); + } 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(3000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } + } + + /** * 超时用户取消不收费的提醒 * 即时单:预估到达预约点时间 + 配置不收费的时间 > 当前时间 (只弹一次) @@ -252,67 +318,7 @@ new OrderTimeOutJob().buildQuartzJob("3_" + orderLogistics.getId() + "_4", "ORDER_TIME_OUT", jobDataMap) , orderLogistics.getEstimateArriveTime(), reminderRules.getCar() * 60000, -1); } - - new Thread(()->{ - 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); - } - } - } - } - 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(); + //推送相关代码------------------start---------------- new Thread(new Runnable() { @@ -443,31 +449,28 @@ orderLogistics.setGetoffTime(new Date()); orderLogistics.setEndServiceTime(new Date()); orderLogistics.setState(6); - tripStatus = "COMPLETE"; + tripStatus = ""; break; } this.updateById(orderLogistics); - Driver driver = driverService.selectById(orderLogistics.getDriverId()); - String finalTripStatus = tripStatus; - new Thread(()->{ - Car car = carMapper.selectById(driver.getCarId()); - //修改行程数据 - boolean updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, car.getVehicleId(), null, orderLogistics.getTripId(), null, null, null, null); + //修改行程数据 + if(ToolUtil.isNotEmpty(tripStatus)){ + boolean updateTrip = fleetEngineUtil.updateTrip(tripStatus, null, 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); + updateTrip = fleetEngineUtil.updateTrip(tripStatus, null, null, orderLogistics.getTripId(), null, null, null, null); if(updateTrip){ break; } try { - Thread.sleep(5000L); + Thread.sleep(3000L); } catch (InterruptedException e) { throw new RuntimeException(e); } } } - }).start(); + } // TODO: 2020/6/5 推送状态 new Thread(new Runnable() { @@ -771,6 +774,9 @@ @Override public void updateEndAddress(Integer orderId, Integer status) { OrderLogistics orderLogistics = this.selectById(orderId); + if(ToolUtil.isEmpty(orderLogistics.getDestinationLon())){ + return; + } if(2 == status){ orderLogistics.setEndLon(Double.valueOf(orderLogistics.getDestinationLon())); orderLogistics.setEndLat(Double.valueOf(orderLogistics.getDestinationLat())); @@ -786,16 +792,13 @@ break; } try { - Thread.sleep(5000L); + Thread.sleep(3000L); } catch (InterruptedException e) { throw new RuntimeException(e); } } } } - orderLogistics.setDestinationLon(""); - orderLogistics.setDestination(""); - orderLogistics.setDestinationLat(""); this.updateById(orderLogistics); pushUtil.pushModifyAddress(1, orderLogistics.getUserId(), orderId, 4, status); } @@ -1127,6 +1130,36 @@ orderLogistics.setBindId(""); } this.updateById(orderLogistics); + //修改行程数据 + boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderLogistics.getTripId(), null, null, null, null); + if(!updateTrip){ + for (int i = 0; i < 5; i++) { + updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderLogistics.getTripId(), null, null, null, null); + if(updateTrip){ + break; + } + try { + Thread.sleep(3000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } + //上报行程 + boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderLogistics.getTripId()); + if(!reportBillableEvent){ + for (int i = 0; i < 5; i++) { + reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderLogistics.getTripId()); + if(reportBillableEvent){ + break; + } + try { + Thread.sleep(3000L); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + } pushUtil.removeTask(orderId, 4);//删除定时任务,结束推送数据 @@ -1146,26 +1179,6 @@ public void run() { pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState(), 0, ""); pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 4, finalOrderTaxi.getState(), 0, ""); - } - }).start(); - - //上报google - OrderLogistics finalOrderLogistics = orderLogistics; - new Thread(()->{ - 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(); @@ -1199,12 +1212,12 @@ Map<String, Double> distance = GeodesyUtil.getDistance(now, old); if(null != distance){ Double distance1 = distance.get("WGS84"); - if(distance1 > 50 && Arrays.asList(3, 4).contains(orderLogistics.getState())){//大于50米表示在移动 + if(distance1 > 30 && Arrays.asList(3, 4).contains(orderLogistics.getState())){//大于50米表示在移动 orderLogistics.setToStartPointMileage(new BigDecimal(orderLogistics.getToStartPointMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); this.updateById(orderLogistics); return true; } - if(distance1 > 50 && orderLogistics.getState()==5){//大于50米表示在移动 + if(distance1 > 30 && orderLogistics.getState()==5){//大于50米表示在移动 orderLogistics.setMileage(new BigDecimal(orderLogistics.getMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); this.updateById(orderLogistics); return true; -- Gitblit v1.7.1