change - iot-Index接口实现

main
wenjy 3 years ago
parent 13fc644f16
commit 91a5157fb7

@ -1,6 +1,14 @@
package com.ruoyi.web.controller.iot; package com.ruoyi.web.controller.iot;
import com.alibaba.fastjson.JSONArray; 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.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; 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.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @author WenJY * @author WenJY
@ -17,6 +26,10 @@ import java.util.List;
@RequestMapping("/iot/index") @RequestMapping("/iot/index")
public class IndexController { public class IndexController {
@Autowired private IBaseMonitorunitTypeService baseMonitorunitTypeService;
@Autowired private IBaseMonitorunitInfoService baseMonitorunitInfoService;
@GetMapping() @GetMapping()
public String index() { public String index() {
return "iot-ui/index"; return "iot-ui/index";
@ -24,43 +37,67 @@ public class IndexController {
/** /**
* *
*
* @author WenJY * @author WenJY
* @date 2022/2/23 14:26 * @date 2022/2/23 14:26
* @return java.lang.String * @return java.lang.String
*/ */
@GetMapping("/getMonitorUnitCharts") @GetMapping("/getMonitorUnitCharts")
@ResponseBody @ResponseBody
public String getMonitorUnitCharts(){ public String getMonitorUnitCharts() {
return "[\n" + try {
" {\n" + List<BaseMonitorunitInfoDto> result = new ArrayList<BaseMonitorunitInfoDto>();
" \"value\": 32,\n" +
" \"name\": \"隔离开关\"\n" + List<BaseMonitorunitType> baseMonitorunitTypes =
" },\n" + baseMonitorunitTypeService.selectBaseMonitorunitTypeList(new BaseMonitorunitType());
" {\n" + List<BaseMonitorunitInfoDto> baseMonitorunitInfoDtos =
" \"value\": 14,\n" + baseMonitorunitInfoService.selectBaseMonitorunitInfoDtoList(new BaseMonitorunitInfo());
" \"name\": \"电流互感器\"\n" +
" },\n" + baseMonitorunitTypes.forEach(
" {\n" + x -> {
" \"value\": 26,\n" + List<BaseMonitorunitInfoDto> collect =
" \"name\": \"电压互感器\"\n" + baseMonitorunitInfoDtos.stream()
" },\n" + .filter(y -> y.getMonitorunitType().equals(x.getMonitorunittypeId()))
" {\n" + .collect(Collectors.toList());
" \"value\": 20,\n" + BaseMonitorunitInfoDto info = new BaseMonitorunitInfoDto();
" \"name\": \"变压器\"\n" + info.setName(x.getMonitorunittypeName());
" },\n" + info.setValue(collect.size());
" {\n" + result.add(info);
" \"value\": 10,\n" + });
" \"name\": \"电容电抗器\"\n" + return JSONArray.toJSONString(result);
" },\n" + } catch (Exception ex) {
" {\n" + return "[\n"
" \"value\": 10,\n" + + " {\n"
" \"name\": \"避雷器\"\n" + + " \"value\": 32,\n"
" }\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 * @author WenJY
* @date 2022/2/23 13:55 * @date 2022/2/23 13:55
* @return java.lang.String * @return java.lang.String
@ -68,36 +105,75 @@ public class IndexController {
@GetMapping("/getMonitorUnitInfo") @GetMapping("/getMonitorUnitInfo")
@ResponseBody @ResponseBody
public String getMonitorUnitInfo() { public String getMonitorUnitInfo() {
return "{\n"
+ " \"header\": [\"名称\", \"监控数量\", \"告警数量\"],\n" try {
+ " \"data\": [\n" List<List<String>> data = new ArrayList<>();
+ " [\"隔离开关\", \"30\", \"30\"],\n"
+ " [\"电流互感器\", \"14\", \"14\"],\n" List<String> header =
+ " [\"电压互感器\", \"26\", \"26\"],\n" new ArrayList<String>() {
+ " [\"变压器\", \"20\", \"20\"],\n" {
+ " [\"电容电抗器\", \"10\", \"10\"],\n" this.add("名称");
+ " [\"避雷器\", \"10\", \"10\"]\n" this.add("监控数量");
+ " ]\n" 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"
+ " [\"隔离开关\", \"30\", \"30\"],\n"
+ " [\"电流互感器\", \"14\", \"14\"],\n"
+ " [\"电压互感器\", \"26\", \"26\"],\n"
+ " [\"变压器\", \"20\", \"20\"],\n"
+ " [\"电容电抗器\", \"10\", \"10\"],\n"
+ " [\"避雷器\", \"10\", \"10\"]\n"
+ " ]\n"
+ "}";
}
} }
/** /**
* *
*
* @author WenJY * @author WenJY
* @date 2022/2/23 13:54 * @date 2022/2/23 13:54
* @return java.lang.String * @return java.lang.String
*/ */
@GetMapping("/getSensorStateCharts") @GetMapping("/getSensorStateCharts")
@ResponseBody @ResponseBody
public String getSensorStateCharts(){ public String getSensorStateCharts() {
return "{\n" + return "{\n"
" \"yAxis\": [\"在线\", \"离线\", \"告警\"],\n" + + " \"yAxis\": [\"在线\", \"离线\", \"告警\"],\n"
" \"data\": [60, 132, 89]\n" + + " \"data\": [60, 132, 89]\n"
"}"; + "}";
} }
/** /**
* *
*
* @author WenJY * @author WenJY
* @date 2022/2/23 13:55 * @date 2022/2/23 13:55
* @return java.lang.String * @return java.lang.String
@ -120,13 +196,14 @@ public class IndexController {
/** /**
* *
*
* @author WenJY * @author WenJY
* @date 2022/2/23 13:54 * @date 2022/2/23 13:54
* @return java.lang.String * @return java.lang.String
*/ */
@GetMapping("/getAlarmAmount") @GetMapping("/getAlarmAmount")
@ResponseBody @ResponseBody
public String getAlarmAmount(){ public String getAlarmAmount() {
return "{\n" return "{\n"
+ " \"yAxis\": [\"设备高温\", \"设备振动\", \"烟雾火情\", \"环境大风\", \"测试一\", \"测试二\", \"测试三\", \"测试四\", \"测试五\", \"测试六\"],\n" + " \"yAxis\": [\"设备高温\", \"设备振动\", \"烟雾火情\", \"环境大风\", \"测试一\", \"测试二\", \"测试三\", \"测试四\", \"测试五\", \"测试六\"],\n"
+ " \"data\": [60, 132, 89, 10,15,23,22,60, 132, 89]\n" + " \"data\": [60, 132, 89, 10,15,23,22,60, 132, 89]\n"
@ -135,17 +212,17 @@ public class IndexController {
/** /**
* *
*
* @author WenJY * @author WenJY
* @date 2022/2/23 14:23 * @date 2022/2/23 14:23
* @return java.lang.String * @return java.lang.String
*/ */
@GetMapping("/getAlarmTrend") @GetMapping("/getAlarmTrend")
@ResponseBody @ResponseBody
public String getAlarmTrend(){ public String getAlarmTrend() {
return "{\n" + return "{\n"
" \"xAxis\": [\"06-21\", \"06-22\", \"06-23\", \"06-24\", \"06-25\", \"06-26\", \"06-27\"],\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" + + " \"data\": [18, 5, 4, 2, 1, 7, 6]\n"
"}"; + "}";
} }
} }

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

@ -15,4 +15,8 @@ public class BaseMonitorunitInfoDto extends BaseMonitorunitInfo {
private String substationName; private String substationName;
private String parentName; 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