liusuyi
2025-03-10 6bcfae60f8c2eaa9c859add62bf14f8c2ce23537
ard-work/src/main/java/com/ard/tianyu/service/control/UavControlService.java
@@ -3,6 +3,7 @@
import com.ard.common.exception.NoPermissionException;
import com.ard.common.utils.SecurityUtils;
import com.ard.tianyu.websocket.domain.UavControlType;
import com.ard.tianyu.websocket.handler.UavControlManager;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@@ -15,7 +16,7 @@
public class UavControlService {
    @Resource
    private WebSocketService webSocketService;
    private UavControlManager uavControlManager;
    /**
     * 记录当前获得飞行控制权限的用户
@@ -63,7 +64,7 @@
        }
        if (!controller.equals(requester)) {
            requestMap.put(boxSn, requester);
            webSocketService.sendControlRequest(controller, boxSn, controlType.getType(), requester);
            uavControlManager.sendControlRequest(controller, boxSn, controlType.getType(), requester);
        } else {
            throw new NoPermissionException("当前已拥有控制权");
        }
@@ -98,9 +99,9 @@
        if (approve) {
            getControlMap(controlType).put(boxSn, requester);
            webSocketService.sendControlApproval(requester, boxSn, controlType.getType());
            uavControlManager.sendControlApproval(requester, boxSn, controlType.getType());
        } else {
            webSocketService.sendControlRejection(requester, boxSn, controlType.getType());
            uavControlManager.sendControlRejection(requester, boxSn, controlType.getType());
        }
        requestMap.remove(boxSn);
@@ -131,7 +132,7 @@
        }
        controlMap.remove(boxSn);
        webSocketService.sendControlRelease(boxSn, controlType.getType());
        uavControlManager.sendControlRelease(boxSn, controlType.getType());
        return true;
    }