| | |
| | | if (StringUtils.isEmpty(oldLocation)) { |
| | | // 首次定位 |
| | | xpOrder.setMileageKilometers(0D); |
| | | xpOrder.setAppUserId(null); |
| | | this.updateById(xpOrder); |
| | | orderTrajectory.setDistance(0D); |
| | | // 存储mongo数据 |
| | | orderTrajectoryService.create(orderTrajectory); |
| | | mongoTemplate.save(orderTrajectory); |
| | | // 存储首次定位 |
| | | redisService.setCacheObject(CacheConstants.ORDER_OLD_LOCATION + orderTrajectory.getOrderId(), orderTrajectory.getLocation()); |
| | | } else { |
| | |
| | | Double distance1 = distance.get("WGS84"); |
| | | if (distance1 > 50 && xpOrder.getStatus() == 6) {//大于50米表示在移动,且在服务中的时候记录里程 |
| | | xpOrder.setMileageKilometers(BigDecimal.valueOf(xpOrder.getMileageKilometers()).add(new BigDecimal(distance1)).setScale(2, RoundingMode.HALF_EVEN).doubleValue()); |
| | | xpOrder.setAppUserId(null); |
| | | this.updateById(xpOrder); |
| | | // 存储本次距离 |
| | | orderTrajectory.setDistance(distance1); |
| | | // 存储mongo数据 |
| | | orderTrajectoryService.create(orderTrajectory); |
| | | mongoTemplate.save(orderTrajectory); |
| | | } |
| | | } else { |
| | | log.error("调用高德计算距离出错"); |
| | |
| | | } |
| | | |
| | | } |
| | | // List<OrderTrajectory> trajectories = mongoTemplate.find( |
| | | // new Query(Criteria.where("orderId").is(orderId)) |
| | | // .with(Sort.by(Sort.Direction.ASC, "locatetime")), |
| | | // OrderTrajectory.class |
| | | // ); |
| | | List<TaxiPricingDemoService.GpsPoint> mockGpsPoints = TaxiPricingDemoService.createMockGpsPoints(DateUtils.toDate(order.getCreateTime())); |
| | | |
| | | // 生成轨迹记录 |
| | | List<OrderTrajectory> trajectories = TrajectoryGenerator.generateTrajectory(mockGpsPoints); |
| | | List<OrderTrajectory> trajectories = mongoTemplate.find( |
| | | new Query(Criteria.where("orderId").is(orderId)) |
| | | .with(Sort.by(Sort.Direction.ASC, "locatetime")), |
| | | OrderTrajectory.class |
| | | ); |
| | | orderDetailVo.setTrajectories(trajectories); |
| | | if (order.getTripBegin() != null && order.getTripEnd() != null) { |
| | | // 计算两个时间相差多少分钟 |