Compare commits

..

No commits in common. 'e876808ff78726908915a967ffcfa2c8033399e9' and 'ace6039895d33ddab8b3ec8de9c9e1fc9c0ca5c2' have entirely different histories.

  1. 29
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java
  2. 4
      ALOps_sys_backend/alops-admin/src/main/resources/application-druid.yml
  3. 27
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/AlertStatisticDto.java
  4. 20
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquMonitorHomeDto.java
  5. 22
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/LevelCountDto.java
  6. 17
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/TypeCountDto.java
  7. 16
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java
  8. 7
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java
  9. 17
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertMessageServiceImpl.java
  10. 14
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java
  11. 98
      ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml

@ -16,7 +16,6 @@ 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;
@ -61,28 +60,16 @@ public class EquBaseController extends BaseController
}
/**查询设备监测信息列表(查询多台显示界面的单独信息)**/
/**
* 查询多台设备的最新监测信息
**/
@PreAuthorize("@ss.hasPermi('device:files:query')")
@GetMapping("/monitorpage")
@ApiOperation("分页查询多台设备的最新监测信息")
public TableDataInfo getMonitorList() {
startPage(); // 无参调用,自动获取 pageNum/pageSize
List<MonitorListDto> list = equBaseService.selectEquMonitorListPaged();
return getDataTable(list); // 自动封装分页结果
}
/**
* 首页展示查询每台设备的最新监测信息
*/
@PreAuthorize("@ss.hasPermi('device:files:query')")
@GetMapping("/monitorById")
@ApiOperation("首页展示:查询每台设备的最新监测信息")
public TableDataInfo getLatestEquMonitorList() {
startPage(); // 启用分页(如果首页不分页可删除)
List<EquMonitorHomeDto> list = equBaseService.selectLatestEquMonitorList();
return getDataTable(list);
@ApiOperation("根据设备ID查询设备最新监测信息(查询多台显示界面的单台信息)")
public AjaxResult getMonitorById(@RequestParam String id) {
MonitorListDto monitor = equBaseService.selectEquMonitorListById(id);
if (monitor != null) {
return AjaxResult.success("查询成功", monitor);
} else {
return AjaxResult.error("未找到设备或监测信息");
}
}

@ -6,9 +6,9 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/alops_sys?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://localhost:3306/aiops_sys?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 200515
password: 1234
# 从库数据源
slave:
# 从数据源开关/默认关闭

@ -1,9 +1,6 @@
package com.alops.system.domain.dto;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
@ -11,23 +8,15 @@ import java.util.Map;
*/
@Data
public class AlertStatisticDto {
// 按设备类型统计
private Map<String, Integer> typeCount;
private List<TypeCountDto> typeCount = new ArrayList<>();
private List<LevelCountDto> levelCount = new ArrayList<>();
private Integer yearCount;
private Integer monthCount;
public List<TypeCountDto> getTypeCount() { return typeCount; }
public void setTypeCount(List<TypeCountDto> typeCount) { this.typeCount = typeCount; }
public List<LevelCountDto> getLevelCount() { return levelCount; }
public void setLevelCount(List<LevelCountDto> levelCount) { this.levelCount = levelCount; }
// 按等级统计
private Map<Integer, Integer> 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; }
// 本年度预警次数
private Integer yearCount;
// 本月预警次数
private Integer monthCount;
}

@ -1,20 +0,0 @@
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; // 采集时间
}

@ -1,22 +0,0 @@
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; }
}

@ -1,17 +0,0 @@
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; }
}

@ -4,13 +4,19 @@ import java.util.List;
import java.util.Map;
import com.alops.system.domain.EquBase;
import com.alops.system.domain.dto.*;
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.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接口
@ -57,13 +63,7 @@ public interface EquBaseMapper
MonitorLastDto selectEquMonitorById(String id);
List<Map<String, Object>> selectEquMonitorByIdToList(EquBaseQueryDto queryDto);
List<MonitorListDto> selectEquMonitorListPaged();
/**
* 查询每台设备的最新监测信息首页展示用
*/
List<EquMonitorHomeDto> selectLatestEquMonitorList();
MonitorListDto selectEquMonitorListById(String id);
/**分类统计界面信息 -YY**/
List<MonitorStatisticDto> selectEquStatisticByType();

