Compare commits

..

2 Commits

Author SHA1 Message Date
YYD-YY 5d69726a64 Merge branch 'dev' of https://gitea.wangzhiwen.top/0214/ALOps_sys1 into dev 8 months ago
YYD-YY 5663d36d70 10.28 新增层数统计、修改首页接口信息 8 months ago
  1. 6
      ALOps_sys_backend/alops-admin/pom.xml
  2. 27
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java
  3. 12
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquMonitorHomeDto.java
  4. 12
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/FloorDeviceCountDto.java
  5. 2
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorStatisticDto.java
  6. 7
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java
  7. 7
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java
  8. 33
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java
  9. 20
      ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml

@ -92,7 +92,11 @@
<version>1.0.0</version> <version>1.0.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- websocket -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
</dependencies> </dependencies>

@ -15,10 +15,7 @@ import com.alops.common.core.page.TableDataInfo;
import com.alops.common.enums.BusinessType; import com.alops.common.enums.BusinessType;
import com.alops.common.utils.poi.ExcelUtil; import com.alops.common.utils.poi.ExcelUtil;
import com.alops.system.domain.EquBase; import com.alops.system.domain.EquBase;
import com.alops.system.domain.dto.EquBaseQueryDto; import com.alops.system.domain.dto.*;
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; import com.alops.system.domain.vo.EquMonitorVO;
import com.alops.system.domain.vo.queryEquBaseVO; import com.alops.system.domain.vo.queryEquBaseVO;
import com.alops.system.service.IEquBaseService; import com.alops.system.service.IEquBaseService;
@ -122,17 +119,27 @@ public class EquBaseController extends BaseController
@ApiOperation("按设备类型分类统计设备信息") @ApiOperation("按设备类型分类统计设备信息")
public AjaxResult listMonitorInfoByType() { public AjaxResult listMonitorInfoByType() {
List<MonitorStatisticDto> list = equBaseService.selectEquStatisticByType(); List<MonitorStatisticDto> list = equBaseService.selectEquStatisticByType();
// 获取总设备数
int totalCount = 0;
if (list != null) {
totalCount = list.stream().mapToInt(MonitorStatisticDto::getCount).sum();
}
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
result.put("totalCount", totalCount); result.put("totalCount", equBaseService.getTotalDeviceCount());
result.put("onlineCount", equBaseService.getOnlineDeviceCount());
result.put("list", list); result.put("list", list);
return AjaxResult.success("查询成功", result); return AjaxResult.success("查询成功", result);
} }
/**
* 统计楼层设备分布
*/
@PreAuthorize("@ss.hasPermi('device:files:statistic')")
@GetMapping("/floorStatistic")
@ApiOperation("统计楼层设备分布信息")
public AjaxResult getFloorDeviceStatistic() {
List<FloorDeviceCountDto> list = equBaseService.selectFloorDeviceStatistic();
return AjaxResult.success("查询成功", list);
}
/** /**
* 获取设备基本信息详细信息 * 获取设备基本信息详细信息

@ -12,11 +12,11 @@ public class EquMonitorHomeDto {
private String id; private String id;
private String equNumber; //设备编号 private String equNumber; //设备编号
private String name; // 设备名称 private String name; // 设备名称
private String location; // 设备位置 //private String location; // 设备位置
private Float cpuUtilization; // CPU 使用率 //private Float cpuUtilization; // CPU 使用率
private Float memoryUtilization; // 内存使用率 //private Float memoryUtilization; // 内存使用率
private Float temperature; // 温度 //private Float temperature; // 温度
private String health; // 健康度 private String health; // 健康度
private String contWorkPeriod; // 持续运行时长 //private String contWorkPeriod; // 持续运行时长
private Date gatherTime; // 采集时间 //private Date gatherTime; // 采集时间
} }

@ -0,0 +1,12 @@
package com.alops.system.domain.dto;
import lombok.Data;
/**
* 楼层设备数量统计 DTO
*/
@Data
public class FloorDeviceCountDto {
private String floor; // 楼层名称
private Integer count; // 设备数量
}

@ -8,7 +8,7 @@ import java.util.List;
@Data @Data
public class MonitorStatisticDto { public class MonitorStatisticDto {
private String equTypeId; // 设备类型ID 或 名称 private String equTypeId; // 设备类型ID 或 名称
private String equTypeName; // 设备类型名称 private String equTypeName;// 设备类型名称
private List<DeviceSimpleInfo> devices; // 属于该类型的设备列表 private List<DeviceSimpleInfo> devices; // 属于该类型的设备列表
// 新增统计数量字段 // 新增统计数量字段

@ -72,7 +72,7 @@ public interface EquBaseMapper
/**分类统计界面信息 -YY**/ /**分类统计界面信息 -YY**/
List<MonitorStatisticDto> selectEquStatisticByType(); List<MonitorStatisticDto> selectEquStatisticByType();
Map<String, Object> selectDeviceCountSummary();
/** /**
* 查询设备基本信息列表 * 查询设备基本信息列表
* *
@ -81,6 +81,11 @@ public interface EquBaseMapper
*/ */
public List<queryEquBaseVO> selectEquBaseList(EquBaseQueryDto equBase); public List<queryEquBaseVO> selectEquBaseList(EquBaseQueryDto equBase);
/**
* 查询楼层设备数量统计
*/
List<FloorDeviceCountDto> selectFloorDeviceStatistic();
/** /**
* 新增设备基本信息 * 新增设备基本信息
* *

@ -36,6 +36,10 @@ public interface IEquBaseService
public imageVo selectEquBaseImageById(String id); public imageVo selectEquBaseImageById(String id);
/**查询界面具体信息**/ /**查询界面具体信息**/
// EquMonitorVO selectEquMonitorInfo(EquBaseQueryDto queryDto); // EquMonitorVO selectEquMonitorInfo(EquBaseQueryDto queryDto);
/**
* 查询楼层设备数量统计
*/
List<FloorDeviceCountDto> selectFloorDeviceStatistic();
/** /**
@ -103,4 +107,7 @@ public interface IEquBaseService
* @return 结果 * @return 结果
*/ */
public int deleteEquBaseById(String id); public int deleteEquBaseById(String id);
int getTotalDeviceCount();
int getOnlineDeviceCount();
} }

