From 6ef494338893f329fe87c7b421d1dbbda829547b Mon Sep 17 00:00:00 2001 From: wenjy Date: Sun, 15 May 2022 16:18:43 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E4=BC=A0=E6=84=9F=E5=99=A8?= =?UTF-8?q?=E6=B1=87=E6=80=BB=E8=A7=92=E8=89=B2=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/SensorSummaryController.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/SensorSummaryController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/SensorSummaryController.java index d4f7b28..3cd333f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/SensorSummaryController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/SensorSummaryController.java @@ -4,14 +4,20 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.json.JsonUtils; +import com.ruoyi.common.utils.ShiroUtils; +import com.ruoyi.system.domain.BaseMonitorunitInfo; import com.ruoyi.system.domain.BaseSensorInfo; import com.ruoyi.system.domain.BaseSensorType; import com.ruoyi.system.domain.SysParamConfig; +import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto; import com.ruoyi.system.domain.dto.BaseSensorInfoDto; import com.ruoyi.system.service.IBaseSensorInfoService; import com.ruoyi.system.service.IBaseSensorTypeService; import com.ruoyi.system.service.ISysParamConfigService; +import com.ruoyi.system.service.ISysRoleService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.StringRedisTemplate; @@ -45,6 +51,9 @@ public class SensorSummaryController extends BaseController { @Autowired private StringRedisTemplate redisTemplate; + @Autowired + private ISysRoleService iSysRoleService; + @GetMapping() public String sensorSummary() { return "iot-ui/sensorSummary"; @@ -64,8 +73,30 @@ public class SensorSummaryController extends BaseController { public String getSensorHistoryData(String sensorTypeId) { int indexId = 1; List> result = new ArrayList<>(); - List baseSensorInfoDtos = - baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(sensorTypeId, 0L)); + List baseSensorInfoDtos = new ArrayList<>(); + + SysUser sysUser = ShiroUtils.getSysUser(); + + List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); + + if(ShiroUtils.getLoginName().equals("admin")){ + List baseSensorInfoDto = + baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(sensorTypeId, 0L)); + baseSensorInfoDtos.addAll(baseSensorInfoDto); + }else{ + for (SysRole sysRole : sysRoles) { + BaseSensorInfo baseSensorInfo = new BaseSensorInfo(); + baseSensorInfo.setSensorType(sensorTypeId); + baseSensorInfo.setRoleId(sysRole.getRoleId()); + baseSensorInfo.setEnableFlag(0L); + List baseSensorInfoDto = + baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); + baseSensorInfoDtos.addAll(baseSensorInfoDto); + } + } + + /*List baseSensorInfoDto = + baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(sensorTypeId, 0L));*/ for (BaseSensorInfoDto x : baseSensorInfoDtos) { Map info = new HashMap<>();