From a82c9a2633c519d5d7d868d3ec89832f77849700 Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: Mon, 17 Mar 2025 09:35:58 +0800
Subject: [PATCH] 增加飞行高度控制切面
---
ard-work/src/main/java/com/ard/tianyu/service/control/UavControlService.java | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/ard-work/src/main/java/com/ard/tianyu/service/control/UavControlService.java b/ard-work/src/main/java/com/ard/tianyu/service/control/UavControlService.java
index 1500f3e..850fb75 100644
--- a/ard-work/src/main/java/com/ard/tianyu/service/control/UavControlService.java
+++ b/ard-work/src/main/java/com/ard/tianyu/service/control/UavControlService.java
@@ -1,8 +1,9 @@
package com.ard.tianyu.service.control;
-import com.ard.common.exception.NoPermissionException;
+import com.ard.common.exception.ControlException;
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,9 +64,9 @@
}
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("当前已拥有控制权");
+ throw new ControlException("当前已拥有控制权");
}
return false;
}
@@ -93,14 +94,14 @@
Long requester = requestMap.get(boxSn);
if (requester == null || requester.equals(controller)) {
- throw new NoPermissionException("无控制请求");
+ throw new ControlException("无控制请求");
}
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);
@@ -127,11 +128,11 @@
ConcurrentHashMap<String, Long> controlMap = getControlMap(controlType);
if (!controller.equals(controlMap.get(boxSn))) {
- throw new NoPermissionException("没有该设备的" + controlType.getType().toUpperCase() + "控制权");
+ throw new ControlException("没有该设备的" + controlType.getType().toUpperCase() + "控制权");
}
controlMap.remove(boxSn);
- webSocketService.sendControlRelease(boxSn, controlType.getType());
+ uavControlManager.sendControlRelease(boxSn, controlType.getType());
return true;
}
--
Gitblit v1.9.3