Compare commits

...

4 Commits

  1. 13
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java
  2. 3
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertMessage.java
  3. 5
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorStatisticDto.java
  4. 31
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java
  5. 7
      ALOps_sys_backend/alops-system/src/main/resources/mapper/system/AlertMessageMapper.xml

@ -1,7 +1,9 @@
package com.alops.web.controller.equManagement;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
@ -106,9 +108,18 @@ public class EquBaseController extends BaseController
@ApiOperation("按设备类型分类统计设备信息")
public AjaxResult listMonitorInfoByType() {
List<MonitorStatisticDto> list = equBaseService.selectEquStatisticByType();
return AjaxResult.success("查询成功", list);
// 获取总设备数
int totalCount = 0;
if (list != null) {
totalCount = list.stream().mapToInt(MonitorStatisticDto::getCount).sum();
}
Map<String, Object> result = new HashMap<>();
result.put("totalCount", totalCount);
result.put("list", list);
return AjaxResult.success("查询成功", result);
}
/**
* 获取设备基本信息详细信息
*/

@ -70,7 +70,8 @@ public class AlertMessage
@Excel(name = "信息批次")
private Integer batch;
@Excel(name ="预警信息")
private String message;

@ -11,6 +11,11 @@ public class MonitorStatisticDto {
private String equTypeName; // 设备类型名称
private List<DeviceSimpleInfo> devices; // 属于该类型的设备列表
// 新增统计数量字段
private Integer count;
// 每类型占总设备数量的百分比
private Double percentage;
@Data
public static class DeviceSimpleInfo {
private String id;

@ -141,11 +141,40 @@ public class EquBaseServiceImpl implements IEquBaseService
/**
* 设备类型分类统计信息
**/
@Override
public List<MonitorStatisticDto> selectEquStatisticByType() {
return equBaseMapper.selectEquStatisticByType();
List<MonitorStatisticDto> list = equBaseMapper.selectEquStatisticByType();
if (list == null || list.isEmpty()) {
return list;
}
// 计算每种类型的数量
int totalCount = 0;
for (MonitorStatisticDto dto : list) {
int count = (dto.getDevices() != null) ? dto.getDevices().size() : 0;
dto.setCount(count);
totalCount += count;
}
// 计算百分比
for (MonitorStatisticDto dto : list) {
if (totalCount > 0) {
double percent = (dto.getCount() * 100.0) / totalCount;
dto.setPercentage(Math.round(percent * 100.0) / 100.0); // 保留两位小数
} else {
dto.setPercentage(0.0);
}
}
this.totalDeviceCount = totalCount; // 注意:你可以在 service 中定义字段存储
return list;
}
// 在类中增加:
private int totalDeviceCount;
public int getTotalDeviceCount() {
return totalDeviceCount;
}
/**

@ -19,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="handleTime" column="handle_time" />
<result property="status" column="status" />
<result property="batch" column="batch" />
<result property="message" column="message" />
</resultMap>
<select id="selectMaxBatch" resultType="integer">
@ -52,13 +52,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
am.handler,
am.handle_time,
am.status,
am.batch
am.batch,
am.message
FROM alert_message am
LEFT JOIN equ_base eb ON am.equ_id = eb.id
</sql>
<sql id="selectAlertMessageVoJoinGather">
select a.id, g.equ_id, type, equ_type, solution, level, occur_time, handler, handle_time, status,batch from alert_message a LEFT JOIN equ_gather g ON a.equ_id = g.equ_id
select a.id, g.equ_id, type, equ_type, solution, level, occur_time, handler, handle_time, status,batch,message from alert_message a LEFT JOIN equ_gather g ON a.equ_id = g.equ_id
</sql>
<select id="selectAlertMessageList" parameterType="AlertDto" resultMap="AlertMessageResult">

Loading…
Cancel
Save