diff --git a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/ScheduleRulesController.java b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/ScheduleRulesController.java index 19a76650..e716b7fd 100644 --- a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/ScheduleRulesController.java +++ b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/ScheduleRulesController.java @@ -60,6 +60,9 @@ public class ScheduleRulesController extends BaseController @ApiOperation("立即确定") public AjaxResult run(@RequestBody ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException { + if(scheduleRulesService.checkRunningOrWaitingRules()){ + return AjaxResult.error("正在采集,请稍后"); + } if (newRule.getRuleType() == 2) { // 立即执行 diff --git a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertMessageController.java b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertMessageController.java index 5722a6b5..526b2816 100644 --- a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertMessageController.java +++ b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertMessageController.java @@ -1,22 +1,16 @@ package com.alops.web.controller.exceptionController; import java.util.List; -import java.util.Map; -import javax.servlet.http.HttpServletResponse; import com.alops.common.annotation.Log; import com.alops.common.core.controller.BaseController; import com.alops.common.core.domain.AjaxResult; import com.alops.common.core.page.TableDataInfo; 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.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.domain.AlertRule; -import com.alops.system.domain.EquInterface; import com.alops.system.domain.dto.AlertStatisticDto; import com.alops.system.service.IAlertMessageService; import io.swagger.annotations.ApiOperation; @@ -92,7 +86,7 @@ public class AlertMessageController extends BaseController public TableDataInfo homeList() { startPage(); - List list = alertMessageService.selectStaticAlertMessageList(); + List list = alertMessageService.selectStaticAlertMessageList(); return getDataTable(list); } diff --git a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/equAssessment.java b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/equAssessment.java new file mode 100644 index 00000000..a24f2b89 --- /dev/null +++ b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/equAssessment.java @@ -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 list = iEquBaseService.getDeviceIAssessmentnfo(); + return getDataTable(list); + } + +} diff --git a/ALOps_sys_backend/alops-system/pom.xml b/ALOps_sys_backend/alops-system/pom.xml index b939dd28..56fc61a0 100644 --- a/ALOps_sys_backend/alops-system/pom.xml +++ b/ALOps_sys_backend/alops-system/pom.xml @@ -16,6 +16,18 @@ system系统模块 + + + + org.apache.maven.plugins + maven-compiler-plugin + + 14 + 14 + + + + diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquBase.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquBase.java index 4b7302fb..8cbc7e76 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquBase.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquBase.java @@ -160,16 +160,6 @@ public class EquBase return ip; } - public void setManufacture(String manufacture) - { - this.equManuId = manufacture; - } - - public String getManufacture() - { - return equManuId; - } - public void setLocation(String location) { this.location = location; @@ -180,16 +170,6 @@ public class EquBase return location; } - public void setEquType(String equType) - { - this.equTypeId = equType; - } - - public String getEquType() - { - return equTypeId; - } - public void setInCharge(String inCharge) { this.inCharge = inCharge; @@ -290,6 +270,11 @@ public class EquBase 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 public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -297,9 +282,9 @@ public class EquBase .append("name", getName()) .append("version", getVersion()) .append("ip", getIp()) - .append("manufacture", getManufacture()) + .append("equManuId", getEquManuId()) .append("location", getLocation()) - .append("equType", getEquType()) + .append("equTypeId", getEquTypeId()) .append("inCharge", getInCharge()) .append("installDate", getInstallDate()) .append("lifeCycle", getLifeCycle()) diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquBaseAddDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquBaseAddDto.java new file mode 100644 index 00000000..afb600cf --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquBaseAddDto.java @@ -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 ; +} diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquBaseQueryDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquBaseQueryDto.java index 30b67a12..33f696dd 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquBaseQueryDto.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquBaseQueryDto.java @@ -16,7 +16,8 @@ public class EquBaseQueryDto implements Serializable { private static final long serialVersionUID = 1L; private String id; - + /** 设备类型 (equ_type, varchar) */ + private String equTypeId; /** 设备类型 (equ_type, varchar) */ private String equTypeId; /** 设备类型 (equ_type, varchar) */ @@ -26,9 +27,6 @@ public class EquBaseQueryDto implements Serializable { /** 安装位置 ID (location, varchar) */ private String location; - - - /** 起始时间 (min_time) */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date minTime; @@ -41,8 +39,6 @@ public class EquBaseQueryDto implements Serializable { private Integer status; // ====== Getter 和 Setter ====== - - public String getName() { return name; } diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/equipmentAssessmentDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/equipmentAssessmentDto.java new file mode 100644 index 00000000..630c2658 --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/equipmentAssessmentDto.java @@ -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; + +} diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/equipmentAssessmentVo.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/equipmentAssessmentVo.java new file mode 100644 index 00000000..e01b0928 --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/equipmentAssessmentVo.java @@ -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 ; +} diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/homeEquAlertMessage.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/homeEquAlertMessageVo.java similarity index 88% rename from ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/homeEquAlertMessage.java rename to ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/homeEquAlertMessageVo.java index 39b631a4..81d7bcf9 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/homeEquAlertMessage.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/homeEquAlertMessageVo.java @@ -1,13 +1,12 @@ package com.alops.system.domain.vo; import com.alops.common.annotation.Excel; -import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.util.Date; @Data -public class homeEquAlertMessage { +public class homeEquAlertMessageVo { /** 预警级别(1-5级) */ diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/queryEquBaseVO.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/queryEquBaseVO.java index c806e4e0..365eb167 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/queryEquBaseVO.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/queryEquBaseVO.java @@ -39,17 +39,23 @@ public class queryEquBaseVO { /** 带外管理 IP */ @Excel(name = "带外管理 IP") private String ip; + @Excel(name = "设备厂商名称id ") + private String equManuId; /** 设备厂商 */ @Excel(name = "设备厂商名称 ") - private String manuName; + private String manufacture; /** 设备厂商 */ - @Excel(name = "设备厂商名称 ") + @Excel(name = "设备供应商名称 ") + private String supplierId; + /** 安装位置 id */ + @Excel(name = "设备供应商名称 ") private String supplierName; /** 安装位置 id */ @Excel(name = "安装位置 id") private String location; - - /** 设备类型 id */ + /** 设备类型 id */ + @Excel(name = "设备类型id") + private String equTypeId; @Excel(name = "设备类型名称") private String equType; @@ -91,6 +97,8 @@ public class queryEquBaseVO { @Excel(name = "设备图片") private String equImage; + @Excel(name = "设备编号") + private String equNumber; public void setId(String id) @@ -230,7 +238,7 @@ public class queryEquBaseVO { .append("version", getVersion()) .append("ip", getIp()) .append("supplierName", getSupplierName()) - .append("manuName", getManuName()) + .append("manuName", getManufacture()) .append("location", getLocation()) .append("equType", getEquType()) .append("inCharge", getInCharge()) diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertMessageMapper.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertMessageMapper.java index ad98dcf8..580fe2a6 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertMessageMapper.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertMessageMapper.java @@ -2,7 +2,7 @@ package com.alops.system.mapper; import com.alops.system.domain.AlertMessage; 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.Param; @@ -46,7 +46,7 @@ public interface AlertMessageMapper */ public List selectAlertMessageList(AlertDto alertMessage); - public List selectStaticAlertMessageList(); + public List selectStaticAlertMessageList(); public ArrayList selectAlertMessageByEquId(Long Equid); /** diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java index 028b2c45..6cada08c 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquBaseMapper.java @@ -21,6 +21,12 @@ import org.springframework.data.repository.query.Param; @Mapper public interface EquBaseMapper { + + + /** + * 查询状态为1的设备及其最新采集信息和类型名称 + */ + List getEquipmentAssessmentList(); int incrementCollectCount(@Param("ids") List ids); @Update("DELETE FROM equ_interface") diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/ScheduleRulesMapper.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/ScheduleRulesMapper.java index a7837a4b..a2df65b0 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/ScheduleRulesMapper.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/ScheduleRulesMapper.java @@ -17,6 +17,8 @@ public interface ScheduleRulesMapper public List selectList(); + + public List selectListOne(); /** * 查询定时采集规则 * diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertMessageService.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertMessageService.java index efcd7596..f528a1ad 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertMessageService.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertMessageService.java @@ -3,7 +3,7 @@ package com.alops.system.service; 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.vo.homeEquAlertMessage; +import com.alops.system.domain.vo.homeEquAlertMessageVo; import java.util.List; @@ -31,7 +31,7 @@ public interface IAlertMessageService * @return 故障统计集合 */ public List selectAlertMessageList(AlertDto alertMessage); - public List selectStaticAlertMessageList(); + public List selectStaticAlertMessageList(); public List selectAlertMessageListByEquId(Long equId); /** diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java index 4ee9e582..301b6bb1 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquBaseService.java @@ -3,6 +3,7 @@ package com.alops.system.service; import com.alops.system.domain.EquBase; import com.alops.system.domain.dto.EquBaseQueryDto; 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.dto.*; import com.alops.system.domain.vo.queryEquBaseVO; @@ -18,7 +19,8 @@ import java.util.List; */ public interface IEquBaseService { - + //获取设备评估信息 + public List getDeviceIAssessmentnfo(); public List selectEquManu(); public List selectEquSupp(); diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IScheduleRulesService.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IScheduleRulesService.java index 01c3656c..931bed97 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IScheduleRulesService.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IScheduleRulesService.java @@ -21,6 +21,8 @@ public interface IScheduleRulesService + public Boolean checkRunningOrWaitingRules(); + public AjaxResult executeRule(ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException; public int executeImmediately() throws ExecutionException, InterruptedException; diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertMessageServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertMessageServiceImpl.java index c6feb4ac..d0708772 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertMessageServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertMessageServiceImpl.java @@ -2,7 +2,6 @@ package com.alops.system.service.impl; import java.time.LocalDate; import java.util.ArrayList; -import java.util.HashMap; import java.util.Date; import java.util.List; 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.LevelCountDto; 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.service.IAlertMessageService; import org.springframework.beans.factory.annotation.Autowired; @@ -55,7 +54,7 @@ public class AlertMessageServiceImpl implements IAlertMessageService } @Override - public List selectStaticAlertMessageList(){ + public List selectStaticAlertMessageList(){ return alertMessageMapper.selectStaticAlertMessageList(); } diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java index 1de921ea..abea0fb5 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquBaseServiceImpl.java @@ -1,14 +1,13 @@ package com.alops.system.service.impl; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.UUID; +import java.math.BigDecimal; +import java.util.*; import com.alops.common.utils.SecurityUtils; import com.alops.system.domain.EquBase; import com.alops.system.domain.dto.EquBaseQueryDto; 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.dto.*; import com.alops.system.domain.vo.queryEquBaseVO; @@ -53,6 +52,54 @@ public class EquBaseServiceImpl implements IEquBaseService return equSupplierMapper.selectEquSupDropDown(); } + //设备评估信息 + @Override + public List getDeviceIAssessmentnfo(){ + + List equAsstDtoList = equBaseMapper.getEquipmentAssessmentList(); + List 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 private EquInterfaceMapper interfaceMapper; /** @@ -184,6 +231,49 @@ public class EquBaseServiceImpl implements IEquBaseService 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; + }; + } + /** * 新增设备基本信息 diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java index a4958add..2f7c2db0 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/ScheduleRulesServiceImpl.java @@ -61,6 +61,19 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService { private static final Logger log = LoggerFactory.getLogger(ScheduleRulesServiceImpl.class); + + @Override + public Boolean checkRunningOrWaitingRules() { + + List runningOrWaiting = scheduleRulesMapper.selectListOne(); + + // 检查列表是否不为空且有数据 + if (runningOrWaiting != null && !runningOrWaiting.isEmpty()) { + return true; + } + return false; + } + @Override public AjaxResult executeRule(ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException { @@ -162,7 +175,7 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService { Map> oidMap = new HashMap<>(); 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); @@ -171,7 +184,7 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService { for (EquBase device : devices) { futures.add(executor.submit(() -> { long start = System.currentTimeMillis(); - List oids = oidMap.getOrDefault(device.getManufacture(), Collections.emptyList()); + List oids = oidMap.getOrDefault(device.getEquManuId(), Collections.emptyList()); Map snmpResults = snmpService.query(device.getIp(), oids); long afterSnmp = System.currentTimeMillis(); System.out.println("SNMP查询耗时: " + (afterSnmp - start) + " ms"); diff --git a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/AlertMessageMapper.xml b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/AlertMessageMapper.xml index 0a2df36b..f5483bd9 100644 --- a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/AlertMessageMapper.xml +++ b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/AlertMessageMapper.xml @@ -86,7 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - SELECT a.level, a.occur_time AS occurTime, diff --git a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml index 5adf8701..a8b32fbf 100644 --- a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml +++ b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquBaseMapper.xml @@ -30,6 +30,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + @@ -87,6 +90,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + + +