| | |
| | | package com.ard.work.component.websocket.handler; |
| | | |
| | | import com.ard.common.constant.CacheConstants; |
| | | import com.ard.common.core.domain.entity.SysUser; |
| | | import com.ard.common.core.redis.RedisCache; |
| | | import com.ard.work.config.RouteStateMachineService; |
| | | import com.ard.work.domain.cache.UavSignalInfoCache; |
| | | import com.ard.work.domain.cache.UavStateCache; |
| | | import com.ard.work.domain.cache.UavTelemetryDataCache; |
| | | import com.ard.work.domain.cache.UavWaylineCache; |
| | | import com.ard.work.domain.dto.signal.SignalInfo; |
| | | import com.ard.work.domain.dto.state.UavState; |
| | | import com.ard.work.domain.dto.telemetry.TelemetryData; |
| | | import com.ard.work.domain.dto.wayline.WaylineInfo; |
| | | import com.ard.work.domain.enums.RouteState; |
| | | import com.ard.work.service.control.UavControlService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Slf4j |
| | |
| | | |
| | | @Resource |
| | | private UavControlService uavControlService; |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | @Autowired |
| | | private RouteStateMachineService stateMachineService; |
| | | |
| | | @Override |
| | | protected Map<String, Object> getData(String boxSn) { |
| | | log.debug("获取无人机所有数据"); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("boxSn", boxSn); |
| | | |
| | | WaylineInfo waylineInfo = UavWaylineCache.get(boxSn); |
| | | if (waylineInfo != null) { |
| | | RouteState currentState = stateMachineService.getCurrentState(boxSn); |
| | | waylineInfo.setRouteState(currentState); |
| | | } |
| | | map.put("wayline", waylineInfo); |
| | | |
| | | UavState uavState = UavStateCache.get(boxSn); |
| | | map.put("state", uavState); |
| | | |
| | | TelemetryData uavTelemetryData = UavTelemetryDataCache.get(boxSn); |
| | | map.put("telemetry", uavTelemetryData); |
| | | |
| | | SignalInfo uavSignalInfo = UavSignalInfoCache.get(boxSn); |
| | | map.put("signal", uavSignalInfo); |
| | | // 获取当前控制飞行的用户ID |
| | | Long flyUserId = uavControlService.getCurrentController(boxSn, "fly"); |
| | | // 将飞行当前控制者用户ID添加到映射中 |
| | | map.put("flyController", flyUserId); |
| | | if(flyUserId!=null) { |
| | | SysUser flyUser = redisCache.getCacheMapValue(CacheConstants.SYS_USER, flyUserId.toString()); |
| | | // 将飞行当前控制者用户ID添加到映射中 |
| | | map.put("flyController", flyUser); |
| | | } |
| | | // 获取当前控制载荷的用户ID |
| | | Long payloadUserId = uavControlService.getCurrentController(boxSn, "payload"); |
| | | // 将载荷当前控制者用户ID添加到映射中 |
| | | map.put("payloadController", payloadUserId); |
| | | if(payloadUserId!=null) { |
| | | SysUser payloadUser = redisCache.getCacheMapValue(CacheConstants.SYS_USER, payloadUserId.toString()); |
| | | // 将载荷当前控制者用户ID添加到映射中 |
| | | map.put("payloadController", payloadUser); |
| | | } |
| | | return map; |
| | | } |
| | | |