xp-robotaxi-account-boot/src/main/java/com/xiaopeng/account/service/impl/XpAppUserCouponServiceImpl.java
@@ -173,8 +173,8 @@ xpAppUserCoupon.setMoney(xpCoupon.getAmount()); xpAppUserCoupon.setCouponId(dto.getCouponId()); xpAppUserCoupon.setAppUserId(uid); xpAppUserCoupon.setExpirationTime(LocalDateTime.now().plusDays(100)); xpAppUserCoupon.setStatus(0); xpAppUserCoupon.setExpirationTime(LocalDateTime.now().plusDays(7)); xpAppUserCoupon.setStatus(1); xpAppUserCoupon.setCouponType(xpCoupon.getCouponType()); xpAppUserCoupon.setPhone(phone); xp-robotaxi-api/src/main/java/com/xiaopeng/api/dto/operation/LonLatCityCodeDto.java
New file @@ -0,0 +1,28 @@ package com.xiaopeng.api.dto.operation; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import javax.validation.constraints.NotNull; @Data @ApiModel(value = "经纬度DTO") @AllArgsConstructor @NoArgsConstructor public class LonLatCityCodeDto { @ApiModelProperty(value = "经度") @NotNull(message = "经度不能为空") private Double longitude; @ApiModelProperty(value = "纬度") @NotNull(message = "纬度不能为空") private Double latitude; @ApiModelProperty(value = "城市编码") private String cityCode; } xp-robotaxi-api/src/main/java/com/xiaopeng/api/dto/operation/LonLatDto.java
@@ -21,4 +21,6 @@ @ApiModelProperty(value = "纬度") @NotNull(message = "纬度不能为空") private Double latitude; } xp-robotaxi-automatic-pilot-boot/src/main/java/com/xiaopeng/automaticPilot/service/KafkaConsumerService.java
@@ -422,15 +422,15 @@ log.info("订单的任务未开始执行"); break; case ROUTE_TO_PICKUP: log.info("驶往上车点的行程"); log.info("驶往上车点的行程 {}", orderId); buildNaviRequest(requestId, orderId, orderPhase, msgContent.getHeader().getSequence()); break; case ROUTE_TO_DESTINATION: log.info("驶往下车点的行程"); log.info("驶往下车点的行程 {}", orderId); buildNaviRequest(requestId, orderId, orderPhase, msgContent.getHeader().getSequence()); break; case ROUTE_TO_CRUISE: log.info("巡游阶段路线"); log.info("巡游阶段路线 {}", orderId); buildNaviRequest(requestId, orderId, orderPhase, msgContent.getHeader().getSequence()); break; } @@ -467,7 +467,7 @@ LonLatDto origin = new LonLatDto(); if (orderId.contains("XU")) { orderType = OrderType.CRUISE_ORDER; // orderType = OrderType.CRUISE_ORDER; R<XpCruiseOrder> cruiseOrder = xpCruiseOrderClient.getCruiseOrder(orderId); XpCruiseOrder xpCruiseOrder = cruiseOrder.getData(); @@ -484,17 +484,18 @@ 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(); // routeID = routeVo.getRouteID(); vehicleId = xpCruiseOrder.getVehicleId(); // vehicleId = xpCruiseOrder.getVehicleId(); } else { orderType = OrderType.USER_ORDER; // orderType = OrderType.USER_ORDER; //正常单 R<XpOrder> xpOrderR = xpOrderClient.queryOrderById(Long.parseLong(orderId)); if (200 != xpOrderR.getCode()) { @@ -516,12 +517,13 @@ 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(); // routeID = routeVo.getRouteID(); //缓存数据,用于后续推给乘客导航线路 redisService.setCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(), JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); } @@ -536,16 +538,17 @@ 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(); // routeID = routeVo.getRouteID(); //缓存导航数据,用于后面的逻辑中给乘客端推送导航数据 redisService.setCacheObject("ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId(), com.alibaba.fastjson.JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); } vehicleId = xpOrder.getVehicleId(); // vehicleId = xpOrder.getVehicleId(); } // TODO 在请求导航哪里返回导航数据 @@ -594,6 +597,7 @@ 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("获取订单线路和运费失败"); @@ -609,7 +613,7 @@ //正常单 R<XpOrder> xpOrderR = xpOrderClient.queryOrderById(Long.parseLong(orderId)); if (200 != xpOrderR.getCode()) { throw new RuntimeException("订单不存在"); throw new RuntimeException("订单不存在 " + orderId); } XpOrder xpOrder = xpOrderR.getData(); XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); @@ -630,6 +634,7 @@ 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("获取订单线路和运费失败"); @@ -654,6 +659,7 @@ 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("获取订单线路和运费失败"); @@ -671,11 +677,13 @@ } if(StringUtils.isNotEmpty(routeID)){ log.info("开始推送导航信息 {}", orderId); XpVehicle xpVehicle = xpVehicleClient.queryById(vehicleId).getData(); R<String> stringR = xpMapClient.queryRouted(routeID); if (200 != stringR.getCode()) { throw new RuntimeException("根据导航ID获取车端需要的导航数据失败"); } log.info("根据导航ID获取车端需要的导航数据 订单 {} 导航数据 {}", orderId, stringR.getData()); //构建导航下发请求对象 cloudPushNavigationInfo(requestId, routeID, stringR.getData(), orderType, orderId, xpVehicle.getVehicleVin(), xpVehicle.getXpuId()); } @@ -1027,13 +1035,7 @@ SnowFlake snowFlake = new SnowFlake(0, 0); snowFlake.withStartTimestamp(1420041600000L); long sequence = snowFlake.nextId(); // 处理数据 JSONObject jsonObject = new JSONObject(); jsonObject.put("event", SystemEventType.PUSH_NAVIGATION); jsonObject.put("orderType", orderType); jsonObject.put("orderId", orderId); jsonObject.put("vin", vin); redisTemplate.opsForValue().set(sequence, jsonObject.toJSONString(),30, TimeUnit.MINUTES); log.info("开始推送导航数据 {}", orderId); MqttPublishDto mqttPublishDto = xpuUtil.cloudPushNavigation(navigationDataBuilder.build(), xpuId, sequence); log.info("推送导航的响应消息,{}", JSON.toJSONString(mqttPublishDto)); } xp-robotaxi-itinerary-boot/src/main/java/com/xiaopeng/itinerary/service/impl/XpPricingServiceImpl.java
@@ -377,6 +377,9 @@ // 12. 设置费用信息 fareVo.setFinalFareStr(new BigDecimal(fareVo.getFinalFare()).setScale(2, RoundingMode.HALF_UP).toString()); if("0.00".equals(fareVo.getFinalFareStr())){ fareVo.setFinalFareStr("0.0"); } fareVo.setOriginalFare(new BigDecimal(fareVo.getOriginalFare()).setScale(2,RoundingMode.HALF_UP).doubleValue()); fareVo.setSystemDiscount(new BigDecimal(fareVo.getSystemDiscount()).setScale(2,RoundingMode.HALF_UP).doubleValue()); routeAndFareVo.setFareEstimate(fareVo); @@ -578,6 +581,7 @@ } XpOpenCity xpOpenCity = openCities.get(0); dto.setOpenCityId(xpOpenCity.getId()); xpOrder.setCityCode(xpOpenCity.getCityCode()); XpRoutePlan xpRoutePlan = xpRoutePlanMapper.selectOne(new LambdaQueryWrapper<XpRoutePlan>().eq(XpRoutePlan::getAuditStatus, 2).eq(XpRoutePlan::getCityCode, xpOpenCity.getCityCode())); if (xpRoutePlan != null) { routeAndFareDto.setRoutePlanRule(xpRoutePlan.getRoutePlanRule()); xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/controller/XpElectronicFenceController.java
@@ -2,6 +2,7 @@ import com.xiaopeng.api.dto.map.RouteAndFareDto; import com.xiaopeng.api.dto.operation.LonLatCityCodeDto; import com.xiaopeng.api.dto.operation.LonLatDto; import com.xiaopeng.api.vo.operation.XpElectronicFenceVo; import com.xiaopeng.common.core.domain.R; @@ -55,7 +56,7 @@ @ApiOperation(value = "判断当前位置是否在运营区域内",tags = {"小程序-判断当前位置是否在运营区域内"}) @PostMapping("/base/v1/mini-program/fence/check") public R<IsInOperationAreaVo> isInOperationArea(@RequestBody @Valid LonLatDto dto) { public R<IsInOperationAreaVo> isInOperationArea(@RequestBody @Valid LonLatCityCodeDto dto) { return R.ok(xpElectronicFenceAreaService.isInOperationArea(dto)); } xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/XpElectronicFenceAreaService.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.xiaopeng.api.dto.map.RouteAndFareDto; import com.xiaopeng.api.dto.operation.LonLatCityCodeDto; import com.xiaopeng.api.dto.operation.LonLatDto; import com.xiaopeng.api.model.operation.XpElectronicFenceArea; import com.xiaopeng.api.vo.operation.XpElectronicFenceVo; @@ -35,7 +36,7 @@ * @param dto * @return */ IsInOperationAreaVo isInOperationArea(LonLatDto dto); IsInOperationAreaVo isInOperationArea(LonLatCityCodeDto dto); /** xp-robotaxi-map-boot/src/main/java/com/xiaopeng/map/service/serviceimpl/XpElectronicFenceAreaServiceImpl.java
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xiaopeng.api.dto.map.RouteAndFareDto; import com.xiaopeng.api.dto.operation.LonLatCityCodeDto; import com.xiaopeng.api.dto.operation.LonLatDto; import com.xiaopeng.api.feignClient.operation.XpElectronicFenceClient; import com.xiaopeng.api.feignClient.operation.XpSystemSettingClient; @@ -204,14 +205,14 @@ * @return */ @Override public IsInOperationAreaVo isInOperationArea(LonLatDto dto) { public IsInOperationAreaVo isInOperationArea(LonLatCityCodeDto dto) { IsInOperationAreaVo vo = new IsInOperationAreaVo(); Map<String, String> geocode = gdMapGeocodingUtil.geocode(dto.getLongitude().toString(), dto.getLatitude().toString()); if(null == geocode){ throw new RuntimeException("经纬度转换城市code失败"); } String cityCode = geocode.get("cityCode"); // Map<String, String> geocode = gdMapGeocodingUtil.geocode(dto.getLongitude().toString(), dto.getLatitude().toString()); // if(null == geocode){ // throw new RuntimeException("经纬度转换城市code失败"); // } String cityCode = dto.getCityCode(); List<XpGeoFencingPolygon> xpGeoFencingPolygons = mongoTemplate.find(new Query(Criteria.where("cityCode").is(cityCode)), XpGeoFencingPolygon.class); for (XpGeoFencingPolygon polygon : xpGeoFencingPolygons) { if (polygon.getPoints() != null && polygon.getPoints().getCoordinates() != null) { xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/dto/NearestDto.java
@@ -17,4 +17,6 @@ @ApiModelProperty(value = "经度") @NotNull(message = "经度不能为空") private Double longitude; } xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/service/impl/XpPointServiceImpl.java
@@ -137,13 +137,15 @@ // 计算距离 小于的站点 double v = FastDistanceCalculator.distanceFastKm(dto.getLatitude(), dto.getLongitude(), xpPoint.getPointLat(), xpPoint.getPointLon()); if (v < orderDistance) { // m做判断 if ((v*1000) < orderDistance) { NearestNextVo nearestNextVo = new NearestNextVo(); nearestNextVo.setId(xpPoint.getId()); nearestNextVo.setName(xpPoint.getPointName()); nearestNextVo.setLatitude(xpPoint.getPointLat()); nearestNextVo.setLongitude(xpPoint.getPointLon()); nearestNextVo.setDistance(v); nearestNextVo.setDistance(new BigDecimal(v).setScale(2, RoundingMode.HALF_UP).doubleValue()); nearestNextVo.setAddress(xpPoint.getPointAddress()); nearestNextVo.setTime(xpPoint.getParkingTimeLimit()); nearestNextVo.setElectronicAreaId(xpPoint.getElectronicAreaId()); xp-robotaxi-operation-boot/src/main/java/com/xiaopeng/operation/utils/TaskOrderUtil.java
@@ -213,7 +213,7 @@ if (xpOrderR.getCode() == 200) { XpOrder xpOrder = xpOrderR.getData(); if (xpOrder.getStatus() == 1) { log.info("五轮推单结束,无车辆接单,执行取消订单 {}", orderNo); log.error("五轮推单结束,无车辆接单,执行取消订单 {}", orderNo); xpOrderClient.cancelOrder(orderId); //推送订单状态给乘客 SendMessageDTO dto = new SendMessageDTO(); @@ -262,7 +262,7 @@ for (int i = 0; i < count; i++) { //等到sleepTime秒钟 Thread.sleep(sleepTime * 1000); log.info("进入找车环节 单号 {} 第{}轮", orderNo, count++); // log.info("进入找车环节 单号 {} 第{}轮", orderNo, count++); // 根据距离找车 // 车多则根据配置找具体车数量 根据距离最近 // 更改 暂不限制数量 xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
@@ -1043,6 +1043,9 @@ @Transactional public void cancelOrder(Long orderId, String uid) { XpOrder order = this.getById(orderId); if(order.getStatus()==0){ return; } if (order == null) { throw new ServiceException("订单不存在", I18nKeyConstant.ORDER_NOT_EXISTS); }