From 25a8da5e1d6260706ec0fef93d615b91eedcb260 Mon Sep 17 00:00:00 2001 From: wenjy Date: Sun, 15 May 2022 15:50:15 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=99=BA=E6=85=A7=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/WisdomScenarioContorller.java | 123 ++++++++++++++++-- .../ruoyi/system/domain/BaseAlarmModule.java | 10 ++ .../com/ruoyi/system/domain/RecordAlarm.java | 10 ++ .../system/mapper/BaseAlarmModuleMapper.java | 1 + .../system/mapper/RecordAlarmMapper.java | 2 + .../system/service/IRecordAlarmService.java | 2 + .../impl/BaseAlarmModuleServiceImpl.java | 5 + .../service/impl/RecordAlarmServiceImpl.java | 5 + .../mapper/system/BaseAlarmModuleMapper.xml | 20 +++ .../mapper/system/RecordAlarmMapper.xml | 30 +++++ 10 files changed, 195 insertions(+), 13 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/WisdomScenarioContorller.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/WisdomScenarioContorller.java index 57e8e09..bd4c8f9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/WisdomScenarioContorller.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/WisdomScenarioContorller.java @@ -3,6 +3,9 @@ package com.ruoyi.web.controller.iot; import com.alibaba.fastjson.JSONArray; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; +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.*; import com.ruoyi.system.domain.dto.BaseAlarmModuleDto; import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto; @@ -41,6 +44,9 @@ public class WisdomScenarioContorller extends BaseController { @Autowired private IRecordAlarmService recordAlarmService; + @Autowired + private ISysRoleService iSysRoleService; + /** * 数量统计:传感器数量、监控单元数量 * @@ -53,8 +59,26 @@ public class WisdomScenarioContorller extends BaseController { @ResponseBody public String quantityStatistics(String monitorUnitType) { - List baseMonitorunitInfos = - baseMonitorunitInfoService.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo()); + List baseMonitorunitInfos = new ArrayList<>(); + + SysUser sysUser = ShiroUtils.getSysUser(); + + List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); + + if(!ShiroUtils.getLoginName().equals("admin")){ + for (SysRole sysRole : sysRoles) { + BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); + baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); + List baseMonitorunitInfos1 = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); + baseMonitorunitInfos.addAll(baseMonitorunitInfos1); + } + }else { + List baseMonitorunitInfos1 = + baseMonitorunitInfoService.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo()); + baseMonitorunitInfos.addAll(baseMonitorunitInfos1); + } + List collect = baseMonitorunitInfos.stream() .filter( @@ -65,10 +89,26 @@ public class WisdomScenarioContorller extends BaseController { .collect(Collectors.toList()); int sensorAmount = 0; for (BaseMonitorunitInfo x : collect) { - List baseSensorInfoDtos = - baseSensorInfoService.selectBaseSensorInfoList( - new BaseSensorInfo(null, null, null, x.getMonitorunitId())); - sensorAmount = sensorAmount + baseSensorInfoDtos.size(); + List baseSensorInfoDtos = new ArrayList<>(); + + if(ShiroUtils.getLoginName().equals("admin")){ + BaseSensorInfo baseSensorInfo = new BaseSensorInfo(); + baseSensorInfo.setMonitorunitId(x.getMonitorunitId()); + List baseSensorInfoDtos1 = + baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); + baseSensorInfoDtos.addAll(baseSensorInfoDtos1); + sensorAmount = sensorAmount + baseSensorInfoDtos.size(); + }else { + for (SysRole sysRole : sysRoles) { + BaseSensorInfo baseSensorInfo = new BaseSensorInfo(); + baseSensorInfo.setMonitorunitId(x.getMonitorunitId()); + baseSensorInfo.setRoleId(sysRole.getRoleId()); + List baseSensorInfoDtos1 = + baseSensorInfoService.selectBaseSensorInfoList(baseSensorInfo); + baseSensorInfoDtos.addAll(baseSensorInfoDtos1); + } + sensorAmount = sensorAmount + baseSensorInfoDtos.size(); + } } int finalSensorAmount = sensorAmount; @@ -93,8 +133,27 @@ public class WisdomScenarioContorller extends BaseController { @GetMapping("/getMonitorUnitModule") @ResponseBody public String getMonitorUnitModule(String monitorUnitType) { - List baseMonitorunitInfoDtos = - baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo()); + List baseMonitorunitInfoDtos = new ArrayList<>(); + SysUser sysUser = ShiroUtils.getSysUser(); + + List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); + + if(!ShiroUtils.getLoginName().equals("admin")){ + for (SysRole sysRole : sysRoles) { + BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); + baseMonitorunitInfo.setRoleId(sysRole.getRoleId()); + List baseMonitorunitInfos1 = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); + baseMonitorunitInfoDtos.addAll(baseMonitorunitInfos1); + } + }else { + List baseMonitorunitInfos1 = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo()); + baseMonitorunitInfoDtos.addAll(baseMonitorunitInfos1); + } + + /*List baseMonitorunitInfoDtos = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());*/ List collect = baseMonitorunitInfoDtos.stream() .filter( @@ -122,9 +181,26 @@ public class WisdomScenarioContorller extends BaseController { @GetMapping("/getAlarmModule") @ResponseBody public String getAlarmModule(String monitorUnitId) { + List baseAlarmModuleDtos = new ArrayList(); + SysUser sysUser = ShiroUtils.getSysUser(); + + List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); + + if(!ShiroUtils.getLoginName().equals("admin")){ + for (SysRole sysRole : sysRoles) { + BaseAlarmModule baseAlarmModule = new BaseAlarmModule(); + baseAlarmModule.setRoleId(sysRole.getRoleId()); + baseAlarmModule.setMonitorunitId(monitorUnitId); + List baseAlarmModuleDtos1 = baseAlarmModuleService.selectAlarmModuleAmountList(baseAlarmModule); + baseAlarmModuleDtos.addAll(baseAlarmModuleDtos1); + } + }else { + List baseAlarmModuleDtos1 = baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId)); + baseAlarmModuleDtos.addAll(baseAlarmModuleDtos1); + } + - List baseAlarmModuleDtos = - baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId)); + //List baseAlarmModuleDtos =baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId)); if (baseAlarmModuleDtos.size() < 6) { List info = new ArrayList<>(); @@ -161,11 +237,32 @@ public class WisdomScenarioContorller extends BaseController { public String getAlarmInfo(String monitorUnitId) { if (!monitorUnitId.isEmpty()) { - List recordAlarmDtos = recordAlarmService.selectAlarmInfoList(monitorUnitId); - String s = JSONArray.toJSONString(recordAlarmDtos); + if(ShiroUtils.getLoginName().equals("admin")){ + List recordAlarmDtos = recordAlarmService.selectAlarmInfoList(monitorUnitId); + + String s = JSONArray.toJSONString(recordAlarmDtos); + + return s; + }else{ + List recordAlarmDtos = new ArrayList<>(); + SysUser sysUser = ShiroUtils.getSysUser(); + + List sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId()); + for (SysRole sysRole : sysRoles) { + RecordAlarm recordAlarm = new RecordAlarm(); + recordAlarm.setRoleId(sysRole.getRoleId()); + recordAlarm.setMonitorUnitTypeId(monitorUnitId); + List recordAlarmDtos1 = recordAlarmService.selectAlarmInfoListByRoleId(recordAlarm); + recordAlarmDtos.addAll(recordAlarmDtos1); + } + + String s = JSONArray.toJSONString(recordAlarmDtos); + + return s; + } + - return s; } return null; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseAlarmModule.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseAlarmModule.java index 75e74f8..e241d85 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseAlarmModule.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/BaseAlarmModule.java @@ -72,6 +72,8 @@ public class BaseAlarmModule extends BaseEntity @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd") private Date updatedTime; + private Long roleId; + public Long getObjId() { return objId; } @@ -185,6 +187,14 @@ public class BaseAlarmModule extends BaseEntity this.alarmCategoryName = alarmCategoryName; } + public Long getRoleId() { + return roleId; + } + + public void setRoleId(Long roleId) { + this.roleId = roleId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/RecordAlarm.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/RecordAlarm.java index 6cd5ec8..a74bbdf 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/RecordAlarm.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/RecordAlarm.java @@ -57,6 +57,8 @@ public class RecordAlarm extends BaseEntity private Long roleId; + private String monitorUnitTypeId; + public void setSensorId(String sensorId) { this.sensorId = sensorId; @@ -168,6 +170,14 @@ public class RecordAlarm extends BaseEntity this.roleId = roleId; } + public String getMonitorUnitTypeId() { + return monitorUnitTypeId; + } + + public void setMonitorUnitTypeId(String monitorUnitTypeId) { + this.monitorUnitTypeId = monitorUnitTypeId; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseAlarmModuleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseAlarmModuleMapper.java index ea53ceb..63e2470 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseAlarmModuleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/BaseAlarmModuleMapper.java @@ -68,6 +68,7 @@ public interface BaseAlarmModuleMapper * @return java.util.List */ public List selectAlarmModuleAmountList(BaseAlarmModule baseAlarmModule); + public List selectAlarmModuleAmountListByRoleId(BaseAlarmModule baseAlarmModule); /** * 查詢告警类别数量 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RecordAlarmMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RecordAlarmMapper.java index 4b5ed48..9aa1917 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RecordAlarmMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RecordAlarmMapper.java @@ -71,6 +71,8 @@ public interface RecordAlarmMapper */ public List selectAlarmInfoList(String monitorUnitTypeId); + public List selectAlarmInfoListByRoleId(RecordAlarm recordAlarm); + /** * 异常趋势分析,一个月内 * @author WenJY diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IRecordAlarmService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IRecordAlarmService.java index c6fac5e..e43498a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/IRecordAlarmService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IRecordAlarmService.java @@ -69,6 +69,8 @@ public interface IRecordAlarmService */ public List selectAlarmInfoList(String monitorUnitTypeId); + public List selectAlarmInfoListByRoleId(RecordAlarm recordAlarm); + /** * 获取异常趋势,一个月内 * @author WenJY diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseAlarmModuleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseAlarmModuleServiceImpl.java index b54b7d3..dcbd0ea 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseAlarmModuleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BaseAlarmModuleServiceImpl.java @@ -103,6 +103,11 @@ public class BaseAlarmModuleServiceImpl implements IBaseAlarmModuleService */ @Override public List selectAlarmModuleAmountList(BaseAlarmModule baseAlarmModule) { + + if(baseAlarmModule.getRoleId() != null && baseAlarmModule.getRoleId() > 1){ + return baseAlarmModuleMapper.selectAlarmModuleAmountListByRoleId(baseAlarmModule); + } + return baseAlarmModuleMapper.selectAlarmModuleAmountList(baseAlarmModule); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RecordAlarmServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RecordAlarmServiceImpl.java index 312bd7b..6a0c3fd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RecordAlarmServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RecordAlarmServiceImpl.java @@ -111,6 +111,11 @@ public class RecordAlarmServiceImpl implements IRecordAlarmService return recordAlarmMapper.selectAlarmInfoList(monitorUnitTypeId); } + @Override + public List selectAlarmInfoListByRoleId(RecordAlarm recordAlarm) { + return recordAlarmMapper.selectAlarmInfoListByRoleId(recordAlarm); + } + /** * 异常趋势分析,一个月内 * @author WenJY diff --git a/ruoyi-system/src/main/resources/mapper/system/BaseAlarmModuleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/BaseAlarmModuleMapper.xml index 8dc39d0..bb7eda9 100644 --- a/ruoyi-system/src/main/resources/mapper/system/BaseAlarmModuleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/BaseAlarmModuleMapper.xml @@ -157,6 +157,26 @@ order by t1.Order_Flag + + + +