xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/SysGroupMenuServiceImpl.java
@@ -59,8 +59,25 @@ return; } List<SysGroupMenu> list = this.list(new LambdaQueryWrapper<SysGroupMenu>().eq(SysGroupMenu::getGroupId, groupId)); List<Long> deleteMenuIds = new ArrayList<>(); List<Long> addMenuIds = new ArrayList<>(); //查找需要删除的数据 for (SysGroupMenu sysGroupMenu : list) { if(!menuIds.contains(sysGroupMenu.getMenuId())){ deleteMenuIds.add(sysGroupMenu.getMenuId()); } } //查找需要添加的数据 List<Long> collect = list.stream().map(SysGroupMenu::getMenuId).collect(Collectors.toList()); for (Long menuId : menuIds) { if(!collect.contains(menuId)){ addMenuIds.add(menuId); } } // 构建批量插入的数据 List<SysGroupMenu> groupMenus = menuIds.stream() List<SysGroupMenu> groupMenus = addMenuIds.stream() .filter(Objects::nonNull) .map(menuId -> { SysGroupMenu groupMenu = new SysGroupMenu(); @@ -74,6 +91,9 @@ if (!groupMenus.isEmpty()) { this.saveBatch(groupMenus); } if(!deleteMenuIds.isEmpty()){ this.remove(new LambdaQueryWrapper<SysGroupMenu>().eq(SysGroupMenu::getGroupId, groupId).in(SysGroupMenu::getMenuId, deleteMenuIds)); } } /** xp-robotaxi-account-boot/xp-robotaxi-account-boot.iml
New file @@ -0,0 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <module version="4"> <component name="AdditionalModuleElements"> <content url="file://$MODULE_DIR$" dumb="true"> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> </content> </component> </module> xp-robotaxi-api/pom.xml
@@ -57,6 +57,12 @@ <artifactId>protobuf-java</artifactId> <version>3.19.4</version> </dependency> <dependency> <groupId>com.github.jeffreyning</groupId> <artifactId>mybatisplus-plus</artifactId> <version>1.5.1-RELEASE</version> <scope>compile</scope> </dependency> </dependencies> <build> xp-robotaxi-api/src/main/java/com/xiaopeng/api/dto/map/HistoryPointDto.java
@@ -25,4 +25,8 @@ * 速度 */ private Float speed; /** * 海拔高度 */ private Float height; } xp-robotaxi-api/src/main/java/com/xiaopeng/api/model/account/SysGroupMenu.java
@@ -3,6 +3,8 @@ import com.baomidou.mybatisplus.annotation.TableName; import java.io.Serializable; import com.github.jeffreyning.mybatisplus.anno.MppMultiId; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -26,9 +28,11 @@ private static final long serialVersionUID = 1L; @MppMultiId @ApiModelProperty(value = "权限组ID") private Long groupId; @MppMultiId @ApiModelProperty(value = "菜单ID") private Long menuId; xp-robotaxi-api/xp-robotaxi-api.iml
New file @@ -0,0 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <module version="4"> <component name="AdditionalModuleElements"> <content url="file://$MODULE_DIR$" dumb="true"> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" /> </content> </component> </module> xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/service/KafkaConsumerService.java
@@ -73,7 +73,7 @@ @Slf4j @Service public class KafkaConsumerService { private static final String CANCEL_ORDER_CONTEXT_PREFIX = "CANCEL_ORDER_CONTEXT:"; private static final String REASSIGN_CANCEL_CONTEXT_PREFIX = "REASSIGN_CANCEL_CONTEXT:"; @Resource @@ -375,16 +375,9 @@ //保存车辆实时信息到mongodb if(0 != longitude && 0 != latitude){ //缓存车辆历史定位,用户辅助获取导航抓路用 List<Object> cacheList = redisService.getCacheList("VEHICLE_HISTORY_POINT_LIST:" + xpVehicle.getId()); List<HistoryPointDto> history = new ArrayList<>(); if(cacheList!=null && !cacheList.isEmpty()){ for (Object cache : cacheList) { HistoryPointDto historyPointDto = JSON.parseObject(cache.toString(), HistoryPointDto.class); history.add(historyPointDto); } } List<HistoryPointDto> history = redisService.getCacheList("VEHICLE_HISTORY_POINT_LIST:" + xpVehicle.getId()); if(history.size() >= 10){ history.subList(history.size() - 10, history.size()); history = new ArrayList<>(history.subList(history.size() - 9, history.size())); } HistoryPointDto historyPointDto = new HistoryPointDto(); historyPointDto.setLocation(longitude + "," + latitude); @@ -392,6 +385,7 @@ historyPointDto.setAccuracy(naviPose.getPosAcc()); historyPointDto.setDirection(course); historyPointDto.setSpeed(dynamicStatus.getSpeed()); historyPointDto.setHeight(naviPose.getAlt()); history.add(historyPointDto); redisService.setCacheList("VEHICLE_HISTORY_POINT_LIST:" + xpVehicle.getId(), history); @@ -782,11 +776,12 @@ dto.setLongitude(longitude); dto.setLatitude(latitude); if (null != routeVo) { dto.setDuration(routeVo.getDuration().doubleValue()); dto.setDistance(routeVo.getDistance().doubleValue()); dto.setDirection(routeVo.getDirection().intValue()); dto.setDuration(null == routeVo.getDuration() ? 0 : routeVo.getDuration().doubleValue()); dto.setDistance(null == routeVo.getDistance() ? 0 : routeVo.getDistance().doubleValue()); dto.setDirection(null == routeVo.getDirection() ? 0 : routeVo.getDirection().intValue()); } xpPushMessageClient.pushOrderRoute(dto); log.info("完成小程序下发导航偏离后的新轨迹:" + orderId); } XpVehicle xpVehicle = xpVehicleClient.queryById(vehicleId).getData(); @@ -794,8 +789,10 @@ if (200 != stringR.getCode()) { throw new RuntimeException("根据导航ID获取车端需要的导航数据失败"); } log.info("开始下发XPU导航偏离后新的导航数据:" + orderId); //构建响应导航数据给车端 cloudPushNavigationInfo(requestId, routeID, stringR.getData(), orderType, orderId, xpVehicle.getVehicleVin(), xpVehicle.getXpuId(), taskId); log.info("完成下发XPU导航偏离后新的导航数据:" + orderId); } } @@ -1239,12 +1236,18 @@ //已取消 if(!orderId.contains("XU")){ String taskId = orderStatusInfo.getTaskId(); JSONObject cancelContext = getCancelOrderContext(taskId); if (shouldSkipCancelForReassign(cancelContext)) { JSONObject reassignCancelContext = resolveReassignCancelContext(orderId, orderStatusInfo); if (Objects.nonNull(reassignCancelContext)) { log.info("改派旧车取消回调,跳过订单取消处理,orderId: {}, taskId: {}, cancelScene: {}, context: {}", orderId, taskId, cancelContext.getString("cancelScene"), cancelContext); orderId, taskId, reassignCancelContext.getString("cancelScene"), reassignCancelContext); //响应消息 responseMessage(cmd, sequence, cancelContext.getString("vin")); String responseVin = resolveReassignCancelResponseVin(reassignCancelContext); if (StringUtils.isNotEmpty(responseVin)) { responseMessage(cmd, sequence, responseVin); } else { log.warn("改派旧车取消回调未找到响应VIN,orderId: {}, taskId: {}, context: {}", orderId, taskId, reassignCancelContext); } return; } if(orderId.contains("TEST")){ @@ -1454,33 +1457,62 @@ } } /** * 根据taskId获取订单取消的上下文信息 * @param taskId * @return */ private JSONObject getCancelOrderContext(String taskId) { if (StringUtils.isEmpty(taskId)) { private JSONObject getReassignCancelContext(String orderId) { if (StringUtils.isEmpty(orderId)) { return null; } Object cacheObject = redisService.getCacheObject(CANCEL_ORDER_CONTEXT_PREFIX + taskId); Object cacheObject = redisService.getCacheObject(REASSIGN_CANCEL_CONTEXT_PREFIX + orderId); if (cacheObject == null) { return null; } return JSON.parseObject(cacheObject.toString()); } /** * 判断是否是改派旧车取消回调,是则跳过订单取消处理 * @param cancelContext * @return */ private boolean shouldSkipCancelForReassign(JSONObject cancelContext) { if (cancelContext == null) { return false; private JSONObject resolveReassignCancelContext(String orderId, OrderStatusInfo orderStatusInfo) { if (OrderStateChangeSource.ORDER_STATE_CHANGE_SOURCE_VEHICLE != orderStatusInfo.getChangeSource()) { return null; } return CancelOrderSceneEnum.REASSIGN_OLD_VEHICLE == CancelOrderSceneEnum.fromCode( cancelContext.getString("cancelScene")); JSONObject cancelContext = getReassignCancelContext(orderId); if (cancelContext == null) { return null; } if (CancelOrderSceneEnum.REASSIGN_OLD_VEHICLE != CancelOrderSceneEnum.fromCode( cancelContext.getString("cancelScene"))) { return null; } R<XpOrder> orderResult = xpOrderClient.queryOrderById(Long.parseLong(orderId)); XpOrder xpOrder = orderResult == null ? null : orderResult.getData(); if (xpOrder == null) { log.warn("改派取消回调识别失败,订单不存在,orderId: {}, context: {}", orderId, cancelContext); return null; } Long newVehicleId = cancelContext.getLong("newVehicleId"); Integer currentStatus = xpOrder.getStatus(); boolean vehicleMatched = Objects.nonNull(newVehicleId) && Objects.equals(newVehicleId, xpOrder.getVehicleId()); boolean statusMatched = Objects.nonNull(currentStatus) && currentStatus > 0 && currentStatus < 8; if (vehicleMatched && statusMatched) { return cancelContext; } log.info("改派取消回调未命中专用上下文,orderId: {}, currentVehicleId: {}, newVehicleId: {}, currentStatus: {}", orderId, xpOrder.getVehicleId(), newVehicleId, currentStatus); return null; } private String resolveReassignCancelResponseVin(JSONObject cancelContext) { if (cancelContext == null) { return null; } String oldVehicleVin = cancelContext.getString("oldVehicleVin"); if (StringUtils.isNotEmpty(oldVehicleVin)) { return oldVehicleVin; } Long oldVehicleId = cancelContext.getLong("oldVehicleId"); if (Objects.isNull(oldVehicleId)) { return null; } R<XpVehicle> vehicleResult = xpVehicleClient.queryById(oldVehicleId); XpVehicle xpVehicle = vehicleResult == null ? null : vehicleResult.getData(); return xpVehicle == null ? null : xpVehicle.getVehicleVin(); } /** xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/config/MiniprogramConfigurer.java
@@ -24,7 +24,9 @@ // 使用安全的统一验证服务拦截器,避免 ClassCastException registry.addInterceptor(safeCheckForClientInterceptor) .addPathPatterns("/base/v1/mini-program/**", "/api/v1/mini-program/**") .excludePathPatterns("/base/v1/mini-program/fence/check", "/base/v1/mini-program/cities/list"); .excludePathPatterns("/base/v1/mini-program/fence/check" , "/base/v1/mini-program/cities/list" , "/base/v1/mini-program/point/getPointByIp"); log.info("小程序拦截器注册成功"); } catch (Exception e) { log.warn("小程序拦截器注册失败: {}", e.getMessage()); xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpMapController.java
@@ -92,14 +92,12 @@ List<HistoryPointDto> history = new ArrayList<>(); if(null != dto.getVehicleId()){ List<Object> cacheList = redisService.getCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId()); if(cacheList!=null && !cacheList.isEmpty()){ for (Object cache : cacheList) { HistoryPointDto historyPointDto = JSON.parseObject(cache.toString(), HistoryPointDto.class); history.add(historyPointDto); } } history = redisService.getCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId()); } if(history.size() > 10){ history = history.subList(history.size() - 10, history.size()); } redisService.setCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId(), history); RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), pointStrParam, fenceId,dto.getRoutePlanRule(), history); if(routeVo==null){ return R.fail("没有找到路线"); @@ -141,14 +139,12 @@ } List<HistoryPointDto> history = new ArrayList<>(); if(null != dto.getVehicleId()){ List<Object> cacheList = redisService.getCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId()); if(cacheList!=null && !cacheList.isEmpty()){ for (Object cache : cacheList) { HistoryPointDto historyPointDto = JSON.parseObject(cache.toString(), HistoryPointDto.class); history.add(historyPointDto); } } history = redisService.getCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId()); } if(history.size() > 10){ history = history.subList(history.size() - 10, history.size()); } redisService.setCacheList("VEHICLE_HISTORY_POINT_LIST:" + dto.getVehicleId(), history); RouteVo routeVo = gdMapGeocodingUtil.getDistanceAndTime(dto.getOrigin(), dto.getDestination(), pointStrParam, fenceId,dto.getRoutePlanRule(), history); if(routeVo==null){ return R.fail("没有找到路线"); xp-robotaxi-traffic-control-boot/Dockerfile
New file @@ -0,0 +1,16 @@ FROM registry.logan.xiaopeng.local/logancloud/logan-base:1.1.4-rc1-J1.8.0_372 LABEL maintainer="Linzhaoming <linzm2@xiaopeng.com>" ENV JAVA_OPTS="-Xmx1024m -Xms512m -XX:NewRatio=1 -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 \ -XX:+UseCMSInitiatingOccupancyOnly -XX:ReservedCodeCacheSize=128M -XX:ParallelGCThreads=2 \ -XX:+ExplicitGCInvokesConcurrent -Duser.timezone=Asia/Shanghai" ENTRYPOINT [ "sh", "-c", "java $APP_OPTS $JMX_OPTS $JAVA_OPTS $GCLOG_OPTS -Djava.security.egd=file:/dev/./urandom -jar xp-robotaxi-traffic-control-boot.jar" ] WORKDIR /home/xpmotors/local RUN mkdir -p /data/log/app/xp-robotaxi-traffic-control-boot /data/tomcat /data/files && chown -R xpmotors:xpmotors /data/log/app/xp-robotaxi-traffic-control-boot /data/tomcat /data/files COPY target/xp-robotaxi-traffic-control-boot-*-exec.jar /home/xpmotors/local/xp-robotaxi-traffic-control-boot.jar USER xpmotors