| | |
| | | Integer distance = dto.getDistance(); |
| | | Integer duration = dto.getDuration(); |
| | | // 计算实时点位到线段的最优截取 |
| | | List<LonLatDto> lonLatDtos = MapMatchingUtil.getRemainingNavigation(routeVo.getPolyline(), dto.getLongitude(), dto.getLatitude()); |
| | | Map<String, List<LonLatDto>> remainingNavigation = MapMatchingUtil.getRemainingNavigation(routeVo.getPolyline(), dto.getLongitude(), dto.getLatitude()); |
| | | //当订单状态为5的时候(乘客已上车)需要推送导航的距离和剩余时间 |
| | | //因为这个状态,车端推的依然是接驾的剩余里程和时间,就会导致数据和小程序的页面跳转匹配不上 |
| | | //小程序是只要乘客上车后就跳转到行程开始页面 |
| | |
| | | distance = routeVo.getDistance(); |
| | | duration = routeVo.getDuration(); |
| | | } |
| | | List<LonLatDto> lonLatDtos = remainingNavigation.get("unserved"); |
| | | List<LonLatDto> lonLatDtos1 = remainingNavigation.get("served"); |
| | | routeVo.setPolyline(lonLatDtos); |
| | | routeVo.setServed(lonLatDtos1); |
| | | |
| | | // 存储最新路线偏离缓存,后续进行轨迹截取 |
| | | redisService.setCacheObject(key, JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | |
| | | polylineMap.put("latitude",lonLatDto.getLatitude()); |
| | | polyline.add(polylineMap); |
| | | } |
| | | List<Map<String, Object>> served = new ArrayList<>(); |
| | | for (LonLatDto lonLatDto : lonLatDtos1) { |
| | | Map<String, Object> polylineMap = new HashMap<>(); |
| | | polylineMap.put("longitude",lonLatDto.getLongitude()); |
| | | polylineMap.put("latitude",lonLatDto.getLatitude()); |
| | | served.add(polylineMap); |
| | | } |
| | | // 封装路由详情 |
| | | Map<String, Object> route = new HashMap<>(); |
| | | route.put("distance",distance); |
| | | route.put("duration",duration); |
| | | route.put("polyline",JSONObject.toJSONString(polyline)); |
| | | route.put("served",JSONObject.toJSONString(served)); |
| | | |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId",dto.getOrderId().toString()); |