|
|
@ -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,10 +186,46 @@ public class IndexController {
|
|
|
|
@GetMapping("/getSensorStateCharts")
|
|
|
|
@GetMapping("/getSensorStateCharts")
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public String getSensorStateCharts() {
|
|
|
|
public String getSensorStateCharts() {
|
|
|
|
return "{\n"
|
|
|
|
try {
|
|
|
|
+ " \"yAxis\": [\"在线\", \"离线\", \"告警\"],\n"
|
|
|
|
List<BaseSensorInfoDto> baseSensorInfoDtos =
|
|
|
|
+ " \"data\": [60, 132, 89]\n"
|
|
|
|
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"
|
|
|
|
|
|
|
|
+ " \"yAxis\": [\"在线\", \"离线\", \"告警\"],\n"
|
|
|
|
|
|
|
|
+ " \"data\": [0, 132, 89]\n"
|
|
|
|
|
|
|
|
+ "}";
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -181,17 +238,80 @@ public class IndexController {
|
|
|
|
@GetMapping("/getSensorStateInfo")
|
|
|
|
@GetMapping("/getSensorStateInfo")
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public String getSensorStateInfo() {
|
|
|
|
public String getSensorStateInfo() {
|
|
|
|
return "{\n"
|
|
|
|
try {
|
|
|
|
+ " \"header\": [\"名称\", \"安装数量\", \"离线数量\"],\n"
|
|
|
|
List<List<String>> data = new ArrayList<>();
|
|
|
|
+ " \"data\": [\n"
|
|
|
|
|
|
|
|
+ " [\"温度\", \"30\", \"30\"],\n"
|
|
|
|
List<String> header =
|
|
|
|
+ " [\"湿度\", \"14\", \"14\"],\n"
|
|
|
|
new ArrayList<String>() {
|
|
|
|
+ " [\"振动\", \"26\", \"26\"],\n"
|
|
|
|
{
|
|
|
|
+ " [\"烟雾\", \"20\", \"20\"],\n"
|
|
|
|
this.add("名称");
|
|
|
|
+ " [\"倾斜\", \"10\", \"10\"],\n"
|
|
|
|
this.add("安装数量");
|
|
|
|
+ " [\"拉力\", \"10\", \"10\"]\n"
|
|
|
|
this.add("离线数量");
|
|
|
|
+ " ]\n"
|
|
|
|
}
|
|
|
|
+ "}";
|
|
|
|
};
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
+ " \"header\": [\"名称\", \"安装数量\", \"离线数量\"],\n"
|
|
|
|
|
|
|
|
+ " \"data\": [\n"
|
|
|
|
|
|
|
|
+ " [\"温度\", \"30\", \"30\"],\n"
|
|
|
|
|
|
|
|
+ " [\"湿度\", \"14\", \"14\"],\n"
|
|
|
|
|
|
|
|
+ " [\"振动\", \"26\", \"26\"],\n"
|
|
|
|
|
|
|
|
+ " [\"烟雾\", \"20\", \"20\"],\n"
|
|
|
|
|
|
|
|
+ " [\"倾斜\", \"10\", \"10\"],\n"
|
|
|
|
|
|
|
|
+ " [\"拉力\", \"10\", \"10\"]\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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|