| | |
| | | import com.xiaopeng.api.dto.map.RouteAndFareDto; |
| | | import com.xiaopeng.api.dto.map.RouteStaleCheckDto; |
| | | import com.xiaopeng.api.dto.map.SelectNavigationRouteDto; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.enums.RouteStrategyKind; |
| | | import com.xiaopeng.api.feignClient.account.UserResourcesClient; |
| | | import com.xiaopeng.api.feignClient.account.UserRoutePlanRuleClient; |
| | |
| | | List<RouteStrategyKind> kinds = planningConfig.getKinds(); |
| | | Map<String, RouteVo> routeById = new LinkedHashMap<>(); |
| | | Map<String, Set<RouteStrategyKind>> strategiesById = new LinkedHashMap<>(); |
| | | for (RouteStrategyKind kind : kinds) { |
| | | Set<List<LonLatDto>> routePoints = new HashSet<>(); |
| | | |
| | | |
| | | aa: for (RouteStrategyKind kind : kinds) { |
| | | RouteAndFareDto copy = new RouteAndFareDto(); |
| | | copy.setOrigin(routeAndFareDto.getOrigin()); |
| | | copy.setDestination(routeAndFareDto.getDestination()); |
| | |
| | | if (r.getCode() != 200 || r.getData() == null || r.getData().getRouteID() == null) { |
| | | continue; |
| | | } |
| | | if(CollUtil.isNotEmpty(routePoints)){ |
| | | for (List<LonLatDto> routePoint : routePoints) { |
| | | if(CollUtil.isEqualList(routePoint, r.getData().getPolyline())){ |
| | | continue aa; |
| | | } |
| | | } |
| | | } |
| | | routePoints.add(r.getData().getPolyline()); |
| | | String fid = r.getData().getRouteID(); |
| | | routeById.putIfAbsent(fid, r.getData()); |
| | | strategiesById.computeIfAbsent(fid, k -> new LinkedHashSet<>()).add(kind); |
| | | } |
| | | |
| | | if (routeById.isEmpty()) { |
| | | throw new ServiceException("获取导肮信息失败", I18nKeyConstant.PATH_NOT_FOUND); |
| | | } |
| | |
| | | opt.setOperateFree(operateFree); |
| | | options.add(opt); |
| | | } |
| | | |
| | | // 根据 pathFingerprint 去重,保留第一次出现的路线 |
| | | // options = new ArrayList<>(options.stream() |
| | | // .collect(Collectors.toMap( |
| | | // RouteOptionVo::getPathFingerprint, |
| | | // option -> option, |
| | | // (existing, replacement) -> existing, |
| | | // LinkedHashMap::new |
| | | // )).values()); |
| | | |
| | | RouteStrategyKind userPref = resolveUserPreferredKind(userId).orElse(RouteStrategyKind.SMART); |
| | | options.sort((a, b) -> compareRouteOptionByUserPreference(a, b, userPref, strategiesById)); |