From e12f665a83621c229c7241e8e1c16efd00809cb2 Mon Sep 17 00:00:00 2001 From: wenjy Date: Sun, 15 May 2022 16:33:15 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E7=9B=91=E6=8E=A7=E5=8D=95?= =?UTF-8?q?=E5=85=83=E4=BC=A0=E6=84=9F=E5=99=A8=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/BaseMonitorunitInfoController.java | 59 +++++++++++++++++-- .../base/BaseSensorInfoController.java | 25 +++++++- .../service/IBaseMonitorunitInfoService.java | 2 +- .../impl/BaseMonitorunitInfoServiceImpl.java | 6 +- 4 files changed, 83 insertions(+), 9 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitInfoController.java index 723abd9..5a9958d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseMonitorunitInfoController.java @@ -1,5 +1,6 @@ package com.ruoyi.web.controller.base; +import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.UUID; @@ -7,6 +8,7 @@ import java.util.UUID; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.system.domain.BaseAlarmInfo; @@ -16,6 +18,7 @@ import com.ruoyi.system.domain.dto.BaseAlarmInfoDto; import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto; import com.ruoyi.system.domain.dto.BaseSensorInfoDto; import com.ruoyi.system.service.IBaseDeviceParamService; +import com.ruoyi.system.service.ISysRoleService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -47,6 +50,9 @@ public class BaseMonitorunitInfoController extends BaseController { @Autowired private IBaseDeviceParamService baseDeviceParamService; + @Autowired + private ISysRoleService iSysRoleService; + @RequiresPermissions("base:monitorUnitInfo:view") @GetMapping() public String monitorUnitInfo() { @@ -58,9 +64,31 @@ public class BaseMonitorunitInfoController extends BaseController { @PostMapping("/list") @ResponseBody public List list(BaseMonitorunitInfo baseMonitorunitInfo) { - List list = - baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); - return list; + /*List list = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);*/ + + List baseMonitorunitInfoDtos = new ArrayList<>(); + SysUser sysUser = ShiroUtils.getSysUser(); + + List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); + + if(ShiroUtils.getLoginName().equals("admin")){ + List baseMonitorunitInfoDtos1 = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList( + new BaseMonitorunitInfo(null, null, null, null, 0L)); + baseMonitorunitInfoDtos.addAll(baseMonitorunitInfoDtos1); + }else{ + for (SysRole sysRole : sysRoles) { + baseMonitorunitInfo = new BaseMonitorunitInfo(); + baseMonitorunitInfo.setEnableFlag(0L); + baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); + List baseMonitorunitInfoDtos1 = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); + baseMonitorunitInfoDtos.addAll(baseMonitorunitInfoDtos1); + } + } + + return baseMonitorunitInfoDtos; } @GetMapping("/listByParent") @@ -272,7 +300,30 @@ public class BaseMonitorunitInfoController extends BaseController { @GetMapping("/treeData") @ResponseBody public List treeData() { - List ztrees = baseMonitorunitInfoService.selectBaseMonitorunitInfoTree(); + + List baseMonitorunitInfoDtos = new ArrayList<>(); + SysUser sysUser = ShiroUtils.getSysUser(); + + List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); + + if(ShiroUtils.getLoginName().equals("admin")){ + List baseMonitorunitInfoDtos1 = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList( + new BaseMonitorunitInfo(null, null, null, null, 0L)); + baseMonitorunitInfoDtos.addAll(baseMonitorunitInfoDtos1); + }else{ + for (SysRole sysRole : sysRoles) { + BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); + baseMonitorunitInfo = new BaseMonitorunitInfo(); + baseMonitorunitInfo.setEnableFlag(0L); + baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); + List baseMonitorunitInfoDtos1 = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); + baseMonitorunitInfoDtos.addAll(baseMonitorunitInfoDtos1); + } + } + + List ztrees = baseMonitorunitInfoService.selectBaseMonitorunitInfoTree(baseMonitorunitInfoDtos); return ztrees; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java index 42a1153..3d4b559 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/BaseSensorInfoController.java @@ -9,13 +9,18 @@ import com.alibaba.fastjson.JSONArray; import com.mysql.cj.xdevapi.JsonArray; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.domain.Ztree; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.system.domain.BaseAlarmInfo; import com.ruoyi.system.domain.BaseAlarmType; +import com.ruoyi.system.domain.BaseMonitorunitInfo; import com.ruoyi.system.domain.dto.BaseAlarmInfoDto; +import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto; import com.ruoyi.system.domain.dto.BaseSensorInfoDto; import com.ruoyi.system.service.IBaseAlarmInfoService; import com.ruoyi.system.service.IBaseAlarmTypeService; +import com.ruoyi.system.service.ISysRoleService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -54,6 +59,9 @@ public class BaseSensorInfoController extends BaseController { @Autowired private IBaseAlarmTypeService baseAlarmTypeService; + @Autowired + private ISysRoleService iSysRoleService; + @RequiresPermissions("base:sensorInfo:view") @GetMapping() public String sensorInfo() { @@ -66,7 +74,22 @@ public class BaseSensorInfoController extends BaseController { @ResponseBody public TableDataInfo list(BaseSensorInfo baseSensorInfo) { startPage(); - List list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); + //List list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); + List list = new ArrayList<>(); + SysUser sysUser = ShiroUtils.getSysUser(); + + List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); + + if(ShiroUtils.getLoginName().equals("admin")){ + List baseSensorInfoDtos = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); + list.addAll(baseSensorInfoDtos); + }else{ + for (SysRole sysRole : sysRoles) { + baseSensorInfo.setRoleId(sysRole.getRoleId()); + List baseSensorInfoDtos = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); + list.addAll(baseSensorInfoDtos); + } + } return getDataTable(list); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseMonitorunitInfoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseMonitorunitInfoService.java index 0775ffa..42fa3c7 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseMonitorunitInfoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IBaseMonitorunitInfoService.java @@ -86,7 +86,7 @@ public interface IBaseMonitorunitInfoService * * @return 所有监控单元信息信息 */ - public List selectBaseMonitorunitInfoTree(); + public List selectBaseMonitorunitInfoTree(List baseMonitorunitInfoList); public List roleMonitorUnitTreeData(SysRole role,Long userId); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseMonitorunitInfoServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseMonitorunitInfoServiceImpl.java index cab2050..30dcd7d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseMonitorunitInfoServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseMonitorunitInfoServiceImpl.java @@ -195,9 +195,9 @@ public class BaseMonitorunitInfoServiceImpl implements IBaseMonitorunitInfoServi * @return 所有监控单元信息信息 */ @Override - public List selectBaseMonitorunitInfoTree() { - List baseMonitorunitInfoList = - baseMonitorunitInfoMapper.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo()); + public List selectBaseMonitorunitInfoTree(List baseMonitorunitInfoList) { + /*List baseMonitorunitInfoList = + baseMonitorunitInfoMapper.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());*/ List ztrees = new ArrayList(); for (BaseMonitorunitInfo baseMonitorunitInfo : baseMonitorunitInfoList) { Ztree ztree = new Ztree();