change - 监控单元传感器权限

main
wenjy 3 years ago
parent 6ef4943388
commit e12f665a83

@ -1,5 +1,6 @@
package com.ruoyi.web.controller.base; package com.ruoyi.web.controller.base;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -7,6 +8,7 @@ import java.util.UUID;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.ruoyi.common.core.domain.entity.SysRole; 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.core.page.TableDataInfo;
import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.system.domain.BaseAlarmInfo; 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.BaseMonitorunitInfoDto;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto; import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
import com.ruoyi.system.service.IBaseDeviceParamService; import com.ruoyi.system.service.IBaseDeviceParamService;
import com.ruoyi.system.service.ISysRoleService;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -47,6 +50,9 @@ public class BaseMonitorunitInfoController extends BaseController {
@Autowired private IBaseDeviceParamService baseDeviceParamService; @Autowired private IBaseDeviceParamService baseDeviceParamService;
@Autowired
private ISysRoleService iSysRoleService;
@RequiresPermissions("base:monitorUnitInfo:view") @RequiresPermissions("base:monitorUnitInfo:view")
@GetMapping() @GetMapping()
public String monitorUnitInfo() { public String monitorUnitInfo() {
@ -58,9 +64,31 @@ public class BaseMonitorunitInfoController extends BaseController {
@PostMapping("/list") @PostMapping("/list")
@ResponseBody @ResponseBody
public List<BaseMonitorunitInfoDto> list(BaseMonitorunitInfo baseMonitorunitInfo) { public List<BaseMonitorunitInfoDto> list(BaseMonitorunitInfo baseMonitorunitInfo) {
List<BaseMonitorunitInfoDto> 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); baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
return list; baseMonitorunitInfoDtos.addAll(baseMonitorunitInfoDtos1);
}
}
return baseMonitorunitInfoDtos;
} }
@GetMapping("/listByParent") @GetMapping("/listByParent")
@ -272,7 +300,30 @@ public class BaseMonitorunitInfoController extends BaseController {
@GetMapping("/treeData") @GetMapping("/treeData")
@ResponseBody @ResponseBody
public List<Ztree> treeData() { 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; return ztrees;
} }

@ -9,13 +9,18 @@ import com.alibaba.fastjson.JSONArray;
import com.mysql.cj.xdevapi.JsonArray; import com.mysql.cj.xdevapi.JsonArray;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.Ztree; 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.common.utils.ShiroUtils;
import com.ruoyi.system.domain.BaseAlarmInfo; import com.ruoyi.system.domain.BaseAlarmInfo;
import com.ruoyi.system.domain.BaseAlarmType; 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.BaseAlarmInfoDto;
import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto;
import com.ruoyi.system.domain.dto.BaseSensorInfoDto; import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
import com.ruoyi.system.service.IBaseAlarmInfoService; import com.ruoyi.system.service.IBaseAlarmInfoService;
import com.ruoyi.system.service.IBaseAlarmTypeService; import com.ruoyi.system.service.IBaseAlarmTypeService;
import com.ruoyi.system.service.ISysRoleService;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -54,6 +59,9 @@ public class BaseSensorInfoController extends BaseController {
@Autowired @Autowired
private IBaseAlarmTypeService baseAlarmTypeService; private IBaseAlarmTypeService baseAlarmTypeService;
@Autowired
private ISysRoleService iSysRoleService;
@RequiresPermissions("base:sensorInfo:view") @RequiresPermissions("base:sensorInfo:view")
@GetMapping() @GetMapping()
public String sensorInfo() { public String sensorInfo() {
@ -66,7 +74,22 @@ public class BaseSensorInfoController extends BaseController {
@ResponseBody @ResponseBody
public TableDataInfo list(BaseSensorInfo baseSensorInfo) { public TableDataInfo list(BaseSensorInfo baseSensorInfo) {
startPage(); 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); return getDataTable(list);
} }

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

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

Loading…
Cancel
Save