change - 设备监测页面初步修改,后端接口完善
parent
2cd5053fa7
commit
8e99db156c
@ -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<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
|
||||
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(
|
||||
new BaseMonitorunitInfo(null, null, null, null, 0L));
|
||||
|
||||
List<BaseMonitorunitInfoDto> collect =
|
||||
baseMonitorunitInfoDtos.stream()
|
||||
.filter(x -> x.getParentId().isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<JsonRootBean> jsonResult = new ArrayList<>();
|
||||
|
||||
collect.forEach(
|
||||
x -> {
|
||||
List<String> tags = new ArrayList<>();
|
||||
List<Nodes> nodes = new ArrayList<>();
|
||||
|
||||
List<BaseMonitorunitInfoDto> collect1 =
|
||||
baseMonitorunitInfoDtos.stream()
|
||||
.filter(y -> y.getParentId().equals(x.getMonitorunitId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
tags.add(collect1.size() + "");
|
||||
|
||||
collect1.forEach(
|
||||
z -> {
|
||||
List<String> 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<BaseMonitorunitInfoDto> 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<BaseSensorInfoDto> baseSensorInfoDtos = new ArrayList<>();
|
||||
|
||||
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
|
||||
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(
|
||||
new BaseMonitorunitInfo(monitorunitId));
|
||||
|
||||
baseMonitorunitInfoDtos.forEach(
|
||||
x -> {
|
||||
/*if(x.getParentId().isEmpty()){
|
||||
BaseMonitorunitInfo baseMonitorunitInfo = new BaseMonitorunitInfo();
|
||||
baseMonitorunitInfo.setParentId(x.getMonitorunitId());
|
||||
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos1 = baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(baseMonitorunitInfo);
|
||||
baseMonitorunitInfoDtos1.forEach(y->{
|
||||
List<BaseSensorInfoDto> baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null, null, null, y.getMonitorunitId()));
|
||||
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
|
||||
});
|
||||
}else{
|
||||
List<BaseSensorInfoDto> baseSensorInfoDtos1 = baseSensorInfoService.selectBaseSensorInfoList(new BaseSensorInfo(null, null, null, x.getMonitorunitId()));
|
||||
baseSensorInfoDtos.addAll(baseSensorInfoDtos1);
|
||||
}*/
|
||||
|
||||
List<BaseSensorInfoDto> 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<String> tags, List<Nodes> nodes) {
|
||||
this.text = text;
|
||||
this.href = href;
|
||||
this.tags = tags;
|
||||
this.nodes = nodes;
|
||||
}
|
||||
|
||||
private String text;
|
||||
private String href;
|
||||
private List<String> tags;
|
||||
private List<Nodes> nodes;
|
||||
}
|
||||
|
||||
@Data
|
||||
class Nodes {
|
||||
|
||||
public Nodes() {}
|
||||
|
||||
public Nodes(String text, String href, List<String> tags) {
|
||||
this.text = text;
|
||||
this.href = href;
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
private String text;
|
||||
private String href;
|
||||
private List<String> tags;
|
||||
}
|
Loading…
Reference in New Issue