From b61c4537a78d58412ef7ccd6e2c30152d807c5b7 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: Mon, 29 Jul 2024 11:04:54 +0800
Subject: [PATCH] 电磁锁密码查询去除上一组密码修改提交
---
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/SdkOperateAspect.java | 39 +++++++++++++++++++++++++--------------
1 files changed, 25 insertions(+), 14 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 dd79534..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,10 +1,12 @@
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;
@@ -14,12 +16,12 @@
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;
-import static jdk.nashorn.internal.runtime.regexp.joni.Config.log;
/**
* SDK控制处理
@@ -28,7 +30,7 @@
*/
@Aspect
@Component
-@Slf4j(topic = "hikSdk")
+@Slf4j(topic = "sdk")
public class SdkOperateAspect {
@Resource
@@ -43,13 +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("已获取相机控制权");
+ log.debug("已获取相机控制权--" + method.getName());
+ // 执行目标方法
return point.proceed();
} else {
- log.debug("未获取相机控制权");
- return false;//代替目标方法的返回值
+ log.debug("未获取相机控制权--" + method.getName());
+ return AjaxResult.error("未获取相机控制权--" + method.getName());//代替目标方法的返回值
}
}
@@ -59,6 +64,7 @@
* @param joinPoint 切点
*/
public Boolean controlScopeFilter(ProceedingJoinPoint joinPoint) {
+
//获取请求控制相机的命令信息
CameraCmd cmd = (CameraCmd) joinPoint.getArgs()[0];
String operator = cmd.getOperator();//申请者
@@ -89,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) {
@@ -137,6 +149,5 @@
}
}
}
-
}
}
--
Gitblit v1.9.3