From 87e378b54ba56484cd92e101f6bac31f45705179 Mon Sep 17 00:00:00 2001 From: YYD-YY <2962062657@qq.com> Date: Mon, 6 Oct 2025 18:33:59 +0800 Subject: [PATCH 1/6] =?UTF-8?q?10.6=E4=BF=AE=E6=AD=A3=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=B1=BB=E5=9E=8Blist=EF=BC=8C=E4=BB=A5=E5=8F=8A=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E4=B8=A4=E4=B8=AA=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../equManagement/EquBaseController.java | 18 ++++++++----- .../system/domain/dto/AlertStatisticDto.java | 27 +++++++++++++------ .../system/domain/dto/LevelCountDto.java | 22 +++++++++++++++ .../alops/system/domain/dto/TypeCountDto.java | 17 ++++++++++++ .../alops/system/mapper/EquBaseMapper.java | 3 ++- .../alops/system/service/IEquBaseService.java | 2 +- .../service/impl/AlertMessageServiceImpl.java | 17 +++++++----- .../service/impl/EquBaseServiceImpl.java | 7 ++--- .../resources/mapper/system/EquBaseMapper.xml | 9 ++++--- 9 files changed, 92 insertions(+), 30 deletions(-) create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/LevelCountDto.java create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/TypeCountDto.java diff --git a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java index e17e40fd..f4ba3e18 100644 --- a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java +++ b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java @@ -60,19 +60,23 @@ public class EquBaseController extends BaseController } /**查询设备监测信息列表(查询多台显示界面的单独信息)**/ + /** + * 查询多台设备的最新监测信息 + **/ @PreAuthorize("@ss.hasPermi('device:files:query')") - @GetMapping("/monitorById") - @ApiOperation("根据设备ID查询设备最新监测信息(查询多台显示界面的单台信息)") - public AjaxResult getMonitorById(@RequestParam String id) { - MonitorListDto monitor = equBaseService.selectEquMonitorListById(id); - if (monitor != null) { - return AjaxResult.success("查询成功", monitor); + @GetMapping("/monitorListById") + @ApiOperation("根据多个设备ID查询多台设备的最新监测信息") + public AjaxResult getMonitorListByIds(@RequestParam List ids) { + List monitors = equBaseService.selectEquMonitorListByIds(ids); + if (monitors != null && !monitors.isEmpty()) { + return AjaxResult.success("查询成功", monitors); } else { - return AjaxResult.error("未找到设备或监测信息"); + return AjaxResult.error("未找到相关设备或监测信息"); } } + /** * 获取设备最新时间的历史监控信息 * @param id 查询对象,包含设备ID、开始时间和结束时间 diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/AlertStatisticDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/AlertStatisticDto.java index 3fe6246c..c53a4876 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/AlertStatisticDto.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/AlertStatisticDto.java @@ -1,6 +1,9 @@ package com.alops.system.domain.dto; import lombok.Data; + +import java.util.ArrayList; +import java.util.List; import java.util.Map; /** @@ -8,15 +11,23 @@ import java.util.Map; */ @Data public class AlertStatisticDto { - // 按设备类型统计 - private Map typeCount; - - // 按等级统计 - private Map levelCount; - // 本年度预警次数 + private List typeCount = new ArrayList<>(); + private List levelCount = new ArrayList<>(); private Integer yearCount; - - // 本月预警次数 private Integer monthCount; + + public List getTypeCount() { return typeCount; } + public void setTypeCount(List typeCount) { this.typeCount = typeCount; } + + public List getLevelCount() { return levelCount; } + public void setLevelCount(List levelCount) { this.levelCount = levelCount; } + + public Integer getYearCount() { return yearCount; } + public void setYearCount(Integer yearCount) { this.yearCount = yearCount; } + + public Integer getMonthCount() { return monthCount; } + public void setMonthCount(Integer monthCount) { this.monthCount = monthCount; } + } + diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/LevelCountDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/LevelCountDto.java new file mode 100644 index 00000000..ed5e76dd --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/LevelCountDto.java @@ -0,0 +1,22 @@ +package com.alops.system.domain.dto; + +public class LevelCountDto { + private String level; + private Integer count; + + // 无参构造器 + public LevelCountDto() {} + + // 带参构造器 + public LevelCountDto(String level, Integer count) { + this.level = level; + this.count = count; + } + + // getter & setter + public String getLevel() { return level; } + public void setLevel(String level) { this.level = level; } + + public Integer getCount() { return count; } + public void setCount(Integer count) { this.count = count; } +} diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/TypeCountDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/TypeCountDto.java new file mode 100644 index 00000000..9b120e25 --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/TypeCountDto.java @@ -0,0 +1,17 @@ +package com.alops.system.domain.dto; + +public class TypeCountDto { + private String name; + private Integer count; + + public TypeCountDto() {} + public TypeCountDto(String name, Integer count) { + this.name = name; + this.count = count; + } + // getter/setter + public String getName() { return name; } + public void setName(String name) { this.name = name; } + public Integer getCount() { return count; } + public void setCount(Integer count) { this.count = count; } +} diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java index 29d74d3d..aeaca38b 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java @@ -63,7 +63,8 @@ public interface EquBaseMapper MonitorLastDto selectEquMonitorById(String id); List> selectEquMonitorByIdToList(EquBaseQueryDto queryDto); - MonitorListDto selectEquMonitorListById(String id); + List selectEquMonitorListByIds(List ids); + /**分类统计界面信息 -YY**/ List selectEquStatisticByType(); diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java index cc7a1869..f269d6c1 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java @@ -60,7 +60,7 @@ public interface IEquBaseService */ public List selectEquBaseList(EquBaseQueryDto equBase); - public MonitorListDto selectEquMonitorListById(String id); + public List selectEquMonitorListByIds(List ids); /**分类统计信息**/ List selectEquStatisticByType(); diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertMessageServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertMessageServiceImpl.java index 5921383b..1cb64e00 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertMessageServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertMessageServiceImpl.java @@ -10,6 +10,8 @@ import java.util.Map; import com.alops.system.domain.AlertMessage; import com.alops.system.domain.dto.AlertDto; import com.alops.system.domain.dto.AlertStatisticDto; +import com.alops.system.domain.dto.LevelCountDto; +import com.alops.system.domain.dto.TypeCountDto; import com.alops.system.mapper.AlertMessageMapper; import com.alops.system.service.IAlertMessageService; import org.springframework.beans.factory.annotation.Autowired; @@ -66,18 +68,18 @@ public class AlertMessageServiceImpl implements IAlertMessageService AlertStatisticDto dto = new AlertStatisticDto(); // 按设备类型统计 - Map typeMap = new HashMap<>(); for (Map row : alertMessageMapper.countByType()) { - typeMap.put((String) row.get("equ_type"), ((Long) row.get("cnt")).intValue()); + String name = (String) row.get("equ_type"); + Integer count = ((Long) row.get("cnt")).intValue(); + dto.getTypeCount().add(new TypeCountDto(name, count)); } - dto.setTypeCount(typeMap); // 按等级统计 - Map levelMap = new HashMap<>(); for (Map row : alertMessageMapper.countByLevel()) { - levelMap.put(((Integer) row.get("level")), ((Long) row.get("cnt")).intValue()); + String level = String.valueOf(row.get("level")); + Integer count = ((Long) row.get("cnt")).intValue(); + dto.getLevelCount().add(new LevelCountDto(level, count)); } - dto.setLevelCount(levelMap); // 年 / 月 LocalDate now = LocalDate.now(); @@ -90,7 +92,8 @@ public class AlertMessageServiceImpl implements IAlertMessageService return dto; } - /** + + /** * 新增故障统计 * * @param alertMessage 故障统计 diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java index 8a046847..021782de 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java @@ -131,13 +131,14 @@ public class EquBaseServiceImpl implements IEquBaseService } /** - * 查询多台显示界面的单独信息 + * 查询多台设备的最新监测信息 **/ @Override - public MonitorListDto selectEquMonitorListById(String id) { - return equBaseMapper.selectEquMonitorListById(id); + public List selectEquMonitorListByIds(List ids) { + return equBaseMapper.selectEquMonitorListByIds(ids); } + /** * 设备类型分类统计信息 **/ diff --git a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml index a3860a73..96c9ff50 100644 --- a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml +++ b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml @@ -152,7 +152,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - SELECT b.id, b.name, @@ -176,8 +176,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN equ_gather g ON b.id = g.equ_id LEFT JOIN equ_type t ON b.equ_type = t.id LEFT JOIN equ_manu m ON b.manufacture = m.id - where b.id = #{id} - AND g.cpu_utilization is not null + WHERE b.id IN + + #{id} + + AND g.cpu_utilization is not null ORDER BY g.gather_time desc limit 1 From a548944f679dcd550977e4f9d341930a0e80ded1 Mon Sep 17 00:00:00 2001 From: Wangxin Date: Tue, 7 Oct 2025 17:00:09 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E3=80=90web=E3=80=91=20=E9=A6=96=E9=A1=B5U?= =?UTF-8?q?I=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/api/inMonitoring/devicesState.js | 2 +- ALOps_sys_fe/alops-ui/src/api/index/index.js | 92 ++ ALOps_sys_fe/alops-ui/src/router/index.js | 2 +- .../alops-ui/src/views/device/files/index.vue | 10 +- .../inMonitoring/devicesState/cardItem.vue | 514 +++++++++-- .../inMonitoring/devicesState/detail.vue | 839 ++++++++++++++---- .../inMonitoring/devicesState/history.vue | 69 ++ .../views/inMonitoring/devicesState/index.vue | 30 +- .../inMonitoring/inMonitor/message/index.vue | 3 - .../inMonitoring/inMonitor/rules/index.vue | 4 +- ALOps_sys_fe/alops-ui/src/views/index.vue | 91 +- 11 files changed, 1398 insertions(+), 258 deletions(-) create mode 100644 ALOps_sys_fe/alops-ui/src/api/index/index.js create mode 100644 ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/history.vue diff --git a/ALOps_sys_fe/alops-ui/src/api/inMonitoring/devicesState.js b/ALOps_sys_fe/alops-ui/src/api/inMonitoring/devicesState.js index eb99e9e3..5ead40a8 100644 --- a/ALOps_sys_fe/alops-ui/src/api/inMonitoring/devicesState.js +++ b/ALOps_sys_fe/alops-ui/src/api/inMonitoring/devicesState.js @@ -5,7 +5,7 @@ const api = '/device/files/' // 查询多台设备列表 export function list(query) { return request({ - url: api + 'listMonitor', + url: api + 'list', method: 'get', params: query }) diff --git a/ALOps_sys_fe/alops-ui/src/api/index/index.js b/ALOps_sys_fe/alops-ui/src/api/index/index.js new file mode 100644 index 00000000..858aa7a0 --- /dev/null +++ b/ALOps_sys_fe/alops-ui/src/api/index/index.js @@ -0,0 +1,92 @@ +import request from '@/utils/request' +import { parseStrEmpty } from "@/utils/ruoyi"; +const api = '/device/files/' + +// 查询详细 +export function getDict() { + return request({ + url: '/sys_dict', + method: 'get' + }) +} + +// 预警信息统 +export function statistic(query) { + return request({ + url: 'inMonitoring/statistic', + method: 'get', + params: query + }) +} + +// 统计预警信息次数 +export function alertMessageTimes(query) { + return request({ + url: 'inMonitoring/alertMessage/times', + method: 'get', + params: query + }) +} + +// 按设备类型分类统计设备信息 +export function byEquType() { + return request({ + url: 'device/files/byEquType', + method: 'get' + }) +} + +// 设备运行状态 +export function listMonitor(query) { + return request({ + url: 'device/files/monitorById', + method: 'get', + params: query + }) +} + + + + + + + + + +// 查询详细 +export function getInfo(id) { + return request({ + url: api + '/queryById/' + parseStrEmpty(id), + method: 'get' + }) +} + +// 新增 +export function add(data) { + return request({ + url: api + 'add', + method: 'post', + data: data + }) +} + +// 修改 +export function update(data) { + return request({ + url: api + 'modify', + method: 'put', + data: data + }) +} + +// 删除 +export function del(id) { + return request({ + url: api + id, + method: 'delete' + }) +} + + + + diff --git a/ALOps_sys_fe/alops-ui/src/router/index.js b/ALOps_sys_fe/alops-ui/src/router/index.js index 02ed4a52..904eb925 100644 --- a/ALOps_sys_fe/alops-ui/src/router/index.js +++ b/ALOps_sys_fe/alops-ui/src/router/index.js @@ -99,7 +99,7 @@ export const dynamicRoutes = [ permissions: ['inMonitoring:devicesState:edit'], children: [ { - path: 'detail/:userId(\\d+)', + path: 'detail/:userId', component: () => import('@/views/inMonitoring/devicesState/detail'), name: 'DevicesStateDetail', meta: { title: '设备详情', activeMenu: '/inMonitoring/devicesState-detail' } diff --git a/ALOps_sys_fe/alops-ui/src/views/device/files/index.vue b/ALOps_sys_fe/alops-ui/src/views/device/files/index.vue index 4185cba1..7b1d03db 100644 --- a/ALOps_sys_fe/alops-ui/src/views/device/files/index.vue +++ b/ALOps_sys_fe/alops-ui/src/views/device/files/index.vue @@ -33,9 +33,9 @@ 删除 - + @@ -119,7 +119,9 @@ - + + + @@ -205,7 +207,7 @@ import "splitpanes/dist/splitpanes.css" export default { name: "User", - dicts: ['device_disable', 'sys_user_sex'], + dicts: ['device_disable', 'sys_user_sex', 'warning_level'], components: { Treeselect, Splitpanes, Pane }, data() { return { diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/cardItem.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/cardItem.vue index 445debfc..378dbb81 100644 --- a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/cardItem.vue +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/cardItem.vue @@ -1,75 +1,485 @@ \ No newline at end of file + + \ No newline at end of file diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/detail.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/detail.vue index c6aeb13f..59c8768a 100644 --- a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/detail.vue +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/detail.vue @@ -1,198 +1,679 @@ - \ No newline at end of file + .tab-top{ + display: flex; + gap: 20px; + } + .top-item{ + color: #2d3748; + font-weight: 400; + font-size:18px ; + cursor: pointer; + } + .top-item.ac{ + font-weight: 600; + border-bottom: 2px solid #2d3748; + } + \ No newline at end of file diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/history.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/history.vue new file mode 100644 index 00000000..f9828db3 --- /dev/null +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/history.vue @@ -0,0 +1,69 @@ + + + \ No newline at end of file diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/index.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/index.vue index 8a4bf9e2..d71f7257 100644 --- a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/index.vue +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/devicesState/index.vue @@ -36,12 +36,10 @@ -
+
- - - - + +
@@ -148,7 +146,7 @@ \ No newline at end of file + + \ No newline at end of file diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/inMonitor/message/index.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/inMonitor/message/index.vue index 3f7ad5e9..0fdf7a3a 100644 --- a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/inMonitor/message/index.vue +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/inMonitor/message/index.vue @@ -19,9 +19,6 @@ - - - 搜索 重置 diff --git a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/inMonitor/rules/index.vue b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/inMonitor/rules/index.vue index 5800c083..fcd5b1c1 100644 --- a/ALOps_sys_fe/alops-ui/src/views/inMonitoring/inMonitor/rules/index.vue +++ b/ALOps_sys_fe/alops-ui/src/views/inMonitoring/inMonitor/rules/index.vue @@ -7,7 +7,7 @@ - + @@ -112,7 +112,7 @@ - + diff --git a/ALOps_sys_fe/alops-ui/src/views/index.vue b/ALOps_sys_fe/alops-ui/src/views/index.vue index d35b56a4..3c06caf7 100644 --- a/ALOps_sys_fe/alops-ui/src/views/index.vue +++ b/ALOps_sys_fe/alops-ui/src/views/index.vue @@ -7,7 +7,7 @@
-

预警信息统计1

+

预警信息统计

@@ -132,6 +132,12 @@ import RaddarChart from './dashboard/RaddarChart' import PieChart from './dashboard/PieChart' import BarChart from './dashboard/BarChart' import digital from './dashboard/digital' +import { statistic, byEquType, listMonitor, alertMessageTimes } from "@/api/index/index" +import { getToken } from "@/utils/auth" +import Treeselect from "@riophae/vue-treeselect" +import "@riophae/vue-treeselect/dist/vue-treeselect.css" +import { Splitpanes, Pane } from "splitpanes" +import "splitpanes/dist/splitpanes.css" export default { name: 'Index', @@ -174,7 +180,47 @@ export default { level: 0, status: 'normal', icon: 'fas fa-check-circle' - } + }, + { + id: 1, + deviceName: 'PLC远程监控系统', + time: '2021-10-16 14:54:11', + location: '污水处理监控系统', + message: '2#电机运行状态等于1', + level: 1, + status: 'warning', + icon: 'fas fa-exclamation-circle' + }, + { + id: 2, + deviceName: 'PLC远程监控系统', + time: '2021-10-16 14:54:04', + location: '污水处理监控系统', + message: '2#电机运行状态报警恢复', + level: 0, + status: 'normal', + icon: 'fas fa-check-circle' + }, + { + id: 1, + deviceName: 'PLC远程监控系统', + time: '2021-10-16 14:54:11', + location: '污水处理监控系统', + message: '2#电机运行状态等于1', + level: 1, + status: 'warning', + icon: 'fas fa-exclamation-circle' + }, + { + id: 2, + deviceName: 'PLC远程监控系统', + time: '2021-10-16 14:54:04', + location: '污水处理监控系统', + message: '2#电机运行状态报警恢复', + level: 0, + status: 'normal', + icon: 'fas fa-check-circle' + }, ], tableHeaders: ['设备名称', '设备位置', 'CPU使用率', '内存使用率', '温度', '健康度', '设备运行时长', '采集时间'], deviceStatus: [ @@ -240,8 +286,45 @@ export default { if (health >= 80) return 'health-good'; if (health >= 60) return 'health-warning'; return 'health-critical'; - } - } + }, + getstatistic() { + this.loading = true + statistic().then(response => { + console.log("%c 🎹: getList -> response ", "font-size:16px;background-color:#624a64;color:white;", response) + this.loading = false + } + ) + }, + getbyEquType() { + this.loading = true + byEquType().then(response => { + this.loading = false + } + ) + }, + getlistMonitor() { + this.loading = true + listMonitor({id:11}).then(response => { + this.loading = false + } + ) + }, + getalertMessageTimes() { + this.loading = true + alertMessageTimes().then(response => { + this.loading = false + } + ) + }, + }, + created() { + this.getstatistic() + this.getbyEquType() + this.getlistMonitor() + this.getalertMessageTimes() + + + }, } From ace6039895d33ddab8b3ec8de9c9e1fc9c0ca5c2 Mon Sep 17 00:00:00 2001 From: Wangxin Date: Tue, 7 Oct 2025 18:52:49 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E3=80=90web=E3=80=91=20=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E9=A2=84=E8=AD=A6=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ALOps_sys_fe/alops-ui/src/api/index/index.js | 2 +- ALOps_sys_fe/alops-ui/src/views/index.vue | 156 ++++++++----------- 2 files changed, 68 insertions(+), 90 deletions(-) diff --git a/ALOps_sys_fe/alops-ui/src/api/index/index.js b/ALOps_sys_fe/alops-ui/src/api/index/index.js index 858aa7a0..92081fa3 100644 --- a/ALOps_sys_fe/alops-ui/src/api/index/index.js +++ b/ALOps_sys_fe/alops-ui/src/api/index/index.js @@ -13,7 +13,7 @@ export function getDict() { // 预警信息统 export function statistic(query) { return request({ - url: 'inMonitoring/statistic', + url: '/inMonitoring/alertMessage/statistic/list', method: 'get', params: query }) diff --git a/ALOps_sys_fe/alops-ui/src/views/index.vue b/ALOps_sys_fe/alops-ui/src/views/index.vue index 3c06caf7..bbb81b8b 100644 --- a/ALOps_sys_fe/alops-ui/src/views/index.vue +++ b/ALOps_sys_fe/alops-ui/src/views/index.vue @@ -10,20 +10,23 @@

预警信息统计

-
-
预警总数
-
{{ totalAlerts }}
-
系统检测到的预警总数
+
+
年预警总数
+
{{ alertMessageData.yearCount }}
-
-
当前预警
-
{{ activeAlerts }}
-
需要处理的预警数量
+
+
月预警总数
+
{{ alertMessageData.monthCount }}
-
-
已处理
-
{{ resolvedAlerts }}
-
已解决的预警数量
+ +
+
{{ `等级${i.level}预警` }}
+
{{ i.count }}
+
+ +
+
{{ `${i.name}预警` }}
+
{{ i.count }}
@@ -44,8 +47,8 @@
{{ device.name }}
{{ device.description }}
- - {{ device.status === 'warning' ? '预警中' : '正常' }} + + {{ device.status === 'UNHANDLED' ? '预警中' : '正常' }} @@ -58,23 +61,25 @@

设备预警信息

-
    -
  • +
      +
    • - +
      -
      {{ alert.deviceName }}
      +
      {{ alert.name }}
      -
      预警时间: {{ alert.time }}
      +
      预警时间: {{ parseTime(alert.occurTime) }}
      设备位置: {{ alert.location }}
      预警信息: {{ alert.message }}
      - - {{ alert.level === 1 ? '等级1' : '等级0' }} + + {{ '等级'+alert.level }}
    • +

      加载中...

      +

      没有更多了

@@ -155,73 +160,19 @@ export default { activeAlerts: 42, resolvedAlerts: 69, lastUpdate: new Date().toLocaleString(), + + isLoading: false, // 加载状态 + noMore: false, // 是否无更多数据 + page: 1, // 当前页码 devices: [ { id: 1, name: 'Forecasts', description: '预测分析系统', status: 'normal', icon: 'fas fa-chart-line' }, { id: 2, name: 'Gold', description: '核心处理单元', status: 'warning', icon: 'fas fa-server' }, { id: 3, name: 'Industries', description: '工业控制系统', status: 'normal', icon: 'fas fa-industry' } ], - alerts: [ - { - id: 1, - deviceName: 'PLC远程监控系统', - time: '2021-10-16 14:54:11', - location: '污水处理监控系统', - message: '2#电机运行状态等于1', - level: 1, - status: 'warning', - icon: 'fas fa-exclamation-circle' - }, - { - id: 2, - deviceName: 'PLC远程监控系统', - time: '2021-10-16 14:54:04', - location: '污水处理监控系统', - message: '2#电机运行状态报警恢复', - level: 0, - status: 'normal', - icon: 'fas fa-check-circle' - }, - { - id: 1, - deviceName: 'PLC远程监控系统', - time: '2021-10-16 14:54:11', - location: '污水处理监控系统', - message: '2#电机运行状态等于1', - level: 1, - status: 'warning', - icon: 'fas fa-exclamation-circle' - }, - { - id: 2, - deviceName: 'PLC远程监控系统', - time: '2021-10-16 14:54:04', - location: '污水处理监控系统', - message: '2#电机运行状态报警恢复', - level: 0, - status: 'normal', - icon: 'fas fa-check-circle' - }, - { - id: 1, - deviceName: 'PLC远程监控系统', - time: '2021-10-16 14:54:11', - location: '污水处理监控系统', - message: '2#电机运行状态等于1', - level: 1, - status: 'warning', - icon: 'fas fa-exclamation-circle' - }, - { - id: 2, - deviceName: 'PLC远程监控系统', - time: '2021-10-16 14:54:04', - location: '污水处理监控系统', - message: '2#电机运行状态报警恢复', - level: 0, - status: 'normal', - icon: 'fas fa-check-circle' - }, - ], + // 设备预警信息 + alerts: [], + // 统计预警信息次数 + alertMessageData: [], tableHeaders: ['设备名称', '设备位置', 'CPU使用率', '内存使用率', '温度', '健康度', '设备运行时长', '采集时间'], deviceStatus: [ { @@ -290,7 +241,7 @@ export default { getstatistic() { this.loading = true statistic().then(response => { - console.log("%c 🎹: getList -> response ", "font-size:16px;background-color:#624a64;color:white;", response) + this.alerts = response.rows this.loading = false } ) @@ -304,7 +255,7 @@ export default { }, getlistMonitor() { this.loading = true - listMonitor({id:11}).then(response => { + listMonitor().then(response => { this.loading = false } ) @@ -312,13 +263,33 @@ export default { getalertMessageTimes() { this.loading = true alertMessageTimes().then(response => { - this.loading = false + this.alertMessageData = response.data + this.loading = false } ) }, + async loadMore() { + console.log("%c 🎧: loadMore -> this.isLoading || this.noMore ", "font-size:16px;background-color:#64b738;color:white;", this.isLoading , this.noMore) + + if (this.isLoading || this.noMore) return; + this.isLoading = true; + try { + const res = await statistic({page:this.page}); // 模拟API请求 + if (res.rows.length < 10) { // 假设每页10条 + this.noMore = true; + } else { + this.alerts = [...this.alerts, ...res.rows]; + this.page++; + } + } catch (error) { + console.error('加载失败:', error); + } finally { + this.isLoading = false; + } + }, }, created() { - this.getstatistic() + // this.getstatistic() this.getbyEquType() this.getlistMonitor() this.getalertMessageTimes() @@ -414,9 +385,13 @@ export default { } .stats-container { - display: flex; + display: grid; justify-content: space-between; + grid-template-columns: repeat(3, 1fr); gap: 15px; + overflow-y: auto; + overflow-x: hidden; + height: 255px; } .stat-card { @@ -424,7 +399,7 @@ export default { background: linear-gradient(135deg, #3498db, #2c3e50); color: white; border-radius: 10px; - padding: 20px; + padding: 12px; text-align: center; box-shadow: 0 4px 8px rgba(52, 152, 219, 0.3); } @@ -452,6 +427,9 @@ export default { .device-list { list-style: none; + overflow-y: auto; + overflow-x: hidden; + max-height: 255px; } .device-item { From ca3ae05b606d6e3c2d796de5863238cf595c0ed8 Mon Sep 17 00:00:00 2001 From: YYD-YY <2962062657@qq.com> Date: Tue, 7 Oct 2025 19:01:28 +0800 Subject: [PATCH 4/6] =?UTF-8?q?10.7=E4=BF=AE=E6=AD=A3=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../equManagement/EquBaseController.java | 27 +++-- .../src/main/resources/application-druid.yml | 4 +- .../system/domain/dto/EquMonitorHomeDto.java | 20 ++++ .../alops/system/mapper/EquBaseMapper.java | 15 ++- .../alops/system/service/IEquBaseService.java | 7 +- .../service/impl/EquBaseServiceImpl.java | 11 +- .../resources/mapper/system/EquBaseMapper.xml | 101 +++++++++++++----- 7 files changed, 134 insertions(+), 51 deletions(-) create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquMonitorHomeDto.java diff --git a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java index f4ba3e18..c6dca97c 100644 --- a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java +++ b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java @@ -16,6 +16,7 @@ import com.alops.common.enums.BusinessType; import com.alops.common.utils.poi.ExcelUtil; import com.alops.system.domain.EquBase; import com.alops.system.domain.dto.EquBaseQueryDto; +import com.alops.system.domain.dto.EquMonitorHomeDto; import com.alops.system.domain.dto.MonitorListDto; import com.alops.system.domain.dto.MonitorStatisticDto; import com.alops.system.domain.vo.EquMonitorVO; @@ -64,17 +65,25 @@ public class EquBaseController extends BaseController * 查询多台设备的最新监测信息 **/ @PreAuthorize("@ss.hasPermi('device:files:query')") - @GetMapping("/monitorListById") - @ApiOperation("根据多个设备ID查询多台设备的最新监测信息") - public AjaxResult getMonitorListByIds(@RequestParam List ids) { - List monitors = equBaseService.selectEquMonitorListByIds(ids); - if (monitors != null && !monitors.isEmpty()) { - return AjaxResult.success("查询成功", monitors); - } else { - return AjaxResult.error("未找到相关设备或监测信息"); - } + @GetMapping("/monitorpage") + @ApiOperation("分页查询多台设备的最新监测信息") + public TableDataInfo getMonitorList() { + startPage(); // 无参调用,自动获取 pageNum/pageSize + List list = equBaseService.selectEquMonitorListPaged(); + return getDataTable(list); // 自动封装分页结果 } + /** + * 首页展示:查询每台设备的最新监测信息 + */ + @PreAuthorize("@ss.hasPermi('device:files:query')") + @GetMapping("/monitorById") + @ApiOperation("首页展示:查询每台设备的最新监测信息") + public TableDataInfo getLatestEquMonitorList() { + startPage(); // 启用分页(如果首页不分页可删除) + List list = equBaseService.selectLatestEquMonitorList(); + return getDataTable(list); + } /** diff --git a/ALOps_sys_backend/alops-admin/src/main/resources/application-druid.yml b/ALOps_sys_backend/alops-admin/src/main/resources/application-druid.yml index 5b4337af..16e1f2f9 100644 --- a/ALOps_sys_backend/alops-admin/src/main/resources/application-druid.yml +++ b/ALOps_sys_backend/alops-admin/src/main/resources/application-druid.yml @@ -6,9 +6,9 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://localhost:3306/aiops_sys?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://localhost:3306/alops_sys?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 username: root - password: 1234 + password: 200515 # 从库数据源 slave: # 从数据源开关/默认关闭 diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquMonitorHomeDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquMonitorHomeDto.java new file mode 100644 index 00000000..23a3355b --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquMonitorHomeDto.java @@ -0,0 +1,20 @@ +package com.alops.system.domain.dto; + +import lombok.Data; + +import java.util.Date; + +/** + * 首页展示:设备监测简要信息 + */ +@Data +public class EquMonitorHomeDto { + private String name; // 设备名称 + private String location; // 设备位置 + private Float cpuUtilization; // CPU 使用率 + private Float memoryUtilization; // 内存使用率 + private Float temperature; // 温度 + private String health; // 健康度 + private String contWorkPeriod; // 持续运行时长 + private Date gatherTime; // 采集时间 +} diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java index aeaca38b..028b2c45 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java @@ -4,19 +4,13 @@ import java.util.List; import java.util.Map; import com.alops.system.domain.EquBase; -import com.alops.system.domain.dto.EquBaseQueryDto; -import com.alops.system.domain.dto.MonitorLastDto; -import com.alops.system.domain.dto.MonitorListDto; -import com.alops.system.domain.dto.MonitorStatisticDto; +import com.alops.system.domain.dto.*; import com.alops.system.domain.vo.imageVo; import com.alops.system.domain.vo.queryEquBaseVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Update; import org.springframework.data.repository.query.Param; -import java.util.List; -import java.util.Map; - /** * 设备基本信息Mapper接口 @@ -63,7 +57,12 @@ public interface EquBaseMapper MonitorLastDto selectEquMonitorById(String id); List> selectEquMonitorByIdToList(EquBaseQueryDto queryDto); - List selectEquMonitorListByIds(List ids); + List selectEquMonitorListPaged(); + + /** + * 查询每台设备的最新监测信息(首页展示用) + */ + List selectLatestEquMonitorList(); /**分类统计界面信息 -YY**/ List selectEquStatisticByType(); diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java index f269d6c1..4ee9e582 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java @@ -60,7 +60,12 @@ public interface IEquBaseService */ public List selectEquBaseList(EquBaseQueryDto equBase); - public List selectEquMonitorListByIds(List ids); + public List selectEquMonitorListPaged(); + + /** + * 查询每台设备的最新监测信息(首页展示用) + */ + List selectLatestEquMonitorList(); /**分类统计信息**/ List selectEquStatisticByType(); diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java index 021782de..1de921ea 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java @@ -134,8 +134,15 @@ public class EquBaseServiceImpl implements IEquBaseService * 查询多台设备的最新监测信息 **/ @Override - public List selectEquMonitorListByIds(List ids) { - return equBaseMapper.selectEquMonitorListByIds(ids); + public List selectEquMonitorListPaged() { + return equBaseMapper.selectEquMonitorListPaged(); + } + /** + * 查询多台设备的最新监测信息首页展示 + **/ + @Override + public List selectLatestEquMonitorList() { + return equBaseMapper.selectLatestEquMonitorList(); } diff --git a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml index 96c9ff50..8b7f5744 100644 --- a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml +++ b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml @@ -152,39 +152,82 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - SELECT - b.id, - b.name, - b.ip, - t.name as equType, - m.name as manufacture, - b.version, - b.device_level AS deviceLevel, - b.location, - b.status, - g.cpu_utilization AS cpuUtilization, - g.health, - g.fan_speed AS fanSpeed, - g.cont_work_period AS contWorkPeriod, - b.failure_frequency AS failureFrequency, - -- 新增列:统计未处理告警数量 - (SELECT COUNT(1) - FROM alert_message a - WHERE a.equ_id = b.id AND a.status = 'HANDLED') AS unhandledAlertCount - FROM equ_base b - LEFT JOIN equ_gather g ON b.id = g.equ_id - LEFT JOIN equ_type t ON b.equ_type = t.id - LEFT JOIN equ_manu m ON b.manufacture = m.id - WHERE b.id IN - - #{id} - - AND g.cpu_utilization is not null + t.id, + t.name, + t.ip, + t.equType, + t.manufacture, + t.version, + t.deviceLevel, + t.location, + t.status, + t.cpuUtilization, + t.health, + t.fanSpeed, + t.contWorkPeriod, + t.failureFrequency, + t.unhandledAlertCount + FROM ( + SELECT + b.id, + b.name, + b.ip, + t.name AS equType, + m.name AS manufacture, + b.version, + b.device_level AS deviceLevel, + b.location, + b.status, + g.cpu_utilization AS cpuUtilization, + g.health, + g.fan_speed AS fanSpeed, + g.cont_work_period AS contWorkPeriod, + b.failure_frequency AS failureFrequency, + (SELECT COUNT(1) + FROM alert_message a + WHERE a.equ_id = b.id AND a.status = 'HANDLED') AS unhandledAlertCount, + ROW_NUMBER() OVER (PARTITION BY b.id ORDER BY g.gather_time DESC) AS rn + FROM equ_base b + LEFT JOIN equ_type t ON b.equ_type = t.id + LEFT JOIN equ_manu m ON b.manufacture = m.id + LEFT JOIN equ_gather g ON b.id = g.equ_id + ) t + WHERE t.rn = 1 + ORDER BY t.id + - ORDER BY g.gather_time desc limit 1 + +