diff --git a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java index e81c9be6..c6dca97c 100644 --- a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java +++ b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquBaseController.java @@ -1,7 +1,9 @@ package com.alops.web.controller.equManagement; import java.io.IOException; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; @@ -14,6 +16,7 @@ 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; @@ -48,9 +51,9 @@ public class EquBaseController extends BaseController * 查询设备基本信息列表 */ @PreAuthorize("@ss.hasPermi('device:files:list')") - @PostMapping("/list") + @GetMapping("/list") @ApiOperation("查询多个设备信息") - public TableDataInfo list(@RequestBody EquBaseQueryDto equBase) + public TableDataInfo list( EquBaseQueryDto equBase) { startPage(); List list = equBaseService.selectEquBaseList(equBase); @@ -58,15 +61,31 @@ public class EquBaseController extends BaseController } /**查询设备监测信息列表(查询多台显示界面的单独信息)**/ + /** + * 查询多台设备的最新监测信息 + **/ @PreAuthorize("@ss.hasPermi('device:files:query')") - @GetMapping("/listMonitor") - @ApiOperation("查询设备监测信息列表(查询多台显示界面的单独信息)") - public AjaxResult listMonitorInfo(EquBaseQueryDto equBaseQueryDto) - { - List list = equBaseService.selectEquMonitorList(equBaseQueryDto); - return AjaxResult.success("查询成功", list); + @GetMapping("/monitorpage") + @ApiOperation("分页查询多台设备的最新监测信息") + public TableDataInfo getMonitorList() { + startPage(); // 无参调用,自动获取 pageNum/pageSize + List list = equBaseService.selectEquMonitorListPaged(); + return getDataTable(list); // 自动封装分页结果 } + /** + * 首页展示:查询每台设备的最新监测信息 + */ + @PreAuthorize("@ss.hasPermi('device:files:query')") + @GetMapping("/monitorById") + @ApiOperation("首页展示:查询每台设备的最新监测信息") + public TableDataInfo getLatestEquMonitorList() { + startPage(); // 启用分页(如果首页不分页可删除) + List list = equBaseService.selectLatestEquMonitorList(); + return getDataTable(list); + } + + /** * 获取设备最新时间的历史监控信息 * @param id 查询对象,包含设备ID、开始时间和结束时间 @@ -80,6 +99,7 @@ public class EquBaseController extends BaseController // 调用职责单一的 Service 方法 return success(equBaseService.selectLatestEquMonitorInfo(id)); } + /** * 获取设备指定时间段内的历史监控信息 * @param equBaseQueryDto 查询对象,包含设备ID、开始时间和结束时间 @@ -101,9 +121,18 @@ public class EquBaseController extends BaseController @ApiOperation("按设备类型分类统计设备信息") public AjaxResult listMonitorInfoByType() { List list = equBaseService.selectEquStatisticByType(); - return AjaxResult.success("查询成功", list); + // 获取总设备数 + int totalCount = 0; + if (list != null) { + totalCount = list.stream().mapToInt(MonitorStatisticDto::getCount).sum(); + } + Map result = new HashMap<>(); + result.put("totalCount", totalCount); + result.put("list", list); + return AjaxResult.success("查询成功", result); } + /** * 获取设备基本信息详细信息 */ @@ -116,38 +145,35 @@ public class EquBaseController extends BaseController } - /** - * 根据设备ID返回图片流 - * 前端直接 - */ - - @PreAuthorize("@ss.hasPermi('device:files:queryimage')") - @GetMapping(value = "/queryimage/{id}") - @ApiOperation("查询单个设备图片") - public void getImage(@PathVariable String id, HttpServletResponse response) throws IOException { - if (id instanceof String) { - System.out.println("这是一个字符串"); - } - - - byte[] imgBytes = equBaseService.selectEquBaseImageById(id).getEquImage(); - +// /** +// * 根据设备ID返回图片流 +// * 前端直接 +// */ +// +// @PreAuthorize("@ss.hasPermi('device:files:queryimage')") +// @GetMapping(value = "/queryimage/{id}") +// @ApiOperation("查询单个设备图片") +// public void getImage(@PathVariable String id, HttpServletResponse response) throws IOException { +// +// byte[] imgBytes = equBaseService.selectEquBaseImageById(id).getEquImage(); +// +// +// if (imgBytes != null && imgBytes.length > 0) { +// // 设置响应类型,可根据实际图片类型动态修改 +// response.setContentType("image/png"); +// // 可选:缓存图片 +// response.setHeader("Cache-Control", "max-age=3600"); +// // 输出流写入响应 +// ServletOutputStream os = response.getOutputStream(); +// os.write(imgBytes); +// os.flush(); +// os.close(); +// } else { +// // 图片不存在 +// response.sendError(HttpServletResponse.SC_NOT_FOUND); +// } +// } - if (imgBytes != null && imgBytes.length > 0) { - // 设置响应类型,可根据实际图片类型动态修改 - response.setContentType("image/png"); - // 可选:缓存图片 - response.setHeader("Cache-Control", "max-age=3600"); - // 输出流写入响应 - ServletOutputStream os = response.getOutputStream(); - os.write(imgBytes); - os.flush(); - os.close(); - } else { - // 图片不存在 - response.sendError(HttpServletResponse.SC_NOT_FOUND); - } - } //厂商下拉表 @PreAuthorize("@ss.hasPermi('device:files:queryManufacture')") @GetMapping( "/manufacture") @@ -181,46 +207,44 @@ public class EquBaseController extends BaseController /** * 新增设备基本信息 + * @ModelAttribute equBase, + * @RequestPart(value = "file", required = false) // 使用 @RequestPart + * @ApiParam(value = "设备图片文件", type = "file") + * MultipartFile file */ @PreAuthorize("@ss.hasPermi('device:files:add')") @Log(title = "设备基本信息", businessType = BusinessType.INSERT) @PostMapping(value = "/add") @ApiOperation("增加设备档案信息") - public AjaxResult add( - @ModelAttribute EquBase equBase, - @RequestPart(value = "file", required = false) // 使用 @RequestPart - @ApiParam(value = "设备图片文件", type = "file") - MultipartFile file - - ) throws IOException { + public AjaxResult add( @RequestBody EquBase equBase + ) { - // 处理图片 - if (file != null && !file.isEmpty()) { - equBase.setEquImage(file.getBytes()); - } +// // 处理图片 +// if (file != null && !file.isEmpty()) { +// equBase.setEquImage(file.getBytes()); +// } // 调用 Service 插入数据库 return toAjax(equBaseService.insertEquBase(equBase)); } /** + * @ModelAttribute EquBase equBase, // 自动绑定表单字段 + * @RequestPart(value = "file", required = false) // 使用 @RequestPart + * @ApiParam(value = "设备图片文件", type = "file") + * MultipartFile file * 修改设备基本信息 */ @PreAuthorize("@ss.hasPermi('device:files:edit')") @Log(title = "设备基本信息", businessType = BusinessType.UPDATE) @PutMapping("/modify") @ApiOperation("修改设备档案信息") - public AjaxResult edit( - @ModelAttribute EquBase equBase, // 自动绑定表单字段 - @RequestPart(value = "file", required = false) // 使用 @RequestPart - @ApiParam(value = "设备图片文件", type = "file") - MultipartFile file - ) throws IOException { - - // 处理图片 - if (file != null && !file.isEmpty()) { - equBase.setEquImage(file.getBytes()); // 存数据库 Blob - } + public AjaxResult edit(@RequestBody EquBase equBase){ + +// // 处理图片 +// if (file != null && !file.isEmpty()) { +// equBase.setEquImage(file.getBytes()); // 存数据库 Blob +// } // 调用 Service 插入数据库 return toAjax(equBaseService.updateEquBase(equBase)); diff --git a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquManuController.java b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquManuController.java index f04873cb..fa5159b0 100644 --- a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquManuController.java +++ b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquManuController.java @@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RestController; * @date 2025-08-01 */ @RestController -@RequestMapping("/deviceManu") +@RequestMapping("/device/deviceManu") public class EquManuController extends BaseController { @Autowired @@ -42,8 +42,8 @@ public class EquManuController extends BaseController /** * 查询设备厂商管理列表 */ - @PreAuthorize("@ss.hasPermi('device:deviceManu:queryByVO')") - @GetMapping("/queryByVO") + @PreAuthorize("@ss.hasPermi('device:deviceManu:query')") + @GetMapping("/query") @ApiOperation("查询设备厂商管理列表") public TableDataInfo list(EquManu equManu) { diff --git a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquSupplierController.java b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquSupplierController.java index a5645cf1..cedc783e 100644 --- a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquSupplierController.java +++ b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquSupplierController.java @@ -1,8 +1,11 @@ package com.alops.web.controller.equManagement; import java.util.List; +import java.util.UUID; import javax.servlet.http.HttpServletResponse; +import com.alops.system.domain.dto.EquSupplierAddDto; +import com.alops.system.domain.dto.EquSupplierUpdateDto; import io.swagger.annotations.ApiOperation; import com.alops.common.annotation.Log; import com.alops.common.core.controller.BaseController; @@ -85,25 +88,27 @@ public class EquSupplierController extends BaseController */ @PreAuthorize("@ss.hasPermi('device:supplier:add')") @Log(title = "供应商功能信息", businessType = BusinessType.INSERT) - @PostMapping - @ApiOperation("新增供应商功能信息列表") - public AjaxResult add(@RequestBody EquSupplier equSupplier) + @PostMapping("/add") + @ApiOperation("新增供应商功能信息") + public AjaxResult add(@RequestBody EquSupplierAddDto dto) { - return toAjax(equSupplierService.insertEquSupplier(equSupplier)); + return toAjax(equSupplierService.insertEquSupplier(dto)); } + + /** * 修改供应商功能信息 */ @PreAuthorize("@ss.hasPermi('device:supplier:edit')") @Log(title = "供应商功能信息", businessType = BusinessType.UPDATE) - @PutMapping + @PutMapping("/edit") @ApiOperation("修改供应商功能信息列表") - public AjaxResult edit(@RequestBody EquSupplier equSupplier) - { - return toAjax(equSupplierService.updateEquSupplier(equSupplier)); + public AjaxResult edit(@RequestBody EquSupplierUpdateDto updateDto) { + return toAjax(equSupplierService.updateEquSupplier(updateDto)); } + /** * 删除供应商功能信息 */ 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..26f2b35d 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 @@ -58,25 +58,29 @@ public class ScheduleRulesController extends BaseController @PreAuthorize("@ss.hasPermi('device:deviceInformation:protoCollect')") @PostMapping("/addRule") @ApiOperation("立即确定") - public AjaxResult run(@RequestBody ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException { - - if (newRule.getRuleType() == 2) { - // 立即执行 - return scheduleRulesService.executeRule(newRule); + public AjaxResult run(@RequestBody ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException { - } else { - // 固定时间/按频率:异步处理异常 - scheduleRulesService.executeRule(newRule); + // 先检查是否有任务正在执行 + if (scheduleRulesService.checkRunningOrWaitingRules()) { + return AjaxResult.error(4001,"正在采集,请稍后,此次采集完成后会站内信通知到你"); + } - return AjaxResult.success("任务已调度成功,异常会通过站内信/邮件通知"); - } + // 执行规则(立即或定时/按频率) + boolean success = scheduleRulesService.executeRule(newRule); + if (success) { + // 返回调度/插入成功 + return AjaxResult.success("任务已调度成功,采集结果会通过站内信/邮件通知"); + } else { + return AjaxResult.error("任务设置失败,请稍后重试"); + } } + /** * 查询定时采集规则列表 */ 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 51756ee8..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,34 +1,22 @@ 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.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; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * 故障统计Controller @@ -91,12 +79,26 @@ public class AlertMessageController extends BaseController /** * 查询预警信息统计列表 */ - @PreAuthorize("@ss.hasPermi('inMonitoring:alertMessage:list')") - @PostMapping ("/list") + @PreAuthorize("@ss.hasPermi('inMonitoring:alertMessage:statistic:list')") + @GetMapping ("/statistic/list") @ApiOperation("查询预警信息") @Log(title = "查询预警信息", businessType = BusinessType.UPDATE) + public TableDataInfo homeList() + { + startPage(); + List list = alertMessageService.selectStaticAlertMessageList(); + return getDataTable(list); + } + - public TableDataInfo list( @RequestBody AlertDto alertMessage) + /** + * 首页查询预警信息统计列表 + */ + @PreAuthorize("@ss.hasPermi('inMonitoring:alertMessage:list')") + @GetMapping ("/list") + @ApiOperation("查询预警信息") + @Log(title = "查询预警信息", businessType = BusinessType.UPDATE) + public TableDataInfo list( AlertDto alertMessage) { startPage(); List list = alertMessageService.selectAlertMessageList(alertMessage); diff --git a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertRuleController.java b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertRuleController.java index 9aaa44de..d2aaeff3 100644 --- a/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertRuleController.java +++ b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertRuleController.java @@ -12,6 +12,7 @@ import com.alops.common.enums.BusinessType; import com.alops.common.utils.poi.ExcelUtil; import com.alops.system.domain.AlertRule; import com.alops.system.domain.dto.AlertRuleAddDto; +import com.alops.system.domain.vo.AlertRuleVo; import com.alops.system.service.IAlertLaunchService; import com.alops.system.service.IAlertRuleService; import com.alops.system.service.IDictAlarmParamService; @@ -55,7 +56,7 @@ public class AlertRuleController extends BaseController { try { - AlertRule alertRule = alertRuleService.saveRule(dto); + AlertRuleVo alertRule = alertRuleService.saveRule(dto); return AjaxResult.success("预警规则新增成功", alertRule); } catch (Exception e) { e.printStackTrace(); @@ -69,7 +70,7 @@ public class AlertRuleController extends BaseController { @PreAuthorize("@ss.hasPermi('inMonitoring:alertRule:edit')") @ApiOperation("修改预警规则") @Log(title = "【修改预警规则】", businessType = BusinessType.DELETE) - @PostMapping("/editRule") + @PutMapping("/editRule") public AjaxResult editRule(@RequestBody AlertRuleAddDto dto) { try { AlertRule alertRule = alertRuleService.updateRule(dto); @@ -89,7 +90,7 @@ public class AlertRuleController extends BaseController { @ApiOperation("查询预警规则") public TableDataInfo list(AlertRule alertRule) { startPage(); - List list = alertRuleService.selectAlertRuleList(alertRule); + List list = alertRuleService.selectAlertRuleList(alertRule); 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-admin/src/main/resources/application-druid.yml b/ALOps_sys_backend/alops-admin/src/main/resources/application-druid.yml index ec051fae..f719c265 100644 --- a/ALOps_sys_backend/alops-admin/src/main/resources/application-druid.yml +++ b/ALOps_sys_backend/alops-admin/src/main/resources/application-druid.yml @@ -6,8 +6,8 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://localhost:3306/AIOps_sys?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: root + url: jdbc:mysql://localhost:3306/aiops_sys?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: aiops_sys password: 1234 # 从库数据源 slave: diff --git a/ALOps_sys_backend/alops-framework/src/main/java/com/alops/framework/web/service/SysLoginService.java b/ALOps_sys_backend/alops-framework/src/main/java/com/alops/framework/web/service/SysLoginService.java index 32240b2d..07e58c00 100644 --- a/ALOps_sys_backend/alops-framework/src/main/java/com/alops/framework/web/service/SysLoginService.java +++ b/ALOps_sys_backend/alops-framework/src/main/java/com/alops/framework/web/service/SysLoginService.java @@ -29,6 +29,8 @@ import com.alops.framework.security.context.AuthenticationContextHolder; import com.alops.system.service.ISysConfigService; import com.alops.system.service.ISysUserService; +import java.util.Date; + /** * 登录校验方法 * diff --git a/ALOps_sys_backend/alops-framework/src/main/java/com/alops/framework/web/service/SysRegisterService.java b/ALOps_sys_backend/alops-framework/src/main/java/com/alops/framework/web/service/SysRegisterService.java index bb402155..ec49fb96 100644 --- a/ALOps_sys_backend/alops-framework/src/main/java/com/alops/framework/web/service/SysRegisterService.java +++ b/ALOps_sys_backend/alops-framework/src/main/java/com/alops/framework/web/service/SysRegisterService.java @@ -19,6 +19,8 @@ import com.alops.framework.manager.factory.AsyncFactory; import com.alops.system.service.ISysConfigService; import com.alops.system.service.ISysUserService; +import java.util.Date; + /** * 注册校验方法 * diff --git a/ALOps_sys_backend/alops-system/pom.xml b/ALOps_sys_backend/alops-system/pom.xml index 22020c68..7ac7efa4 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/AlertMessage.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertMessage.java index c80ad07f..ce625b13 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertMessage.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertMessage.java @@ -9,6 +9,8 @@ import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import javax.mail.Message; + /** * 故障统计对象 alert_message * @@ -23,7 +25,6 @@ public class AlertMessage /** ID */ private Long id; - /** 设备ID */ @Excel(name = "设备ID") private String equId; @@ -70,6 +71,9 @@ public class AlertMessage @Excel(name = "信息批次") private Integer batch; + @Excel(name ="预警信息") + private String message; + diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertRule.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertRule.java index ff6a59fe..1a593e09 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertRule.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/AlertRule.java @@ -62,6 +62,7 @@ public class AlertRule extends BaseEntity + public void setId(Long id) { this.id = id; 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 4e40d8cb..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 @@ -15,7 +15,7 @@ import org.apache.commons.lang3.builder.ToStringStyle; * 设备基本信息对象 equ_base * * @author ruoyi - * @date 2025-09-19 + * @date 2025-09-19F */ @Data public class EquBase @@ -25,6 +25,9 @@ public class EquBase /** 设备唯一标识(设备编号) */ private String id; + /** (设备编号) */ + private String equNumber; + /** 设备名称 */ @Excel(name = "设备名称") private String name; @@ -39,15 +42,8 @@ public class EquBase /** 设备厂商 id */ @Excel(name = "设备厂商 id") - private String manufacture; + private String equManuId; - public EquManu getManufactureVO() { - return manufactureVO; - } - - public void setManufactureVO(EquManu manufactureVO) { - this.manufactureVO = manufactureVO; - } private EquManu manufactureVO; @@ -57,7 +53,9 @@ public class EquBase /** 设备类型 id */ @Excel(name = "设备类型 id") - private String equType; + private String equTypeId; + + public EquType getEquTypeVO() { return equTypeVO; @@ -118,8 +116,8 @@ public class EquBase @Excel(name = "采集次数") private Long createBy ; - @Excel(name = "设备图片") - private byte[] equImage ; + @Excel(name = "设备图片地址") + private String equImage ; public void setId(String id) @@ -162,16 +160,6 @@ public class EquBase return ip; } - public void setManufacture(String manufacture) - { - this.manufacture = manufacture; - } - - public String getManufacture() - { - return manufacture; - } - public void setLocation(String location) { this.location = location; @@ -182,16 +170,6 @@ public class EquBase return location; } - public void setEquType(String equType) - { - this.equType = equType; - } - - public String getEquType() - { - return equType; - } - public void setInCharge(String inCharge) { this.inCharge = inCharge; @@ -292,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) @@ -299,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/EquInterface.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquInterface.java index b88d2466..85619033 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquInterface.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquInterface.java @@ -17,7 +17,7 @@ import org.apache.commons.lang3.builder.ToStringStyle; * @date 2025-08-20 */ @Data -public class EquInterface extends BaseEntity +public class EquInterface { private static final long serialVersionUID = 1L; diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquManu.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquManu.java index c514d6b6..318581ca 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquManu.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquManu.java @@ -31,8 +31,8 @@ public class EquManu @Excel(name = "厂商简介") private String description; - /** 联系人ID */ - @Excel(name = "联系人ID") + /** 联系人*/ + @Excel(name = "联系人") private String contactBy; /** 联系方式 */ diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquRouting.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquRouting.java index 3982896b..c3a24392 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquRouting.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquRouting.java @@ -14,7 +14,7 @@ import org.apache.ibatis.annotations.Mapper; * @date 2025-08-15 */ @Data -public class EquRouting extends BaseEntity +public class EquRouting { private static final long serialVersionUID = 1L; diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquSupplier.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquSupplier.java index d627d1a5..b67e0985 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquSupplier.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquSupplier.java @@ -41,8 +41,8 @@ public class EquSupplier @Excel(name = "l联系方式") private String contactWay; /** 联系人姓名 */ - @Excel(name = "创建人id") - private long createBy; + @Excel(name = "创建人") + private String createBy; @@ -117,12 +117,12 @@ public class EquSupplier return status; } - public Long getCreateBy() + public String getCreateBy() { return createBy; } - public void setCreateBy(Long createBy) + public void setCreateBy(String createBy) { this.createBy = createBy; } diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquVeneer.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquVeneer.java index b45d8e71..b5195d57 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquVeneer.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquVeneer.java @@ -14,7 +14,7 @@ import org.apache.ibatis.annotations.Mapper; * @date 2025-08-15 */ @Data -public class EquVeneer extends BaseEntity +public class EquVeneer { private static final long serialVersionUID = 1L; @@ -34,8 +34,7 @@ public class EquVeneer extends BaseEntity @Excel(name = "采集id") private String equGatherId; - @Excel(name = "采集+预警同一批标志") - private String batchId; + public void setId(String id) { diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/AlertStatisticDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/AlertStatisticDto.java index 3fe6246c..c53a4876 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/AlertStatisticDto.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/AlertStatisticDto.java @@ -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 typeCount; - - // 按等级统计 - private Map levelCount; - // 本年度预警次数 + private List typeCount = new ArrayList<>(); + private List levelCount = new ArrayList<>(); private Integer yearCount; - - // 本月预警次数 private Integer monthCount; + + public List getTypeCount() { return typeCount; } + public void setTypeCount(List typeCount) { this.typeCount = typeCount; } + + public List getLevelCount() { return levelCount; } + public void setLevelCount(List 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; } + } + 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 22de5c60..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,18 +16,17 @@ 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) */ private String equType; - /** 设备名称 (name, varchar) */ private String name; /** 安装位置 ID (location, varchar) */ private String location; - - - /** 起始时间 (min_time) */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date minTime; @@ -40,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/EquMonitorHomeDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquMonitorHomeDto.java new file mode 100644 index 00000000..b49b12df --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquMonitorHomeDto.java @@ -0,0 +1,22 @@ +package com.alops.system.domain.dto; + +import lombok.Data; + +import java.util.Date; + +/** + * 首页展示:设备监测简要信息 + */ +@Data +public class EquMonitorHomeDto { + private String id; + private String equNumber; //设备编号 + 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; // 采集时间 +} diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquSupplierAddDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquSupplierAddDto.java new file mode 100644 index 00000000..521f48d6 --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquSupplierAddDto.java @@ -0,0 +1,17 @@ +package com.alops.system.domain.dto; + +import lombok.Data; + +/** + * 新增供应商 DTO + * 只包含前端可传的字段 + */ +@Data +public class EquSupplierAddDto { + + private String name; + private String description; + private String contactBy; + private String contactWay; + private Long status; +} diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquSupplierUpdateDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquSupplierUpdateDto.java new file mode 100644 index 00000000..aa0bbcbd --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/EquSupplierUpdateDto.java @@ -0,0 +1,13 @@ +package com.alops.system.domain.dto; + +import lombok.Data; + +@Data +public class EquSupplierUpdateDto { + private String contactBy; + private String contactWay; + private String description; + private String id; + private String name; + private Long status; +} diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/LevelCountDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/LevelCountDto.java new file mode 100644 index 00000000..ed5e76dd --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/LevelCountDto.java @@ -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; } +} diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorHistoryDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorHistoryDto.java index 58c2d0f7..21e0d451 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorHistoryDto.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorHistoryDto.java @@ -7,9 +7,9 @@ import java.util.List; public class MonitorHistoryDto { // 返回给前端的字段 private List temperatureList = new ArrayList<>(); - private List involtageList = new ArrayList<>(); - private List outvoltageList = new ArrayList<>(); + private List memoryList = new ArrayList<>(); + private List cpuList = new ArrayList<>(); + private List healthList = new ArrayList<>(); private List timeList = new ArrayList<>(); - - } + diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorLastDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorLastDto.java index 9f50c91d..3a571f1f 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorLastDto.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorLastDto.java @@ -1,19 +1,25 @@ package com.alops.system.domain.dto; import lombok.Data; + +import java.sql.Blob; import java.util.Date; @Data public class MonitorLastDto { // equ_gather 表 - private Integer contWorkPeriod; + private String contWorkPeriod; private Float fanSpeed; private Float cpuUtilization; private Float memoryUtilization; private String health; + private String volIn; + private String volOut; + private String temperature; // equ_base 表 - private Long id; + private String id; + private String equNumber; private String name; private String version; private String deviceLevel; @@ -21,17 +27,24 @@ public class MonitorLastDto { private String location; private Date installDate; private String inCharge; - private Integer failureFrequency; - private Integer warranty; + private String status; + private int warranty; + private String equImage; // equ_type - private String equType; + private String equTypeId; + private String equTypeName; // equ_manu - private String manufacture; - private String manufactureContactBy; - private String manufactureContactWay; + private String equManuId; + private String equManuName; + private String ContactBy; + private String ContactWay; // equ_supplier private String supplierId; + private String supplierName; + + private int AlertCount; + private String unhandledAlertCount; } diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorListDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorListDto.java index 3bb98c55..6c146d16 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorListDto.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorListDto.java @@ -11,15 +11,23 @@ import java.sql.Blob; public class MonitorListDto { private String id; private String name; + private String ip; + private String equTypeId; + private String equTypeName; + private String equManuId; + private String equManuName; private String version; private String deviceLevel; private String location; private String status; - private Integer failureFrequency; - private Blob equImage; // 监控指标 private Float cpuUtilization; private String health; - private Integer fanSpeed; + private int fanSpeed; + private String contWorkPeriod; + + private int AlertCount;; + private int unhandledAlertCount; + } diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorStatisticDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorStatisticDto.java index cc27f6f1..6f9fb488 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorStatisticDto.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/MonitorStatisticDto.java @@ -11,6 +11,11 @@ public class MonitorStatisticDto { private String equTypeName; // 设备类型名称 private List devices; // 属于该类型的设备列表 + // 新增统计数量字段 + private Integer count; + // 每类型占总设备数量的百分比 + private Double percentage; + @Data public static class DeviceSimpleInfo { private String id; diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/TypeCountDto.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/TypeCountDto.java new file mode 100644 index 00000000..9b120e25 --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/TypeCountDto.java @@ -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; } +} 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/AlertRuleVo.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/AlertRuleVo.java new file mode 100644 index 00000000..b790d1f8 --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/AlertRuleVo.java @@ -0,0 +1,75 @@ +package com.alops.system.domain.vo; + +import com.alops.common.annotation.Excel; +import com.alops.common.core.domain.BaseEntity; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; + +import java.util.Date; + +@Data +public class AlertRuleVo extends BaseEntity { + + private static final long serialVersionUID = 1L; + + /** 主键 */ + private Long id; + + /** 预警规则名称 */ + @Excel(name = "预警规则名称") + private String ruleName; + + /** 预警级别 */ + @Excel(name = "预警级别") + private Long severity; + + /** 预警方式(email/message) */ + @Excel(name = "预警方式(email/message)") + private String alertWay; + + /** 预警到站方 */ + @Excel(name = "预警到站方") + private String alertStation; + + /** 预警规则内容描述 */ + @Excel(name = "预警规则内容描述") + private String description; + + /** 启用状态(0为启用) */ + @Excel(name = "启用状态", readConverterExp = "0=为启用") + private Integer enable; + + /** 表格名称 */ + @Excel(name = "表格名称") + private String tableName; + + /** 预警sql语句查询 */ + @Excel(name = "预警sql语句查询") + @JsonIgnore + private String alertSql; + + /** 预警模版(参数用数据库命名法) */ + @Excel(name = "预警模版", readConverterExp = "参=数用数据库命名法") + private String alertTemplate; + + /** 预警类型 */ + @Excel(name = "预警类型") + private String type; + + /** 参数名称 */ + @Excel(name = "参数名称") + private String paramName; + + /** 比较符号 */ + @Excel(name = "比较符号") + private String operator; + + /** 比较值 */ + @Excel(name = "比较值") + private String compareValue; + + + + +} 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/homeEquAlertMessageVo.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/homeEquAlertMessageVo.java new file mode 100644 index 00000000..81d7bcf9 --- /dev/null +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/homeEquAlertMessageVo.java @@ -0,0 +1,37 @@ +package com.alops.system.domain.vo; + +import com.alops.common.annotation.Excel; +import lombok.Data; + +import java.util.Date; + +@Data +public class homeEquAlertMessageVo { + + + /** 预警级别(1-5级) */ + @Excel(name = "预警级别(1-5级)") + private Long level; + + /** 发生时间 */ + @Excel(name = "发生时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date occurTime; + + + @Excel(name = "预警信息") + private String message; + + + /** 处理状态(open、in_progress_closed) */ + @Excel(name = "处理状态") + private String status; + + @Excel(name = "处理状态") + private String name; + + @Excel(name = "处理状态") + private String location; + + + +} 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 63602ba3..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; @@ -59,7 +65,7 @@ public class queryEquBaseVO { /** 安装日期 */ @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "安装日期", width = 30, dateFormat = "yyyy-MM-dd") + @Excel(name = "安装日期", width = 30) private Date installDate; /** 预计年限(年) */ @@ -78,8 +84,8 @@ public class queryEquBaseVO { @Excel(name = "健康度") private BigDecimal health; /** 添加日期 */ - @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "添加日期", width = 30, dateFormat = "yyyy-MM-dd") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "添加日期", width = 30) private Date createDate; /** 启用状态 */ @Excel(name = "启用状态") @@ -88,6 +94,12 @@ public class queryEquBaseVO { @Excel(name = "累积故障次数") private String deviceLevel; + @Excel(name = "设备图片") + private String equImage; + + @Excel(name = "设备编号") + private String equNumber; + public void setId(String id) { @@ -226,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/job/GatherJob.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/job/GatherJob.java index 2d516c6f..d7a376d6 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/job/GatherJob.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/job/GatherJob.java @@ -39,7 +39,23 @@ public class GatherJob implements Job { try { if (rule == null) return; - // 按频率判断时间范围 + // 1.状态为4时取消调度任务 + if (rule.getStatus() == 4) { + Scheduler scheduler = context.getScheduler(); + JobKey jobKey = context.getJobDetail().getKey(); + scheduler.deleteJob(jobKey); + String Content=String.format("任务执行完此次,已取消后续任务"); + + iAlertSenderService.sendInternalMessage( Content,"2" ); + log.info("规则[{}] 已标记为取消状态(4),对应定时任务已删除: {}", rule.getId(), jobKey); + + return; + } + // 2.设置状态为执行中 + rule.setStatus(1); + scheduleRulesMapper.updateScheduleRules(rule); + + // 3.判断是否执行完成 按频率判断时间范围 if (rule.getRuleType() == 0) { Date start = rule.getStartTime(); Date end = rule.getEndTime(); @@ -48,7 +64,6 @@ public class GatherJob implements Job { if ( now.after(end)) { rule.setStatus(2); // 超出范围标记完成 scheduleRulesMapper.updateScheduleRules(rule); - return; } } @@ -58,10 +73,17 @@ public class GatherJob implements Job { iScheduleRulesService.executeImmediately(); // 执行成功 - if (rule.getRuleType() == 0 || rule.getRuleType() == 1) { + if (rule.getRuleType() == 1 ) { rule.setStatus(2); + + String Content=String.format("任务执行完成", + rule.getId(), rule.getRuleName()); + + iAlertSenderService.sendInternalMessage( Content,"2" ); + scheduleRulesMapper.updateScheduleRules(rule); } - scheduleRulesMapper.updateScheduleRules(rule); + + } catch (Exception e) { //执行失败是不会有采集信息和预警信息的 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 98050cf4..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,6 +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.homeEquAlertMessageVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -44,6 +45,8 @@ public interface AlertMessageMapper * @return 故障统计集合 */ public List selectAlertMessageList(AlertDto alertMessage); + + public List selectStaticAlertMessageList(); public ArrayList selectAlertMessageByEquId(Long Equid); /** diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertRuleMapper.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertRuleMapper.java index b0dc7705..6c51a8e4 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertRuleMapper.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/AlertRuleMapper.java @@ -2,6 +2,7 @@ package com.alops.system.mapper; import com.alops.system.domain.AlertRule; import com.alops.system.domain.dto.AlertRuleAddDto; +import com.alops.system.domain.vo.AlertRuleVo; import org.apache.ibatis.annotations.Mapper; import org.springframework.data.repository.query.Param; @@ -26,15 +27,15 @@ public interface AlertRuleMapper * @param id 【请填写功能名称】主键 * @return 【请填写功能名称】 */ - public AlertRule selectAlertRuleById(Long id); - + public AlertRuleVo selectAlertRuleById(Long id); + public AlertRule selectAlertRuleByToId(Long id); /** * 查询【请填写功能名称】列表 * * @param alertRule 【请填写功能名称】 * @return 【请填写功能名称】集合 */ - public List selectAlertRuleList(AlertRule alertRule); + public List selectAlertRuleList(AlertRule alertRule); /** * 新增【请填写功能名称】 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 bddf5e62..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 @@ -4,19 +4,13 @@ import java.util.List; import java.util.Map; import com.alops.system.domain.EquBase; -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.dto.*; 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接口 @@ -27,6 +21,12 @@ import java.util.Map; @Mapper public interface EquBaseMapper { + + + /** + * 查询状态为1的设备及其最新采集信息和类型名称 + */ + List getEquipmentAssessmentList(); int incrementCollectCount(@Param("ids") List ids); @Update("DELETE FROM equ_interface") @@ -63,7 +63,13 @@ public interface EquBaseMapper MonitorLastDto selectEquMonitorById(String id); List> selectEquMonitorByIdToList(EquBaseQueryDto queryDto); - List selectEquMonitorList(EquBaseQueryDto equBaseQueryDto); + List selectEquMonitorListPaged(); + + /** + * 查询每台设备的最新监测信息(首页展示用) + */ + List selectLatestEquMonitorList(); + /**分类统计界面信息 -YY**/ List selectEquStatisticByType(); 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 03ca8cf9..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,6 +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.homeEquAlertMessageVo; import java.util.List; @@ -30,7 +31,7 @@ public interface IAlertMessageService * @return 故障统计集合 */ public List selectAlertMessageList(AlertDto alertMessage); - + public List selectStaticAlertMessageList(); public List selectAlertMessageListByEquId(Long equId); /** diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertRuleService.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertRuleService.java index ee90857d..0ec2269b 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertRuleService.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IAlertRuleService.java @@ -2,6 +2,7 @@ package com.alops.system.service; import com.alops.system.domain.AlertRule; import com.alops.system.domain.dto.AlertRuleAddDto; +import com.alops.system.domain.vo.AlertRuleVo; import java.util.List; import java.util.Map; @@ -15,7 +16,7 @@ import java.util.Map; public interface IAlertRuleService { - public AlertRule saveRule(AlertRuleAddDto dto); + public AlertRuleVo saveRule(AlertRuleAddDto dto); public AlertRule updateRule(AlertRuleAddDto dto); @@ -40,7 +41,7 @@ public interface IAlertRuleService * @param alertRule 【请填写功能名称】 * @return 【请填写功能名称】集合 */ - public List selectAlertRuleList(AlertRule alertRule); + public List selectAlertRuleList(AlertRule alertRule); /** * 新增【请填写功能名称】 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 d54cfde9..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(); @@ -60,7 +62,12 @@ public interface IEquBaseService */ public List selectEquBaseList(EquBaseQueryDto equBase); - public List selectEquMonitorList(EquBaseQueryDto equBaseQueryDto); + public List selectEquMonitorListPaged(); + + /** + * 查询每台设备的最新监测信息(首页展示用) + */ + List selectLatestEquMonitorList(); /**分类统计信息**/ List selectEquStatisticByType(); diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquSupplierService.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquSupplierService.java index 863d2b95..2ca7b09b 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquSupplierService.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquSupplierService.java @@ -2,6 +2,8 @@ package com.alops.system.service; import java.util.List; import com.alops.system.domain.EquSupplier; +import com.alops.system.domain.dto.EquSupplierAddDto; +import com.alops.system.domain.dto.EquSupplierUpdateDto; import java.util.List; @@ -31,19 +33,17 @@ public interface IEquSupplierService /** * 新增【请填写功能名称】 - * - * @param equSupplier 【请填写功能名称】 + * @return 结果 */ - public int insertEquSupplier(EquSupplier equSupplier); + public int insertEquSupplier(EquSupplierAddDto dto); /** * 修改【请填写功能名称】 - * - * @param equSupplier 【请填写功能名称】 + * * @return 结果 */ - public int updateEquSupplier(EquSupplier equSupplier); + public int updateEquSupplier(EquSupplierUpdateDto updateDto); /** * 批量删除【请填写功能名称】 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..8843a655 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,7 +21,9 @@ public interface IScheduleRulesService - public AjaxResult executeRule(ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException; + public Boolean checkRunningOrWaitingRules() throws SchedulerException; + + public Boolean 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/AlertLaunchServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertLaunchServiceImpl.java index 70504743..ea5c0aec 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertLaunchServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertLaunchServiceImpl.java @@ -153,7 +153,7 @@ public class AlertLaunchServiceImpl implements IAlertLaunchService { String msgdes = fillTemplate(rule.getAlertTemplate(), row, rule); msg.setBatch(currentBatch); - + msg.setMessage(msgdes); messages.add(msg); msgs.add(msgdes); @@ -213,7 +213,7 @@ public class AlertLaunchServiceImpl implements IAlertLaunchService { // 3. SQL:取每台设备最新记录和次新记录,比较该字段是否变化,并关联设备类型 String sql = - "SELECT g1.*, t.name AS equ_type,b.name AS equ_name" + + "SELECT g1.*, t.name AS equ_type,b.name AS equ_name,b.equ_number" + "FROM equ_gather g1 " + "JOIN equ_gather g2 ON g1.equ_id = g2.equ_id " + "JOIN equ_base b ON g1.equ_id = b.id " + 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 5921383b..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; @@ -10,6 +9,9 @@ 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.homeEquAlertMessageVo; import com.alops.system.mapper.AlertMessageMapper; import com.alops.system.service.IAlertMessageService; import org.springframework.beans.factory.annotation.Autowired; @@ -51,6 +53,12 @@ public class AlertMessageServiceImpl implements IAlertMessageService return alertMessageMapper.selectAlertMessageList(alertMessage); } + @Override + public List selectStaticAlertMessageList(){ + + return alertMessageMapper.selectStaticAlertMessageList(); + } + @Override public List selectAlertMessageListByEquId(Long equId) { @@ -66,18 +74,18 @@ public class AlertMessageServiceImpl implements IAlertMessageService AlertStatisticDto dto = new AlertStatisticDto(); // 按设备类型统计 - Map typeMap = new HashMap<>(); for (Map 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 levelMap = new HashMap<>(); for (Map 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 +98,8 @@ public class AlertMessageServiceImpl implements IAlertMessageService return dto; } - /** + + /** * 新增故障统计 * * @param alertMessage 故障统计 diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java index 46d971ed..bad959f0 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/AlertRuleServiceImpl.java @@ -8,6 +8,7 @@ import com.alops.common.utils.SecurityUtils; import com.alops.system.domain.AlertRule; import com.alops.system.domain.AlertRuleCondition; import com.alops.system.domain.dto.AlertRuleAddDto; +import com.alops.system.domain.vo.AlertRuleVo; import com.alops.system.mapper.AlertRuleConditionMapper; import com.alops.system.mapper.AlertRuleMapper; import com.alops.system.service.IAlertRuleService; @@ -37,7 +38,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService */ @Override - public AlertRule saveRule(AlertRuleAddDto dto) { + public AlertRuleVo saveRule(AlertRuleAddDto dto) { Long userId = SecurityUtils.getLoginUser().getUserId(); AlertRule rule = dto.getAlertRule(); @@ -56,7 +57,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService sql = buildSql(rule, conditions); } rule.setAlertSql(sql); - + rule.setEnable(1); // 插入规则 alertRuleMapper.insertAlertRule(rule); @@ -67,7 +68,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService alertRuleConditionMapper.insertAlertRuleCondition(c); } } - AlertRule fullRule = alertRuleMapper.selectAlertRuleById(rule.getId()); + AlertRuleVo fullRule = alertRuleMapper.selectAlertRuleById(rule.getId()); return fullRule; } @@ -104,14 +105,14 @@ public class AlertRuleServiceImpl implements IAlertRuleService alertRuleConditionMapper.insertAlertRuleCondition(c); } } - AlertRule fullRule = alertRuleMapper.selectAlertRuleById(rule.getId()); + AlertRule fullRule = alertRuleMapper.selectAlertRuleByToId(rule.getId()); return fullRule; } @Override public AlertRuleAddDto selectDetailAlertRuleById(Long id) { // 1. 查询主表 - AlertRule rule = alertRuleMapper.selectAlertRuleById(id); + AlertRule rule = alertRuleMapper.selectAlertRuleByToId(id); if (rule == null) { return null; } @@ -140,7 +141,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService if ("equ_gather".equalsIgnoreCase(rule.getTableName())) { // equ_gather 作为主表 - sql.append("g.*, t.name AS equ_type ,b.name AS equ_name") + sql.append("g.*, t.name AS equ_type ,b.name AS equ_name,b.equ_number ") .append("FROM equ_gather g ") .append("JOIN equ_base b ON g.equ_id = b.id ") .append("JOIN equ_type t ON b.equ_type = t.id ") // ★ 新增关联 @@ -153,7 +154,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService .append(buildConditionsSql(conditions)); } else { // 其他表,需要连 equ_gather → equ_base → equ_type - sql.append("src.*, g.equ_id, t.name AS equ_type,b.name AS equ_name ") + sql.append("src.*, g.equ_id, t.name AS equ_type,b.name AS equ_name,b.equ_number ") .append("FROM ").append(rule.getTableName()).append(" src ") .append("JOIN equ_gather g ON src.equ_gather_id = g.id ") .append("JOIN equ_base b ON g.equ_id = b.id ") @@ -316,7 +317,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService @Override public AlertRule selectAlertRuleById(Long id) { - return alertRuleMapper.selectAlertRuleById(id); + return alertRuleMapper.selectAlertRuleByToId(id); } /** @@ -326,7 +327,7 @@ public class AlertRuleServiceImpl implements IAlertRuleService * @return 【请填写功能名称】 */ @Override - public List selectAlertRuleList(AlertRule alertRule) + public List selectAlertRuleList(AlertRule alertRule) { return alertRuleMapper.selectAlertRuleList(alertRule); } 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 daf816bf..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,16 +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.EquSupplier; -import com.alops.system.domain.EquType; 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; @@ -55,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; /** @@ -110,14 +155,16 @@ public class EquBaseServiceImpl implements IEquBaseService MonitorHistoryDto dto = new MonitorHistoryDto(); for (Map row : rows) { dto.getTemperatureList().add(row.get("temperature_value") != null ? ((Number) row.get("temperature_value")).floatValue() : null); - dto.getInvoltageList().add(row.get("involtage_value") != null ? ((Number) row.get("involtage_value")).floatValue() : null); - dto.getOutvoltageList().add(row.get("outvoltage_value") != null ? ((Number) row.get("outvoltage_value")).floatValue() : null); - dto.getTimeList().add(row.get("gather_time").toString()); + dto.getMemoryList().add(row.get("memory_value") != null ? ((Number) row.get("memory_value")).floatValue() : null); + dto.getCpuList().add(row.get("cpu_value") != null ? ((Number) row.get("cpu_value")).floatValue() : null); + dto.getHealthList().add(row.get("health_value") != null ? ((Number) row.get("health_value")).floatValue() : null); + dto.getTimeList().add(row.get("gather_time") != null ? row.get("gather_time").toString() : null); } return dto; } + /** * 查询设备基本信息列表 * @@ -131,21 +178,101 @@ public class EquBaseServiceImpl implements IEquBaseService } /** - * 查询多台显示界面的单独信息 + * 查询多台设备的最新监测信息 + **/ + @Override + public List selectEquMonitorListPaged() { + return equBaseMapper.selectEquMonitorListPaged(); + } + /** + * 查询多台设备的最新监测信息首页展示 **/ @Override - public List selectEquMonitorList(EquBaseQueryDto equBaseQueryDto) { - return equBaseMapper.selectEquMonitorList(equBaseQueryDto); + public List selectLatestEquMonitorList() { + return equBaseMapper.selectLatestEquMonitorList(); } + /** * 设备类型分类统计信息 **/ + @Override public List selectEquStatisticByType() { - return equBaseMapper.selectEquStatisticByType(); + List list = equBaseMapper.selectEquStatisticByType(); + if (list == null || list.isEmpty()) { + return list; + } + + // 计算每种类型的数量 + int totalCount = 0; + for (MonitorStatisticDto dto : list) { + int count = (dto.getDevices() != null) ? dto.getDevices().size() : 0; + dto.setCount(count); + totalCount += count; + } + + // 计算百分比 + for (MonitorStatisticDto dto : list) { + if (totalCount > 0) { + double percent = (dto.getCount() * 100.0) / totalCount; + dto.setPercentage(Math.round(percent * 100.0) / 100.0); // 保留两位小数 + } else { + dto.setPercentage(0.0); + } + } + this.totalDeviceCount = totalCount; // 注意:你可以在 service 中定义字段存储 + return list; } + // 在类中增加: + private int totalDeviceCount; + public int getTotalDeviceCount() { + 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; + }; + } /** @@ -160,6 +287,7 @@ public class EquBaseServiceImpl implements IEquBaseService if (equBase.getCreateDate() == null) { equBase.setCreateDate(new Date()); } + equBase.setId(UUID.randomUUID().toString()); equBase.setCreateBy(SecurityUtils.getLoginUser().getUserId()); return equBaseMapper.insertEquBase(equBase); } diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquManuServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquManuServiceImpl.java index 875a9c5d..01f63a2d 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquManuServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquManuServiceImpl.java @@ -59,7 +59,8 @@ public class EquManuServiceImpl implements IEquManuService { equManu.setId(UUID.randomUUID().toString()); equManu.setCreateDate(new Date()); - Long userId = SecurityUtils.getLoginUser().getUserId(); + String userName = SecurityUtils.getLoginUser().getUser().getUserName(); + equManu.setCreateBy(userName); return equManuMapper.insertEquManu(equManu); } @@ -72,7 +73,8 @@ public class EquManuServiceImpl implements IEquManuService @Override public int updateEquManu(EquManu equManu) { - Long userId = SecurityUtils.getLoginUser().getUserId(); + String userName = SecurityUtils.getLoginUser().getUser().getUserName(); + equManu.setCreateBy(userName); return equManuMapper.updateEquManu(equManu); } diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquSupplierServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquSupplierServiceImpl.java index 86ef3093..7f5ec8a7 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquSupplierServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquSupplierServiceImpl.java @@ -2,8 +2,12 @@ package com.alops.system.service.impl; import java.util.Date; import java.util.List; +import java.util.UUID; import com.alops.common.utils.DateUtils; +import com.alops.common.utils.SecurityUtils; +import com.alops.system.domain.dto.EquSupplierAddDto; +import com.alops.system.domain.dto.EquSupplierUpdateDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.alops.system.mapper.EquSupplierMapper; @@ -53,26 +57,52 @@ public class EquSupplierServiceImpl implements IEquSupplierService /** * 新增【请填写功能名称】 - * - * @param equSupplier 【请填写功能名称】 + * * @return 结果 */ @Override - public int insertEquSupplier(EquSupplier equSupplier) + public int insertEquSupplier(EquSupplierAddDto dto) { - equSupplier.setCreateTime(new Date()); + EquSupplier equSupplier = new EquSupplier(); + + // DTO 转换到实体 + equSupplier.setId(UUID.randomUUID().toString()); // 自动生成 id + equSupplier.setName(dto.getName()); + equSupplier.setDescription(dto.getDescription()); + equSupplier.setContactBy(dto.getContactBy()); + equSupplier.setContactWay(dto.getContactWay()); + + equSupplier.setCreateTime(new Date()); // 自动生成创建时间 + equSupplier.setStatus(dto.getStatus()); + + String userName = SecurityUtils.getLoginUser().getUser().getUserName(); + equSupplier.setCreateBy(userName); return equSupplierMapper.insertEquSupplier(equSupplier); } + /** * 修改【请填写功能名称】 * - * @param equSupplier 【请填写功能名称】 + * @return 结果 */ @Override - public int updateEquSupplier(EquSupplier equSupplier) - { + public int updateEquSupplier(EquSupplierUpdateDto updateDto) { + // 将 DTO 转换成 Entity + EquSupplier equSupplier = new EquSupplier(); + equSupplier.setId(updateDto.getId()); + equSupplier.setName(updateDto.getName()); + equSupplier.setDescription(updateDto.getDescription()); + equSupplier.setContactBy(updateDto.getContactBy()); + equSupplier.setContactWay(updateDto.getContactWay()); + equSupplier.setStatus(updateDto.getStatus()); + + // 后端自动设置修改时间 + equSupplier.setCreateTime(new Date()); + + String userName = SecurityUtils.getLoginUser().getUser().getUserName(); + equSupplier.setCreateBy(userName); return equSupplierMapper.updateEquSupplier(equSupplier); } diff --git a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquTypeServiceImpl.java b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquTypeServiceImpl.java index cd95be3d..047158a1 100644 --- a/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquTypeServiceImpl.java +++ b/ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquTypeServiceImpl.java @@ -56,7 +56,8 @@ public class EquTypeServiceImpl implements IEquTypeService public int insertEquType(EquType equType) { equType.setId(UUID.randomUUID().toString()); - Long userId = SecurityUtils.getLoginUser().getUserId(); + String userName = SecurityUtils.getLoginUser().getUser().getUserName(); + equType.setCreateBy(userName); return equTypeMapper.insertEquType(equType); } @@ -69,7 +70,8 @@ public class EquTypeServiceImpl implements IEquTypeService @Override public int updateEquType(EquType equType) { - Long userId = SecurityUtils.getLoginUser().getUserId(); + String userName = SecurityUtils.getLoginUser().getUser().getUserName(); + equType.setCreateBy(userName); return equTypeMapper.updateEquType(equType); } 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 18aa1a24..e4b85269 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 @@ -5,10 +5,7 @@ import java.sql.SQLOutput; import java.sql.Timestamp; import java.time.LocalDateTime; import java.util.*; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; +import java.util.concurrent.*; import java.util.stream.Collectors; import com.alops.common.core.domain.AjaxResult; @@ -25,6 +22,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -57,69 +55,117 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService { @Autowired private MemoryToolService memoryToolService; + @Autowired + private IAlertSenderService iAlertSenderService; private static final Logger log = LoggerFactory.getLogger(ScheduleRulesServiceImpl.class); - @Override - public AjaxResult executeRule(ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException { + @Override + @Transactional(propagation = Propagation.REQUIRES_NEW) + public Boolean checkRunningOrWaitingRules() throws SchedulerException { - // 1. 获取所有正在执行(1)和待执行(0)的规则 List runningOrWaiting = scheduleRulesMapper.selectList(); if (runningOrWaiting!=null) { for (ScheduleRules rule : runningOrWaiting) { switch (rule.getStatus()) { case 1: // 正在执行 log.info("规则[{}]:正在执行上一个任务,等待上一个任务完成……", rule.getId()); - waitTaskFinish(rule.getId()); - log.info("规则[{}]:完成上一个任务任务,开始新的任务…", rule.getId()); if (rule.getRuleType() == 2 || rule.getRuleType() == 1) { rule.setStatus(2); } else if (rule.getRuleType() == 0) { + log.info("改变状态为4"); rule.setStatus(4); } scheduleRulesMapper.updateScheduleRules(rule); - break; + return true; case 0: // 待执行 if (rule.getRuleType() == 0 || rule.getRuleType() == 1) { quartzService.deleteJob(rule.getId()); } rule.setStatus(4); scheduleRulesMapper.updateScheduleRules(rule); - break; + return false; default: - break; + return true; } } } - // 2. 执行新规则 - + return false; + } - //首先存入规则在执行 - Date now = new Date(); - Long userId = SecurityUtils.getLoginUser().getUserId(); - newRule.setCreatedBy(userId); - newRule.setCreatedAt(now); - newRule.setStatus(0); - scheduleRulesMapper.insertScheduleRules(newRule); - switch (newRule.getRuleType().toString()) { - case "2": // 立即执行 - newRule.setStatus(1); - scheduleRulesMapper.updateScheduleRules(newRule); - try { - executeImmediately(); - newRule.setStatus(2); - scheduleRulesMapper.updateScheduleRules(newRule); - return AjaxResult.success("立即执行任务成功:"); // 异常会抛出,前端收到 - } catch (Exception e) { - - newRule.setStatus(3); + @Override + public Boolean executeRule(ScheduleRules newRule) throws SchedulerException, ExecutionException, InterruptedException { + + +// // 1. 获取所有正在执行(1)和待执行(0)的规则 +// List runningOrWaiting = scheduleRulesMapper.selectList(); +// if (runningOrWaiting!=null) { +// for (ScheduleRules rule : runningOrWaiting) { +// switch (rule.getStatus()) { +// case 1: // 正在执行 +// log.info("规则[{}]:正在执行上一个任务,等待上一个任务完成……", rule.getId()); +// waitTaskFinish(rule.getId()); +// log.info("规则[{}]:完成上一个任务任务,开始新的任务…", rule.getId()); +// if (rule.getRuleType() == 2 || rule.getRuleType() == 1) { +// rule.setStatus(2); +// } else if (rule.getRuleType() == 0) { +// rule.setStatus(4); +// } +// scheduleRulesMapper.updateScheduleRules(rule); +// break; +// case 0: // 待执行 +// if (rule.getRuleType() == 0 || rule.getRuleType() == 1) { +// quartzService.deleteJob(rule.getId()); +// } +// rule.setStatus(4); +// scheduleRulesMapper.updateScheduleRules(rule); +// break; +// default: +// break; +// } +// } +// } + // 2. 执行新规则 + try { + Date now = new Date(); + Long userId = SecurityUtils.getLoginUser().getUserId(); + + // 1. 初始化规则 + newRule.setCreatedBy(userId); + newRule.setCreatedAt(now); + newRule.setStatus(0); + scheduleRulesMapper.insertScheduleRules(newRule); // 插入成功与否决定返回值 + + switch (newRule.getRuleType().toString()) { + case "2": // 立即执行 + newRule.setStatus(1); // 执行中 scheduleRulesMapper.updateScheduleRules(newRule); - // 只捕获立即执行异常 - return AjaxResult.error("立即执行任务失败:" + e.getMessage()); - } + // 异步立即执行采集任务 + CompletableFuture.runAsync(() -> { + try { + executeImmediately(); // 实际采集逻辑 + newRule.setStatus(2); // 执行成功 + scheduleRulesMapper.updateScheduleRules(newRule); + + String content = String.format("立即任务 [%s] 执行完成", newRule.getRuleName()); + iAlertSenderService.sendInternalMessage(content, "2"); + + } catch (Exception e) { + newRule.setStatus(3); // 执行失败 + scheduleRulesMapper.updateScheduleRules(newRule); + + String content = String.format("立即任务 [%s] 执行失败:%s", newRule.getRuleName(), e.getMessage()); + try { + iAlertSenderService.sendInternalMessage(content, "2"); + } catch (Exception ne) { + log.error("发送站内信失败: {}", ne.getMessage(), ne); + } + } + }); + break; case "1": // 固定时间 newRule.setStatus(0); scheduleRulesMapper.updateScheduleRules(newRule); @@ -136,10 +182,14 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService { quartzService.createOrUpdateJob(newRule); } break; - default: - throw new IllegalArgumentException("Unsupported rule type"); + default: + throw new IllegalArgumentException("Unsupported rule type"); + } + return true; // 插入和调度成功 + } catch (Exception e) { + log.error("规则设置失败: {}", e.getMessage(), e); + return false; // 插入或调度失败 } - return null; } /** @@ -163,7 +213,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); @@ -172,7 +222,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"); @@ -243,6 +293,7 @@ public class ScheduleRulesServiceImpl implements IScheduleRulesService { // 执行最新预警 iAlertLaunchService.executeImmediateAlerts(); + log.info("采集完一次!!!"); return result; } 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 3230bf97..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 @@ -19,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + @@ -83,7 +84,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ORDER BY am.batch DESC - + + + + + + + + + + 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 646b96a9..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 @@ -9,9 +9,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - + @@ -24,29 +24,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - - - - - - - + - - - - - - - - - - + + + @@ -57,23 +43,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + - + - - + - - + + @@ -91,7 +76,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, name, version, ip, manufacture, location, equ_type, in_charge, install_date, life_cycle, warranty, create_by, create_date, status, device_level, supplier_id from equ_base + select id,equ_number, name, version, ip, manufacture, location, equ_type, in_charge, install_date, life_cycle, warranty, create_by, create_date, status, device_level, supplier_id from equ_base @@ -105,6 +90,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + + @@ -152,100 +181,141 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) tmp ON eg.equ_id = tmp.equ_id AND eg.gather_time = tmp.max_time ) g ON b.id = g.equ_id - - AND b.name LIKE CONCAT('%', #{name}, '%') - - - AND b.location LIKE CONCAT('%', #{location}, '%') - AND b.create_date >= #{minTime} AND b.create_date <= #{maxTime} - - AND b.status = #{status} - - SELECT - b.id, - b.name, - b.version, - b.device_level, - b.location, - b.status, - g.cpu_utilization, - g.health, - g.fan_speed, - b.failure_frequency, - b.equ_image - FROM equ_base b - LEFT JOIN equ_gather g ON b.id = g.equ_id - - g.cpu_utilization is not null - - AND b.equ_type = #{equType} - - - AND b.name LIKE concat('%', #{equName}, '%') - - - AND b.location = #{location} - - - AND b.manufacture = #{manufacture} - - - AND b.in_charge = #{inCharge} - - - AND b.status = #{status} - - - AND b.create_date =]]> #{minTime} - - - AND b.create_date #{maxTime} - - - AND g.health =]]> #{health} - - - ORDER BY g.gather_time desc limit 1 + c.id, + c.name, + c.ip, + c.equTypeId, + c.equTypeName, + c.equManuId, + c.equManuName, + c.version, + c.deviceLevel, + c.location, + c.status, + c.cpuUtilization, + c.health, + c.fanSpeed, + c.contWorkPeriod, + c.unhandledAlertCount, + c.AlertCount + FROM ( + SELECT + b.id, + b.name, + b.ip, + b.equ_type AS equTypeId, + t.name AS equTypeName, + b.manufacture AS equManuId, + m.name AS equManuName, + 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, + (SELECT COUNT(1) + FROM alert_message a + WHERE a.equ_id = b.id AND a.status = 'UNHANDLED') AS unhandledAlertCount, + (SELECT COUNT(1) + FROM alert_message a + WHERE a.equ_id = b.id ) AS AlertCount, + 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 + ) c + WHERE c.rn = 1 + ORDER BY c.id + + + - + SELECT -- 从 equ_gather 表中获取需要填充到List中的数据 g.temperature AS temperature_value, - g.vol_in AS involtage_value, - g.vol_out AS outvoltage_value, + g.memory_utilization AS memory_value, + g.cpu_utilization AS cpu_value, + g.health AS health_value, g.gather_time AS gather_time FROM equ_base b @@ -271,8 +343,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN equ_type t ON b.equ_type = t.id LEFT JOIN equ_gather g ON b.id = g.equ_id - where g.cpu_utilization is not null - and b.id = #{id} + where b.id = #{id} -- 添加时间范围约束 and g.gather_time BETWEEN #{minTime} AND #{maxTime} @@ -352,15 +423,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" name, version, ip, - manufacture, + manufacture, location, - equ_type, + equ_type, in_charge, install_date, life_cycle, warranty, create_by, create_date, + equ_number, status, equ_image, @@ -374,18 +446,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{name}, #{version}, #{ip}, - #{manufacture}, + #{equManuId}, #{location}, - #{equType}, + #{equTypeId}, #{inCharge}, #{installDate}, #{lifeCycle}, #{warranty}, #{createBy}, #{createDate}, - + #{equNumber}, COALESCE(#{status,jdbcType=INTEGER}, 0), - #{equImage,jdbcType=BLOB}, + #{equImage}, COALESCE(#{failureFrequency,jdbcType=BIGINT}, 0), COALESCE(#{gatherFrequency,jdbcType=BIGINT}, 0), #{deviceLevel}, @@ -400,9 +472,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" name = #{name}, version = #{version}, ip = #{ip}, - manufacture = #{manufacture}, + manufacture = #{equManuId}, location = #{location}, - equ_type = #{equType}, + equ_type = #{equTypeId}, in_charge = #{inCharge}, install_date = #{installDate}, life_cycle = #{lifeCycle}, @@ -411,6 +483,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" device_level = #{deviceLevel}, supplier_id = #{supplierId}, equ_image = #{equImage}, + equ_number = #{equNumber}, where id = #{id} diff --git a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquManuMapper.xml b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquManuMapper.xml index a8e0608d..7906ad34 100644 --- a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquManuMapper.xml +++ b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquManuMapper.xml @@ -32,10 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and name like concat('%', #{name}, '%') and description = #{description} - and contact_by = #{contactBy} + and contact_by LIKE CONCAT('%', #{contactBy}, '%') and contact_way = #{contactWay} and create_date = #{createDate} and status = #{status} + and create_by LIKE CONCAT('%', #{createBy}, '%') diff --git a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquSupplierMapper.xml b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquSupplierMapper.xml index 1a8077ee..59f346b3 100644 --- a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquSupplierMapper.xml +++ b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquSupplierMapper.xml @@ -30,9 +30,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and name like concat('%', #{name}, '%') and description = #{description} - and contact_by = #{contactBy} + and contact_by LIKE CONCAT('%', #{contactBy}, '%') and contact_way = #{contactWay} and status = #{status} + and create_by LIKE CONCAT('%', #{createBy}, '%') @@ -42,27 +43,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - insert into equ_supplier - - id, - name, - description, - contact_by, - contact_way, - create_by, - create_time, - status, - - - #{id}, - #{name}, - #{description}, - #{contactBy}, - #{contactWay}, - #{createBy}, - #{createTime}, - #{status}, - + INSERT INTO equ_supplier + (id, name, description, contact_by, contact_way, create_by, create_time, status) + VALUES + (#{id}, #{name}, #{description}, #{contactBy}, #{contactWay}, #{createBy}, #{createTime}, #{status}) + diff --git a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquTypeMapper.xml b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquTypeMapper.xml index a9f2ba48..0001b1e9 100644 --- a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquTypeMapper.xml +++ b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquTypeMapper.xml @@ -33,6 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and description = #{description} and image = #{image} and create_date = #{createDate} + and create_by LIKE CONCAT('%', #{createBy}, '%') diff --git a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquVlanMapper.xml b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquVlanMapper.xml index 9c27c008..0e86ff32 100644 --- a/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquVlanMapper.xml +++ b/ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquVlanMapper.xml @@ -35,7 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select vl.id, g.equ_id, equ_gather_id, main_id, ip_address, subnet_mask, create_time, update_by, vlan_id from equ_vlan vl LEFT JOIN equ_gather g ON vl.equ_gather_id = g.id + select vl.id, g.equ_id as equId, equ_gather_id, main_id, ip_address, subnet_mask, create_time, update_by, vlan_id from equ_vlan vl LEFT JOIN equ_gather g ON vl.equ_gather_id = g.id + +