| | |
| | | * @param msgContent |
| | | */ |
| | | public void navigationDeviationEvent(MsgContent msgContent) { |
| | | //先响应消息 |
| | | long sequence = msgContent.getHeader().getSequence(); |
| | | //开始处理消息对应的业务逻辑 |
| | | NavigationDeviationEvent deviationEvent = msgContent.getNaviDeviationEvent(); |
| | | // todo 请求id确认是否有这个参数 |
| | | // String requestId = deviationEvent.getRequestId(); |
| | | String requestId = ""; |
| | | String requestId = deviationEvent.getNavigationDeviationMessage().getNaviRecalcRequestSeq() + ""; |
| | | //导航id |
| | | String routeID = ""; |
| | | Long vehicleId = null; |
| | | String orderType = ""; |
| | | //偏航事件类型 1:请求导航,2:取消导航 |
| | | // if (deviationEvent.getEvent_type().equals(RtEventType.RT_EVENT_TYPE_REQUEST)) { |
| | | NavigationDeviationMessage navigationDeviationMessage = deviationEvent.getNavigationDeviationMessage(); |
| | | String orderId = navigationDeviationMessage.getOrderId(); |
| | | String taskId = navigationDeviationMessage.getTaskId(); |
| | | Wgs wgs = navigationDeviationMessage.getPoint(); |
| | | Double longitude = wgs.getLongitude(); |
| | | Double latitude = wgs.getLatitude(); |
| | | //订单类型 1:乘客订单,2=巡游订单 |
| | | LonLatDto destination = new LonLatDto(); |
| | | LonLatDto origin = new LonLatDto(); |
| | | NavigationDeviationMessage navigationDeviationMessage = deviationEvent.getNavigationDeviationMessage(); |
| | | String orderId = navigationDeviationMessage.getOrderId(); |
| | | String taskId = navigationDeviationMessage.getTaskId(); |
| | | Wgs wgs = navigationDeviationMessage.getPoint(); |
| | | Double longitude = wgs.getLongitude(); |
| | | Double latitude = wgs.getLatitude(); |
| | | //订单类型 1:乘客订单,2=巡游订单 |
| | | LonLatDto destination = new LonLatDto(); |
| | | LonLatDto origin = new LonLatDto(); |
| | | |
| | | if (orderId.contains("XU")) { |
| | | // orderType = OrderType.CRUISE_ORDER; |
| | | if (orderId.contains("XU")) { |
| | | orderType = OrderType.CRUISE_ORDER; |
| | | |
| | | R<XpCruiseOrder> cruiseOrder = xpCruiseOrderClient.getCruiseOrder(Long.parseLong(orderId.substring(2))); |
| | | XpCruiseOrder xpCruiseOrder = cruiseOrder.getData(); |
| | | R<XpCruiseOrder> cruiseOrder = xpCruiseOrderClient.getCruiseOrder(Long.parseLong(orderId.substring(2))); |
| | | XpCruiseOrder xpCruiseOrder = cruiseOrder.getData(); |
| | | |
| | | //先响应消息 |
| | | responseMessage(sequence, ""); |
| | | //构建导航数据给到车端 |
| | | //构建导航数据给到车端 |
| | | origin.setLongitude(longitude); |
| | | origin.setLatitude(latitude); |
| | | destination.setLongitude(xpCruiseOrder.getEndLon()); |
| | | destination.setLatitude(xpCruiseOrder.getEndLat()); |
| | | |
| | | OrderRouteAndFareDto dto = new OrderRouteAndFareDto(); |
| | | dto.setOrderId(Long.parseLong(orderId)); |
| | | dto.setOrigin(origin); |
| | | dto.setDestination(destination); |
| | | dto.setRouteType(3); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto); |
| | | if (200 != routeVoR.getCode()) { |
| | | throw new RuntimeException("获取订单线路和运费失败"); |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | routeID = routeVo.getRouteID(); |
| | | |
| | | |
| | | vehicleId = xpCruiseOrder.getVehicleId(); |
| | | } else { |
| | | orderType = OrderType.USER_ORDER; |
| | | //正常单 |
| | | R<XpOrder> xpOrderR = xpOrderClient.queryOrderById(Long.parseLong(orderId)); |
| | | if (200 != xpOrderR.getCode()) { |
| | | throw new RuntimeException("订单不存在"); |
| | | } |
| | | XpOrder xpOrder = xpOrderR.getData(); |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | //驶往上车点的行程 |
| | | if (3 == xpOrder.getStatus()) { |
| | | //查询司机当前位置到起点的线路 |
| | | origin.setLongitude(longitude); |
| | | origin.setLatitude(latitude); |
| | | destination.setLongitude(xpCruiseOrder.getEndLon()); |
| | | destination.setLatitude(xpCruiseOrder.getEndLat()); |
| | | destination.setLongitude(xpOrder.getStartLon()); |
| | | destination.setLatitude(xpOrder.getStartLat()); |
| | | |
| | | OrderRouteAndFareDto dto = new OrderRouteAndFareDto(); |
| | | dto.setOrderId(Long.parseLong(orderId)); |
| | | dto.setOrigin(origin); |
| | | dto.setDestination(destination); |
| | | dto.setRouteType(3); |
| | | dto.setRouteType(1); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto); |
| | | if (200 != routeVoR.getCode()) { |
| | | throw new RuntimeException("获取订单线路和运费失败"); |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | // routeID = routeVo.getRouteID(); |
| | | |
| | | |
| | | // vehicleId = xpCruiseOrder.getVehicleId(); |
| | | } else { |
| | | // orderType = OrderType.USER_ORDER; |
| | | //正常单 |
| | | R<XpOrder> xpOrderR = xpOrderClient.queryOrderById(Long.parseLong(orderId)); |
| | | if (200 != xpOrderR.getCode()) { |
| | | throw new RuntimeException("订单不存在"); |
| | | } |
| | | XpOrder xpOrder = xpOrderR.getData(); |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | //响应消息 |
| | | responseMessage(sequence, xpVehicle.getVehicleVin()); |
| | | //驶往上车点的行程 |
| | | if (Arrays.asList(3).contains(xpOrder.getStatus())) { |
| | | //查询司机当前位置到起点的线路 |
| | | origin.setLongitude(longitude); |
| | | origin.setLatitude(latitude); |
| | | destination.setLongitude(xpOrder.getStartLon()); |
| | | destination.setLatitude(xpOrder.getStartLat()); |
| | | |
| | | OrderRouteAndFareDto dto = new OrderRouteAndFareDto(); |
| | | dto.setOrderId(Long.parseLong(orderId)); |
| | | dto.setOrigin(origin); |
| | | dto.setDestination(destination); |
| | | dto.setRouteType(1); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto); |
| | | if (200 != routeVoR.getCode()) { |
| | | throw new RuntimeException("获取订单线路和运费失败"); |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | // routeID = routeVo.getRouteID(); |
| | | //缓存数据,用于后续推给乘客导航线路 |
| | | redisService.setCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(), JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | } |
| | | //驶往下车点的行程 |
| | | if (Arrays.asList(6).contains(xpOrder.getStatus())) { |
| | | origin.setLongitude(longitude); |
| | | origin.setLatitude(latitude); |
| | | destination.setLongitude(xpOrder.getEndLon()); |
| | | destination.setLatitude(xpOrder.getEndLat()); |
| | | |
| | | OrderRouteAndFareDto dto = new OrderRouteAndFareDto(); |
| | | dto.setOrderId(Long.parseLong(orderId)); |
| | | dto.setOrigin(origin); |
| | | dto.setDestination(destination); |
| | | dto.setRouteType(2); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto); |
| | | if (200 != routeVoR.getCode()) { |
| | | throw new RuntimeException("获取订单线路和运费失败"); |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | // routeID = routeVo.getRouteID(); |
| | | //缓存导航数据,用于后面的逻辑中给乘客端推送导航数据 |
| | | redisService.setCacheObject("ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId(), com.alibaba.fastjson.JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | } |
| | | // vehicleId = xpOrder.getVehicleId(); |
| | | routeID = routeVo.getRouteID(); |
| | | //缓存数据,用于后续推给乘客导航线路 |
| | | redisService.setCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(), JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | } |
| | | //驶往下车点的行程 |
| | | if (6 == xpOrder.getStatus()) { |
| | | origin.setLongitude(longitude); |
| | | origin.setLatitude(latitude); |
| | | destination.setLongitude(xpOrder.getEndLon()); |
| | | destination.setLatitude(xpOrder.getEndLat()); |
| | | |
| | | // TODO 在请求导航哪里返回导航数据 |
| | | // if(StringUtils.isNotEmpty(routeID)){ |
| | | // XpVehicle xpVehicle = xpVehicleClient.queryById(vehicleId).getData(); |
| | | // R<String> stringR = xpMapClient.queryRouted(routeID); |
| | | // if (200 != stringR.getCode()) { |
| | | // throw new RuntimeException("根据导航ID获取车端需要的导航数据失败"); |
| | | // } |
| | | // //TODO 这里的逻辑不太对,收到导航偏航事件之后 |
| | | // //构建响应导航数据给车端 |
| | | // cloudPushNavigationInfo(requestId, routeID, stringR.getData(), orderType, orderId, xpVehicle.getVehicleVin(), xpVehicle.getXpuId()); |
| | | // } |
| | | // } |
| | | OrderRouteAndFareDto dto = new OrderRouteAndFareDto(); |
| | | dto.setOrderId(Long.parseLong(orderId)); |
| | | dto.setOrigin(origin); |
| | | dto.setDestination(destination); |
| | | dto.setRouteType(2); |
| | | R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto); |
| | | if (200 != routeVoR.getCode()) { |
| | | throw new RuntimeException("获取订单线路和运费失败"); |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | routeID = routeVo.getRouteID(); |
| | | //缓存导航数据,用于后面的逻辑中给乘客端推送导航数据 |
| | | redisService.setCacheObject("ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId(), com.alibaba.fastjson.JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | } |
| | | vehicleId = xpOrder.getVehicleId(); |
| | | } |
| | | //直接响应回最新导航数据 |
| | | if(StringUtils.isNotEmpty(routeID)){ |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(vehicleId).getData(); |
| | | R<String> stringR = xpMapClient.queryRouted(routeID); |
| | | if (200 != stringR.getCode()) { |
| | | throw new RuntimeException("根据导航ID获取车端需要的导航数据失败"); |
| | | } |
| | | //构建响应导航数据给车端 |
| | | cloudPushNavigationInfo(requestId, routeID, stringR.getData(), orderType, orderId, xpVehicle.getVehicleVin(), xpVehicle.getXpuId()); |
| | | } |
| | | } |
| | | |
| | | |