|
|
|
@ -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<BaseMonitorunitInfo> baseMonitorunitInfos =
|
|
|
|
|
List<BaseMonitorunitInfo> baseMonitorunitInfos = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
SysUser sysUser = ShiroUtils.getSysUser();
|
|
|
|
|
|
|
|
|
|
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
|
|
|
|
|
|
|
|
|
|
if(!ShiroUtils.getLoginName().equals("admin")){
|
|
|
|
|
for (SysRole sysRole : sysRoles) {
|
|
|
|
|
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
|
|
|
|
|
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
|
|
|
|
|
List<BaseMonitorunitInfoDto> baseMonitorunitInfos1 =
|
|
|
|
|
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
|
|
|
|
|
baseMonitorunitInfos.addAll(baseMonitorunitInfos1);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
List<BaseMonitorunitInfo> baseMonitorunitInfos1 =
|
|
|
|
|
baseMonitorunitInfoService.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());
|
|
|
|
|
baseMonitorunitInfos.addAll(baseMonitorunitInfos1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<BaseMonitorunitInfo> collect =
|
|
|
|
|
baseMonitorunitInfos.stream()
|
|
|
|
|
.filter(
|
|
|
|
@ -65,10 +89,26 @@ public class WisdomScenarioContorller extends BaseController {
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
int sensorAmount = 0;
|
|
|
|
|
for (BaseMonitorunitInfo x : collect) {
|
|
|
|
|
List<BaseSensorInfoDto> baseSensorInfoDtos =
|
|
|
|
|
baseSensorInfoService.selectBaseSensorInfoList(
|
|
|
|
|
new BaseSensorInfo(null, null, null, x.getMonitorunitId()));
|
|
|
|
|
List<BaseSensorInfoDto> baseSensorInfoDtos = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
if(ShiroUtils.getLoginName().equals("admin")){
|
|
|
|
|
BaseSensorInfo baseSensorInfo = new BaseSensorInfo();
|
|
|
|
|
baseSensorInfo.setMonitorunitId(x.getMonitorunitId());
|
|
|
|
|
List<BaseSensorInfoDto> 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<BaseSensorInfoDto> 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<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
|
|
|
|
|
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos = new ArrayList<>();
|
|
|
|
|
SysUser sysUser = ShiroUtils.getSysUser();
|
|
|
|
|
|
|
|
|
|
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
|
|
|
|
|
|
|
|
|
|
if(!ShiroUtils.getLoginName().equals("admin")){
|
|
|
|
|
for (SysRole sysRole : sysRoles) {
|
|
|
|
|
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
|
|
|
|
|
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
|
|
|
|
|
List<BaseMonitorunitInfoDto> baseMonitorunitInfos1 =
|
|
|
|
|
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
|
|
|
|
|
baseMonitorunitInfoDtos.addAll(baseMonitorunitInfos1);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
List<BaseMonitorunitInfoDto> baseMonitorunitInfos1 =
|
|
|
|
|
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());
|
|
|
|
|
baseMonitorunitInfoDtos.addAll(baseMonitorunitInfos1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
|
|
|
|
|
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());*/
|
|
|
|
|
List<BaseMonitorunitInfoDto> collect =
|
|
|
|
|
baseMonitorunitInfoDtos.stream()
|
|
|
|
|
.filter(
|
|
|
|
@ -122,9 +181,26 @@ public class WisdomScenarioContorller extends BaseController {
|
|
|
|
|
@GetMapping("/getAlarmModule")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public String getAlarmModule(String monitorUnitId) {
|
|
|
|
|
List<BaseAlarmModuleDto> baseAlarmModuleDtos = new ArrayList();
|
|
|
|
|
SysUser sysUser = ShiroUtils.getSysUser();
|
|
|
|
|
|
|
|
|
|
List<SysRole> 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<BaseAlarmModuleDto> baseAlarmModuleDtos1 = baseAlarmModuleService.selectAlarmModuleAmountList(baseAlarmModule);
|
|
|
|
|
baseAlarmModuleDtos.addAll(baseAlarmModuleDtos1);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
List<BaseAlarmModuleDto> baseAlarmModuleDtos1 = baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId));
|
|
|
|
|
baseAlarmModuleDtos.addAll(baseAlarmModuleDtos1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<BaseAlarmModuleDto> baseAlarmModuleDtos =
|
|
|
|
|
baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId));
|
|
|
|
|
//List<BaseAlarmModuleDto> baseAlarmModuleDtos =baseAlarmModuleService.selectAlarmModuleAmountList(new BaseAlarmModule(monitorUnitId));
|
|
|
|
|
|
|
|
|
|
if (baseAlarmModuleDtos.size() < 6) {
|
|
|
|
|
List<BaseAlarmModuleDto> info = new ArrayList<>();
|
|
|
|
@ -161,11 +237,32 @@ public class WisdomScenarioContorller extends BaseController {
|
|
|
|
|
public String getAlarmInfo(String monitorUnitId) {
|
|
|
|
|
|
|
|
|
|
if (!monitorUnitId.isEmpty()) {
|
|
|
|
|
|
|
|
|
|
if(ShiroUtils.getLoginName().equals("admin")){
|
|
|
|
|
List<RecordAlarmDto> recordAlarmDtos = recordAlarmService.selectAlarmInfoList(monitorUnitId);
|
|
|
|
|
|
|
|
|
|
String s = JSONArray.toJSONString(recordAlarmDtos);
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
}else{
|
|
|
|
|
List<RecordAlarmDto> recordAlarmDtos = new ArrayList<>();
|
|
|
|
|
SysUser sysUser = ShiroUtils.getSysUser();
|
|
|
|
|
|
|
|
|
|
List<SysRole> sysRoles = iSysRoleService.selectRolesByUserId(sysUser.getUserId());
|
|
|
|
|
for (SysRole sysRole : sysRoles) {
|
|
|
|
|
RecordAlarm recordAlarm = new RecordAlarm();
|
|
|
|
|
recordAlarm.setRoleId(sysRole.getRoleId());
|
|
|
|
|
recordAlarm.setMonitorUnitTypeId(monitorUnitId);
|
|
|
|
|
List<RecordAlarmDto> recordAlarmDtos1 = recordAlarmService.selectAlarmInfoListByRoleId(recordAlarm);
|
|
|
|
|
recordAlarmDtos.addAll(recordAlarmDtos1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String s = JSONArray.toJSONString(recordAlarmDtos);
|
|
|
|
|
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|