| | |
| | | package com.ard.sample.manage.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.ard.common.core.redis.RedisConst; |
| | | import com.ard.common.core.redis.RedisOpsUtils; |
| | | import com.ard.ossdock.service.impl.OssDockServiceContext; |
| | | import com.ard.sample.component.websocket.enums.MessageType; |
| | | import com.ard.sample.component.websocket.handler.DockWebSocketHandler; |
| | | import com.ard.sample.manage.model.dto.DeviceDTO; |
| | |
| | | @Autowired |
| | | protected ObjectMapper _objectMapper; |
| | | |
| | | @Resource |
| | | 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"); |
| | |
| | | String json = getJSONString(MessageType.STATE.getType(), device.getDeviceSn(), dockStatus, droneStatus); |
| | | |
| | | // 发送给websocket客户端 |
| | | _dockWebSocketHandler.sendMessageToSubscribers(device.getDeviceSn(), MessageType.STATE.getType(), json); |
| | | _dockWebSocketHandler.sendMessageToSubscribers(device.getDeviceSn(), MessageType.STATE.getType(), json, ""); |
| | | } |
| | | } |
| | | |