Merge remote-tracking branch 'origin/master'
# Conflicts:
# xp-robotaxi-vehicle-convoy-boot/src/main/java/com/xiaopeng/vehicleConvoy/service/impl/XpVehicleServiceImpl.java
| | |
| | | |
| | | private String routeID; |
| | | |
| | | @ApiModelProperty(value = "方向角度") |
| | | private Double direction; |
| | | |
| | | private List<LonLatDto> polyline; |
| | | } |
| | |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | |
| | | import java.util.concurrent.LinkedBlockingQueue; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | |
| | | } |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | //缓存数据,用于后续推给乘客导航线路 |
| | | redisService.setCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(), com.alibaba.fastjson.JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | redisService.setCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(), JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | |
| | | PopOrderDto dto1 = new PopOrderDto(); |
| | | dto1.setOrderId(Long.valueOf(orderId)); |
| | |
| | | //构建推送消息 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", orderId); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("status", 3); |
| | | params.put("type", PushMessageTypeEnum.ORDER_STATUS.getDesc()); |
| | | params.put("content", JSONObject.toJSONString(content)); |
| | |
| | | log.error("推送消息失败:{}", stringR.getMsg()); |
| | | } |
| | | xpOrderClient.updateOrderStatus(orderId, OrderStatusEnum.PICK_UP.getCode()); |
| | | |
| | | // PushOrderRouteDTO dto3 = new PushOrderRouteDTO(); |
| | | // dto3.setOrderId(orderId); |
| | | // dto3.setRouteType(1); |
| | | // dto3.setLongitude(startLon); |
| | | // dto3.setLatitude(startLat); |
| | | // dto3.setDuration(10); |
| | | // dto3.setDistance(2); |
| | | // dto3.setDirection(60); |
| | | // xpPushMessageClient.pushOrderRoute(dto3); |
| | | |
| | | return r; |
| | | } |
| | | |
| | |
| | | Double longitude = lonLatDto.getLongitude(); |
| | | |
| | | //保存车辆实时位置到redis |
| | | redisTemplate.opsForGeo().add("vehiclePosition:" + vin, new GeoJsonPoint(longitude, latitude), vin); |
| | | redisTemplate.opsForGeo().add("vehiclePosition:" + vin, new Point(longitude, latitude), vin); |
| | | |
| | | //保存车辆实时信息到mongodb |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | |
| | | dto.setLatitude(latitude); |
| | | dto.setDuration(10); |
| | | dto.setDistance(2); |
| | | dto.setDirection(60); |
| | | xpPushMessageClient.pushOrderRoute(dto); |
| | | } |
| | | |
| | | //5秒钟循环一次 |
| | | //2秒钟循环一次 |
| | | try { |
| | | Thread.sleep(2000); |
| | | } catch (InterruptedException e) { |
| | |
| | | //构建推送消息 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", orderId); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("status", 4); |
| | | params.put("type", PushMessageTypeEnum.ORDER_STATUS.getDesc()); |
| | | params.put("content", JSONObject.toJSONString(content)); |
| | |
| | | //构建推送消息 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", orderId); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("status", status); |
| | | params.put("type", PushMessageTypeEnum.ORDER_STATUS.getDesc()); |
| | | params.put("content", JSONObject.toJSONString(content)); |
| | |
| | | log.error("推送消息失败:{}", stringR.getMsg()); |
| | | } |
| | | xpOrderClient.updateOrderStatus(orderId, status); |
| | | if(5 == status){ |
| | | //主动推一次全程轨迹 |
| | | Object cacheObject = redisService.getCacheObject("ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId()); |
| | | RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class); |
| | | com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject(); |
| | | jsonObject.put("type", "ORDER_ROUTE"); |
| | | jsonObject.put("timestamp", System.currentTimeMillis()); |
| | | com.alibaba.fastjson2.JSONObject content1 = new com.alibaba.fastjson2.JSONObject(); |
| | | content1.put("orderId", orderId.toString()); |
| | | content1.put("routeType", 1); |
| | | com.alibaba.fastjson2.JSONObject route = new com.alibaba.fastjson2.JSONObject(); |
| | | route.put("distance", routeVo.getDistance()); |
| | | route.put("duration", routeVo.getDuration()); |
| | | route.put("routeID", routeVo.getRouteID()); |
| | | |
| | | List<com.alibaba.fastjson2.JSONObject> collect = routeVo.getPolyline().stream().map(item -> { |
| | | com.alibaba.fastjson2.JSONObject point = new com.alibaba.fastjson2.JSONObject(); |
| | | point.put("latitude", item.getLatitude()); |
| | | point.put("longitude", item.getLongitude()); |
| | | return point; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | route.put("polyline", JSON.toJSONString(collect)); |
| | | content1.put("route", route.toJSONString()); |
| | | jsonObject.put("content", content1.toJSONString()); |
| | | SendMessageDTO messageDTO = new SendMessageDTO(); |
| | | messageDTO.setAppUserId(xpOrder.getAppUserId().toString()); |
| | | messageDTO.setMessage(jsonObject.toJSONString()); |
| | | xpPushMessageClient.sendRoute(messageDTO); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | Double longitude = lonLatDto.getLongitude(); |
| | | |
| | | //保存车辆实时位置到redis |
| | | redisTemplate.opsForGeo().add("vehiclePosition:" + vin, new GeoJsonPoint(longitude, latitude), vin); |
| | | redisTemplate.opsForGeo().add("vehiclePosition:" + vin, new Point(longitude, latitude), vin); |
| | | |
| | | //保存车辆实时信息到mongodb |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | |
| | | if (null != orderId) { |
| | | PushOrderRouteDTO dto = new PushOrderRouteDTO(); |
| | | dto.setOrderId(orderId); |
| | | dto.setRouteType(2); |
| | | dto.setRouteType(1); |
| | | dto.setLongitude(longitude); |
| | | dto.setLatitude(latitude); |
| | | dto.setDuration(20); |
| | | dto.setDistance(10); |
| | | dto.setDirection(60); |
| | | xpPushMessageClient.pushOrderRoute(dto); |
| | | } |
| | | |
| | | //5秒钟循环一次 |
| | | try { |
| | | Thread.sleep(2000); |
| | | Thread.sleep(500); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | |
| | | //构建推送消息 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", orderId); |
| | | content.put("status", 4); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("status", 7); |
| | | params.put("type", PushMessageTypeEnum.ORDER_STATUS.getDesc()); |
| | | params.put("content", JSONObject.toJSONString(content)); |
| | | params.put("timestamp", System.currentTimeMillis() + ""); |
| | |
| | | if (R.isError(stringR)) { |
| | | log.error("推送消息失败:{}", stringR.getMsg()); |
| | | } |
| | | xpOrderClient.updateOrderStatus(orderId, OrderStatusEnum.PICK_UP_GUESTS.getCode()); |
| | | xpOrderClient.updateOrderStatus(orderId, OrderStatusEnum.SEE_OFF_GUESTS.getCode()); |
| | | }); |
| | | } |
| | | |
| | |
| | | import com.xiaopeng.common.core.utils.uuid.UUID; |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | |
| | | long sequence = msgContent.getHeader().getSequence(); |
| | | responseMessage(sequence, vin); |
| | | //保存车辆实时位置到redis |
| | | redisTemplate.opsForGeo().add("vehiclePosition:" + vin, new GeoJsonPoint(longitude, latitude), vin); |
| | | redisTemplate.opsForGeo().add("vehiclePosition:" + vin, new Point(longitude, latitude), vin); |
| | | |
| | | //保存车辆实时信息到mongodb |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | routeID = routeVo.getRouteID(); |
| | | //缓存数据,用于后续推给乘客导航线路 |
| | | redisService.setCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(), com.alibaba.fastjson.JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | redisService.setCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(), JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | } |
| | | //驶往下车点的行程 |
| | | if (Arrays.asList(6).contains(xpOrder.getStatus())) { |
| | |
| | | RouteVo routeVo = routeVoR.getData(); |
| | | routeID = routeVo.getRouteID(); |
| | | //缓存数据,用于后续推给乘客导航线路 |
| | | redisService.setCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(), com.alibaba.fastjson.JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | redisService.setCacheObject("ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(), JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | } |
| | | //驶往下车点的行程 |
| | | if (orderPhase.equals(OrderPhase.ROUTE_TO_DESTINATION)) { |
| | | //直接取缓存中的导航数据推送给车端和乘客 |
| | | Object cacheObject = redisService.getCacheObject("ORDER_NAVIGATION_DATA:" + xpOrder.getAppUserId()); |
| | | Object cacheObject = redisService.getCacheObject("ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId()); |
| | | if(null == cacheObject){ |
| | | //没有缓存数据,重新规划线路 |
| | | //查询起点到终点的线路 |
| | |
| | | //构建推送消息 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", orderId); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("status", status.getCode()); |
| | | params.put("type", PushMessageTypeEnum.ORDER_STATUS.getDesc()); |
| | | params.put("content", JSONObject.toJSONString(content)); |
| | |
| | | jsonObject.put("type", "ORDER_ROUTE"); |
| | | jsonObject.put("timestamp", System.currentTimeMillis()); |
| | | com.alibaba.fastjson2.JSONObject content = new com.alibaba.fastjson2.JSONObject(); |
| | | content.put("orderId", orderId); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("routeType", 1); |
| | | com.alibaba.fastjson2.JSONObject route = new com.alibaba.fastjson2.JSONObject(); |
| | | route.put("distance", routeVo.getDistance()); |
| | |
| | | return point; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | route.put("polyline", collect); |
| | | route.put("polyline", JSON.toJSONString(collect)); |
| | | content.put("route", route.toJSONString()); |
| | | jsonObject.put("content", content.toJSONString()); |
| | | SendMessageDTO messageDTO = new SendMessageDTO(); |
| | |
| | | jsonObject.put("type", "ORDER_ROUTE"); |
| | | jsonObject.put("timestamp", System.currentTimeMillis()); |
| | | com.alibaba.fastjson2.JSONObject content = new com.alibaba.fastjson2.JSONObject(); |
| | | content.put("orderId", orderId); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("routeType", 2); |
| | | com.alibaba.fastjson2.JSONObject route = new com.alibaba.fastjson2.JSONObject(); |
| | | route.put("distance", routeVo.getDistance()); |
| | |
| | | point.put("longitude", item.getLongitude()); |
| | | return point; |
| | | }).collect(Collectors.toList()); |
| | | route.put("polyline", collect); |
| | | route.put("polyline", JSON.toJSONString(collect)); |
| | | content.put("route", route.toJSONString()); |
| | | jsonObject.put("content", content.toJSONString()); |
| | | SendMessageDTO messageDTO = new SendMessageDTO(); |
| | |
| | | } |
| | | |
| | | // 设置任务状态为待到达 |
| | | task.setStatus(TaskScheduleConstants.TASK_STATUS_PENDING_ARRIVE); |
| | | task.setStatus(TaskScheduleConstants.TASK_STATUS_PENDING); |
| | | |
| | | // 设置任务接收人(配置角色下的所有运维人员都可以看到) |
| | | task.setHandleUserId(belongUserIds); |
| | |
| | | } |
| | | |
| | | // 设置任务状态为待到达 |
| | | task.setStatus(TaskScheduleConstants.TASK_STATUS_PENDING_ARRIVE); |
| | | task.setStatus(TaskScheduleConstants.TASK_STATUS_PENDING); |
| | | |
| | | // 设置任务接收人(配置角色下的所有运维人员都可以看到) |
| | | task.setHandleUserId(belongUserIds); |
| | |
| | | } |
| | | |
| | | // 设置任务状态为待到达 |
| | | task.setStatus(TaskScheduleConstants.TASK_STATUS_PENDING_ARRIVE); |
| | | task.setStatus(TaskScheduleConstants.TASK_STATUS_PENDING); |
| | | |
| | | // 设置任务接收人(配置角色下的所有运维人员都可以看到) |
| | | task.setHandleUserId(belongUserIds); |
| | |
| | | } |
| | | |
| | | // 设置任务状态为待到达 |
| | | task.setStatus(TaskScheduleConstants.TASK_STATUS_PENDING_ARRIVE); |
| | | task.setStatus(TaskScheduleConstants.TASK_STATUS_PENDING); |
| | | |
| | | // 设置任务接收人(配置角色下的所有运维人员都可以看到) |
| | | task.setHandleUserId(belongUserIds); |
| | |
| | | } |
| | | |
| | | // 设置任务状态为待到达 |
| | | task.setStatus(TaskScheduleConstants.TASK_STATUS_PENDING_ARRIVE); |
| | | task.setStatus(TaskScheduleConstants.TASK_STATUS_PENDING); |
| | | |
| | | // 设置任务接收人(配置角色下的所有运维人员都可以看到) |
| | | task.setHandleUserId(belongUserIds); |
| | |
| | | String endTime = ""; |
| | | if(StringUtils.isNotEmpty(query.getStatisticDate())){ |
| | | String statisticDate = query.getStatisticDate(); |
| | | startTime = statisticDate.split(" - ")[0]; |
| | | endTime = statisticDate.split(" - ")[1]; |
| | | startTime = statisticDate.split(" - ")[0].split(" ")[0]; |
| | | endTime = statisticDate.split(" - ")[1].split(" ")[0]; |
| | | } |
| | | //查询数据 |
| | | List<ClockInStatisticsDto> clockInStatistics = this.baseMapper.getClockInStatistics(pageInfo, appUserIds, startTime, endTime); |
| | |
| | | String endTime = ""; |
| | | if(StringUtils.isNotEmpty(query.getStatisticDate())){ |
| | | String statisticDate = query.getStatisticDate(); |
| | | startTime = statisticDate.split(" - ")[0]; |
| | | endTime = statisticDate.split(" - ")[1]; |
| | | startTime = statisticDate.split(" - ")[0].split(" ")[0]; |
| | | endTime = statisticDate.split(" - ")[1].split(" ")[0]; |
| | | } |
| | | //查询数据 |
| | | List<ClockInStatisticsDto> clockInStatistics = this.baseMapper.getClockInStatistics(pageInfo, appUserIds, startTime, endTime); |
| | |
| | | String endTime = ""; |
| | | if(StringUtils.isNotEmpty(query.getStatisticDate())){ |
| | | String statisticDate = query.getStatisticDate(); |
| | | startTime = statisticDate.split(" - ")[0]; |
| | | endTime = statisticDate.split(" - ")[1]; |
| | | startTime = statisticDate.split(" - ")[0].split(" ")[0]; |
| | | endTime = statisticDate.split(" - ")[1].split(" ")[0]; |
| | | } |
| | | List<ClockInStatisticsDetailsDto> clockInStatisticsDetails = this.baseMapper.getClockInStatisticsDetails(pageInfo, query.getAppUserId(), startTime, endTime); |
| | | List<XpOperationsUserWithRoleVO> data = xpOperationUserClient.listByIdsWithRole(Arrays.asList(query.getAppUserId())).getData(); |
| | |
| | | String endTime = ""; |
| | | if(StringUtils.isNotEmpty(query.getStatisticDate())){ |
| | | String statisticDate = query.getStatisticDate(); |
| | | startTime = statisticDate.split(" - ")[0]; |
| | | endTime = statisticDate.split(" - ")[1]; |
| | | startTime = statisticDate.split(" - ")[0].split(" ")[0]; |
| | | endTime = statisticDate.split(" - ")[1].split(" ")[0]; |
| | | } |
| | | List<ClockInStatisticsDetailsDto> clockInStatisticsDetails = this.baseMapper.getClockInStatisticsDetails(pageInfo, query.getAppUserId(), startTime, endTime); |
| | | List<XpOperationsUserWithRoleVO> data = xpOperationUserClient.listByIdsWithRole(Arrays.asList(query.getAppUserId())).getData(); |
| | |
| | | // 存储redis |
| | | redisService.setCacheObject(CacheConstants.ORDER_ROUTE + "_" + dto.getOrderId() + "_" +dto.getRouteType(), routeVo); |
| | | // 存储路线偏离缓存,后续进行轨迹截取 |
| | | redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +dto.getRouteType(), routeVo); |
| | | // redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +dto.getRouteType(), routeVo); |
| | | |
| | | return R.ok(routeVo); |
| | | } |
| | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.xiaopeng.api.dto.QueryOrderRouteDTO; |
| | | import com.xiaopeng.api.dto.order.GetOrderNumDto; |
| | | import com.xiaopeng.api.dto.order.PopOrderDto; |
| | | import com.xiaopeng.api.dto.statistics.OrderStatisticsDTO; |
| | | import com.xiaopeng.api.dto.statistics.StatisticsQueryDTO; |
| | | 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.api.vo.operation.RouteVo; |
| | | import com.xiaopeng.api.vo.order.FareBreakdownVo; |
| | | import com.xiaopeng.api.vo.order.XpHistoryEndPointsVo; |
| | |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | 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.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | |
| | | private final IXpOrderService xpOrderService; |
| | | private final RedisService redisService; |
| | | @Autowired |
| | | private MongoTemplate mongoTemplate; |
| | | @Autowired |
| | | private XpVehicleClient xpVehicleClient; |
| | | |
| | | /** |
| | | * 获取订单统计数据(内部接口) |
| | |
| | | public R<RouteVo> queryOrderRoute(@Validated @RequestBody QueryOrderRouteDTO dto, HttpServletRequest request) { |
| | | String uid = request.getHeader("XP-Uid"); |
| | | // 查询订单信息 |
| | | // XpOrder xpOrder = xpOrderService.getById(dto.getOrderId()); |
| | | XpOrder xpOrder = xpOrderService.getById(dto.getOrderId()); |
| | | // 获取路线规划 |
| | | RouteVo routeVo = redisService.getCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +dto.getRouteType()); |
| | | // RouteVo routeVo = redisService.getCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +dto.getRouteType()); |
| | | |
| | | String key = ""; |
| | | //接驾情况,获取车辆位置到起点的导航 |
| | | if(xpOrder.getStatus() < 5){ |
| | | key = "ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(); |
| | | } |
| | | //服务中,获取起点到终点的导航数据 |
| | | if(xpOrder.getStatus() >= 5){ |
| | | key = "ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId(); |
| | | } |
| | | Object cacheObject = redisService.getCacheObject(key); |
| | | RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class); |
| | | XpVehicle xpVehicle = xpVehicleClient.queryById(xpOrder.getVehicleId()).getData(); |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(xpVehicle.getVehicleVin())), VehiclePosition.class); |
| | | routeVo.setDirection(null != vehiclePosition ? vehiclePosition.getCourse() : 90); |
| | | return R.ok(routeVo); |
| | | } |
| | | |
| | |
| | | import com.xiaopeng.api.vo.OrderType; |
| | | import com.xiaopeng.api.vo.account.GetUserListByUidsVo; |
| | | import com.xiaopeng.api.vo.account.UserCouponVo; |
| | | import com.xiaopeng.api.vo.automaticPilot.VehiclePosition; |
| | | import com.xiaopeng.api.vo.automaticPilot.proto.down.cloudOrderOperation.OrderOperationType; |
| | | import com.xiaopeng.api.vo.operation.RouteVo; |
| | | import com.xiaopeng.api.vo.order.*; |
| | |
| | | // 消息推送 |
| | | Map<String, Object> params = new HashMap<>(); |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId", order.getId()); |
| | | 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)); |
| | |
| | | //乘客单处理逻辑 |
| | | if(OrderType.USER_ORDER.equals(orderType)){ |
| | | XpOrder order = this.getById(orderId); |
| | | Long appUserId = order.getAppUserId(); |
| | | //订单为待接单状态 |
| | | if(order.getStatus() == 1){ |
| | | if(order.getStatus() < 4){ |
| | | AddTaxiPassengerVo addTaxiPassengerVo = new AddTaxiPassengerVo(); |
| | | order.setAcceptanceTime(LocalDateTime.now()); |
| | | R<XpVehicle> byVehicleVin = xpVehicleClient.findByVehicleVin(dto.getXpVehicleVin()); |
| | |
| | | String[] split = popFirstElement.split("_"); |
| | | xpGeoQueryEntity.setOrderId(split[0]); |
| | | // 存mongo数据 |
| | | xpPricingClient.updateXpGeoQueryEntity(split[0]); |
| | | order.setAppUserId(null); |
| | | xpPricingClient.updateXpGeoQueryEntity(order.getId().toString()); |
| | | |
| | | |
| | | // 修改车辆信息 |
| | |
| | | xpVehicleClient.updateVehicleById(vehicle); |
| | | |
| | | //绑定用户和车辆关系 |
| | | addTaxiPassengerVo.setUid(order.getAppUserId().toString()); |
| | | addTaxiPassengerVo.setUid(appUserId.toString()); |
| | | |
| | | order.setAppUserId(null); |
| | | this.updateById(order); |
| | | addTaxiPassengerVo.setOrderNo(order.getOrderNumber()); |
| | | // TODO appid |
| | | addTaxiPassengerVo.setAppId(""); |
| | | userVehicleClient.addTaxiPassenger(addTaxiPassengerVo); |
| | | //推送乘客车辆到达预约点的导航数据 |
| | | sendRoute(order.getAppUserId().toString(), orderId, "ORDER_NAVIGATION_START_DATA"); |
| | | sendRoute(addTaxiPassengerVo.getUid(), orderId, "ORDER_NAVIGATION_START_DATA", dto.getXpVehicleVin()); |
| | | }else{ |
| | | //推送行起点到终点的驶轨迹给乘客端 |
| | | sendRoute(order.getAppUserId().toString(), orderId, "ORDER_NAVIGATION_END_DATA"); |
| | | sendRoute(appUserId.toString(), orderId, "ORDER_NAVIGATION_END_DATA", dto.getXpVehicleVin()); |
| | | } |
| | | } |
| | | } |
| | |
| | | * @param appUserId |
| | | * @param keyStr |
| | | */ |
| | | public void sendRoute(String appUserId, Long orderId, String keyStr){ |
| | | public void sendRoute(String appUserId, Long orderId, String keyStr, String vin){ |
| | | VehiclePosition vehiclePosition = mongoTemplate.findOne(new Query(Criteria.where("vin").is(vin)), VehiclePosition.class); |
| | | Object cacheObject = redisService.getCacheObject(keyStr + ":" + appUserId); |
| | | if(null != cacheObject){ |
| | | RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class); |
| | |
| | | jsonObject.put("type", "ORDER_ROUTE"); |
| | | jsonObject.put("timestamp", System.currentTimeMillis()); |
| | | JSONObject content = new JSONObject(); |
| | | content.put("orderId", orderId); |
| | | content.put("orderId", orderId.toString()); |
| | | content.put("routeType", "ORDER_NAVIGATION_START_DATA".equals(keyStr) ? 1 : 2); |
| | | content.put("direction", null != vehiclePosition ? vehiclePosition.getCourse() : 90); |
| | | JSONObject route = new JSONObject(); |
| | | route.put("distance", routeVo.getDistance()); |
| | | route.put("duration", routeVo.getDuration()); |
| | |
| | | return point; |
| | | }).collect(Collectors.toList()); |
| | | |
| | | route.put("polyline", collect); |
| | | route.put("polyline", JSON.toJSONString(collect)); |
| | | content.put("route", route.toJSONString()); |
| | | jsonObject.put("content", content.toJSONString()); |
| | | SendMessageDTO messageDTO = new SendMessageDTO(); |
| | | messageDTO.setAppUserId(appUserId); |
| | | messageDTO.setMessage(jsonObject.toJSONString()); |
| | | System.err.println(messageDTO); |
| | | xpPushMessageClient.sendRoute(messageDTO); |
| | | } |
| | | } |
| | |
| | | package com.xiaopeng.pushMessage.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.xiaopeng.api.dto.operation.LonLatDto; |
| | | import com.xiaopeng.api.dto.pushMessage.PushOrderRouteDTO; |
| | |
| | | import com.xiaopeng.common.redis.service.RedisService; |
| | | import com.xiaopeng.pushMessage.utils.MapMatchingUtil; |
| | | import io.swagger.annotations.Api; |
| | | import org.powermock.core.ListMap; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | @Api(tags = "订单推送轨迹接口") |
| | | @RestController |
| | |
| | | routeType = xpOrder.getStatus() == 3 ? 1 : 2; |
| | | } |
| | | // 获取路线规划 |
| | | RouteVo routeVo = redisService.getCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType); |
| | | String key = ""; |
| | | //接驾情况,获取车辆位置到起点的导航 |
| | | if(1 == routeType){ |
| | | key = "ORDER_NAVIGATION_START_DATA:" + xpOrder.getAppUserId(); |
| | | }else{ |
| | | key = "ORDER_NAVIGATION_END_DATA:" + xpOrder.getAppUserId(); |
| | | } |
| | | Object cacheObject = redisService.getCacheObject(key); |
| | | RouteVo routeVo = JSON.parseObject(cacheObject.toString(), RouteVo.class); |
| | | |
| | | if(Objects.nonNull(routeVo)){ |
| | | |
| | |
| | | routeVo.setPolyline(lonLatDtos); |
| | | |
| | | // 存储最新路线偏离缓存,后续进行轨迹截取 |
| | | redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType, routeVo); |
| | | // redisService.setCacheObject(CacheConstants.ORDER_ROUTE_CAPTURE + "_" + dto.getOrderId() + "_" +routeType, routeVo); |
| | | |
| | | redisService.setCacheObject(key, JSON.toJSONString(routeVo), 24L, TimeUnit.HOURS); |
| | | |
| | | // 封装轨迹点位集合 |
| | | Map<String, Object> polyline = new HashMap<>(); |
| | | List<Map<String, Object>> polyline = new ArrayList<>(); |
| | | for (LonLatDto lonLatDto : lonLatDtos) { |
| | | polyline.put("longitude",lonLatDto.getLongitude()); |
| | | polyline.put("latitude",lonLatDto.getLatitude()); |
| | | Map<String, Object> polylineMap = new HashMap<>(); |
| | | polylineMap.put("longitude",lonLatDto.getLongitude()); |
| | | polylineMap.put("latitude",lonLatDto.getLatitude()); |
| | | polyline.add(polylineMap); |
| | | } |
| | | // 封装路由详情 |
| | | Map<String, Object> route = new HashMap<>(); |
| | |
| | | route.put("polyline",JSONObject.toJSONString(polyline)); |
| | | |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("orderId",dto.getOrderId()); |
| | | content.put("orderId",dto.getOrderId().toString()); |
| | | content.put("routeType",routeType); |
| | | content.put("direction",dto.getDirection()); |
| | | content.put("route",JSONObject.toJSONString(route)); |