10.6修正返回类型list,以及输出两个数组

dev
YYD-YY 9 months ago
parent 5cd5dfb78f
commit 87e378b54b
  1. 18
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java
  2. 27
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/AlertStatisticDto.java
  3. 22
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/LevelCountDto.java
  4. 17
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/TypeCountDto.java
  5. 3
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java
  6. 2
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java
  7. 17
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertMessageServiceImpl.java
  8. 7
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java
  9. 9
      ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml

@ -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<String> ids) {
List<MonitorListDto> monitors = equBaseService.selectEquMonitorListByIds(ids);
if (monitors != null && !monitors.isEmpty()) {
return AjaxResult.success("查询成功", monitors);
} else {
return AjaxResult.error("未找到设备或监测信息");
return AjaxResult.error("未找到相关设备或监测信息");
}
}
/**
* 获取设备最新时间的历史监控信息
* @param id 查询对象包含设备ID开始时间和结束时间

@ -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<String, Integer> typeCount;
// 按等级统计
private Map<Integer, Integer> levelCount;
// 本年度预警次数
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; }
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; }
}

@ -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; }
}

@ -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; }
}

@ -63,7 +63,8 @@ public interface EquBaseMapper
MonitorLastDto selectEquMonitorById(String id);
List<Map<String, Object>> selectEquMonitorByIdToList(EquBaseQueryDto queryDto);
MonitorListDto selectEquMonitorListById(String id);
List<MonitorListDto> selectEquMonitorListByIds(List<String> ids);
/**分类统计界面信息 -YY**/
List<MonitorStatisticDto> selectEquStatisticByType();

@ -60,7 +60,7 @@ public interface IEquBaseService
*/
public List<queryEquBaseVO> selectEquBaseList(EquBaseQueryDto equBase);
public MonitorListDto selectEquMonitorListById(String id);
public List<MonitorListDto> selectEquMonitorListByIds(List<String> ids);
/**分类统计信息**/
List<MonitorStatisticDto> selectEquStatisticByType();

@ -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<String, Integer> typeMap = new HashMap<>();
for (Map<String, Object> 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<Integer, Integer> levelMap = new HashMap<>();
for (Map<String, Object> 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 故障统计

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

@ -152,7 +152,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where>
</select>
<select id="selectEquMonitorListById" parameterType="string" resultType="MonitorListDto">
<select id="selectEquMonitorListByIds" parameterType="list" resultType="MonitorListDto">
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
<foreach collection="list" item="id" open="(" separator="," close=")">
#{id}
</foreach>
AND g.cpu_utilization is not null
ORDER BY g.gather_time desc limit 1
</select>

Loading…
Cancel
Save