xp-robotaxi-api/src/main/java/com/xiaopeng/api/factory/operation/XpPricingClientFallbackFactory.java
@@ -39,6 +39,12 @@ return R.fail(); } @Override public R<?> deleteXpGeoQueryEntity(String orderId) { log.error("删除XpGeoQueryEntity失败", cause); return null; } }; } } xp-robotaxi-api/src/main/java/com/xiaopeng/api/feignClient/operation/XpPricingClient.java
@@ -31,4 +31,14 @@ R<?> updateXpGeoQueryEntity(@RequestParam String orderId); /** * 删除XpGeoQueryEntity * @param orderId * @return */ @PostMapping("/inner/deleteXpGeoQueryEntity") R<?> deleteXpGeoQueryEntity(@RequestParam String orderId); } xp-robotaxi-api/src/main/java/com/xiaopeng/api/model/operation/XpGeoQueryEntity.java
@@ -48,6 +48,9 @@ private String time; /** * 0待接单 1已处理 2取消 */ @Field("status") private Integer status; xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/controller/OrderMissionController.java
@@ -42,9 +42,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.Date;import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.*; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -222,7 +220,7 @@ dto.setRouteType(1); R<RouteVo> routeVoR = xpMapClient.getOrderDistanceAndDuration(dto); if (200 != routeVoR.getCode()) { throw new RuntimeException("获取订单线路和运费失败"); // throw new RuntimeException("获取订单线路和运费失败"); } RouteVo routeVo = routeVoR.getData(); //缓存数据,用于后续推给乘客导航线路 @@ -276,8 +274,16 @@ orderId = xpOrder.getId(); String vin = xpVehicle.getVehicleVin(); Long appUserId = xpOrder.getAppUserId(); Object cacheObject = redisService.getCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId()); RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class); // Object cacheObject = redisService.getCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId()); // RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class); RouteVo routeVo =new RouteVo(); ArrayList<LonLatDto> lonLatDtos = new ArrayList<>(); LonLatDto lonLatDto1 = new LonLatDto(); lonLatDto1.setLatitude(30.575685); lonLatDto1.setLongitude(104.001118); lonLatDtos.add(lonLatDto1); routeVo.setPolyline(lonLatDtos); ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(1000)); Long finalOrderId = orderId; @@ -288,7 +294,6 @@ } catch (InterruptedException e) { throw new RuntimeException(e); } List<LonLatDto> polyline = routeVo.getPolyline(); for (LonLatDto lonLatDto : polyline) { Double latitude = lonLatDto.getLatitude(); xp-robotaxi-automatic-pilot-boot/src/main/resources/bootstrap.yml
@@ -29,7 +29,7 @@ namespace: 5185ac4b-6369-48eb-a21b-a7cbc441c5f1 username: nacos password: nacos ip: 192.168.110.85 # ip: 192.168.110.85 config: # 配置中心地址 server-addr: 192.168.110.80:8848 xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java
@@ -407,13 +407,15 @@ } else { // 已完成接单的数据 List<XpGeoQueryEntity> validEntities = entities.stream().filter(e -> e.getStatus() == 1).collect(Collectors.toList()); long waitNum = entities.stream().filter(e -> e.getStatus() == 0).count(); // 计算平均等待时间 OptionalDouble averageOptional = validEntities.stream().mapToDouble(XpGeoQueryEntity::getSeconds).average(); if (averageOptional.isPresent()) { double average = averageOptional.getAsDouble(); // 未完成接单的数量 int count = entities.size() - validEntities.size(); int count = (int) waitNum; if (count == 0) { return 1; } else { xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/controller/XpPricingController.java
@@ -143,6 +143,12 @@ } @PostMapping("/inner/deleteXpGeoQueryEntity") public R<?> deleteXpGeoQueryEntity(@RequestParam String orderId){ xpGeoQueryEntityService.deleteXpGeoQueryEntity(orderId); return R.ok(); } /** * 播单 */ xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/IXpGeoQueryEntityService.java
@@ -54,4 +54,12 @@ * @return 实体列表 */ List<XpGeoQueryEntity> findAll(); /** * 删除 * @param orderId */ void deleteXpGeoQueryEntity(String orderId); } xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpGeoQueryEntityServiceImpl.java
@@ -40,7 +40,7 @@ */ @Override public List<XpGeoQueryEntity> findByLocationWithin500MetersAndLastWeekAndStatusGreater( double longitude, double longitude, double latitude, String time ) { @@ -105,7 +105,6 @@ } @Override public XpGeoQueryEntity updateByOrderId(String orderId) { Query query = new Query(Criteria.where("orderId").is(orderId)); @@ -114,9 +113,9 @@ Long timestamp = xpGeoQueryEntity.getTimestamp(); long time = new Date().getTime(); // 计算2个时间的秒数差 long seconds = (time- timestamp) / 1000; long seconds = (time - timestamp) / 1000; Update update = new Update().set("seconds", seconds).set("status", 1); if(xpGeoQueryEntity.getStatus()==0){ if (xpGeoQueryEntity.getStatus() == 0) { mongoTemplate.findAndModify(query, update, XpGeoQueryEntity.class); } return null; @@ -150,4 +149,11 @@ public List<XpGeoQueryEntity> findAll() { return repository.findAll(); } @Override public void deleteXpGeoQueryEntity(String orderId) { Query query = new Query(Criteria.where("orderId").is(orderId)); Update update = new Update().set("status", 2); mongoTemplate.findAndModify(query, update, XpGeoQueryEntity.class); } } xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
@@ -1034,6 +1034,24 @@ redisService.setCacheCancelOrder("CANCEL_ORDER_" + uid, i + 1); } // 消息推送 Map<String, Object> params = new HashMap<>(); Map<String, Object> content = new HashMap<>(); content.put("orderId", order.getId().toString()); content.put("status", OrderStatusEnum.CANCELED.getCode()); params.put("type", PushMessageTypeEnum.ORDER_STATUS.getDesc()); params.put("content", com.alibaba.fastjson2.JSONObject.toJSONString(content)); params.put("timestamp", new Date().getTime() + ""); String message = JSONObject.toJSONString(params); SendMessageDTO sendMessageDTO = new SendMessageDTO(); sendMessageDTO.setMessage(message); sendMessageDTO.setAppUserId(String.valueOf(order.getAppUserId())); xpPushMessageClient.sendStatus(sendMessageDTO); log.info("订单取消消息推送完毕"); // 移除mongo数据 xpPricingClient.deleteXpGeoQueryEntity(order.getId().toString()); // 下发命令 if(order.getStatus()>1){ PushOrderDto pushOrderDto = new PushOrderDto(); @@ -1083,6 +1101,9 @@ xpPushMessageClient.sendStatus(sendMessageDTO); log.info("订单取消消息推送完毕"); // 移除mongo数据 xpPricingClient.deleteXpGeoQueryEntity(order.getId().toString()); // 下发命令 if(order.getStatus()>1){ PushOrderDto pushOrderDto = new PushOrderDto();