| | |
| | | |
| | | // 结束服务时查询轨迹,计算距离 |
| | | Driver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | double sum = 0; |
| | | try { |
| | | String tid = gdFalconUtil.selectTerminal(driver.getPhone()); |
| | | String result = gdFalconUtil.selectTrack(tid, orderPrivateCar.getTrackId(),1); |
| | | |
| | |
| | | points.addAll(point); |
| | | } |
| | | |
| | | System.out.println("轨迹坐标点=====:"+points); |
| | | String toLonLat = ""; |
| | | double sum = 0; |
| | | List<OrderPosition> orderPositions = new ArrayList<>(); |
| | | for (Object o : points) { |
| | | String s = JSONObject.toJSONString(o); |
| | |
| | | GlobalCoordinates source = new GlobalCoordinates(Double.valueOf(from[1]), Double.valueOf(from[0])); |
| | | GlobalCoordinates target = new GlobalCoordinates(Double.valueOf(to[1]), Double.valueOf(to[0])); |
| | | double WGS84 = getDistanceMeter(source, target, Ellipsoid.WGS84); |
| | | System.err.println("WGS84坐标系计算结果:"+WGS84 + "米"); |
| | | sum += WGS84; |
| | | } |
| | | toLonLat = fromLonLat; |
| | |
| | | out.write(JSON.toJSONString(orderPositions)); |
| | | out.flush(); |
| | | out.close(); |
| | | |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | System.err.println("查询高德轨迹出错,使用本地轨迹计算"); |
| | | List<OrderPosition> list = orderPositionService.queryPosition(orderId, 1); |
| | | String fromLonLat = ""; |
| | | for (OrderPosition orderPosition : list) { |
| | | String toLonLat = orderPosition.getLon() + "," + orderPosition.getLat(); |
| | | if(StringUtils.hasLength(fromLonLat) && StringUtils.hasLength(toLonLat)){ |
| | | String[] from = fromLonLat.split(","); |
| | | String[] to = toLonLat.split(","); |
| | | GlobalCoordinates source = new GlobalCoordinates(Double.valueOf(from[1]), Double.valueOf(from[0])); |
| | | GlobalCoordinates target = new GlobalCoordinates(Double.valueOf(to[1]), Double.valueOf(to[0])); |
| | | double WGS84 = getDistanceMeter(source, target, Ellipsoid.WGS84); |
| | | sum += WGS84; |
| | | } |
| | | fromLonLat = toLonLat; |
| | | } |
| | | } |
| | | orderPrivateCar.setMileage(sum); |
| | | orderPrivateCar.setIsAbnormal(0); |
| | | |
| | | //获取预估里程,使用预估里程作为行驶里程计算金额 |
| | | // String origins = orderPrivateCar.getStartLon() + "," + orderPrivateCar.getStartLat(); |
| | | // String destination = orderPrivateCar.getGetoffLon() + "," + orderPrivateCar.getGetoffLat(); |
| | | // Map<String, String> distance = gdMapElectricFenceUtil.getDistance(origins, destination, 1); |
| | | // Double distance1 = Double.valueOf(distance.get("distance")); |
| | | // if(distance1 - sum > 1000){ |
| | | // orderPrivateCar.setMileage(distance1); |
| | | // orderPrivateCar.setIsAbnormal(1); |
| | | // }else{ |
| | | // orderPrivateCar.setMileage(sum); |
| | | // orderPrivateCar.setIsAbnormal(0); |
| | | // } |
| | | break; |
| | | } |
| | | this.updateById(orderPrivateCar); |