2025-12-12 zwy 优化,机场及飞行器状态存入redis中时没有时间限制,不清除。
| | |
| | | String deviceSn = receiver.getGateway(); |
| | | if(method.equals("cover_close")){ |
| | | _deviceService.updateWorkType(deviceSn, 2L); |
| | | RedisOpsUtils.setWithExpire(RedisConst.OSD_STATUS_PREFIX + deviceSn, 2, RedisConst.DEVICE_ALIVE_SECOND); |
| | | RedisOpsUtils.set(RedisConst.OSD_STATUS_PREFIX + deviceSn, 2); |
| | | } |
| | | String sn = RedisOpsUtils.get(key).toString(); |
| | | receiver.setType(MessageType.PROGRESS.getType()); |
| | |
| | | // 更新设备列表状态--飞行器开机中... |
| | | if(method.equals("drone_open")){ |
| | | _deviceService.updateWorkType(device.getChildDeviceSn(), 7L); |
| | | RedisOpsUtils.setWithExpire(RedisConst.OSD_STATUS_PREFIX + device.getChildDeviceSn(), 7, RedisConst.DEVICE_ALIVE_SECOND); |
| | | RedisOpsUtils.set(RedisConst.OSD_STATUS_PREFIX + device.getChildDeviceSn(), 7); |
| | | } |
| | | |
| | | String dockProgress =""; |
| | |
| | | Long code = jsonNode.get("data").get("mode_code").asLong(); |
| | | if ("0,1,2,3,4,5,8,9,10,11,13,14".contains(code.toString())) { |
| | | _deviceService.updateWorkType(device.getDeviceSn(), code); |
| | | RedisOpsUtils.setWithExpire(RedisConst.OSD_STATUS_PREFIX + device.getDeviceSn(), code, RedisConst.DEVICE_ALIVE_SECOND); |
| | | RedisOpsUtils.set(RedisConst.OSD_STATUS_PREFIX + device.getDeviceSn(), code); |
| | | } |
| | | } |
| | | } |
| | |
| | | //只要状态 "0":"作业准备中","1":"飞行作业中","5":"任务空闲" |
| | | if(code == 0 || code == 1 || code == 5) { |
| | | _deviceService.updateWorkType(deviceSn,code); |
| | | RedisOpsUtils.setWithExpire(RedisConst.OSD_STATUS_PREFIX + deviceSn, code, RedisConst.DEVICE_ALIVE_SECOND); |
| | | RedisOpsUtils.set(RedisConst.OSD_STATUS_PREFIX + deviceSn, code); |
| | | } |
| | | } |
| | | } |
| | |
| | | Long deviceOnlineStatus = jsonNode.get("sub_device").get("device_online_status").asLong(); |
| | | if (inDock.equals(1L) && deviceOnlineStatus.equals(0L)) {// 飞行器在舱内且关机状态为6 |
| | | _deviceService.updateWorkType(childDeviceSn, 6L); |
| | | RedisOpsUtils.setWithExpire(RedisConst.OSD_STATUS_PREFIX + device.getChildDeviceSn(), 6, RedisConst.DEVICE_ALIVE_SECOND); |
| | | RedisOpsUtils.set(RedisConst.OSD_STATUS_PREFIX + device.getChildDeviceSn(), 6); |
| | | } |
| | | } |
| | | } |
| | |
| | | private OssDockServiceContext _ossService; |
| | | |
| | | /** |
| | | * 定时任务,每5秒取一次机场设备的在线状态,如已离线更新状态 |
| | | * 定时任务,每2秒取一次机场设备的在线状态,如已离线更新状态 |
| | | * */ |
| | | @Scheduled(cron = "0/2 * * * * ?") |
| | | public void cronOnlineTask() { |
| | |
| | | // 更新机场设备状态:"3"-"设备已离线", |
| | | if(!_deviceService.checkDeviceOnline(device.getDeviceSn())){ |
| | | _deviceService.updateWorkType(device.getDeviceSn(), 3L); |
| | | RedisOpsUtils.setWithExpire(RedisConst.OSD_STATUS_PREFIX + device.getDeviceSn(), 3, RedisConst.DEVICE_ALIVE_SECOND); |
| | | RedisOpsUtils.set(RedisConst.OSD_STATUS_PREFIX + device.getDeviceSn(), 3); |
| | | RedisOpsUtils.del(RedisConst.WEBSOCKET_VIDEO_ADDRESS_PREFIX + device.getDeviceSn()); |
| | | RedisOpsUtils.del(RedisConst.COVER_STATE_PREFIX + device.getDeviceSn()); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 定时任务,每5秒读一次redis的机场设备的状态,并发送到websocket客户端 |
| | | * 定时任务,每1秒读一次redis的机场设备的状态,并发送到websocket客户端 |
| | | * */ |
| | | @Scheduled(cron = "0/2 * * * * ?") |
| | | @Scheduled(cron = "0/1 * * * * ?") |
| | | public void sendDeviceStatus(){ |
| | | // 测试 机场oss读取文件 |
| | | // URL url = _ossService.getObjectUrl("kmz","/2025/11/25/新建航点航线(1)_20251125161322A001.kmz"); |