|
|
@ -1,13 +1,20 @@
|
|
|
|
package com.ruoyi.web.controller.iot;
|
|
|
|
package com.ruoyi.web.controller.iot;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
|
|
|
import com.ruoyi.system.domain.BaseMonitorunitInfo;
|
|
|
|
import com.ruoyi.system.domain.BaseMonitorunitInfo;
|
|
|
|
import com.ruoyi.system.domain.BaseMonitorunitType;
|
|
|
|
import com.ruoyi.system.domain.BaseMonitorunitType;
|
|
|
|
|
|
|
|
import com.ruoyi.system.domain.BaseSensorInfo;
|
|
|
|
|
|
|
|
import com.ruoyi.system.domain.BaseSensorType;
|
|
|
|
|
|
|
|
import com.ruoyi.system.domain.dto.BarChatsDto;
|
|
|
|
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.ScrollTableDto;
|
|
|
|
import com.ruoyi.system.domain.dto.ScrollTableDto;
|
|
|
|
import com.ruoyi.system.service.IBaseMonitorunitInfoService;
|
|
|
|
import com.ruoyi.system.service.IBaseMonitorunitInfoService;
|
|
|
|
import com.ruoyi.system.service.IBaseMonitorunitTypeService;
|
|
|
|
import com.ruoyi.system.service.IBaseMonitorunitTypeService;
|
|
|
|
|
|
|
|
import com.ruoyi.system.service.IBaseSensorInfoService;
|
|
|
|
|
|
|
|
import com.ruoyi.system.service.IBaseSensorTypeService;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
@ -30,6 +37,10 @@ public class IndexController {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired private IBaseMonitorunitInfoService baseMonitorunitInfoService;
|
|
|
|
@Autowired private IBaseMonitorunitInfoService baseMonitorunitInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired private IBaseSensorTypeService baseSensorTypeService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired private IBaseSensorInfoService baseSensorInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping()
|
|
|
|
@GetMapping()
|
|
|
|
public String index() {
|
|
|
|
public String index() {
|
|
|
|
return "iot-ui/index";
|
|
|
|
return "iot-ui/index";
|
|
|
@ -57,7 +68,10 @@ public class IndexController {
|
|
|
|
x -> {
|
|
|
|
x -> {
|
|
|
|
List<BaseMonitorunitInfoDto> collect =
|
|
|
|
List<BaseMonitorunitInfoDto> collect =
|
|
|
|
baseMonitorunitInfoDtos.stream()
|
|
|
|
baseMonitorunitInfoDtos.stream()
|
|
|
|
.filter(y -> y.getMonitorunitType().equals(x.getMonitorunittypeId()))
|
|
|
|
.filter(
|
|
|
|
|
|
|
|
y ->
|
|
|
|
|
|
|
|
!y.getParentId().isEmpty()
|
|
|
|
|
|
|
|
&& y.getMonitorunitType().equals(x.getMonitorunittypeId()))
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
BaseMonitorunitInfoDto info = new BaseMonitorunitInfoDto();
|
|
|
|
BaseMonitorunitInfoDto info = new BaseMonitorunitInfoDto();
|
|
|
|
info.setName(x.getMonitorunittypeName());
|
|
|
|
info.setName(x.getMonitorunittypeName());
|
|
|
@ -127,14 +141,21 @@ public class IndexController {
|
|
|
|
x -> {
|
|
|
|
x -> {
|
|
|
|
List<BaseMonitorunitInfoDto> collect =
|
|
|
|
List<BaseMonitorunitInfoDto> collect =
|
|
|
|
baseMonitorunitInfoDtos.stream()
|
|
|
|
baseMonitorunitInfoDtos.stream()
|
|
|
|
.filter(y -> y.getMonitorunitType().equals(x.getMonitorunittypeId()))
|
|
|
|
.filter(
|
|
|
|
|
|
|
|
y ->
|
|
|
|
|
|
|
|
!y.getParentId().isEmpty()
|
|
|
|
|
|
|
|
&& y.getMonitorunitType().equals(x.getMonitorunittypeId()))
|
|
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
List<BaseMonitorunitInfoDto> collect2 =
|
|
|
|
|
|
|
|
collect.stream()
|
|
|
|
|
|
|
|
.filter(z -> z.getMonitorunitStatus().equals(0))
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
data.add(
|
|
|
|
data.add(
|
|
|
|
new ArrayList<String>() {
|
|
|
|
new ArrayList<String>() {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.add(x.getMonitorunittypeName());
|
|
|
|
this.add(x.getMonitorunittypeName());
|
|
|
|
this.add(collect.size() + "");
|
|
|
|
this.add(collect.size() + "");
|
|
|
|
this.add(collect.size() + "");
|
|
|
|
this.add(collect2.size() + "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -165,11 +186,47 @@ public class IndexController {
|
|
|
|
@GetMapping("/getSensorStateCharts")
|
|
|
|
@GetMapping("/getSensorStateCharts")
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public String getSensorStateCharts() {
|
|
|
|
public String getSensorStateCharts() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<BaseSensorInfoDto> baseSensorInfoDtos =
|
|
|
|
|
|
|
|
baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo());
|
|
|
|
|
|
|
|
List<String> yAxis =
|
|
|
|
|
|
|
|
new ArrayList<String>() {
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.add("在线");
|
|
|
|
|
|
|
|
this.add("离线");
|
|
|
|
|
|
|
|
this.add("告警");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Integer> data =
|
|
|
|
|
|
|
|
new ArrayList<Integer>() {
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.add(
|
|
|
|
|
|
|
|
baseSensorInfoDtos.stream()
|
|
|
|
|
|
|
|
.filter(x -> x.getSensorStatus() == 0)
|
|
|
|
|
|
|
|
.collect(Collectors.toList())
|
|
|
|
|
|
|
|
.size()); // 在线
|
|
|
|
|
|
|
|
this.add(
|
|
|
|
|
|
|
|
baseSensorInfoDtos.stream()
|
|
|
|
|
|
|
|
.filter(x -> x.getSensorStatus() == 1)
|
|
|
|
|
|
|
|
.collect(Collectors.toList())
|
|
|
|
|
|
|
|
.size()); // 离线
|
|
|
|
|
|
|
|
this.add(
|
|
|
|
|
|
|
|
baseSensorInfoDtos.stream()
|
|
|
|
|
|
|
|
.filter(x -> x.getSensorStatus() == 2)
|
|
|
|
|
|
|
|
.collect(Collectors.toList())
|
|
|
|
|
|
|
|
.size()); // 告警
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return JSONArray.toJSONString(new BarChatsDto(yAxis, data));
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
return "{\n"
|
|
|
|
return "{\n"
|
|
|
|
+ " \"yAxis\": [\"在线\", \"离线\", \"告警\"],\n"
|
|
|
|
+ " \"yAxis\": [\"在线\", \"离线\", \"告警\"],\n"
|
|
|
|
+ " \"data\": [60, 132, 89]\n"
|
|
|
|
+ " \"data\": [0, 132, 89]\n"
|
|
|
|
+ "}";
|
|
|
|
+ "}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 传感器状态统计
|
|
|
|
* 传感器状态统计
|
|
|
@ -181,6 +238,40 @@ public class IndexController {
|
|
|
|
@GetMapping("/getSensorStateInfo")
|
|
|
|
@GetMapping("/getSensorStateInfo")
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public String getSensorStateInfo() {
|
|
|
|
public String getSensorStateInfo() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
List<List<String>> data = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<String> header =
|
|
|
|
|
|
|
|
new ArrayList<String>() {
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.add("名称");
|
|
|
|
|
|
|
|
this.add("安装数量");
|
|
|
|
|
|
|
|
this.add("离线数量");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
List<BaseSensorType> baseSensorTypeList =
|
|
|
|
|
|
|
|
baseSensorTypeService.selectBaseSensorTypeList(new BaseSensorType());
|
|
|
|
|
|
|
|
baseSensorTypeList.forEach(
|
|
|
|
|
|
|
|
x -> {
|
|
|
|
|
|
|
|
List<BaseSensorInfoDto> baseSensorInfoDtos =
|
|
|
|
|
|
|
|
baseSensorInfoService.selectBaseSensorInfoList(
|
|
|
|
|
|
|
|
new BaseSensorInfo(x.getSensortypeId(), 0L));
|
|
|
|
|
|
|
|
data.add(
|
|
|
|
|
|
|
|
new ArrayList<String>() {
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.add(x.getSensortypeName());
|
|
|
|
|
|
|
|
this.add(baseSensorInfoDtos.size() + "");
|
|
|
|
|
|
|
|
this.add(
|
|
|
|
|
|
|
|
baseSensorInfoDtos.stream()
|
|
|
|
|
|
|
|
.filter(z -> z.getSensorStatus() == 1)
|
|
|
|
|
|
|
|
.collect(Collectors.toList())
|
|
|
|
|
|
|
|
.size()
|
|
|
|
|
|
|
|
+ "");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return JSONArray.toJSONString(new ScrollTableDto(header, data));
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
return "{\n"
|
|
|
|
return "{\n"
|
|
|
|
+ " \"header\": [\"名称\", \"安装数量\", \"离线数量\"],\n"
|
|
|
|
+ " \"header\": [\"名称\", \"安装数量\", \"离线数量\"],\n"
|
|
|
|
+ " \"data\": [\n"
|
|
|
|
+ " \"data\": [\n"
|
|
|
@ -193,6 +284,35 @@ public class IndexController {
|
|
|
|
+ " ]\n"
|
|
|
|
+ " ]\n"
|
|
|
|
+ "}";
|
|
|
|
+ "}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 数量统计:传感器数量、监控单元数量
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @author WenJY
|
|
|
|
|
|
|
|
* @date 2022/3/11 17:08
|
|
|
|
|
|
|
|
* @return java.lang.String
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@GetMapping("/quantityStatistics")
|
|
|
|
|
|
|
|
@ResponseBody
|
|
|
|
|
|
|
|
public String quantityStatistics() {
|
|
|
|
|
|
|
|
List<BaseSensorInfoDto> baseSensorInfoDtos =
|
|
|
|
|
|
|
|
baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo("", 0L));
|
|
|
|
|
|
|
|
List<BaseMonitorunitInfo> baseMonitorunitInfos =
|
|
|
|
|
|
|
|
baseMonitorunitInfoService.selectBaseMonitorunitInfoList(new BaseMonitorunitInfo());
|
|
|
|
|
|
|
|
List<Integer> result =
|
|
|
|
|
|
|
|
new ArrayList<Integer>() {
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.add(baseSensorInfoDtos.size());
|
|
|
|
|
|
|
|
this.add(
|
|
|
|
|
|
|
|
baseMonitorunitInfos.stream()
|
|
|
|
|
|
|
|
.filter(x -> !x.getParentId().isEmpty() && x.getEnableFlag() == 0L)
|
|
|
|
|
|
|
|
.collect(Collectors.toList())
|
|
|
|
|
|
|
|
.size());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
return JSONArray.toJSONString(result);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 告警数量统计
|
|
|
|
* 告警数量统计
|
|
|
|