diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java index c7609c5..e5d6cd2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/IndexController.java @@ -1,6 +1,14 @@ package com.ruoyi.web.controller.iot; import com.alibaba.fastjson.JSONArray; +import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.system.domain.BaseMonitorunitInfo; +import com.ruoyi.system.domain.BaseMonitorunitType; +import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto; +import com.ruoyi.system.domain.dto.ScrollTableDto; +import com.ruoyi.system.service.IBaseMonitorunitInfoService; +import com.ruoyi.system.service.IBaseMonitorunitTypeService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -8,6 +16,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; /** * @author WenJY @@ -17,6 +26,10 @@ import java.util.List; @RequestMapping("/iot/index") public class IndexController { + @Autowired private IBaseMonitorunitTypeService baseMonitorunitTypeService; + + @Autowired private IBaseMonitorunitInfoService baseMonitorunitInfoService; + @GetMapping() public String index() { return "iot-ui/index"; @@ -24,43 +37,67 @@ public class IndexController { /** * 监控单元统计 + * * @author WenJY * @date 2022/2/23 14:26 * @return java.lang.String */ @GetMapping("/getMonitorUnitCharts") @ResponseBody - public String getMonitorUnitCharts(){ - return "[\n" + - " {\n" + - " \"value\": 32,\n" + - " \"name\": \"隔离开关\"\n" + - " },\n" + - " {\n" + - " \"value\": 14,\n" + - " \"name\": \"电流互感器\"\n" + - " },\n" + - " {\n" + - " \"value\": 26,\n" + - " \"name\": \"电压互感器\"\n" + - " },\n" + - " {\n" + - " \"value\": 20,\n" + - " \"name\": \"变压器\"\n" + - " },\n" + - " {\n" + - " \"value\": 10,\n" + - " \"name\": \"电容电抗器\"\n" + - " },\n" + - " {\n" + - " \"value\": 10,\n" + - " \"name\": \"避雷器\"\n" + - " }\n" + - " ]"; + public String getMonitorUnitCharts() { + try { + List result = new ArrayList(); + + List baseMonitorunitTypes = + baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType()); + List baseMonitorunitInfoDtos = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo()); + + baseMonitorunitTypes.forEach( + x -> { + List collect = + baseMonitorunitInfoDtos.stream() + .filter(y -> y.getMonitorunitType().equals(x.getMonitorunittypeId())) + .collect(Collectors.toList()); + BaseMonitorunitInfoDto info = new BaseMonitorunitInfoDto(); + info.setName(x.getMonitorunittypeName()); + info.setValue(collect.size()); + result.add(info); + }); + return JSONArray.toJSONString(result); + } catch (Exception ex) { + return "[\n" + + " {\n" + + " \"value\": 32,\n" + + " \"name\": \"隔离开关\"\n" + + " },\n" + + " {\n" + + " \"value\": 14,\n" + + " \"name\": \"电流互感器\"\n" + + " },\n" + + " {\n" + + " \"value\": 26,\n" + + " \"name\": \"电压互感器\"\n" + + " },\n" + + " {\n" + + " \"value\": 20,\n" + + " \"name\": \"变压器\"\n" + + " },\n" + + " {\n" + + " \"value\": 10,\n" + + " \"name\": \"电容电抗器\"\n" + + " },\n" + + " {\n" + + " \"value\": 10,\n" + + " \"name\": \"避雷器\"\n" + + " }\n" + + " ]"; + } } /** * 监控单元统计 + * * @author WenJY * @date 2022/2/23 13:55 * @return java.lang.String @@ -68,36 +105,75 @@ public class IndexController { @GetMapping("/getMonitorUnitInfo") @ResponseBody public String getMonitorUnitInfo() { - 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" - + "}"; + + try { + List> data = new ArrayList<>(); + + List header = + new ArrayList() { + { + this.add("名称"); + this.add("监控数量"); + this.add("告警数量"); + } + }; + + List baseMonitorunitTypes = + baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType()); + List baseMonitorunitInfoDtos = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo()); + + baseMonitorunitTypes.forEach( + x -> { + List collect = + baseMonitorunitInfoDtos.stream() + .filter(y -> y.getMonitorunitType().equals(x.getMonitorunittypeId())) + .collect(Collectors.toList()); + data.add( + new ArrayList() { + { + this.add(x.getMonitorunittypeName()); + this.add(collect.size() + ""); + this.add(collect.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/2/23 13:54 * @return java.lang.String */ @GetMapping("/getSensorStateCharts") @ResponseBody - public String getSensorStateCharts(){ - return "{\n" + - " \"yAxis\": [\"在线\", \"离线\", \"告警\"],\n" + - " \"data\": [60, 132, 89]\n" + - "}"; + public String getSensorStateCharts() { + return "{\n" + + " \"yAxis\": [\"在线\", \"离线\", \"告警\"],\n" + + " \"data\": [60, 132, 89]\n" + + "}"; } /** * 传感器状态统计 + * * @author WenJY * @date 2022/2/23 13:55 * @return java.lang.String @@ -120,13 +196,14 @@ public class IndexController { /** * 告警数量统计 + * * @author WenJY * @date 2022/2/23 13:54 * @return java.lang.String */ @GetMapping("/getAlarmAmount") @ResponseBody - public String getAlarmAmount(){ + public String getAlarmAmount() { return "{\n" + " \"yAxis\": [\"设备高温\", \"设备振动\", \"烟雾火情\", \"环境大风\", \"测试一\", \"测试二\", \"测试三\", \"测试四\", \"测试五\", \"测试六\"],\n" + " \"data\": [60, 132, 89, 10,15,23,22,60, 132, 89]\n" @@ -135,17 +212,17 @@ public class IndexController { /** * 告警趋势 + * * @author WenJY * @date 2022/2/23 14:23 * @return java.lang.String */ @GetMapping("/getAlarmTrend") @ResponseBody - public String getAlarmTrend(){ - return "{\n" + - " \"xAxis\": [\"06-21\", \"06-22\", \"06-23\", \"06-24\", \"06-25\", \"06-26\", \"06-27\"],\n" + - " \"data\": [18, 5, 4, 2, 1, 7, 6]\n" + - "}"; + public String getAlarmTrend() { + return "{\n" + + " \"xAxis\": [\"06-21\", \"06-22\", \"06-23\", \"06-24\", \"06-25\", \"06-26\", \"06-27\"],\n" + + " \"data\": [18, 5, 4, 2, 1, 7, 6]\n" + + "}"; } - } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java index e18d2cc..a648963 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java @@ -55,7 +55,7 @@ public class SwaggerConfig // 用ApiInfoBuilder进行定制 return new ApiInfoBuilder() // 设置标题 - .title("标题:若依管理系统_接口文档") + .title("标题:变电站智慧物联监控平台_接口文档") // 描述 .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...") // 作者信息 diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseMonitorunitInfoDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseMonitorunitInfoDto.java index adca0b2..d38d925 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseMonitorunitInfoDto.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/BaseMonitorunitInfoDto.java @@ -15,4 +15,8 @@ public class BaseMonitorunitInfoDto extends BaseMonitorunitInfo { private String substationName; private String parentName; + + private String name; + + private int value; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/ScrollTableDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/ScrollTableDto.java new file mode 100644 index 0000000..4834d1a --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/dto/ScrollTableDto.java @@ -0,0 +1,25 @@ +package com.ruoyi.system.domain.dto; + +import lombok.Data; + +import java.util.List; + +/** + * @author WenJY + * @date 2022年03月11日 10:59 + */ +@Data +public class ScrollTableDto { + + public ScrollTableDto() { + } + + public ScrollTableDto(List header, List> data) { + this.header = header; + this.data = data; + } + + private List header; + + private List> data; +}