10.10设备档案改变增删改查

dev
xiaohuo 9 months ago
parent d4106e0e7b
commit 62be1abd27
  1. 3
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/ScheduleRulesController.java
  2. 10
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertMessageController.java
  3. 41
      ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/equAssessment.java
  4. 12
      ALOps_sys_backend/alops-system/pom.xml
  5. 33
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquBase.java
  6. 112
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquBaseAddDto.java
  7. 9
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquBaseQueryDto.java
  8. 48
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/equipmentAssessmentDto.java
  9. 45
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/equipmentAssessmentVo.java
  10. 3
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/homeEquAlertMessageVo.java
  11. 12
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/queryEquBaseVO.java
  12. 4
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertMessageMapper.java
  13. 6
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java
  14. 2
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/ScheduleRulesMapper.java
  15. 4
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertMessageService.java
  16. 4
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java
  17. 2
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IScheduleRulesService.java
  18. 5
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertMessageServiceImpl.java
  19. 98
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java
  20. 17
      ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java
  21. 2
      ALOps_sys_backend/alops-system/src/main/resources/mapper/system/AlertMessageMapper.xml
  22. 61
      ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml
  23. 6
      ALOps_sys_backend/alops-system/src/main/resources/mapper/system/ScheduleRulesMapper.xml

