From 8e99db156c52f1dabc2951d0c41279347374a380 Mon Sep 17 00:00:00 2001 From: wenjy Date: Tue, 15 Mar 2022 15:04:13 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E8=AE=BE=E5=A4=87=E7=9B=91?= =?UTF-8?q?=E6=B5=8B=E9=A1=B5=E9=9D=A2=E5=88=9D=E6=AD=A5=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=8C=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/DeviceMonitorController.java | 173 +++++++++ .../templates/section/transformer-detail.html | 363 +++++++++--------- .../system/domain/BaseMonitorunitInfo.java | 8 + .../system/BaseMonitorunitInfoMapper.xml | 2 +- 4 files changed, 353 insertions(+), 193 deletions(-) create mode 100644 ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/DeviceMonitorController.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/DeviceMonitorController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/DeviceMonitorController.java new file mode 100644 index 0000000..71e4a7b --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/iot/DeviceMonitorController.java @@ -0,0 +1,173 @@ +package com.ruoyi.web.controller.iot; + +import com.alibaba.fastjson.JSONArray; +import com.ruoyi.system.domain.BaseMonitorunitInfo; +import com.ruoyi.system.domain.BaseSensorInfo; +import com.ruoyi.system.domain.dto.BaseMonitorunitInfoDto; +import com.ruoyi.system.domain.dto.BaseSensorInfoDto; +import com.ruoyi.system.service.IBaseMonitorunitInfoService; +import com.ruoyi.system.service.IBaseSensorInfoService; +import lombok.Data; +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; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 设备监测 + * + * @author WenJY + * @date 2022年03月15日 10:25 + */ +@Controller +@RequestMapping("/iot/deviceMonitor") +public class DeviceMonitorController { + + @Autowired private IBaseMonitorunitInfoService baseMonitorunitInfoService; + + @Autowired private IBaseSensorInfoService baseSensorInfoService; + + /** + * 获取监控单元列表 + * + * @author WenJY + * @date 2022/3/15 10:27 + * @return java.lang.String + */ + @GetMapping("/getMonitorUnitTree") + @ResponseBody + public String getMonitorUnitTree() { + List baseMonitorunitInfoDtos = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList( + new BaseMonitorunitInfo(null, null, null, null, 0L)); + + List collect = + baseMonitorunitInfoDtos.stream() + .filter(x -> x.getParentId().isEmpty()) + .collect(Collectors.toList()); + + List jsonResult = new ArrayList<>(); + + collect.forEach( + x -> { + List tags = new ArrayList<>(); + List nodes = new ArrayList<>(); + + List collect1 = + baseMonitorunitInfoDtos.stream() + .filter(y -> y.getParentId().equals(x.getMonitorunitId())) + .collect(Collectors.toList()); + + tags.add(collect1.size() + ""); + + collect1.forEach( + z -> { + List nodesTags = new ArrayList<>(); + nodesTags.add("0"); + nodes.add(new Nodes(z.getMonitorunitName(), z.getMonitorunitId(), nodesTags)); + }); + + jsonResult.add( + new JsonRootBean(x.getMonitorunitName(), x.getMonitorunitId(), tags, nodes)); + }); + + return JSONArray.toJSONString(jsonResult); + } + + /** + * 监控单元模块 + * + * @author WenJY + * @date 2022/3/15 13:52 + * @param monitorunitId + * @return java.lang.String + */ + @GetMapping("/getMonitorUnitInfo") + @ResponseBody + public String getMonitorUnitInfo(String monitorunitId) { + List baseMonitorunitInfoDtos = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList( + new BaseMonitorunitInfo(monitorunitId)); + return JSONArray.toJSONString(baseMonitorunitInfoDtos); + } + + /** + * 传感器信息 + * + * @author WenJY + * @date 2022/3/15 13:52 + * @param monitorunitId + * @return java.lang.String + */ + @GetMapping("/getSensorInfo") + @ResponseBody + public String getSensorInfo(String monitorunitId) { + List baseSensorInfoDtos = new ArrayList<>(); + + List baseMonitorunitInfoDtos = + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList( + new BaseMonitorunitInfo(monitorunitId)); + + baseMonitorunitInfoDtos.forEach( + x -> { + /*if(x.getParentId().isEmpty()){ + BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo(); + baseMonitorunitInfo.setParentId(x.getMonitorunitId()); + List baseMonitorunitInfoDtos1 = baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo); + baseMonitorunitInfoDtos1.forEach(y->{ + List baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null, null, null, y.getMonitorunitId())); + baseSensorInfoDtos.addAll(baseSensorInfoDtos1); + }); + }else{ + List baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null, null, null, x.getMonitorunitId())); + baseSensorInfoDtos.addAll(baseSensorInfoDtos1); + }*/ + + List baseSensorInfoDtos1 = + baseSensorInfoService.selectBaseSensorInfoList( + new BaseSensorInfo(null, null, null, x.getMonitorunitId())); + baseSensorInfoDtos.addAll(baseSensorInfoDtos1); + }); + + return JSONArray.toJSONString(baseSensorInfoDtos); + } +} + +@Data +class JsonRootBean { + + public JsonRootBean() {} + + public JsonRootBean(String text, String href, List tags, List nodes) { + this.text = text; + this.href = href; + this.tags = tags; + this.nodes = nodes; + } + + private String text; + private String href; + private List tags; + private List nodes; +} + +@Data +class Nodes { + + public Nodes() {} + + public Nodes(String text, String href, List tags) { + this.text = text; + this.href = href; + this.tags = tags; + } + + private String text; + private String href; + private List tags; +} diff --git a/ruoyi-admin/src/main/resources/templates/section/transformer-detail.html b/ruoyi-admin/src/main/resources/templates/section/transformer-detail.html index f12b0d2..cc78964 100644 --- a/ruoyi-admin/src/main/resources/templates/section/transformer-detail.html +++ b/ruoyi-admin/src/main/resources/templates/section/transformer-detail.html @@ -20,6 +20,27 @@ @@ -376,10 +404,10 @@
监控单元
- 监控单元 +
-
+

设备编号:10kv 主变压器001

设备型号:SC(B)10型干式电力变压器

启用时间:2020年1月20日

@@ -391,6 +419,7 @@