From 5262d2ad6fb4126f2e34565f33384085e09afb1a Mon Sep 17 00:00:00 2001 From: wenjy Date: Sun, 15 May 2022 17:14:17 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E9=A6=96=E9=A1=B5=E7=9B=91?= =?UTF-8?q?=E6=8E=A7=E5=8D=95=E5=85=83=E6=95=B0=E9=87=8F=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/iot/IndexController.java | 102 +++++++++++------- 1 file changed, 62 insertions(+), 40 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java index 30189d7..0113660 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java @@ -70,12 +70,18 @@ public class IndexController { SysUser sysUser = ShiroUtils.getSysUser(); List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); - for (SysRole sysRole : sysRoles) { - // - BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); - baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); + if(!ShiroUtils.getLoginName().equals("admin")){ + for (SysRole sysRole : sysRoles) { + // + BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); + baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); + List baseMonitorunitInfoDtos = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); + baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos); + } + }else{ List baseMonitorunitInfoDtos = - baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo()); baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos); } @@ -139,51 +145,67 @@ public class IndexController { List> data = new ArrayList<>(); List header = - new ArrayList() { - { - this.add("名称"); - this.add("监控数量"); - this.add("告警数量"); - } - }; + new ArrayList() { + { + this.add("名称"); + this.add("监控数量"); + this.add("告警数量"); + } + }; List baseMonitorunitTypes = - baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType()); + baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType()); List baseMonitorunitInfoDtoList = new ArrayList(); SysUser sysUser = ShiroUtils.getSysUser(); List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); - for (SysRole sysRole : sysRoles) { - // - BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); - baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); + + if(!ShiroUtils.getLoginName().equals("admin")){ + for (SysRole sysRole : sysRoles) { + // + BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); + baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); + List baseMonitorunitInfoDtos = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); + baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos); + } + }else { List baseMonitorunitInfoDtos = - baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo()); baseMonitorunitInfoDtoList.addAll(baseMonitorunitInfoDtos); } - baseMonitorunitTypes.forEach( - x -> { - List collect = - baseMonitorunitInfoDtoList.stream() - .filter( - y -> - !y.getParentId().isEmpty() - && y.getMonitorunitType().equals(x.getMonitorunittypeId())) - .collect(Collectors.toList()); - List collect2 = - collect.stream() - .filter(z -> z.getMonitorunitStatus().equals(0)) - .collect(Collectors.toList()); - data.add( - new ArrayList() { - { - this.add(x.getMonitorunittypeName()); - this.add(collect.size() + ""); - this.add(collect2.size() + ""); - } - }); - }); + + for (BaseMonitorunitType baseMonitorunitType : baseMonitorunitTypes) { + List baseMonitorunitInfoDtoList1 = + baseMonitorunitInfoDtoList.stream() + .filter( + y ->!y.getParentId().isEmpty()&& y.getMonitorunitType().equals(baseMonitorunitType.getMonitorunittypeId())) + .collect(Collectors.toList()); + if(baseMonitorunitInfoDtoList1.size() > 0){ + /*List collect2 = + baseMonitorunitInfoDtoList1.stream().filter(z -> z.getMonitorunitStatus().equals(0L)).collect(Collectors.toList());*/ + + //List longList = baseMonitorunitInfoDtoList1.stream().filter(z -> z.getMonitorunitStatus().equals(0L)).map(BaseMonitorunitInfoDto::getMonitorunitStatus).collect(Collectors.toList()); + data.add( + new ArrayList() { + { + this.add(baseMonitorunitType.getMonitorunittypeName()); + this.add(baseMonitorunitInfoDtoList1.size() + ""); + this.add(0 + ""); + } + }); + }else{ + data.add( + new ArrayList() { + { + this.add(baseMonitorunitType.getMonitorunittypeName()); + this.add(0 + ""); + this.add(0 + ""); + } + }); + } + } return JSONArray.toJSONString(new ScrollTableDto(header, data)); } catch (Exception ex) {