| | |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | //检查google车辆信息或者添加新的车辆信息 |
| | | Car car = carService.selectById(orderPrivateCar.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(orderPrivateCar.getTripId()); |
| | | if(ToolUtil.isEmpty(trip)){ |
| | | JSONObject createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | JSONObject error = createTrip.getJSONObject("error"); |
| | | if(null != error){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.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, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 超时用户取消不收费的提醒 |
| | |
| | | , orderPrivateCar.getTravelTime(), reminderRules.getCar() * 60000, -1); |
| | | } |
| | | } |
| | | |
| | | new Thread(()->{ |
| | | try { |
| | | Car car = carService.selectById(orderPrivateCar.getCarId()); |
| | | if(!StringUtils.hasLength(car.getVehicleId())){ |
| | | car.setVehicleId(UUIDUtil.getRandomCode()); |
| | | carService.updateById(car); |
| | | } |
| | | String trip = fleetEngineUtil.getTrip(orderPrivateCar.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, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(!createTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | createTrip = fleetEngineUtil.createTrip(car.getVehicleId(), 1, orderPrivateCar.getTripId(), |
| | | orderPrivateCar.getStartLat().toString(), orderPrivateCar.getStartLon().toString(), orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(createTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //开始修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | new Thread(new Runnable() { |
| | |
| | | orderPrivateCar.setGetoffAddress(address); |
| | | orderPrivateCar.setGetoffTime(new Date()); |
| | | orderPrivateCar.setEndServiceTime(new Date()); |
| | | tripStatus = "COMPLETE"; |
| | | tripStatus = ""; |
| | | switch (language){ |
| | | case 1: |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/ReachDestination-CN.mp3"; |
| | |
| | | } |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | String finalTripStatus = tripStatus; |
| | | new Thread(()->{ |
| | | //修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, null, 1, orderPrivateCar.getTripId(), null, null, null, null); |
| | | //修改行程数据 |
| | | if(ToolUtil.isNotEmpty(tripStatus)){ |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(tripStatus, null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, null, 1, orderPrivateCar.getTripId(), null, null, null, null); |
| | | updateTrip = fleetEngineUtil.updateTrip(tripStatus, null, null, orderPrivateCar.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 推送状态 |
| | | OrderPrivateCar finalOrderPrivateCar = orderPrivateCar; |
| | |
| | | if(orderPrivateCar.getArriveTime()==null){ |
| | | orderPrivateCar.setArriveTime(orderPrivateCar.getStartServiceTime()); |
| | | } |
| | | |
| | | //获取google trip_info获取轨迹线路,重新存储轨迹和计算行驶距离和时间 |
| | | |
| | | |
| | | orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用 |
| | | orderPrivateCar.setPayManner(type); |
| | |
| | | orderPrivateCar.setBindId(""); |
| | | } |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | |
| | | |
| | | //修改行程数据 |
| | | boolean updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip("COMPLETE", null, null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //上报行程 |
| | | boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId()); |
| | | if(!reportBillableEvent){ |
| | | for (int i = 0; i < 5; i++) { |
| | | reportBillableEvent = fleetEngineUtil.reportBillableEvent(orderPrivateCar.getTripId()); |
| | | if(reportBillableEvent){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据 |
| | | UserInfo userInfo = userInfoMapper.selectById(orderPrivateCar.getUserId()); |
| | | Integer language1 = userInfo.getLanguage(); |
| | |
| | | } |
| | | }).start(); |
| | | |
| | | OrderPrivateCar finalOrderPrivateCar = orderPrivateCar; |
| | | new Thread(()->{ |
| | | //上报google |
| | | log.warn("行程结束:{} {}", System.currentTimeMillis(), finalOrderPrivateCar.getTripId()); |
| | | boolean reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderPrivateCar.getTripId()); |
| | | if(!reportBillableEvent){ |
| | | for (int i = 0; i < 5; i++) { |
| | | reportBillableEvent = fleetEngineUtil.reportBillableEvent(finalOrderPrivateCar.getTripId()); |
| | | if(reportBillableEvent){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | |
| | | Map<String, Double> distance = GeodesyUtil.getDistance(now, old); |
| | | if(null != distance){ |
| | | Double distance1 = distance.get("WGS84"); |
| | | if(distance1 > 50 && Arrays.asList(3, 4).contains(orderPrivateCar.getState())){//大于50米表示在移动 |
| | | if(distance1 > 30 && Arrays.asList(3, 4).contains(orderPrivateCar.getState())){//大于50米表示在移动 |
| | | orderPrivateCar.setToStartPointMileage(new BigDecimal(orderPrivateCar.getToStartPointMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | this.updateById(orderPrivateCar); |
| | | return true; |
| | | } |
| | | if(distance1 > 50 && orderPrivateCar.getState()==5){//大于50米表示在移动 |
| | | if(distance1 > 30 && orderPrivateCar.getState()==5){//大于50米表示在移动 |
| | | orderPrivateCar.setMileage(new BigDecimal(orderPrivateCar.getMileage()).add(new BigDecimal(distance1)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | this.updateById(orderPrivateCar); |
| | | return true; |
| | |
| | | @Override |
| | | public void updateEndAddress(Integer orderId, Integer status) { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | if(ToolUtil.isEmpty(orderPrivateCar.getDestinationLon())){ |
| | | return; |
| | | } |
| | | if(2 == status){ |
| | | orderPrivateCar.setEndLon(Double.valueOf(orderPrivateCar.getDestinationLon())); |
| | | orderPrivateCar.setEndLat(Double.valueOf(orderPrivateCar.getDestinationLat())); |
| | |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | Thread.sleep(3000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | orderPrivateCar.setDestinationLon(""); |
| | | orderPrivateCar.setDestination(""); |
| | | orderPrivateCar.setDestinationLat(""); |
| | | this.updateById(orderPrivateCar); |
| | | pushUtil.pushModifyAddress(1, orderPrivateCar.getUserId(), orderId, 1, status); |
| | | } |