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<>();