| | |
| | | return R.fail("获取订单距离和时长失败,"+cause.getMessage()); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public R<String> queryRouted(String routedID) { |
| | | log.error("根据导航ID获取车端需要的导航数据失败:{}", cause.getMessage()); |
| | | return R.fail("根据导航ID获取车端需要的导航数据失败:" + cause.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<Boolean> diagnosisArea(RouteAndFareDto dto) { |
| | | log.error("判断是否同一经营区域失败:{}", cause.getMessage()); |
| | |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | @FeignClient(contextId = "XpMapClient", value = ServiceNameConstantsEnum.XP_MAP_SERVICE, fallbackFactory = XpMapClientFallbackFactory.class) |
| | | public interface XpMapClient { |
| | |
| | | |
| | | |
| | | /** |
| | | * 根据导航ID获取车端需要的导航数据 |
| | | * @param routedID |
| | | * @return |
| | | */ |
| | | @PostMapping("/base/v1/mini-program/map/queryRouted") |
| | | R<String> queryRouted(@RequestParam("routedID") String routedID); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 判断是否同一经营区域 |
| | | * @param dto |
| | | * @return |
| | |
| | | private String routeID; |
| | | |
| | | private List<LonLatDto> polyline; |
| | | /** |
| | | * 导航原始数据 |
| | | */ |
| | | private String routeDataContent; |
| | | } |
| | |
| | | throw new RuntimeException("获取订单线路和运费失败"); |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | R<String> stringR = xpMapClient.queryRouted(routeVo.getRouteID()); |
| | | if (200 != stringR.getCode()) { |
| | | throw new RuntimeException("根据导航ID获取车端需要的导航数据失败"); |
| | | } |
| | | |
| | | //构建导航下发请求对象 |
| | | cloudPushNavigationInfo(requestId, routeVo.getRouteID(), routeVo.getRouteDataContent(), orderId, xpVehicle.getVehicleVin(), xpVehicle.getXpuId()); |
| | | cloudPushNavigationInfo(requestId, routeVo.getRouteID(), stringR.getData(), orderId, xpVehicle.getVehicleVin(), xpVehicle.getXpuId()); |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | R<String> stringR = xpMapClient.queryRouted(routeVo.getRouteID()); |
| | | if (200 != stringR.getCode()) { |
| | | throw new RuntimeException("根据导航ID获取车端需要的导航数据失败"); |
| | | } |
| | | //构建导航下发请求对象 |
| | | cloudPushNavigationInfo(requestId, routeVo.getRouteID(), routeVo.getRouteDataContent(), orderId, xpVehicle.getVehicleVin(), xpVehicle.getXpuId()); |
| | | cloudPushNavigationInfo(requestId, routeVo.getRouteID(), stringR.getData(), orderId, xpVehicle.getVehicleVin(), xpVehicle.getXpuId()); |
| | | } |
| | | } |
| | | |
| | |
| | | return R.ok(routeVo); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据导航ID获取车端需要的导航数据 |
| | | * @param routedID |
| | | * @return |
| | | */ |
| | | @PostMapping("/map/queryRouted") |
| | | public R<String> getOrderDistanceAndDuration(@RequestParam("routedID") String routedID){ |
| | | return R.ok(gdMapGeocodingUtil.routed(routedID)); |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | JSONObject jsonObject1 = JSON.parseObject(data); |
| | | String routeID = jsonObject1.getString("routeID"); |
| | | JSONArray path = jsonObject1.getJSONArray("paths"); |
| | | JSONArray path = jsonObject1.getJSONArray("path"); |
| | | routeVo.setRouteDataContent(data); |
| | | for (Object o : path) { |
| | | JSONObject jsonObject2 = (JSONObject) o; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 线路还原接口 |
| | | * 车端使用的数据 |
| | | * @param routeID |
| | | * @return |
| | | */ |
| | | public String routed(String routeID){ |
| | | String url = "https://tsapi.amap.com/v1/route/query/routeid?key=" + key; |
| | | HashMap<String, Object> params = new HashMap<>(); |
| | | params.put("routeID", routeID); |
| | | params.put("sdkVersion", ""); |
| | | params.put("encoderVersion", "5.1"); |
| | | String post = HttpUtils.post(url, JSON.toJSONString(params)); |
| | | System.out.println("高德地图返回结果:"+ post); |
| | | JSONObject jsonObject = JSON.parseObject(post); |
| | | return jsonObject.getString("data"); |
| | | } |
| | | |
| | | } |