@ -163,6 +163,11 @@ public class EquBaseServiceImpl implements IEquBaseService
return dto; return dto;
} }
//查询楼层数据
@Override
public List<FloorDeviceCountDto> selectFloorDeviceStatistic() {
return equBaseMapper.selectFloorDeviceStatistic();
}
/** /**
@ -200,11 +205,14 @@ public class EquBaseServiceImpl implements IEquBaseService
@Override @Override
public List<MonitorStatisticDto> selectEquStatisticByType() { public List<MonitorStatisticDto> selectEquStatisticByType() {
List<MonitorStatisticDto> list = equBaseMapper.selectEquStatisticByType(); List<MonitorStatisticDto> list = equBaseMapper.selectEquStatisticByType();
if (list == null || list.isEmpty()) { if (list == null || list.isEmpty()) {
this.totalDeviceCount = 0;
this.onlineDeviceCount = 0;
return list; return list;
} }
// 计算每种类型的数量 // 按类型计算每类设备数量
int totalCount = 0; int totalCount = 0;
for (MonitorStatisticDto dto : list) { for (MonitorStatisticDto dto : list) {
int count = (dto.getDevices() != null) ? dto.getDevices().size() : 0; int count = (dto.getDevices() != null) ? dto.getDevices().size() : 0;
@ -212,24 +220,39 @@ public class EquBaseServiceImpl implements IEquBaseService
totalCount += count; totalCount += count;
} }
// 计算百分比 // 计算百分比
for (MonitorStatisticDto dto : list) { for (MonitorStatisticDto dto : list) {
if (totalCount > 0) { if (totalCount > 0) {
double percent = (dto.getCount() * 100.0) / totalCount; double percent = (dto.getCount() * 100.0) / totalCount;
dto.setPercentage(Math.round(percent * 100.0) / 100.0); // 保留两位小数 dto.setPercentage(Math.round(percent * 100.0) / 100.0);
} else { } else {
dto.setPercentage(0.0); dto.setPercentage(0.0);
} }
} }
this.totalDeviceCount = totalCount; // 注意:你可以在 service 中定义字段存储
// 查询数据库总设备数和在线数
Map<String, Object> summary = equBaseMapper.selectDeviceCountSummary();
if (summary != null) {
this.totalDeviceCount = ((Number) summary.get("totalCount")).intValue();
this.onlineDeviceCount = ((Number) summary.get("onlineCount")).intValue();
} else {
this.totalDeviceCount = 0;
this.onlineDeviceCount = 0;
}
return list; return list;
} }
// 在类中增加:
// 在类中增加:(统计设备总数量以及在线设备数量)
private int totalDeviceCount; private int totalDeviceCount;
private int onlineDeviceCount;
public int getTotalDeviceCount() { public int getTotalDeviceCount() {
return totalDeviceCount; return totalDeviceCount;
} }
public int getOnlineDeviceCount() {return onlineDeviceCount;}
/** 通用百分比指标判断(CPU/内存) */ /** 通用百分比指标判断(CPU/内存) */
private String checkStatus(BigDecimal val, double healthy, double good, double average) { private String checkStatus(BigDecimal val, double healthy, double good, double average) {

@ -279,6 +279,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ORDER BY t.name ORDER BY t.name
</select> </select>
<select id="selectFloorDeviceStatistic" resultType="com.alops.system.domain.dto.FloorDeviceCountDto">
SELECT
floor,
COUNT(*) AS count
FROM equ_base
WHERE floor IS NOT NULL AND floor != ''
GROUP BY floor
ORDER BY
CAST(REGEXP_REPLACE(floor, '[^0-9]', '') AS SIGNED)
</select>
<select id="selectEquMonitorById" parameterType="string" resultType="MonitorLastDto"> <select id="selectEquMonitorById" parameterType="string" resultType="MonitorLastDto">
SELECT SELECT
@ -367,11 +378,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
b.equ_type AS equTypeId, b.equ_type AS equTypeId,
t.name AS equTypeName, t.name AS equTypeName,
b.id AS id, b.id AS id,
b.name AS name b.name AS name,
b.status AS status
FROM equ_base b FROM equ_base b
LEFT JOIN equ_type t ON b.equ_type = t.id LEFT JOIN equ_type t ON b.equ_type = t.id
ORDER BY b.equ_type, b.id ORDER BY b.equ_type, b.id
</select> </select>
<select id="selectDeviceCountSummary" resultType="map">
SELECT
COUNT(*) AS totalCount,
SUM(CASE WHEN status = '001' THEN 1 ELSE 0 END) AS onlineCount
FROM equ_base
</select>

Loading…
Cancel
Save