diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java index 73d2f00..f291a1f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java @@ -3,8 +3,11 @@ package com.ruoyi.web.controller.iot; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.system.domain.*; import com.ruoyi.system.domain.dto.*; import com.ruoyi.system.service.*; @@ -40,6 +43,9 @@ public class IndexController { @Autowired private IRecordAlarmService recordAlarmService; + @Autowired + private ISysRoleService iSysRoleService; + @GetMapping() public String index() { return "iot-ui/index"; @@ -57,16 +63,26 @@ public class IndexController { public String getMonitorUnitCharts() { try { List result = new ArrayList(); - + List baseMonitorunitInfoDtoList = new ArrayList(); List baseMonitorunitTypes = baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType()); - List baseMonitorunitInfoDtos = - baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo()); + + SysUser sysUser = ShiroUtils.getSysUser(); + + List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); + for (SysRole sysRole : sysRoles) { + // + BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); + baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); + List baseMonitorunitInfoDtos = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); + baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos); + } baseMonitorunitTypes.forEach( x -> { List collect = - baseMonitorunitInfoDtos.stream() + baseMonitorunitInfoDtoList.stream() .filter( y -> !y.getParentId().isEmpty() diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseMonitorunitInfo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseMonitorunitInfo.java index a177820..aad8d43 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseMonitorunitInfo.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseMonitorunitInfo.java @@ -58,6 +58,8 @@ public class BaseMonitorunitInfo extends TreeEntity private String monitorunitImage; + private Long roleId; + public void setObjId(Long objId) { this.objId = objId; @@ -129,6 +131,14 @@ public class BaseMonitorunitInfo extends TreeEntity this.monitorunitImage = monitorunitImage; } + public Long getRoleId() { + return roleId; + } + + public void setRoleId(Long roleId) { + this.roleId = roleId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseMonitorunitInfoMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseMonitorunitInfoMapper.java index bf9af00..1a43d14 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseMonitorunitInfoMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseMonitorunitInfoMapper.java @@ -37,6 +37,16 @@ public interface BaseMonitorunitInfoMapper */ public List selectBaseMonitorunitInfoDtoList(BaseMonitorunitInfo baseMonitorunitInfo); + /** + * 根據角色編號查询监控单元信息列表 + * @author WenJY + * @date 2022-05-15 11:28 + * @param baseMonitorunitInfo + * @return java.util.List + */ + public List selectBaseMonitorunitInfoDtoListByRoleId(BaseMonitorunitInfo baseMonitorunitInfo); + + /** * 新增监控单元信息 * 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 a0d2a90..5642e54 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 @@ -61,6 +61,11 @@ public class BaseMonitorunitInfoServiceImpl implements IBaseMonitorunitInfoServi @Override public List selectBaseMonitorunitInfoDtoList( BaseMonitorunitInfo baseMonitorunitInfo) { + + if(baseMonitorunitInfo.getRoleId() != null){ + return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoDtoListByRoleId(baseMonitorunitInfo); + } + return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 348052e..595acd1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -91,6 +91,9 @@ public class SysRoleServiceImpl implements ISysRoleService { List userRoles = roleMapper.selectRolesByUserId(userId); List roles = selectRoleAll(); + if (roles.size() == 0){ + return userRoles; + } for (SysRole role : roles) { for (SysRole userRole : userRoles) diff --git a/ruoyi-system/src/main/resources/mapper/system/BaseMonitorunitInfoMapper.xml b/ruoyi-system/src/main/resources/mapper/system/BaseMonitorunitInfoMapper.xml index e736094..a792d92 100644 --- a/ruoyi-system/src/main/resources/mapper/system/BaseMonitorunitInfoMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/BaseMonitorunitInfoMapper.xml @@ -17,6 +17,7 @@ + @@ -77,6 +78,28 @@ order by t1.objId + +