| | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | // 1. 获取所有车辆信息 |
| | | List<VehicleInfo> vehicleList = vehicleInfoService.selectVehicleInfoList(new VehicleInfo()); |
| | | |
| | | List<String> deviceIds = vehicleList.stream().map(VehicleInfo::getDeviceId).collect(Collectors.toList()); |
| | | // 2. 获取所有车辆的GPS最后位置 |
| | | GpsLastPositionResponse gpsLastPositionResponse = gpsCollectService.getLastPosition(new GpsLastPositionRequest()); |
| | | GpsLastPositionRequest request = new GpsLastPositionRequest(); |
| | | // request.setDeviceids(deviceIds); |
| | | GpsLastPositionResponse gpsLastPositionResponse = gpsCollectService.getLastPosition(request); |
| | | |
| | | // 3. 遍历车辆列表,获取每个车辆的GPS位置 |
| | | for (VehicleInfo vehicle : vehicleList) { |
| | |
| | | // 保存GPS位置信息 |
| | | vehicleGpsService.insertVehicleGps(gps); |
| | | |
| | | log.info("车辆[{}]GPS位置已更新: 经度={}, 纬度={}, 设备时间={}, 处理时间={}", |
| | | vehicle.getVehicleNo(), position.getCallon(), position.getCallat(), |
| | | gps.getDeviceReportTime(), gps.getPlatformProcessTime()); |
| | | // log.info("车辆[{}]GPS位置已更新: 经度={}, 纬度={}, 设备时间={}, 处理时间={}", |
| | | // vehicle.getVehicleNo(), position.getCallon(), position.getCallat(), |
| | | // gps.getDeviceReportTime(), gps.getPlatformProcessTime()); |
| | | } catch (Exception e) { |
| | | log.error("更新车辆[{}]GPS位置失败: {}", vehicle.getVehicleNo(), e.getMessage()); |
| | | } |