change - 设备监测数据权限

main
wenjy 3 years ago
parent 25a8da5e1d
commit 9b84bfd660

@ -3,7 +3,10 @@ package com.ruoyi.web.controller.iot;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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.BaseDeviceParam;
import com.ruoyi.system.domain.BaseMonitorunitInfo;
import com.ruoyi.system.domain.BaseSensorInfo;
@ -12,6 +15,7 @@ import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
import com.ruoyi.system.service.IBaseDeviceParamService;
import com.ruoyi.system.service.IBaseMonitorunitInfoService;
import com.ruoyi.system.service.IBaseSensorInfoService;
import com.ruoyi.system.service.ISysRoleService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
@ -44,6 +48,9 @@ public class DeviceMonitorController {
@Autowired
private IBaseDeviceParamService baseDeviceParamService;
@Autowired
private ISysRoleService iSysRoleService;
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
/**
@ -56,9 +63,26 @@ public class DeviceMonitorController {
@GetMapping("/getMonitorUnitTree")
@ResponseBody
public String getMonitorUnitTree() {
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos = new ArrayList<>();
SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
if(ShiroUtils.getLoginName().equals("admin")){
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos1 =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(
new BaseMonitorunitInfo(null, null, null, null, 0L));
baseMonitorunitInfoDtos.addAll(baseMonitorunitInfoDtos1);
}else{
for (SysRole sysRole : sysRoles) {
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setEnableFlag(0L);
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos1 =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
baseMonitorunitInfoDtos.addAll(baseMonitorunitInfoDtos1);
}
}
List<BaseMonitorunitInfoDto> collect =
baseMonitorunitInfoDtos.stream()
@ -103,8 +127,30 @@ public class DeviceMonitorController {
@GetMapping("/getFirstMonitorUnit")
@ResponseBody
public String getFirstMonitorUnit(){
List<BaseMonitorunitInfoDto> baseMonitorunitInfos = new ArrayList<>();
SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
if(ShiroUtils.getLoginName().equals("admin")){
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos1 =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(
new BaseMonitorunitInfo(null, null, null, null, 0L));
baseMonitorunitInfos.addAll(baseMonitorunitInfoDtos1);
}else{
for (SysRole sysRole : sysRoles) {
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
baseMonitorunitInfo.setEnableFlag(0L);
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos1 =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
baseMonitorunitInfos.addAll(baseMonitorunitInfoDtos1);
}
}
String monitorunitId = "";
List<BaseMonitorunitInfo> baseMonitorunitInfos = baseMonitorunitInfoService.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());
//List<BaseMonitorunitInfo> baseMonitorunitInfos = baseMonitorunitInfoService.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());
if(baseMonitorunitInfos.size() > 0){
BaseMonitorunitInfo baseMonitorunitInfo = baseMonitorunitInfos.stream().filter(x -> !x.getParentId().isEmpty()).collect(Collectors.toList()).get(0);
monitorunitId = baseMonitorunitInfo.getMonitorunitId();

@ -62,7 +62,7 @@ public class BaseMonitorunitInfoServiceImpl implements IBaseMonitorunitInfoServi
public List<BaseMonitorunitInfoDto> selectBaseMonitorunitInfoDtoList(
BaseMonitorunitInfo baseMonitorunitInfo) {
if(baseMonitorunitInfo.getRoleId() != null){
if(baseMonitorunitInfo.getRoleId() != null && baseMonitorunitInfo.getRoleId() > 1){
return baseMonitorunitInfoMapper.selectBaseMonitorunitInfoDtoListByRoleId(baseMonitorunitInfo);
}

Loading…
Cancel
Save