| | |
| | | import com.ard.common.core.redis.RedisCache; |
| | | import com.ard.common.utils.DateUtils; |
| | | import com.ard.work.component.forest.TyClient; |
| | | import com.ard.work.domain.cache.UavTelemetryDataCache; |
| | | import com.ard.work.domain.cache.UavWaylineCache; |
| | | import com.ard.work.domain.dto.telemetry.TelemetryData; |
| | | import com.ard.work.domain.dto.wayline.WaylineInfo; |
| | | import com.ard.work.domain.dto.BoxHistoryDTO; |
| | | import com.ard.work.domain.entity.ArdFlightTask; |
| | | import com.ard.work.domain.receiver.BoxHistoryReceiver; |
| | |
| | | */ |
| | | @Scheduled(fixedDelay = 5000) |
| | | public void syncAllFlightHistory() { |
| | | List<String> serverIds = ardServerInfoService.getServerIdsList(); |
| | | for (String serverId : serverIds) { |
| | | // 获取上次同步的时间(即数据库中最大 startTime) |
| | | Date lastSyncTime = getLastSyncTimeForServer(serverId); |
| | | // 根据上次同步时间同步飞行历史 |
| | | syncFlightHistory(serverId, lastSyncTime); |
| | | try { |
| | | List<String> serverIds = ardServerInfoService.getServerIdsList(); |
| | | for (String serverId : serverIds) { |
| | | // 获取上次同步的时间(即数据库中最大 startTime) |
| | | Date lastSyncTime = getLastSyncTimeForServer(serverId); |
| | | // 根据上次同步时间同步飞行历史 |
| | | syncFlightHistory(serverId, lastSyncTime); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("同步飞行历史失败", e); |
| | | } |
| | | } |
| | | |
| | |
| | | .maxSpeed(boxHistoryReceiver.getMaxSpeed()) |
| | | .build(); |
| | | |
| | | // 从遥测缓存和航线缓存直接获取 flightMode 和 routeId |
| | | // UavWaylineCache 在飞行中持续有效,仅在飞行中 flightMode!=14 时被清除 |
| | | String boxSn = flightTask.getBoxSn(); |
| | | WaylineInfo waylineInfo = UavWaylineCache.get(boxSn); |
| | | if (waylineInfo != null && waylineInfo.getWaylineId() != null) { |
| | | flightTask.setRouteId(waylineInfo.getWaylineId()); |
| | | } |
| | | TelemetryData telemetryData = UavTelemetryDataCache.get(boxSn); |
| | | if (telemetryData != null && telemetryData.getFlightMode() > 0) { |
| | | flightTask.setFlightMode(telemetryData.getFlightMode()); |
| | | } |
| | | |
| | | Long flyUserId = uavControlService.getCurrentController(flightTask.getBoxSn(), "fly"); |
| | | if (flyUserId != null) { |
| | | SysUser flyUser = redisCache.getCacheObject(CacheConstants.SYS_USER_KEY + flyUserId); |
| | | SysUser flyUser = redisCache.getCacheMapValue(CacheConstants.SYS_USER, flyUserId.toString()); |
| | | if (flyUser != null && flyUser.getNickName() != null) { |
| | | flightTask.setCreateBy(flyUser.getNickName()); |
| | | } |