From 0c738efb5ecca9727ed4b0cf01250c4c07e83b3c Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期六, 28 二月 2026 20:29:24 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/Robotaxi
---
xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java | 130 +++++++++++++++++++++----------------------
1 files changed, 64 insertions(+), 66 deletions(-)
diff --git a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
index 24150c9..73245f4 100644
--- a/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
+++ b/xp-robotaxi-order-boot/src/main/java/com/xiaopeng/order/service/impl/XpOrderServiceImpl.java
@@ -870,7 +870,7 @@
Page<XpOrderHistoryListVO> page = new Page<>(query.getPageNum(), query.getPageSize());
List<XpOrderHistoryListVO> list = this.baseMapper.getHistoryOrderList(page, query, Long.parseLong(uid));
XpOrderHistoryVO xpOrderHistoryVO = new XpOrderHistoryVO();
- if (list.isEmpty()) {
+ if(list.isEmpty()){
return xpOrderHistoryVO;
}
@@ -894,7 +894,7 @@
for (XpOrderHistoryListVO xpOrderHistoryListVO : value) {
XpPoint xpPoint = pointList.stream().filter(e -> e.getId().equals(xpOrderHistoryListVO.getStartPointId())).findFirst().orElse(null);
- if (xpPoint != null) {
+ if(xpPoint!=null){
xpOrderHistoryListVO.setStartPointName(xpPoint.getPointName());
xpOrderHistoryListVO.setStartLat(xpPoint.getPointLat());
xpOrderHistoryListVO.setStartLon(xpPoint.getPointLon());
@@ -903,7 +903,7 @@
}
xpPoint = pointList.stream().filter(e -> e.getId().equals(xpOrderHistoryListVO.getEndPointId())).findFirst().orElse(null);
- if (xpPoint != null) {
+ if(xpPoint!=null){
xpOrderHistoryListVO.setEndPointName(xpPoint.getPointName());
xpOrderHistoryListVO.setEndLat(xpPoint.getPointLat());
xpOrderHistoryListVO.setEndLon(xpPoint.getPointLon());
@@ -933,13 +933,13 @@
public void cancelOrder(Long orderId, String uid) {
XpOrder order = this.getById(orderId);
if (order == null) {
- throw new ServiceException("订单不存在", I18nKeyConstant.ORDER_NOT_EXISTS);
+ throw new ServiceException("订单不存在",I18nKeyConstant.ORDER_NOT_EXISTS);
}
if (!order.getAppUserId().toString().equals(uid)) {
- throw new ServiceException("订单不存在", I18nKeyConstant.ORDER_NOT_EXISTS);
+ throw new ServiceException("订单不存在",I18nKeyConstant.ORDER_NOT_EXISTS);
}
if (order.getStatus() > 5 || order.getStatus() < 1) {
- throw new ServiceException("订单状态错误", I18nKeyConstant.ORDER_STATUS_ERROR);
+ throw new ServiceException("订单状态错误",I18nKeyConstant.ORDER_STATUS_ERROR);
}
order.setStatus(0);
@@ -949,7 +949,7 @@
R<XpVehicle> xpVehicleR = xpVehicleClient.queryById(vehicleId);
XpVehicle xpVehicle = xpVehicleR.getData();
if (xpVehicle == null) {
- throw new ServiceException("车辆不存在", I18nKeyConstant.VEHICLE_NOT_EXISTS);
+ throw new ServiceException("车辆不存在",I18nKeyConstant.VEHICLE_NOT_EXISTS);
}
cancelTaxiPassengerVo.setVin(xpVehicle.getVehicleVin());
cancelTaxiPassengerVo.setUid(order.getAppUserId().toString());
@@ -958,7 +958,7 @@
cancelTaxiPassengerVo.setAppId("");
BaseVehicleUserDto baseVehicleUserDto = userVehicleClient.cancelTaxiPassenger(cancelTaxiPassengerVo);
- if (baseVehicleUserDto == null) {
+ if (baseVehicleUserDto==null) {
// TODO 本地无法调通
// throw new RuntimeException("取消订单失败");
}
@@ -982,7 +982,7 @@
}
// 下发命令
- if (order.getStatus() > 1) {
+ if(order.getStatus()>1){
PushOrderDto pushOrderDto = new PushOrderDto();
pushOrderDto.setOrderId(order.getId().toString());
pushOrderDto.setVin(xpVehicle.getVehicleVin());
@@ -997,7 +997,7 @@
public void cancelOrder(String orderId) {
XpOrder order = this.getById(orderId);
if (order == null) {
- throw new ServiceException("订单不存在", I18nKeyConstant.ORDER_NOT_EXISTS);
+ throw new ServiceException("订单不存在",I18nKeyConstant.ORDER_NOT_EXISTS);
}
order.setStatus(0);
baseMapper.updateById(order);
@@ -1030,7 +1030,7 @@
log.info("订单取消消息推送完毕");
// 下发命令
- if (order.getStatus() > 1) {
+ if(order.getStatus()>1){
PushOrderDto pushOrderDto = new PushOrderDto();
pushOrderDto.setOrderId(order.getId().toString());
pushOrderDto.setVin(xpVehicle.getVehicleVin());
@@ -1051,13 +1051,13 @@
public void comment(XpOrderCommentDto dto, String uid) {
XpOrder xpOrder = this.getById(dto.getOrderId());
if (xpOrder == null) {
- throw new ServiceException("订单不存在", I18nKeyConstant.ORDER_NOT_EXISTS);
+ throw new ServiceException("订单不存在",I18nKeyConstant.ORDER_NOT_EXISTS);
}
if (!xpOrder.getAppUserId().toString().equals(uid)) {
- throw new ServiceException("订单不存在", I18nKeyConstant.ORDER_NOT_EXISTS);
+ throw new ServiceException("订单不存在",I18nKeyConstant.ORDER_NOT_EXISTS);
}
if (xpOrder.getStatus() != 9) {
- throw new ServiceException("订单状态错误", I18nKeyConstant.ORDER_STATUS_ERROR);
+ throw new ServiceException("订单状态错误",I18nKeyConstant.ORDER_STATUS_ERROR);
}
xpOrder.setAppUserId(null);
xpOrder.setStatus(10);
@@ -1176,6 +1176,7 @@
}
+
// 根据订单所属开通城市id 查询定价
R<XpPricing> pricingByCityId = xpPricingClient.getPricingByCid(order.getCityId());
XpPricing pricing = pricingByCityId.getData();
@@ -1194,13 +1195,13 @@
// TaxiPricingDemoService.GpsPoint point = new TaxiPricingDemoService.GpsPoint(trajectory.getDistance(), trajectory.getLocatetime());
// gpsPoints.add(point);
// }
- // 补充临时轨迹数据
+ // 补充临时轨迹数据
List<TaxiPricingDemoService.GpsPoint> gpsPoints = TaxiPricingDemoService.createMockGpsPoints(DateUtils.toDate(order.getCreateTime()));
TaxiPricingDemoService.PricingConfig config = new TaxiPricingDemoService.PricingConfig();
JSONArray startingFareJsonArray = JSONArray.parseArray(pricing.getStartingFareJson());
- if (pricing.getPricingType() == 1) {
+ if(pricing.getPricingType()==1){
JSONObject basicPricingJson = JSONObject.parseObject(pricing.getBasicPricingJson());
config.peaks.add(new TaxiPricingDemoService.PricingRule("高峰期", basicPricingJson.getString("num21").split(" - ")[0], basicPricingJson.getString("num21").split(" - ")[1], Double.parseDouble(basicPricingJson.getString("num24")), Double.parseDouble(basicPricingJson.getString("num25")), Double.parseDouble(basicPricingJson.getString("num26")), Double.parseDouble(basicPricingJson.getString("num27")), Double.parseDouble(basicPricingJson.getString("num28"))));
config.peaks.add(new TaxiPricingDemoService.PricingRule("高峰期", basicPricingJson.getString("num22").split(" - ")[0], basicPricingJson.getString("num22").split(" - ")[1], Double.parseDouble(basicPricingJson.getString("num24")), Double.parseDouble(basicPricingJson.getString("num25")), Double.parseDouble(basicPricingJson.getString("num26")), Double.parseDouble(basicPricingJson.getString("num27")), Double.parseDouble(basicPricingJson.getString("num28"))));
@@ -1235,7 +1236,7 @@
System.err.println("--------------------------");
System.err.println("应付总额: " + totalAmount + " 元");
BigDecimal startMoney = BigDecimal.ZERO;
- // 默认费率1
+ // 默认费率1
double priceRate = 1;
if (pricing.getIsDynamicPrice() == 1) {
// 先判断是否已经调价过了
@@ -1383,11 +1384,11 @@
xpOrderDetailMapper.insert(xpOrderDetail);
}
for (XpOrderDetail xpOrderDetail : xpOrderDetails) {
- if (xpOrderDetail.getDetailType() == 1) {
+ if (xpOrderDetail.getDetailType() == 1){
order.setDurationType(xpOrderDetail.getType());
order.setDurationMoney(xpOrderDetail.getMoney());
order.setDuration(Double.parseDouble(xpOrderDetail.getDuration() + ""));
- } else {
+ }else{
order.setLongDistanceType(order.getDurationType());
order.setLongDistance(xpOrderDetail.getMileage().doubleValue());
order.setLongDistancemoney(xpOrderDetail.getMoney());
@@ -1397,7 +1398,7 @@
BigDecimal orderMoney = startMoney.add(mileageMoney).add(order.getDurationMoney() != null ? order.getDurationMoney() : BigDecimal.ZERO)
.add(order.getLongDistancemoney() != null ? order.getLongDistancemoney() : BigDecimal.ZERO)
- .add(order.getWaitMoney() != null ? order.getWaitMoney() : BigDecimal.ZERO);
+ .add(order.getWaitMoney()!=null?order.getWaitMoney():BigDecimal.ZERO);
order.setOrderMoney(orderMoney);
order.setAppUserId(null);
baseMapper.updateById(order);
@@ -1410,7 +1411,7 @@
useUserCouponDto.setUserCouponId(order.getCouponId());
xpAppUserCouponClient.useUserCoupon(useUserCouponDto);
}
- // 计算完价格后 挑选优惠券
+ // 计算完价格后 挑选优惠券
GetUserCouponDto getUserCouponDto = new GetUserCouponDto();
getUserCouponDto.setUserId(Long.valueOf(uid));
getUserCouponDto.setTotalAmount(order.getOrderMoney().doubleValue());
@@ -1424,8 +1425,11 @@
baseMapper.updateById(order);
+
+
+
// 结束后的车辆操作
- if (vehicle != null) {
+ if(vehicle!=null){
// 修改车辆状态
vehicle.setState(0);
@@ -1435,11 +1439,11 @@
// 生成新的巡游单子 回到最新巡游的初始起点位置
XpCruiseOrder xpCruiseOrders = xpCruiseOrderMapper.selectOne(new LambdaQueryWrapper<XpCruiseOrder>().eq(XpCruiseOrder::getVehicleId, vehicle.getId()).eq(XpCruiseOrder::getStatus, 2).orderByDesc(BaseModel::getCreateTime).last("limit 1"));
- int temp = 0;
- if (xpCruiseOrders == null) {
- temp = 1;
+ int temp=0;
+ if(xpCruiseOrders==null){
+ temp=1;
//特殊情况 可能没有产生终止的订单 (到站点就被正常接单了)所以找正常订单
- xpCruiseOrders = xpCruiseOrderMapper.selectOne(new LambdaQueryWrapper<XpCruiseOrder>().eq(XpCruiseOrder::getVehicleId, vehicle.getId()).eq(XpCruiseOrder::getStatus, 3).orderByDesc(BaseModel::getCreateTime).last("limit 1"));
+ xpCruiseOrders=xpCruiseOrderMapper.selectOne(new LambdaQueryWrapper<XpCruiseOrder>().eq(XpCruiseOrder::getVehicleId, vehicle.getId()).eq(XpCruiseOrder::getStatus, 3).orderByDesc(BaseModel::getCreateTime).last("limit 1"));
}
XpCruiseOrder xpCruiseOrder = new XpCruiseOrder();
xpCruiseOrder.setVehicleId(vehicle.getId());
@@ -1453,12 +1457,12 @@
xpCruiseOrder.setStartLat(order.getEndLat());
// 完成的直接走终点 终止的走起点
- if (temp == 0) {
+ if(temp==0){
xpCruiseOrder.setEndPointId(xpCruiseOrders.getStartPointId());
xpCruiseOrder.setEndPointName(xpCruiseOrders.getStartPointName());
xpCruiseOrder.setEndLon(xpCruiseOrders.getStartLon());
xpCruiseOrder.setEndLat(xpCruiseOrders.getStartLat());
- } else {
+ }else {
xpCruiseOrder.setEndPointId(xpCruiseOrders.getEndPointId());
xpCruiseOrder.setEndPointName(xpCruiseOrders.getEndPointName());
xpCruiseOrder.setEndLon(xpCruiseOrders.getEndLon());
@@ -1469,7 +1473,7 @@
xpCruiseOrder.setStatus(1);
xpCruiseOrder.setLastOrderId(xpCruiseOrders.getId());
xpCruiseOrder.setCreateTime(LocalDateTime.now());
- xpCruiseOrder.setId("XU" + IdUtil.fastUUID());
+ xpCruiseOrder.setId("XU"+ IdUtil.fastUUID());
// 判断当前时分秒是否大于收车时间
LocalTime vehicleCollectionTime = xpTaskRule.getVehicleCollectionTime();
@@ -1502,6 +1506,15 @@
}
+
+
+
+
+
+
+
+
+
}
@@ -1726,14 +1739,14 @@
detail.setTime(xpOrderDetail.getTime());
detail.setMileage(xpOrderDetail.getMileage());
detail.setDuration(xpOrderDetail.getDuration());
- if (xpOrderDetail.getDetailType() == 1) {
+ if (xpOrderDetail.getDetailType() == 1){
start.add(detail);
- } else {
+ }else{
mileage.add(detail);
}
}
List<FareBreakdownDetailVo> duration = new ArrayList<>();
- if (order.getDuration() != null && order.getDuration() > 0) {
+ if (order.getDuration()!=null&&order.getDuration()>0){
FareBreakdownDetailVo durationDetail = new FareBreakdownDetailVo();
durationDetail.setType(order.getDurationType());
durationDetail.setDuration(order.getDuration());
@@ -1742,24 +1755,24 @@
}
List<FareBreakdownDetailVo> longDistance = new ArrayList<>();
- if (order.getLongDistance() != null && order.getLongDistance() > 0) {
+ if (order.getLongDistance()!=null&&order.getLongDistance()>0){
FareBreakdownDetailVo longDistanceDetail = new FareBreakdownDetailVo();
longDistanceDetail.setType(order.getLongDistanceType());
longDistanceDetail.setMileage(BigDecimal.valueOf(order.getLongDistance()));
longDistanceDetail.setMoney(order.getLongDistancemoney());
longDistance.add(longDistanceDetail);
}
- res.setStart(start);
- res.setMileage(mileage);
- res.setDuration(duration);
- res.setLongDistance(longDistance);
+ res.setStart( start);
+ res.setMileage( mileage);
+ res.setDuration( duration);
+ res.setLongDistance( longDistance);
res.setRedPacketMoney(order.getRedPacketMoney());
res.setCouponMoney(order.getCouponMoney());
res.setOrderMoney(order.getOrderMoney());
- res.setKilometer(order.getMileageKilometers() == null ? BigDecimal.ZERO : BigDecimal.valueOf(order.getMileageKilometers()));
+ res.setKilometer(order.getMileageKilometers()==null?BigDecimal.ZERO:BigDecimal.valueOf(order.getMileageKilometers()));
LocalDateTime createTime = order.getCreateTime();
LocalDateTime tripEnd = order.getTripEnd();
- if (tripEnd == null) {
+ if (tripEnd==null){
tripEnd = LocalDateTime.now();
order.setTripEnd(tripEnd);
this.updateById(order);
@@ -1912,7 +1925,7 @@
XpPricing pricing = pricingByCityId.getData();
if (pricing == null) {
throw new ServiceException("当前城市未配置定价规则", I18nKeyConstant.ORDER_PRICING_NOT_EXISTS);
- } else {
+ }else{
return R.ok(pricing.getPriceRule());
}
}
@@ -1930,34 +1943,17 @@
String orderType = dto.getOrderType();
Long orderId = dto.getOrderId();
//巡游单处理逻辑
- if (OrderType.CRUISE_ORDER.equals(orderType)) {
+ if(OrderType.CRUISE_ORDER.equals(orderType)){
// todo 需要处理巡游的逻辑
+
}
//乘客单处理逻辑
- if (OrderType.USER_ORDER.equals(orderType)) {
+ if(OrderType.USER_ORDER.equals(orderType)){
XpOrder order = this.getById(orderId);
-
- // 判断是否改派的 查看是否有车信息
- if (order.getVehicleId() != null) {
- R<XpVehicle> oldVehicleR = xpVehicleClient.queryById(order.getVehicleId());
- XpVehicle oldVehicle = oldVehicleR.getData();
- if (oldVehicle != null) {
- // 解绑
- CancelTaxiPassengerVo cancelTaxiPassengerVo = new CancelTaxiPassengerVo();
- cancelTaxiPassengerVo.setVin(oldVehicle.getVehicleVin());
- cancelTaxiPassengerVo.setUid(order.getAppUserId().toString());
- cancelTaxiPassengerVo.setOrderNo(order.getOrderNumber());
- // TODO
- cancelTaxiPassengerVo.setAppId("");
- userVehicleClient.cancelTaxiPassenger(cancelTaxiPassengerVo);
- }
-
- }
-
//订单为待接单状态
- if (order.getStatus() == 1) {
+ if(order.getStatus() == 1){
AddTaxiPassengerVo addTaxiPassengerVo = new AddTaxiPassengerVo();
order.setAcceptanceTime(LocalDateTime.now());
R<XpVehicle> byVehicleVin = xpVehicleClient.findByVehicleVin(dto.getXpVehicleVin());
@@ -1992,7 +1988,7 @@
userVehicleClient.addTaxiPassenger(addTaxiPassengerVo);
//推送乘客车辆到达预约点的导航数据
sendRoute(order.getAppUserId().toString(), orderId, "ORDER_NAVIGATION_START_DATA");
- } else {
+ }else{
//推送行起点到终点的驶轨迹给乘客端
sendRoute(order.getAppUserId().toString(), orderId, "ORDER_NAVIGATION_END_DATA");
}
@@ -2005,9 +2001,9 @@
* @param appUserId
* @param keyStr
*/
- public void sendRoute(String appUserId, Long orderId, String keyStr) {
+ public void sendRoute(String appUserId, Long orderId, String keyStr){
Object cacheObject = redisService.getCacheObject(keyStr + ":" + appUserId);
- if (null != cacheObject) {
+ if(null != cacheObject){
RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class);
JSONObject jsonObject = new JSONObject();
jsonObject.put("type", "ORDER_ROUTE");
@@ -2020,7 +2016,7 @@
route.put("duration", routeVo.getDuration());
route.put("routeID", routeVo.getRouteID());
- List<JSONObject> collect = routeVo.getPolyline().stream().map(item -> {
+ List<JSONObject> collect = routeVo.getPolyline().stream().map(item->{
JSONObject point = new JSONObject();
point.put("latitude", item.getLatitude());
point.put("longitude", item.getLongitude());
@@ -2038,6 +2034,8 @@
}
+
+
/**
* 获取当前用户正在执行的订单
*
@@ -2047,7 +2045,7 @@
@Override
public XpOrderDetailVO getActiveOrder(String uid) {
XpOrderDetailVO xpOrderDetailVO = new XpOrderDetailVO();
- XpOrder xpOrder = this.baseMapper.selectOne(new LambdaQueryWrapper<XpOrder>().eq(XpOrder::getAppUserId, Long.parseLong(uid)).in(XpOrder::getStatus, Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8)).orderByDesc(BaseModel::getCreateTime).last("LIMIT 1"));
+ XpOrder xpOrder = this.baseMapper.selectOne(new LambdaQueryWrapper<XpOrder>().eq(XpOrder::getAppUserId, Long.parseLong(uid)).in(XpOrder::getStatus, Arrays.asList(1,2,3, 4, 5, 6, 7, 8)).orderByDesc(BaseModel::getCreateTime).last("LIMIT 1"));
if (xpOrder == null) {
return null;
}
--
Gitblit v1.7.1