change - iot-Index接口实现

main
wenjy 3 years ago
parent 13fc644f16
commit 91a5157fb7

@ -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<BaseMonitorunitInfoDto> result = new ArrayList<BaseMonitorunitInfoDto>();
List<BaseMonitorunitType> baseMonitorunitTypes =
baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());
baseMonitorunitTypes.forEach(
x -> {
List<BaseMonitorunitInfoDto> 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,6 +105,42 @@ public class IndexController {
@GetMapping("/getMonitorUnitInfo")
@ResponseBody
public String getMonitorUnitInfo() {
try {
List<List<String>> data = new ArrayList<>();
List<String> header =
new ArrayList<String>() {
{
this.add("名称");
this.add("监控数量");
this.add("告警数量");
}
};
List<BaseMonitorunitType> baseMonitorunitTypes =
baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType());
List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());
baseMonitorunitTypes.forEach(
x -> {
List<BaseMonitorunitInfoDto> collect =
baseMonitorunitInfoDtos.stream()
.filter(y -> y.getMonitorunitType().equals(x.getMonitorunittypeId()))
.collect(Collectors.toList());
data.add(
new ArrayList<String>() {
{
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"
@ -80,24 +153,27 @@ public class IndexController {
+ " ]\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"
+ "}";
}
}

@ -55,7 +55,7 @@ public class SwaggerConfig
// 用ApiInfoBuilder进行定制
return new ApiInfoBuilder()
// 设置标题
.title("标题:若依管理系统_接口文档")
.title("标题:变电站智慧物联监控平台_接口文档")
// 描述
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
// 作者信息

@ -15,4 +15,8 @@ public class BaseMonitorunitInfoDto extends BaseMonitorunitInfo {
private String substationName;
private String parentName;
private String name;
private int value;
}

@ -0,0 +1,25 @@
package com.ruoyi.system.domain.dto;
import lombok.Data;
import java.util.List;
/**
* @author WenJY
* @date 20220311 10:59
*/
@Data
public class ScrollTableDto {
public ScrollTableDto() {
}
public ScrollTableDto(List<String> header, List<List<String>> data) {
this.header = header;
this.data = data;
}
private List<String> header;
private List<List<String>> data;
}
Loading…
Cancel
Save