| | |
| | | VehicleInfo vehicleInfo = vehicleInfoService.selectVehicleInfoByPlateNumber(plateNumber); |
| | | if (vehicleInfo != null) { |
| | | vehicleInfo.setDeviceId(deviceId); |
| | | //获得数据字典中的平台编码 |
| | | |
| | | vehicleInfo.setPlatformCode("GPS51"); |
| | | vehicleInfoService.updateVehicleInfo(vehicleInfo); |
| | | } else { |
| | | VehicleInfo newVehicle = new VehicleInfo(); |
| | | newVehicle.setVehicleNo(plateNumber); |
| | | newVehicle.setDeviceId(deviceId); |
| | | newVehicle.setStatus("0"); |
| | | newVehicle.setPlatformCode("GPS51"); |
| | | vehicleInfoService.insertVehicleInfo(newVehicle); |
| | | } |
| | | } |
| | |
| | | |
| | | //devicetime 这个是一个linux时间戳,要转换成北京时间,再转成yyyy-MM-dd HH:mm:ss格式 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | |
| | | //getArrivedtime 这个是一个linux时间戳,要转换成北京时间,再转成yyyy-MM-dd HH:mm:ss格式 |
| | | long arrivedTime = position.getArrivedtime(); |
| | | Date arrivedDate; |
| | | // 检查时间戳是否有效(大于0) |
| | | if (arrivedTime > 0) { |
| | | arrivedDate = new Date(arrivedTime); |
| | | // 减去8小时 |
| | | arrivedDate.setTime(arrivedDate.getTime() - 8 * 60 * 60 * 1000); |
| | | } else { |
| | | // 时间戳无效,使用当前时间 |
| | | arrivedDate = new Date(); |
| | | } |
| | | gps.setPlatformProcessTime(sdf.format(arrivedDate)); |
| | | |
| | | // 设备上报时间 |
| | | long deviceTime = position.getDevicetime(); |
| | | if (deviceTime > 0 && deviceTime < 4102444800L) { // 2100-01-01 00:00:00 |
| | | gps.setDeviceReportTime(sdf.format(new Date(deviceTime * 1000L))); |
| | | Date date; |
| | | // 检查时间戳是否有效(大于0) |
| | | if (deviceTime > 0) { |
| | | date = new Date(deviceTime); |
| | | // 减去8小时 |
| | | date.setTime(date.getTime() - 8 * 60 * 60 * 1000); |
| | | } else { |
| | | log.warn("车辆[{}]的设备时间戳[{}]无效,使用当前时间", vehicle.getVehicleNo(), deviceTime); |
| | | gps.setDeviceReportTime(sdf.format(new Date())); |
| | | // 时间戳无效,使用当前时间 |
| | | date = arrivedDate; |
| | | } |
| | | |
| | | // 平台处理时间(当前时间) |
| | | gps.setPlatformProcessTime(sdf.format(new Date())); |
| | | gps.setDeviceReportTime(sdf.format(date)); |
| | | |
| | | |
| | | |
| | | // 采集时间(使用设备上报时间) |
| | | gps.setCollectTime(gps.getDeviceReportTime()); |
| | | gps.setCollectTime(sdf.format(new Date( ))); |
| | | |
| | | // 保存GPS位置信息 |
| | | vehicleGpsService.insertVehicleGps(gps); |