| | |
| | | package com.xiaopeng.order.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.xiaopeng.api.dto.account.UcUserInfo; |
| | | import com.xiaopeng.api.dto.vehicleConvoy.ServiceVehicleListDto; |
| | |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpVehicleClient; |
| | | import com.xiaopeng.api.model.order.XpOrder; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpVehicle; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.utils.StringUtils; |
| | | import com.xiaopeng.order.dto.UserOrderListDto; |
| | | import com.xiaopeng.order.mangodb.model.OrderTrajectory; |
| | | import com.xiaopeng.order.service.IXpOrderService; |
| | | import com.xiaopeng.order.vo.OrderInfoVo; |
| | | import com.xiaopeng.order.vo.ServiceOrderVo; |
| | | import com.xiaopeng.order.vo.ServiceVehicleListVo; |
| | | import com.xiaopeng.order.vo.UserOrderListVo; |
| | | import com.xiaopeng.order.vo.*; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @Resource |
| | | private UserResourcesClient userResourcesClient; |
| | | |
| | | @Resource |
| | | private MongoTemplate mongoTemplate; |
| | | |
| | | |
| | | /** |
| | | * 1. 判断 VIN 是否为 robotaxi 车辆 |
| | |
| | | @ApiOperation(value = "判断 VIN 是否为 robotaxi 车辆", notes = "客服系统对接") |
| | | @ApiImplicitParam(name = "vim", value = "VIN码", required = true, dataType = "string", paramType = "path") |
| | | public R<Boolean> isRobotaxi(@PathVariable String vim){ |
| | | if(StringUtils.isEmpty(vim)){ |
| | | return R.fail("VIM码不能为空"); |
| | | } |
| | | XpVehicle xpVehicle = xpVehicleClient.findByVehicleVin(vim).getData(); |
| | | if(null != xpVehicle){ |
| | | return R.ok(true); |
| | |
| | | @ApiOperation(value = "根据 VIN 查询在途/最近订单客户手机号", notes = "客服系统对接") |
| | | @ApiImplicitParam(name = "vim", value = "VIN码", required = true, dataType = "string", paramType = "path") |
| | | public R<ServiceOrderVo> getServiceOrder(@PathVariable String vim){ |
| | | if(StringUtils.isEmpty(vim)){ |
| | | return R.fail("VIM码不能为空"); |
| | | } |
| | | XpVehicle xpVehicle = xpVehicleClient.findByVehicleVin(vim).getData(); |
| | | if(null == xpVehicle){ |
| | | return R.fail("VIM码不存在"); |
| | | return R.ok(new ServiceOrderVo()); |
| | | } |
| | | XpOrder one = xpOrderService.getOne(new QueryWrapper<XpOrder>().eq("vehicle_id", xpVehicle.getId()) |
| | | .eq("is_deleted", 0).last(" order by create_time desc limit 1")); |
| | |
| | | @ApiOperation(value = "根据订单号查询订单详情", notes = "客服系统对接") |
| | | @ApiImplicitParam(name = "orderId", value = "订单ID", required = true, dataType = "Long", paramType = "path") |
| | | public R<OrderInfoVo> getOrderDetail(@PathVariable Long orderId){ |
| | | if(null == orderId){ |
| | | return R.fail("订单ID不能为空"); |
| | | } |
| | | return R.ok(xpOrderService.getOrderInfo(orderId)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 7. 根据订单号查询实际行驶路径 |
| | | * @param orderId |
| | | * @return |
| | | */ |
| | | @GetMapping("/getOrderHistoryTrajectory/{orderId}") |
| | | @ApiOperation(value = "根据订单号查询实际行驶路径", notes = "客服系统对接") |
| | | @ApiImplicitParam(name = "orderId", value = "订单ID", required = true, dataType = "Long", paramType = "path") |
| | | public R<List<TrajectoryVo>> getOrderHistoryTrajectory(@PathVariable Long orderId){ |
| | | List<OrderTrajectory> orderTrajectoryList = mongoTemplate.find(Query.query(Criteria.where("orderId").is(orderId)), OrderTrajectory.class); |
| | | List<TrajectoryVo> collect = orderTrajectoryList.stream().map(trajectory -> { |
| | | String[] split = trajectory.getLocation().split(","); |
| | | TrajectoryVo jsonObject = new TrajectoryVo(); |
| | | jsonObject.setLng(Double.parseDouble(split[0])); |
| | | jsonObject.setLat(Double.parseDouble(split[1])); |
| | | return jsonObject; |
| | | }).collect(Collectors.toList()); |
| | | return R.ok(collect); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 10. 根据 VIN 查询剩余电量及预估续航 |
| | | * @param vin |
| | | * @return |
| | | */ |
| | | @GetMapping("/getVehicleRange/{vin}") |
| | | @ApiOperation(value = "根据 VIN 查询剩余电量及预估续航", notes = "客服系统对接") |
| | | @ApiImplicitParam(name = "vin", value = "vin码", required = true, dataType = "string", paramType = "path") |
| | | public R<VehicleRangeVo> getVehicleRange(@PathVariable String vin){ |
| | | VehiclePosition vehiclePositions = mongoTemplate.findOne(Query.query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | | if(null == vehiclePositions){ |
| | | return R.ok(new VehicleRangeVo()); |
| | | } |
| | | VehicleRangeVo vo = new VehicleRangeVo(); |
| | | vo.setBatteryLevel(vehiclePositions.getCurrentElectricity()); |
| | | vo.setEstimatedRange(Double.valueOf(vehiclePositions.getMileageRange())); |
| | | return R.ok(vo); |
| | | } |
| | | } |