From 06842b9c367083c3bf77b8b54a1e1a32b68a2e5e Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期六, 06 七月 2024 09:02:33 +0800
Subject: [PATCH] 电磁锁分页bug修改提交

---
 ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SdkOperateAspect.java |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 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 3217b04..b96c19a 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,22 +1,27 @@
 package com.ruoyi.framework.aspectj;
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.model.LoginUser;
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.utils.DictUtils;
 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.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.Around;
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
 import org.springframework.stereotype.Component;
-
 import javax.annotation.Resource;
+import java.lang.reflect.Method;
 import java.util.Date;
+
 
 /**
  * SDK鎺у埗澶勭悊
@@ -25,6 +30,7 @@
  */
 @Aspect
 @Component
+@Slf4j(topic = "sdk")
 public class SdkOperateAspect {
 
     @Resource
@@ -39,11 +45,16 @@
 
     @Around("dsPointCut()")
     public Object around(ProceedingJoinPoint point) throws Throwable {
+        MethodSignature signature = (MethodSignature) point.getSignature();
+        Method method = signature.getMethod();
         Boolean result = controlScopeFilter(point);
         if (result) {
+            log.debug("宸茶幏鍙栫浉鏈烘帶鍒舵潈--" + method.getName());
+            // 鎵ц鐩爣鏂规硶
             return point.proceed();
         } else {
-            return false;//浠f浛鐩爣鏂规硶鐨勮繑鍥炲��
+            log.debug("鏈幏鍙栫浉鏈烘帶鍒舵潈--" + method.getName());
+            return AjaxResult.error("鏈幏鍙栫浉鏈烘帶鍒舵潈--" + method.getName());//浠f浛鐩爣鏂规硶鐨勮繑鍥炲��
         }
     }
 
@@ -53,6 +64,7 @@
      * @param joinPoint 鍒囩偣
      */
     public Boolean controlScopeFilter(ProceedingJoinPoint joinPoint) {
+
         //鑾峰彇璇锋眰鎺у埗鐩告満鐨勫懡浠や俊鎭�
         CameraCmd cmd = (CameraCmd) joinPoint.getArgs()[0];
         String operator = cmd.getOperator();//鐢宠鑰�
@@ -83,23 +95,29 @@
                 } else {
                     /*褰撳墠鐩告満鏈変汉鎺у埗骞朵笖閰嶇疆浜嗚繃鏈熸椂闂达紝鍏堝垽鏂紭鍏堢骇锛屼紭鍏堢骇楂樺厑璁告帶鍒�*/
                     Integer currentLevel = 0;//褰撳墠鐩告満鐨勬搷浣滆�呯殑浼樺厛绾�
-                    if (CamPriority.priorityMap.containsKey(currentOperator)) {
+                    String camerasPriority = DictUtils.getDictValue("cameras_priority", currentOperator);
+                    if(StringUtils.isNotEmpty(camerasPriority)) {
                         /*褰撳墠鎺у埗鑰呬负绯荤粺鎶ヨ鐢ㄦ埛*/
-                        currentLevel = (Integer) CamPriority.priorityMap.get(currentOperator);
+                        currentLevel = Integer.valueOf(camerasPriority);
                     } else {
                         /*褰撳墠鎺у埗鑰呬负鏅�氱敤鎴�*/
                         SysUser sysUser = sysUserService.selectUserById(currentOperator);
-                        currentLevel = sysUser.getCameraPriority();
+                        if(StringUtils.isNull(sysUser))
+                        {
+                            return true;
+                        }
+                        currentLevel = Integer.valueOf(sysUser.getCameraPriority());
                     }
                     Integer operatorLevel = 0;//鑾峰彇鐢宠鑰呯殑浼樺厛绾�
-                    if (CamPriority.priorityMap.containsKey(operator)) {
+                    String operatorPriority = DictUtils.getDictValue("cameras_priority", operator);
+                    if (StringUtils.isNotEmpty(operatorPriority)) {
                         /*鍖呭惈璇存槑褰撳墠鐢宠鎺у埗鑰呬负绯荤粺鎶ヨ鐢ㄦ埛*/
-                        operatorLevel = (Integer) CamPriority.priorityMap.get(operator);
+                        operatorLevel = Integer.valueOf(operatorPriority);
                     } else {
                         /*鍚﹀垯鐢宠鎺у埗鑰呬负褰撳墠鐧诲綍鐢ㄦ埛*/
                         LoginUser loginUser = SecurityUtils.getLoginUser();
                         SysUser user = loginUser.getUser();//鑾峰彇鐧诲綍鐢ㄦ埛鐨勪俊鎭�
-                        operatorLevel = user.getCameraPriority();
+                        operatorLevel = Integer.valueOf(user.getCameraPriority());
                     }
                     /*鐢宠鑰呮湭鎺у垯鍒ゆ柇浼樺厛绾�*/
                     if (operatorLevel > currentLevel) {
@@ -131,6 +149,5 @@
                 }
             }
         }
-
     }
 }

--
Gitblit v1.9.3