@ -60,12 +60,7 @@ public interface IEquBaseService
*/
public List<queryEquBaseVO> selectEquBaseList(EquBaseQueryDto equBase);
public List<MonitorListDto> selectEquMonitorListPaged();
/**
* 查询每台设备的最新监测信息首页展示用
*/
List<EquMonitorHomeDto> selectLatestEquMonitorList();
public MonitorListDto selectEquMonitorListById(String id);
/**分类统计信息**/
List<MonitorStatisticDto> selectEquStatisticByType();

@ -10,8 +10,6 @@ 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.domain.vo.homeEquAlertMessage;
import com.alops.system.mapper.AlertMessageMapper;
import com.alops.system.service.IAlertMessageService;
@ -75,18 +73,18 @@ public class AlertMessageServiceImpl implements IAlertMessageService
AlertStatisticDto dto = new AlertStatisticDto();
// 按设备类型统计
Map<String, Integer> typeMap = new HashMap<>();
for (Map<String, Object> row : alertMessageMapper.countByType()) {
String name = (String) row.get("equ_type");
Integer count = ((Long) row.get("cnt")).intValue();
dto.getTypeCount().add(new TypeCountDto(name, count));
typeMap.put((String) row.get("equ_type"), ((Long) row.get("cnt")).intValue());
}
dto.setTypeCount(typeMap);
// 按等级统计
Map<Integer, Integer> levelMap = new HashMap<>();
for (Map<String, Object> row : alertMessageMapper.countByLevel()) {
String level = String.valueOf(row.get("level"));
Integer count = ((Long) row.get("cnt")).intValue();
dto.getLevelCount().add(new LevelCountDto(level, count));
levelMap.put(((Integer) row.get("level")), ((Long) row.get("cnt")).intValue());
}
dto.setLevelCount(levelMap);
// 年 / 月
LocalDate now = LocalDate.now();
@ -99,8 +97,7 @@ public class AlertMessageServiceImpl implements IAlertMessageService
return dto;
}
/**
/**
* 新增故障统计
*
* @param alertMessage 故障统计

@ -131,20 +131,12 @@ public class EquBaseServiceImpl implements IEquBaseService
}
/**
* 查询多台设备的最新监测信息
* 查询多台显示界面的单独信息
**/
@Override
public List<MonitorListDto> selectEquMonitorListPaged() {
return equBaseMapper.selectEquMonitorListPaged();
public MonitorListDto selectEquMonitorListById(String id) {
return equBaseMapper.selectEquMonitorListById(id);
}
/**
* 查询多台设备的最新监测信息首页展示
**/
@Override
public List<EquMonitorHomeDto> selectLatestEquMonitorList() {
return equBaseMapper.selectLatestEquMonitorList();
}
/**
* 设备类型分类统计信息

@ -152,82 +152,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectEquMonitorListPaged" resultType="MonitorListDto">
<select id="selectEquMonitorListById" parameterType="string" resultType="MonitorListDto">
SELECT
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
</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 = #{id}
AND g.cpu_utilization is not null
<select id="selectLatestEquMonitorList" resultType="com.alops.system.domain.dto.EquMonitorHomeDto">
SELECT
t.name,
t.location,
t.cpuUtilization,
t.memoryUtilization,
t.temperature,
t.health,
t.contWorkPeriod,
t.gatherTime
FROM (
SELECT
b.name,
b.location,
g.cpu_utilization AS cpuUtilization,
g.memory_utilization AS memoryUtilization,
g.temperature,
g.health,
g.cont_work_period AS contWorkPeriod,
g.gather_time AS gatherTime,
ROW_NUMBER() OVER (PARTITION BY b.id ORDER BY g.gather_time DESC) AS rn
FROM equ_base b
LEFT JOIN equ_gather g ON b.id = g.equ_id
WHERE g.cpu_utilization IS NOT NULL
) t
WHERE t.rn = 1
ORDER BY t.name
ORDER BY g.gather_time desc limit 1
</select>
<select id="selectEquMonitorById" parameterType="string" resultType="MonitorLastDto">
SELECT
g.cont_work_period AS contWorkPeriod,

Loading…
Cancel
Save