From 2a53365575128e1161f4376b4be902049de38a82 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期二, 25 三月 2025 14:59:24 +0800
Subject: [PATCH] art: 设备台账-用户数据权限过滤

---
 lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java
index 779b7c6..e77f582 100644
--- a/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java
+++ b/lxzn-module-eam-common/src/main/java/org/jeecg/modules/eam/service/impl/EamEquipmentServiceImpl.java
@@ -8,7 +8,9 @@
 import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.constant.DataBaseConstant;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.eam.aspect.annotation.EquipmentHistoryLog;
 import org.jeecg.modules.eam.constant.AssetStatusEnum;
 import org.jeecg.modules.eam.constant.EquipmentMaintenanceStatus;
@@ -104,7 +106,15 @@
         if(sysUser == null){
             return page;
         }
-        queryWrapper.exists("select 1 from mdc_user_production t where t.user_id=? and t.pro_id=e.org_id", sysUser.getId());
+        if(StringUtils.isNotBlank(sysUser.getEquipmentIds())){
+            //閫夋嫨浜嗚澶囷紝鏍规嵁璁惧id杩囨护璁惧
+            List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(","));
+            queryWrapper.in("e.equipment_code", equipArr);
+        }else {
+            //娌℃湁閫夋嫨璁惧锛屾牴鎹溅闂磋繃婊よ澶�
+            queryWrapper.exists("select 1 from mdc_user_production t where t.user_id=? and t.pro_id=e.org_id", sysUser.getId());
+        }
+        //鏌ヨ鏉′欢杩囨护
         if(eamEquipment != null){
             if(StringUtils.isNotBlank(eamEquipment.getEquipmentCode())){
                 queryWrapper.like("e.equipment_code", eamEquipment.getEquipmentCode());
@@ -133,7 +143,15 @@
             //鎺掑簭
             if(StringUtils.isNotBlank(eamEquipment.getColumn()) && StringUtils.isNotBlank(eamEquipment.getOrder())){
                 //queryWrapper.like("column", eamEquipment.getColumn());
-                queryWrapper.orderByDesc("e.create_time");
+                String column = eamEquipment.getColumn();
+                if(column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) {
+                    column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX));
+                }
+                if(DataBaseConstant.SQL_ASC.equalsIgnoreCase(eamEquipment.getOrder())){
+                    queryWrapper.orderByAsc("e." + oConvertUtils.camelToUnderline(column));
+                }else {
+                    queryWrapper.orderByDesc("e." + oConvertUtils.camelToUnderline(column));
+                }
             }else {
                 queryWrapper.orderByDesc("e.create_time");
             }

--
Gitblit v1.9.3