change - 监控单元传感器权限

main
wenjy 3 years ago
parent 6ef4943388
commit e12f665a83

@ -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<BaseMonitorunitInfoDto> list(BaseMonitorunitInfo baseMonitorunitInfo) {
List<BaseMonitorunitInfoDto> list =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
return list;
/*List<BaseMonitorunitInfoDto> list =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);*/
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 = new BaseMonitorunitInfo();
baseMonitorunitInfo.setEnableFlag(0L);
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
List<BaseMonitorunitInfoDto> 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<Ztree> treeData() {
List<Ztree> ztrees = baseMonitorunitInfoService.selectBaseMonitorunitInfoTree();
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 = new BaseMonitorunitInfo();
baseMonitorunitInfo.setEnableFlag(0L);
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos1 =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
baseMonitorunitInfoDtos.addAll(baseMonitorunitInfoDtos1);
}
}
List<Ztree> ztrees = baseMonitorunitInfoService.selectBaseMonitorunitInfoTree(baseMonitorunitInfoDtos);
return ztrees;
}

@ -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<BaseSensorInfoDto> list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
//List<BaseSensorInfoDto> list = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
List<BaseSensorInfoDto> list = new ArrayList<>();
SysUser sysUser = ShiroUtils.getSysUser();
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
if(ShiroUtils.getLoginName().equals("admin")){
List<BaseSensorInfoDto> baseSensorInfoDtos = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
list.addAll(baseSensorInfoDtos);
}else{
for (SysRole sysRole : sysRoles) {
baseSensorInfo.setRoleId(sysRole.getRoleId());
List<BaseSensorInfoDto> baseSensorInfoDtos = baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo);
list.addAll(baseSensorInfoDtos);
}
}
return getDataTable(list);
}

@ -86,7 +86,7 @@ public interface IBaseMonitorunitInfoService
*
* @return
*/
public List<Ztree> selectBaseMonitorunitInfoTree();
public List<Ztree> selectBaseMonitorunitInfoTree(List<BaseMonitorunitInfoDto> baseMonitorunitInfoList);
public List<Ztree> roleMonitorUnitTreeData(SysRole role,Long userId);
}

@ -195,9 +195,9 @@ public class BaseMonitorunitInfoServiceImpl implements IBaseMonitorunitInfoServi
* @return
*/
@Override
public List<Ztree> selectBaseMonitorunitInfoTree() {
List<BaseMonitorunitInfo> baseMonitorunitInfoList =
baseMonitorunitInfoMapper.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());
public List<Ztree> selectBaseMonitorunitInfoTree(List<BaseMonitorunitInfoDto> baseMonitorunitInfoList) {
/*List<BaseMonitorunitInfo> baseMonitorunitInfoList =
baseMonitorunitInfoMapper.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());*/
List<Ztree> ztrees = new ArrayList<Ztree>();
for (BaseMonitorunitInfo baseMonitorunitInfo : baseMonitorunitInfoList) {
Ztree ztree = new Ztree();

Loading…
Cancel
Save