| | |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.DistancematrixVo; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.GoogleMapUtil; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.ReverseGeocodeVo; |
| | | import com.stylefeng.guns.modular.system.util.quartz.QuartzUtil; |
| | | import com.stylefeng.guns.modular.system.util.quartz.jobs.OrderTimeOutJob; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | |
| | | @Override |
| | | public synchronized ResultUtil grabOrder(Integer orderId, Integer uid, Integer language) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | String tripId = redisUtil.getValue("trip" + orderPrivateCar.getUserId()); |
| | | //处理摆渡车的情况 |
| | | if(orderPrivateCar.getType() == 2){ |
| | | //查看用户下的摆渡车是否已被人抢了 |
| | |
| | | String value = redisUtil.getValue("DRIVER" + driver.getId()); |
| | | if(ToolUtil.isNotEmpty(value)) { |
| | | String[] split = value.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderPrivateCar.getStartLat(), orderPrivateCar.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0])); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderPrivateCar.getStartLat(), orderPrivateCar.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0]), tripId); |
| | | //超时时间 |
| | | long timeOut = System.currentTimeMillis() + (distancematrix.getDuration() * 1000); |
| | | orderPrivateCar.setEstimateArriveTime(new Date(timeOut)); |
| | |
| | | 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()); |
| | | 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, orderPrivateCar.getTripId(), |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //开始修改行程数据 |
| | | fleetEngineUtil.updateTrip(null, car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null); |
| | | 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(); |
| | | } |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String address,String phone, Integer language, Integer uid) throws Exception { |
| | | public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat,String phone, Integer language, Integer uid) throws Exception { |
| | | OrderPrivateCar orderPrivateCar = this.selectById(orderId); |
| | | String tripId = redisUtil.getValue("trip" + orderPrivateCar.getUserId()); |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(lat, lon, tripId); |
| | | if(null == reverseGeocode){ |
| | | return ResultUtil.error(language == 1 ? "无效的经纬度" : language == 2 ? "Invalid longitude and latitude" : "Longitude et latitude non valides"); |
| | | } |
| | | String address = reverseGeocode.getAddress(); |
| | | if(!uid.equals(orderPrivateCar.getDriverId())){ |
| | | return ResultUtil.error(language == 1 ? "操作失败,请刷新订单" : language == 2 ? "Operation failed, please refresh the order" : "L’opération a échoué, veuillez actualiser la commande"); |
| | | } |
| | |
| | | tripStatus = "ENROUTE_TO_DROPOFF"; |
| | | switch (language){ |
| | | case 1: |
| | | audioUrl = "http://182.160.16.251:81/files/audio/system/OnboardReminder-CN.mp3"; |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/OnboardReminder-CN.mp3"; |
| | | break; |
| | | case 2: |
| | | audioUrl = "http://182.160.16.251:81/files/audio/system/OnboardReminder-EN.mp3"; |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/OnboardReminder-EN.mp3"; |
| | | break; |
| | | case 3: |
| | | audioUrl = "http://182.160.16.251:81/files/audio/system/OnboardReminder-FR.mp3"; |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/OnboardReminder-FR.mp3"; |
| | | break; |
| | | } |
| | | break; |
| | |
| | | tripStatus = "COMPLETE"; |
| | | switch (language){ |
| | | case 1: |
| | | audioUrl = "http://182.160.16.251:81/files/audio/system/ReachDestination-CN.mp3"; |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/ReachDestination-CN.mp3"; |
| | | break; |
| | | case 2: |
| | | audioUrl = "http://182.160.16.251:81/files/audio/system/ReachDestination-EN.mp3"; |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/ReachDestination-EN.mp3"; |
| | | break; |
| | | case 3: |
| | | audioUrl = "http://182.160.16.251:81/files/audio/system/ReachDestination-FR.mp3"; |
| | | audioUrl = "https://igo.i-go.group/files/audio/system/ReachDestination-FR.mp3"; |
| | | break; |
| | | } |
| | | break; |
| | |
| | | String finalTripStatus = tripStatus; |
| | | new Thread(()->{ |
| | | //修改行程数据 |
| | | try { |
| | | fleetEngineUtil.updateTrip(finalTripStatus, null, 1, orderPrivateCar.getTripId(), null, null, null, null); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(finalTripStatus, null, 1, 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); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | }).start(); |
| | | |
| | | // TODO: 2020/6/5 推送状态 |
| | |
| | | if(orderPrivateCar.getArriveTime()==null){ |
| | | orderPrivateCar.setArriveTime(orderPrivateCar.getStartServiceTime()); |
| | | } |
| | | |
| | | //获取google trip_info获取轨迹线路,重新存储轨迹和计算行驶距离和时间 |
| | | |
| | | |
| | | orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用 |
| | | orderPrivateCar.setPayManner(type); |
| | | orderPrivateCar.setParkMoney(null == parkingFee ? 0D : parkingFee); |
| | |
| | | |
| | | OrderPrivateCar finalOrderPrivateCar = orderPrivateCar; |
| | | new Thread(()->{ |
| | | try { |
| | | //上报google |
| | | fleetEngineUtil.reportBillableEvent(finalOrderPrivateCar.getTripId()); |
| | | log.warn("上报时间:{},tripid:{},created_at:{},completed_at:{}", System.currentTimeMillis(), finalOrderPrivateCar.getTripId(), |
| | | finalOrderPrivateCar.getInsertTime().getTime(), finalOrderPrivateCar.getEndServiceTime().getTime()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | //上报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(); |
| | |
| | | orderPrivateCar.setEndLat(Double.valueOf(orderPrivateCar.getDestinationLat())); |
| | | orderPrivateCar.setEndAddress(orderPrivateCar.getDestination()); |
| | | //修改google地图行程终点 |
| | | try { |
| | | fleetEngineUtil.updateTrip(null, null, null, orderPrivateCar.getTripId(), |
| | | null, null, orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(e); |
| | | boolean updateTrip = fleetEngineUtil.updateTrip(null, null, null, orderPrivateCar.getTripId(), |
| | | null, null, orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(!updateTrip){ |
| | | for (int i = 0; i < 5; i++) { |
| | | updateTrip = fleetEngineUtil.updateTrip(null, null, null, orderPrivateCar.getTripId(), |
| | | null, null, orderPrivateCar.getEndLat().toString(), orderPrivateCar.getEndLon().toString()); |
| | | if(updateTrip){ |
| | | break; |
| | | } |
| | | try { |
| | | Thread.sleep(5000L); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | orderPrivateCar.setDestinationLon(""); |