|
|
@ -3,7 +3,10 @@ package com.ruoyi.web.controller.iot;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
import com.ruoyi.common.json.JsonUtils;
|
|
|
|
import com.ruoyi.common.json.JsonUtils;
|
|
|
|
|
|
|
|
import com.ruoyi.common.utils.ShiroUtils;
|
|
|
|
import com.ruoyi.system.domain.BaseDeviceParam;
|
|
|
|
import com.ruoyi.system.domain.BaseDeviceParam;
|
|
|
|
import com.ruoyi.system.domain.BaseMonitorunitInfo;
|
|
|
|
import com.ruoyi.system.domain.BaseMonitorunitInfo;
|
|
|
|
import com.ruoyi.system.domain.BaseSensorInfo;
|
|
|
|
import com.ruoyi.system.domain.BaseSensorInfo;
|
|
|
@ -12,6 +15,7 @@ import com.ruoyi.system.domain.dto.BaseSensorInfoDto;
|
|
|
|
import com.ruoyi.system.service.IBaseDeviceParamService;
|
|
|
|
import com.ruoyi.system.service.IBaseDeviceParamService;
|
|
|
|
import com.ruoyi.system.service.IBaseMonitorunitInfoService;
|
|
|
|
import com.ruoyi.system.service.IBaseMonitorunitInfoService;
|
|
|
|
import com.ruoyi.system.service.IBaseSensorInfoService;
|
|
|
|
import com.ruoyi.system.service.IBaseSensorInfoService;
|
|
|
|
|
|
|
|
import com.ruoyi.system.service.ISysRoleService;
|
|
|
|
import lombok.Data;
|
|
|
|
import lombok.Data;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
@ -44,6 +48,9 @@ public class DeviceMonitorController {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IBaseDeviceParamService baseDeviceParamService;
|
|
|
|
private IBaseDeviceParamService baseDeviceParamService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ISysRoleService iSysRoleService;
|
|
|
|
|
|
|
|
|
|
|
|
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -56,9 +63,26 @@ public class DeviceMonitorController {
|
|
|
|
@GetMapping("/getMonitorUnitTree")
|
|
|
|
@GetMapping("/getMonitorUnitTree")
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public String getMonitorUnitTree() {
|
|
|
|
public String getMonitorUnitTree() {
|
|
|
|
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
|
|
|
|
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos = new ArrayList<>();
|
|
|
|
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(
|
|
|
|
SysUser sysUser = ShiroUtils.getSysUser();
|
|
|
|
new BaseMonitorunitInfo(null, null, null, null, 0L));
|
|
|
|
|
|
|
|
|
|
|
|
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.setEnableFlag(0L);
|
|
|
|
|
|
|
|
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
|
|
|
|
|
|
|
|
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos1 =
|
|
|
|
|
|
|
|
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
|
|
|
|
|
|
|
|
baseMonitorunitInfoDtos.addAll(baseMonitorunitInfoDtos1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<BaseMonitorunitInfoDto> collect =
|
|
|
|
List<BaseMonitorunitInfoDto> collect =
|
|
|
|
baseMonitorunitInfoDtos.stream()
|
|
|
|
baseMonitorunitInfoDtos.stream()
|
|
|
@ -103,8 +127,30 @@ public class DeviceMonitorController {
|
|
|
|
@GetMapping("/getFirstMonitorUnit")
|
|
|
|
@GetMapping("/getFirstMonitorUnit")
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public String getFirstMonitorUnit(){
|
|
|
|
public String getFirstMonitorUnit(){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<BaseMonitorunitInfoDto> baseMonitorunitInfos = 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));
|
|
|
|
|
|
|
|
baseMonitorunitInfos.addAll(baseMonitorunitInfoDtos1);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
for (SysRole sysRole : sysRoles) {
|
|
|
|
|
|
|
|
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
|
|
|
|
|
|
|
|
baseMonitorunitInfo.setEnableFlag(0L);
|
|
|
|
|
|
|
|
baseMonitorunitInfo.setRoleId(sysRole.getRoleId());
|
|
|
|
|
|
|
|
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos1 =
|
|
|
|
|
|
|
|
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
|
|
|
|
|
|
|
|
baseMonitorunitInfos.addAll(baseMonitorunitInfoDtos1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String monitorunitId = "";
|
|
|
|
String monitorunitId = "";
|
|
|
|
List<BaseMonitorunitInfo> baseMonitorunitInfos = baseMonitorunitInfoService.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());
|
|
|
|
//List<BaseMonitorunitInfo> baseMonitorunitInfos = baseMonitorunitInfoService.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());
|
|
|
|
if(baseMonitorunitInfos.size() > 0){
|
|
|
|
if(baseMonitorunitInfos.size() > 0){
|
|
|
|
BaseMonitorunitInfo baseMonitorunitInfo = baseMonitorunitInfos.stream().filter(x -> !x.getParentId().isEmpty()).collect(Collectors.toList()).get(0);
|
|
|
|
BaseMonitorunitInfo baseMonitorunitInfo = baseMonitorunitInfos.stream().filter(x -> !x.getParentId().isEmpty()).collect(Collectors.toList()).get(0);
|
|
|
|
monitorunitId = baseMonitorunitInfo.getMonitorunitId();
|
|
|
|
monitorunitId = baseMonitorunitInfo.getMonitorunitId();
|
|
|
|