@ -60,6 +60,9 @@ public class ScheduleRulesController extends BaseController
@ApiOperation("立即确定") @ApiOperation("立即确定")
public AjaxResult run(@RequestBody ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException { public AjaxResult run(@RequestBody ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException {
if(scheduleRulesService.checkRunningOrWaitingRules()){
return AjaxResult.error("正在采集,请稍后");
}
if (newRule.getRuleType() == 2) { if (newRule.getRuleType() == 2) {
// 立即执行 // 立即执行

@ -1,22 +1,16 @@
package com.alops.web.controller.exceptionController; package com.alops.web.controller.exceptionController;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.alops.common.annotation.Log; import com.alops.common.annotation.Log;
import com.alops.common.core.controller.BaseController; import com.alops.common.core.controller.BaseController;
import com.alops.common.core.domain.AjaxResult; import com.alops.common.core.domain.AjaxResult;
import com.alops.common.core.page.TableDataInfo; import com.alops.common.core.page.TableDataInfo;
import com.alops.common.enums.BusinessType; import com.alops.common.enums.BusinessType;
import com.alops.common.utils.SecurityUtils;
import com.alops.common.utils.poi.ExcelUtil;
import com.alops.system.domain.AlertMessage; import com.alops.system.domain.AlertMessage;
import com.alops.system.domain.dto.AlertDto; import com.alops.system.domain.dto.AlertDto;
import com.alops.system.domain.vo.homeEquAlertMessage; import com.alops.system.domain.vo.homeEquAlertMessageVo;
import com.alops.system.service.IAlertLaunchService; import com.alops.system.service.IAlertLaunchService;
import com.alops.system.domain.AlertRule;
import com.alops.system.domain.EquInterface;
import com.alops.system.domain.dto.AlertStatisticDto; import com.alops.system.domain.dto.AlertStatisticDto;
import com.alops.system.service.IAlertMessageService; import com.alops.system.service.IAlertMessageService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -92,7 +86,7 @@ public class AlertMessageController extends BaseController
public TableDataInfo homeList() public TableDataInfo homeList()
{ {
startPage(); startPage();
List<homeEquAlertMessage> list = alertMessageService.selectStaticAlertMessageList(); List<homeEquAlertMessageVo> list = alertMessageService.selectStaticAlertMessageList();
return getDataTable(list); return getDataTable(list);
} }

@ -0,0 +1,41 @@
package com.alops.web.controller.exceptionController;
import com.alops.common.annotation.Log;
import com.alops.common.core.controller.BaseController;
import com.alops.common.core.page.TableDataInfo;
import com.alops.common.enums.BusinessType;
import com.alops.system.domain.vo.equipmentAssessmentVo;
import com.alops.system.service.IEquBaseService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/inMonitoring/equAssessment")
public class equAssessment extends BaseController {
@Autowired
public IEquBaseService iEquBaseService;
/**
* 设备信息评估表
* 获取所有设备id
*/
@PreAuthorize("@ss.hasPermi('inMonitoring:equAssessment:list')")
@GetMapping("/list")
@ApiOperation("设备评估信息")
@Log(title = "设备评估与预测", businessType = BusinessType.UPDATE)
public TableDataInfo homeList()
{
startPage();
List<equipmentAssessmentVo> list = iEquBaseService.getDeviceIAssessmentnfo();
return getDataTable(list);
}
}

@ -16,6 +16,18 @@
<description> <description>
system系统模块 system系统模块
</description> </description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>14</source>
<target>14</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies> <dependencies>
<!-- org.snmp4j --> <!-- org.snmp4j -->

@ -42,7 +42,7 @@ public class EquBase
/** 设备厂商 id */ /** 设备厂商 id */
@Excel(name = "设备厂商 id") @Excel(name = "设备厂商 id")
private String manufacture; private String equManuId;
private EquManu manufactureVO; private EquManu manufactureVO;
@ -53,7 +53,7 @@ public class EquBase
/** 设备类型 id */ /** 设备类型 id */
@Excel(name = "设备类型 id") @Excel(name = "设备类型 id")
private String equType; private String equTypeId;
@ -160,16 +160,6 @@ public class EquBase
return ip; return ip;
} }
public void setManufacture(String manufacture)
{
this.manufacture = manufacture;
}
public String getManufacture()
{
return manufacture;
}
public void setLocation(String location) public void setLocation(String location)
{ {
this.location = location; this.location = location;
@ -180,16 +170,6 @@ public class EquBase
return location; return location;
} }
public void setEquType(String equType)
{
this.equType = equType;
}
public String getEquType()
{
return equType;
}
public void setInCharge(String inCharge) public void setInCharge(String inCharge)
{ {
this.inCharge = inCharge; this.inCharge = inCharge;
@ -290,6 +270,11 @@ public class EquBase
return gatherFrequency; return gatherFrequency;
} }
public String getEquManuId() { return equManuId; }
public void setEquManuId(String equManuId) { this.equManuId = equManuId; }
public String getEquTypeId() { return equTypeId; }
public void setEquTypeId(String equTypeId) { this.equTypeId = equTypeId; }
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -297,9 +282,9 @@ public class EquBase
.append("name", getName()) .append("name", getName())
.append("version", getVersion()) .append("version", getVersion())
.append("ip", getIp()) .append("ip", getIp())
.append("manufacture", getManufacture()) .append("equManuId", getEquManuId())
.append("location", getLocation()) .append("location", getLocation())
.append("equType", getEquType()) .append("equTypeId", getEquTypeId())
.append("inCharge", getInCharge()) .append("inCharge", getInCharge())
.append("installDate", getInstallDate()) .append("installDate", getInstallDate())
.append("lifeCycle", getLifeCycle()) .append("lifeCycle", getLifeCycle())

@ -0,0 +1,112 @@
package com.alops.system.domain.dto;
import com.alops.common.annotation.Excel;
import com.alops.system.domain.EquManu;
import com.alops.system.domain.EquType;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class EquBaseAddDto {
private static final long serialVersionUID = 1L;
/** 设备唯一标识(设备编号) */
private String id;
/** (设备编号) */
private String equNumber;
/** 设备名称 */
@Excel(name = "设备名称")
private String name;
/** 设备版本 */
@Excel(name = "设备版本")
private String version;
/** 带外管理 IP */
@Excel(name = "带外管理 IP")
private String ip;
/** 设备厂商 id */
@Excel(name = "设备厂商 id")
private String manufacture;
private EquManu manufactureVO;
/** 安装位置 */
@Excel(name = "安装位置 ")
private String location;
/** 设备类型 id */
@Excel(name = "设备类型 id")
private String equType;
public EquType getEquTypeVO() {
return equTypeVO;
}
public void setEquTypeVO(EquType equTypeVO) {
this.equTypeVO = equTypeVO;
}
private EquType equTypeVO;
/** 设备管理员姓名 */
@Excel(name = "设备管理员姓名")
private String inCharge;
/** 安装日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "安装日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date installDate;
/** 预计年限(年) */
@Excel(name = "预计年限(年)")
private Long lifeCycle;
/** 质保时间(年) */
@Excel(name = "质保时间(年)")
private Long warranty;
/** 添加日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "添加日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date createDate;
/** 启用状态(1启用0禁用) */
@Excel(name = "启用状态", readConverterExp = "0=启用1禁用")
private Long status;
/** 累计预警次数 */
@Excel(name = "累计预警次数")
private Long failureFrequency;
/** 设备级别 */
@Excel(name = "设备级别")
private String deviceLevel;
/** 供应商id */
@Excel(name = "供应商id")
private String supplierId;
/** 采集次数 */
@Excel(name = "采集次数")
private Long gatherFrequency;
@Excel(name = "采集次数")
private Long createBy ;
@Excel(name = "设备图片地址")
private String equImage ;
}

@ -16,18 +16,15 @@ public class EquBaseQueryDto implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String id; private String id;
/** 设备类型 (equ_type, varchar) */
private String equTypeId;
/** 设备类型 (equ_type, varchar) */ /** 设备类型 (equ_type, varchar) */
private String equType; private String equType;
/** 设备名称 (name, varchar) */ /** 设备名称 (name, varchar) */
private String name; private String name;
/** 安装位置 ID (location, varchar) */ /** 安装位置 ID (location, varchar) */
private String location; private String location;
/** 起始时间 (min_time) */ /** 起始时间 (min_time) */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date minTime; private Date minTime;
@ -40,8 +37,6 @@ public class EquBaseQueryDto implements Serializable {
private Integer status; private Integer status;
// ====== Getter 和 Setter ====== // ====== Getter 和 Setter ======
public String getName() { public String getName() {
return name; return name;
} }

@ -0,0 +1,48 @@
package com.alops.system.domain.dto;
import com.alops.common.annotation.Excel;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class equipmentAssessmentDto {
/** 设备唯一标识(设备编号) */
private String id;
/** (设备编号) */
private String equNumber;
/** 设备名称 */
@Excel(name = "设备名称")
private String name;
/** 安装位置 */
@Excel(name = "安装位置 ")
private String location;
/** 设备类型 id */
@Excel(name = "设备类型名称")
private String equType;
/** 设备级别 */
@Excel(name = "设备级别")
private String deviceLevel;
@Excel(name = "综合计算的健康度指标(%)")
private BigDecimal health;
/** 设备温度 */
@Excel(name = "设备温度")
private BigDecimal temperature;
/** CPU 使用率(%) */
@Excel(name = "CPU 使用率(%)")
private BigDecimal cpuUtilization;
/** 内存使用率(%) */
@Excel(name = "内存使用率(%)")
private BigDecimal memoryUtilization;
}

@ -0,0 +1,45 @@
package com.alops.system.domain.vo;
import com.alops.common.annotation.Excel;
import lombok.Data;
@Data
public class equipmentAssessmentVo {
/** 设备唯一标识(设备编号) */
private String id;
/** (设备编号) */
private String equNumber;
/** 设备名称 */
@Excel(name = "设备名称")
private String name;
/** 安装位置 */
@Excel(name = "安装位置 ")
private String location;
/** 设备类型 id */
@Excel(name = "设备类型名称")
private String equType;
/** 设备级别 */
@Excel(name = "设备级别")
private String deviceLevel;
/** CPU使用率(%) */
private String cpuStatus;
/** 内存使用率(%) */
private String memoryStatus;
/** 温度(℃) */
private String temperatureStatus;
/** 健康状态(健康、良好、一般、需维护) */
private String healthStatus;
/** 风险等级 */
private String riskGrade ;
}

@ -1,13 +1,12 @@
package com.alops.system.domain.vo; package com.alops.system.domain.vo;
import com.alops.common.annotation.Excel; import com.alops.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
@Data @Data
public class homeEquAlertMessage { public class homeEquAlertMessageVo {
/** 预警级别(1-5级) */ /** 预警级别(1-5级) */

@ -39,17 +39,23 @@ public class queryEquBaseVO {
/** 带外管理 IP */ /** 带外管理 IP */
@Excel(name = "带外管理 IP") @Excel(name = "带外管理 IP")
private String ip; private String ip;
@Excel(name = "设备厂商名称id ")
private String equManuId;
/** 设备厂商 */ /** 设备厂商 */
@Excel(name = "设备厂商名称 ") @Excel(name = "设备厂商名称 ")
private String manufacture; private String manufacture;
/** 设备厂商 */ /** 设备厂商 */
@Excel(name = "设备厂商名称 ") @Excel(name = "设备供应商名称 ")
private String supplierId;
/** 安装位置 id */
@Excel(name = "设备供应商名称 ")
private String supplierName; private String supplierName;
/** 安装位置 id */ /** 安装位置 id */
@Excel(name = "安装位置 id") @Excel(name = "安装位置 id")
private String location; private String location;
/** 设备类型 id */ /** 设备类型 id */
@Excel(name = "设备类型id")
private String equTypeId;
@Excel(name = "设备类型名称") @Excel(name = "设备类型名称")
private String equType; private String equType;
@ -91,6 +97,8 @@ public class queryEquBaseVO {
@Excel(name = "设备图片") @Excel(name = "设备图片")
private String equImage; private String equImage;
@Excel(name = "设备编号")
private String equNumber;
public void setId(String id) public void setId(String id)

@ -2,7 +2,7 @@ package com.alops.system.mapper;
import com.alops.system.domain.AlertMessage; import com.alops.system.domain.AlertMessage;
import com.alops.system.domain.dto.AlertDto; import com.alops.system.domain.dto.AlertDto;
import com.alops.system.domain.vo.homeEquAlertMessage; import com.alops.system.domain.vo.homeEquAlertMessageVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -46,7 +46,7 @@ public interface AlertMessageMapper
*/ */
public List<AlertMessage> selectAlertMessageList(AlertDto alertMessage); public List<AlertMessage> selectAlertMessageList(AlertDto alertMessage);
public List<homeEquAlertMessage> selectStaticAlertMessageList(); public List<homeEquAlertMessageVo> selectStaticAlertMessageList();
public ArrayList<AlertMessage> selectAlertMessageByEquId(Long Equid); public ArrayList<AlertMessage> selectAlertMessageByEquId(Long Equid);
/** /**

@ -21,6 +21,12 @@ import org.springframework.data.repository.query.Param;
@Mapper @Mapper
public interface EquBaseMapper public interface EquBaseMapper
{ {
/**
* 查询状态为1的设备及其最新采集信息和类型名称
*/
List<equipmentAssessmentDto> getEquipmentAssessmentList();
int incrementCollectCount(@Param("ids") List<String> ids); int incrementCollectCount(@Param("ids") List<String> ids);
@Update("DELETE FROM equ_interface") @Update("DELETE FROM equ_interface")

@ -17,6 +17,8 @@ public interface ScheduleRulesMapper
public List<ScheduleRules> selectList(); public List<ScheduleRules> selectList();
public List<ScheduleRules> selectListOne();
/** /**
* 查询定时采集规则 * 查询定时采集规则
* *

@ -3,7 +3,7 @@ package com.alops.system.service;
import com.alops.system.domain.AlertMessage; import com.alops.system.domain.AlertMessage;
import com.alops.system.domain.dto.AlertDto; import com.alops.system.domain.dto.AlertDto;
import com.alops.system.domain.dto.AlertStatisticDto; import com.alops.system.domain.dto.AlertStatisticDto;
import com.alops.system.domain.vo.homeEquAlertMessage; import com.alops.system.domain.vo.homeEquAlertMessageVo;
import java.util.List; import java.util.List;
@ -31,7 +31,7 @@ public interface IAlertMessageService
* @return 故障统计集合 * @return 故障统计集合
*/ */
public List<AlertMessage> selectAlertMessageList(AlertDto alertMessage); public List<AlertMessage> selectAlertMessageList(AlertDto alertMessage);
public List<homeEquAlertMessage> selectStaticAlertMessageList(); public List<homeEquAlertMessageVo> selectStaticAlertMessageList();
public List<AlertMessage> selectAlertMessageListByEquId(Long equId); public List<AlertMessage> selectAlertMessageListByEquId(Long equId);
/** /**

@ -3,6 +3,7 @@ package com.alops.system.service;
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.EquBaseQueryDto;
import com.alops.system.domain.vo.dropDownVo; import com.alops.system.domain.vo.dropDownVo;
import com.alops.system.domain.vo.equipmentAssessmentVo;
import com.alops.system.domain.vo.imageVo; import com.alops.system.domain.vo.imageVo;
import com.alops.system.domain.dto.*; import com.alops.system.domain.dto.*;
import com.alops.system.domain.vo.queryEquBaseVO; import com.alops.system.domain.vo.queryEquBaseVO;
@ -18,7 +19,8 @@ import java.util.List;
*/ */
public interface IEquBaseService public interface IEquBaseService
{ {
//获取设备评估信息
public List<equipmentAssessmentVo> getDeviceIAssessmentnfo();
public List<dropDownVo> selectEquManu(); public List<dropDownVo> selectEquManu();
public List<dropDownVo> selectEquSupp(); public List<dropDownVo> selectEquSupp();

@ -21,6 +21,8 @@ public interface IScheduleRulesService
public Boolean checkRunningOrWaitingRules();
public AjaxResult executeRule(ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException; public AjaxResult executeRule(ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException;
public int executeImmediately() throws ExecutionException, InterruptedException; public int executeImmediately() throws ExecutionException, InterruptedException;

@ -2,7 +2,6 @@ package com.alops.system.service.impl;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -12,7 +11,7 @@ import com.alops.system.domain.dto.AlertDto;
import com.alops.system.domain.dto.AlertStatisticDto; import com.alops.system.domain.dto.AlertStatisticDto;
import com.alops.system.domain.dto.LevelCountDto; import com.alops.system.domain.dto.LevelCountDto;
import com.alops.system.domain.dto.TypeCountDto; import com.alops.system.domain.dto.TypeCountDto;
import com.alops.system.domain.vo.homeEquAlertMessage; import com.alops.system.domain.vo.homeEquAlertMessageVo;
import com.alops.system.mapper.AlertMessageMapper; import com.alops.system.mapper.AlertMessageMapper;
import com.alops.system.service.IAlertMessageService; import com.alops.system.service.IAlertMessageService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -55,7 +54,7 @@ public class AlertMessageServiceImpl implements IAlertMessageService
} }
@Override @Override
public List<homeEquAlertMessage> selectStaticAlertMessageList(){ public List<homeEquAlertMessageVo> selectStaticAlertMessageList(){
return alertMessageMapper.selectStaticAlertMessageList(); return alertMessageMapper.selectStaticAlertMessageList();
} }

@ -1,14 +1,13 @@
package com.alops.system.service.impl; package com.alops.system.service.impl;
import java.util.Date; import java.math.BigDecimal;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.UUID;
import com.alops.common.utils.SecurityUtils; import com.alops.common.utils.SecurityUtils;
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.EquBaseQueryDto;
import com.alops.system.domain.vo.dropDownVo; import com.alops.system.domain.vo.dropDownVo;
import com.alops.system.domain.vo.equipmentAssessmentVo;
import com.alops.system.domain.vo.imageVo; import com.alops.system.domain.vo.imageVo;
import com.alops.system.domain.dto.*; import com.alops.system.domain.dto.*;
import com.alops.system.domain.vo.queryEquBaseVO; import com.alops.system.domain.vo.queryEquBaseVO;
@ -53,6 +52,54 @@ public class EquBaseServiceImpl implements IEquBaseService
return equSupplierMapper.selectEquSupDropDown(); return equSupplierMapper.selectEquSupDropDown();
} }
//设备评估信息
@Override
public List<equipmentAssessmentVo> getDeviceIAssessmentnfo(){
List<equipmentAssessmentDto> equAsstDtoList = equBaseMapper.getEquipmentAssessmentList();
List<equipmentAssessmentVo> resultList = new ArrayList<>();
for (equipmentAssessmentDto dto : equAsstDtoList) {
equipmentAssessmentVo vo = new equipmentAssessmentVo();
vo.setId(dto.getId());
vo.setEquNumber(dto.getEquNumber());
vo.setName(dto.getName());
vo.setLocation(dto.getLocation());
vo.setEquType(dto.getEquType());
vo.setDeviceLevel(dto.getDeviceLevel());
// 四项指标
String cpuStatus = checkStatus(dto.getCpuUtilization(), 80, 90, 95);
String memoryStatus = checkStatus(dto.getMemoryUtilization(), 80, 90, 95);
String temperatureStatus = checkTemperatureStatus(dto.getTemperature());
String healthStatus = checkHealthStatus(dto.getHealth());
vo.setCpuStatus(cpuStatus);
vo.setMemoryStatus(memoryStatus);
vo.setTemperatureStatus(temperatureStatus);
vo.setHealthStatus(healthStatus);
// 风险等级 = 四项指标中最严重的
int riskLevel = Math.max(
Math.max(getRisk(cpuStatus), getRisk(memoryStatus)),
Math.max(getRisk(temperatureStatus), getRisk(healthStatus))
);
vo.setRiskGrade(switch (riskLevel) {
case 1 -> "无风险";
case 2 -> "低";
case 3 -> "中";
case 4 -> "高";
default -> "未知";
});
resultList.add(vo);
}
return resultList;
}
@Autowired @Autowired
private EquInterfaceMapper interfaceMapper; private EquInterfaceMapper interfaceMapper;
/** /**
@ -184,6 +231,49 @@ public class EquBaseServiceImpl implements IEquBaseService
return totalDeviceCount; return totalDeviceCount;
} }
/** 通用百分比指标判断(CPU/内存) */
private String checkStatus(BigDecimal val, double healthy, double good, double average) {
if (val == null) return "未知";
double v = val.doubleValue();
if (v < healthy) return "健康";
if (v < good) return "良好";
if (v < average) return "一般";
return "需维护";
}
/** 温度判断 */
private String checkTemperatureStatus(BigDecimal temp) {
if (temp == null) return "未知";
double val = temp.doubleValue();
if (val >= 25 && val <= 45) return "健康";
if ((val >= 20 && val < 25) || (val > 45 && val <= 50)) return "良好";
if ((val >= 16 && val < 20) || (val > 50 && val <= 55)) return "一般";
return "需维护";
}
/** 健康度判断 */
private String checkHealthStatus(BigDecimal health) {
if (health == null) return "未知";
return switch (health.intValue()) {
case 1 -> "健康";
case 2 -> "良好";
case 3 -> "一般";
case 4 -> "需维护";
default -> "未知";
};
}
/** 风险等级映射:健康=1,良好=2,一般=3,需维护=4 */
private int getRisk(String status) {
return switch (status) {
case "健康" -> 1;
case "良好" -> 2;
case "一般" -> 3;
case "需维护" -> 4;
default -> 0;
};
}
/** /**
* 新增设备基本信息 * 新增设备基本信息

@ -61,6 +61,19 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService {
private static final Logger log = LoggerFactory.getLogger(ScheduleRulesServiceImpl.class); private static final Logger log = LoggerFactory.getLogger(ScheduleRulesServiceImpl.class);
@Override
public Boolean checkRunningOrWaitingRules() {
List<ScheduleRules> runningOrWaiting = scheduleRulesMapper.selectListOne();
// 检查列表是否不为空且有数据
if (runningOrWaiting != null && !runningOrWaiting.isEmpty()) {
return true;
}
return false;
}
@Override @Override
public AjaxResult executeRule(ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException { public AjaxResult executeRule(ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException {
@ -162,7 +175,7 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService {
Map<String, List<EquOid>> oidMap = new HashMap<>(); Map<String, List<EquOid>> oidMap = new HashMap<>();
for (EquBase dev : devices) { for (EquBase dev : devices) {
oidMap.put(dev.getManufacture(), equOidMapper.findByManuIdAndStatus(dev.getManufacture())); oidMap.put(dev.getEquManuId(), equOidMapper.findByManuIdAndStatus(dev.getEquManuId()));
} }
ExecutorService executor = Executors.newFixedThreadPool(10); ExecutorService executor = Executors.newFixedThreadPool(10);
@ -171,7 +184,7 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService {
for (EquBase device : devices) { for (EquBase device : devices) {
futures.add(executor.submit(() -> { futures.add(executor.submit(() -> {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
List<EquOid> oids = oidMap.getOrDefault(device.getManufacture(), Collections.emptyList()); List<EquOid> oids = oidMap.getOrDefault(device.getEquManuId(), Collections.emptyList());
Map<String, Object> snmpResults = snmpService.query(device.getIp(), oids); Map<String, Object> snmpResults = snmpService.query(device.getIp(), oids);
long afterSnmp = System.currentTimeMillis(); long afterSnmp = System.currentTimeMillis();
System.out.println("SNMP查询耗时: " + (afterSnmp - start) + " ms"); System.out.println("SNMP查询耗时: " + (afterSnmp - start) + " ms");

@ -86,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<!-- 查询最新预警信息(按时间排序,取前N条) --> <!-- 查询最新预警信息(按时间排序,取前N条) -->
<select id="selectStaticAlertMessageList" resultType="homeEquAlertMessage"> <select id="selectStaticAlertMessageList" resultType="homeEquAlertMessageVo">
SELECT SELECT
a.level, a.level,
a.occur_time AS occurTime, a.occur_time AS occurTime,

@ -9,9 +9,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="name" column="name" /> <result property="name" column="name" />
<result property="version" column="version" /> <result property="version" column="version" />
<result property="ip" column="ip" /> <result property="ip" column="ip" />
<result property="manufacture" column="manufacture" /> <result property="equManuId" column="manufacture" />
<result property="location" column="location" /> <result property="location" column="location" />
<result property="equType" column="equ_type" /> <result property="equTypeId" column="equ_type" />
<result property="inCharge" column="in_charge" /> <result property="inCharge" column="in_charge" />
<result property="installDate" column="install_date" /> <result property="installDate" column="install_date" />
<result property="lifeCycle" column="life_cycle" /> <result property="lifeCycle" column="life_cycle" />
@ -30,6 +30,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<resultMap id="EquMonitorResult" type="com.alops.system.domain.vo.EquMonitorVO"> <resultMap id="EquMonitorResult" type="com.alops.system.domain.vo.EquMonitorVO">
<result property="id" column="id" /> <result property="id" column="id" />
@ -85,6 +88,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<select id="getEquipmentAssessmentList"
resultType="com.alops.system.domain.dto.equipmentAssessmentDto">
SELECT
b.id AS id,
b.equ_number AS equNumber,
b.name AS name,
b.location AS location,
t.name AS equType, -- 从 equ_type 表取类型名称
b.device_level AS deviceLevel,
-- 从 equ_gather 最新一条记录中取数据
g.health AS health,
g.temperature AS temperature,
g.cpu_utilization AS cpuUtilization,
g.memory_utilization AS memoryUtilization
FROM equ_base b
LEFT JOIN equ_type t
ON b.equ_type = t.id
LEFT JOIN (
SELECT eg1.*
FROM equ_gather eg1
INNER JOIN (
SELECT equ_id, MAX(gather_time) AS max_time
FROM equ_gather
GROUP BY equ_id
) eg2
ON eg1.equ_id = eg2.equ_id AND eg1.gather_time = eg2.max_time
) g
ON b.id = g.equ_id
WHERE b.status = 1
ORDER BY b.id
</select>
<select id="findEquBaseList" resultMap="EquBaseResult"> <select id="findEquBaseList" resultMap="EquBaseResult">
<include refid="selectEquBaseVo"/> <include refid="selectEquBaseVo"/>
<where> <where>
@ -99,9 +141,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
b.name AS name, b.name AS name,
b.version AS version, b.version AS version,
b.ip AS ip, b.ip AS ip,
b.manufacture AS equManuId,
m.name AS manufacture, m.name AS manufacture,
b.supplier_id AS supplierId,
s.name AS supplierName, s.name AS supplierName,
b.location AS location, b.location AS location,
b.equ_type AS equTypeId,
t.name AS equType, t.name AS equType,
b.in_charge AS inCharge, b.in_charge AS inCharge,
b.install_date AS installDate, b.install_date AS installDate,
@ -370,9 +415,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="name != null">name,</if> <if test="name != null">name,</if>
<if test="version != null">version,</if> <if test="version != null">version,</if>
<if test="ip != null">ip,</if> <if test="ip != null">ip,</if>
<if test="manufacture != null">manufacture,</if> <if test="equManuId != null">manufacture,</if>
<if test="location != null">location,</if> <if test="location != null">location,</if>
<if test="equType != null">equ_type,</if> <if test="equTypeId != null">equ_type,</if>
<if test="inCharge != null">in_charge,</if> <if test="inCharge != null">in_charge,</if>
<if test="installDate != null">install_date,</if> <if test="installDate != null">install_date,</if>
<if test="lifeCycle != null">life_cycle,</if> <if test="lifeCycle != null">life_cycle,</if>
@ -393,9 +438,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="name != null">#{name},</if> <if test="name != null">#{name},</if>
<if test="version != null">#{version},</if> <if test="version != null">#{version},</if>
<if test="ip != null">#{ip},</if> <if test="ip != null">#{ip},</if>
<if test="manufacture != null">#{manufacture},</if> <if test="equManuId != null">#{equManuId},</if>
<if test="location != null">#{location},</if> <if test="location != null">#{location},</if>
<if test="equType != null">#{equType},</if> <if test="equTypeId != null">#{equTypeId},</if>
<if test="inCharge != null">#{inCharge},</if> <if test="inCharge != null">#{inCharge},</if>
<if test="installDate != null">#{installDate},</if> <if test="installDate != null">#{installDate},</if>
<if test="lifeCycle != null">#{lifeCycle},</if> <if test="lifeCycle != null">#{lifeCycle},</if>
@ -419,9 +464,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="name != null">name = #{name},</if> <if test="name != null">name = #{name},</if>
<if test="version != null">version = #{version},</if> <if test="version != null">version = #{version},</if>
<if test="ip != null">ip = #{ip},</if> <if test="ip != null">ip = #{ip},</if>
<if test="manufacture != null">manufacture = #{manufacture},</if> <if test="equManuId != null">manufacture = #{equManuId},</if>
<if test="location != null">location = #{location},</if> <if test="location != null">location = #{location},</if>
<if test="equType != null">equ_type = #{equType},</if> <if test="equTypeId != null">equ_type = #{equTypeId},</if>
<if test="inCharge != null">in_charge = #{inCharge},</if> <if test="inCharge != null">in_charge = #{inCharge},</if>
<if test="installDate != null">install_date = #{installDate},</if> <if test="installDate != null">install_date = #{installDate},</if>
<if test="lifeCycle != null">life_cycle = #{lifeCycle},</if> <if test="lifeCycle != null">life_cycle = #{lifeCycle},</if>

@ -49,6 +49,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectListOne" resultMap="ScheduleRulesResult">
SELECT *
FROM schedule_rules
WHERE status = 1
</select>
<select id="selectScheduleRulesList" parameterType="ScheduleRules" resultMap="ScheduleRulesResult"> <select id="selectScheduleRulesList" parameterType="ScheduleRules" resultMap="ScheduleRulesResult">
<include refid="selectScheduleRulesVo"/> <include refid="selectScheduleRulesVo"/>
<where> <where>

Loading…
Cancel
Save