From a7c7965a518359a1c81bde0a8c451f2fc1cc25fe Mon Sep 17 00:00:00 2001
From: zhangjian <zhangjianrock@163.com>
Date: 星期五, 07 七月 2023 16:31:40 +0800
Subject: [PATCH] 无人机转发接口
---
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SdkOperateAspect.java | 111 ++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 93 insertions(+), 18 deletions(-)
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SdkOperateAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SdkOperateAspect.java
index 6f27a17..25cb772 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SdkOperateAspect.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SdkOperateAspect.java
@@ -1,19 +1,31 @@
package com.ruoyi.framework.aspectj;
+import com.ruoyi.common.annotation.SdkOperate;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.constant.CamPriority;
import com.ruoyi.device.camera.domain.ArdCameras;
import com.ruoyi.device.camera.domain.CameraCmd;
import com.ruoyi.device.camera.service.IArdCamerasService;
+import com.ruoyi.system.service.ISysUserService;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
+
+import javax.annotation.Nullable;
import javax.annotation.Resource;
+import java.lang.reflect.Method;
import java.util.Date;
+
+import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;
/**
* SDK鎺у埗澶勭悊
@@ -22,10 +34,13 @@
*/
@Aspect
@Component
+@Slf4j(topic = "hikSdk")
public class SdkOperateAspect {
@Resource
IArdCamerasService ardCamerasService;
+ @Resource
+ ISysUserService sysUserService;
@Pointcut("@annotation(com.ruoyi.common.annotation.SdkOperate)")
public void dsPointCut() {
@@ -34,10 +49,14 @@
@Around("dsPointCut()")
public Object around(ProceedingJoinPoint point) throws Throwable {
- Boolean resultMap = dataScopeFilter(point);
- if (resultMap) {
+ MethodSignature signature = (MethodSignature) point.getSignature();
+ Method method = signature.getMethod();
+ Boolean result = controlScopeFilter(point);
+ if (result) {
+ log.debug("宸茶幏鍙栫浉鏈烘帶鍒舵潈--" + method.getName());
return point.proceed();
} else {
+ log.debug("鏈幏鍙栫浉鏈烘帶鍒舵潈--" + method.getName());
return false;//浠f浛鐩爣鏂规硶鐨勮繑鍥炲��
}
}
@@ -47,28 +66,84 @@
*
* @param joinPoint 鍒囩偣
*/
- public Boolean dataScopeFilter(ProceedingJoinPoint joinPoint) {
- //鑾峰彇璇锋眰鎺у埗鐩告満鐨勪俊鎭�
+ public Boolean controlScopeFilter(ProceedingJoinPoint joinPoint) {
+ //鑾峰彇璇锋眰鎺у埗鐩告満鐨勫懡浠や俊鎭�
CameraCmd cmd = (CameraCmd) joinPoint.getArgs()[0];
+ String operator = cmd.getOperator();//鐢宠鑰�
+ /*鑾峰彇鐩告満褰撳墠鐨勮鎺т俊鎭�*/
ArdCameras ardCameras = ardCamerasService.selectArdCamerasById(cmd.getCameraId());
if (StringUtils.isNull(ardCameras)) {
return false;
}
- //浼樺厛绾ф瘮瀵�
- Date operatorExpired = ardCameras.getOperatorExpired();
- Date now = new Date();
- if (now.before(operatorExpired)) {
- //鏈繃鏈�
-
- LoginUser loginUser = SecurityUtils.getLoginUser();
- if (StringUtils.isNull(loginUser)) {
- return false;//褰撳墠鐧诲綍鐢ㄦ埛涓虹┖涓嶅彲浠ユ帶鍒�
- }
- SysUser user = loginUser.getUser();
- if (!user.getUserId().equals(ardCameras.getOperatorId())) {
- return false;//鏈繃鏈熷苟涓斾笉鏄綋鍓嶇敤鎴峰垯涓嶅彲鎺�
+ Date currentExpired = ardCameras.getOperatorExpired();//褰撳墠鐩告満鐨勮繃鏈熸椂闂�
+ String currentOperator = ardCameras.getOperatorId();//褰撳墠鐩告満鐨勬搷浣滆��
+ /*鍏堝垽鏂攣瀹氭椂闂�*/
+ if (currentExpired == null) {
+ /*濡傛灉鏈厤缃攣瀹氭椂闂达紝浠讳綍浜哄彲鎺у埗*/
+ ardCameras.setOperatorId(operator);
+ ardCamerasService.updateArdCameras(ardCameras);//鏇存柊鐩告満褰撳墠鎺у埗鑰�
+ return true;
+ } else {
+ /*閿佸畾鏃堕棿閰嶇疆浜嗭紝鍒ゆ柇褰撳墠鎿嶄綔鑰�*/
+ if (StringUtils.isEmpty(currentOperator)) {
+ /*褰撳墠鐩告満鎺у埗鑰呬负绌烘椂锛屼换浣曚汉鍙帶*/
+ ardCameras.setOperatorId(operator);
+ ardCamerasService.updateArdCameras(ardCameras);//鏇存柊鐩告満褰撳墠鎺у埗鑰�
+ return true;
+ } else {
+ /*鍒ゆ柇鏄惁鏈汉缁х画鎺у埗*/
+ if (currentOperator.equals(operator)) {
+ return true;
+ } else {
+ /*褰撳墠鐩告満鏈変汉鎺у埗骞朵笖閰嶇疆浜嗚繃鏈熸椂闂达紝鍏堝垽鏂紭鍏堢骇锛屼紭鍏堢骇楂樺厑璁告帶鍒�*/
+ Integer currentLevel = 0;//褰撳墠鐩告満鐨勬搷浣滆�呯殑浼樺厛绾�
+ if (CamPriority.priorityMap.containsKey(currentOperator)) {
+ /*褰撳墠鎺у埗鑰呬负绯荤粺鎶ヨ鐢ㄦ埛*/
+ currentLevel = (Integer) CamPriority.priorityMap.get(currentOperator);
+ } else {
+ /*褰撳墠鎺у埗鑰呬负鏅�氱敤鎴�*/
+ SysUser sysUser = sysUserService.selectUserById(currentOperator);
+ currentLevel = sysUser.getCameraPriority();
+ }
+ Integer operatorLevel = 0;//鑾峰彇鐢宠鑰呯殑浼樺厛绾�
+ if (CamPriority.priorityMap.containsKey(operator)) {
+ /*鍖呭惈璇存槑褰撳墠鐢宠鎺у埗鑰呬负绯荤粺鎶ヨ鐢ㄦ埛*/
+ operatorLevel = (Integer) CamPriority.priorityMap.get(operator);
+ } else {
+ /*鍚﹀垯鐢宠鎺у埗鑰呬负褰撳墠鐧诲綍鐢ㄦ埛*/
+ LoginUser loginUser = SecurityUtils.getLoginUser();
+ SysUser user = loginUser.getUser();//鑾峰彇鐧诲綍鐢ㄦ埛鐨勪俊鎭�
+ operatorLevel = user.getCameraPriority();
+ }
+ /*鐢宠鑰呮湭鎺у垯鍒ゆ柇浼樺厛绾�*/
+ if (operatorLevel > currentLevel) {
+ /*濡傛灉鐢宠鑰呬紭鍏堢骇楂橈紝鍏佽鎺у埗*/
+ ardCameras.setOperatorId(operator);
+ ardCameras.setOperatorExpired(null);
+ ardCamerasService.updateArdCameras(ardCameras);//鏇存柊鐩告満褰撳墠鎺у埗鑰�
+ return true;
+ } else {
+ /*濡傛灉鐢宠鑰呬紭鍏堢骇浣庯紝鍒欏垽鏂繃鏈熸椂闂�*/
+ if (currentExpired == null) {
+ /*褰撳墠鐩告満鏈厤缃繃鏈熸椂闂达紝鍙帶*/
+ ardCameras.setOperatorId(operator);
+ ardCameras.setOperatorExpired(null);
+ ardCamerasService.updateArdCameras(ardCameras);//鏇存柊鐩告満褰撳墠鎺у埗鑰�
+ return true;
+ } else {
+ if (new Date().before(currentExpired)) {
+ /*鏃堕棿鏈繃鏈燂紝涓嶅彲鎺�*/
+ return false;
+ } else {
+ /*鏃堕棿杩囨湡锛屽彲浠ユ帶鍒讹紝鏇存柊鎺у埗鑰�*/
+ ardCameras.setOperatorId(operator);
+ ardCamerasService.updateArdCameras(ardCameras);//鏇存柊鐩告満褰撳墠鎺у埗鑰�
+ return true;
+ }
+ }
+ }
+ }
}
}
- return true;
}
}
--
Gitblit v1.9.3