From cfc19c4f05cb74170d319da0cc86627811fbd215 Mon Sep 17 00:00:00 2001 From: xiaohuo <14141624+dsgfhrh@user.noreply.gitee.com> Date: Tue, 23 Sep 2025 21:44:04 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=A2=84=E8=AD=A6?= =?UTF-8?q?=E7=AE=A1=E6=8E=A7+=E8=AE=BE=E5=A4=87=E6=A1=A3=E6=A1=88+?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AF=E9=87=87=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../equManagement/EquBaseController.java | 185 +++++++--- .../equManagement/EquSupplierController.java | 105 ++++++ .../ScheduleRulesController.java | 177 +++++---- .../AlertMessageController.java | 139 ++++--- .../AlertRuleController.java | 175 ++++----- .../alops/common/utils/html/EscapeUtil.java | 12 +- ALOps_sys_backend/alops-system/pom.xml | 15 + .../com/alops/system/domain/AlertMessage.java | 66 +--- .../com/alops/system/domain/AlertRule.java | 4 + .../system/domain/AlertRuleCondition.java | 5 +- .../alops/system/domain/DictAlarmParam.java | 2 +- .../java/com/alops/system/domain/EquBase.java | 157 ++++---- .../com/alops/system/domain/EquGather.java | 3 +- .../com/alops/system/domain/EquInterface.java | 3 + .../com/alops/system/domain/EquRouting.java | 4 +- .../com/alops/system/domain/EquSupplier.java | 125 +++++++ .../java/com/alops/system/domain/EquValn.java | 3 +- .../com/alops/system/domain/EquVeneer.java | 6 +- .../java/com/alops/system/domain/EquVlan.java | 4 +- .../alops/system/domain/InternalMessage.java | 4 + .../alops/system/domain/ScheduleRules.java | 104 ++---- .../com/alops/system/domain/dto/AlertDto.java | 15 + .../system/domain/dto/EquBaseQueryDto.java | 48 +-- .../alops/system/domain/vo/RolePickerVo.java | 11 + .../alops/system/domain/vo/dropDownVo.java | 13 + .../com/alops/system/domain/vo/imageVo.java | 8 + .../system/domain/vo/queryEquBaseVO.java | 97 ++--- .../java/com/alops/system/job/GatherJob.java | 101 +++++ .../system/mapper/AlertMessageMapper.java | 8 +- .../mapper/AlertRuleConditionMapper.java | 10 + .../alops/system/mapper/AlertRuleMapper.java | 5 +- .../system/mapper/DictAlarmParamMapper.java | 2 +- .../alops/system/mapper/EquBaseMapper.java | 38 +- .../alops/system/mapper/EquManuMapper.java | 2 + .../system/mapper/EquSupplierMapper.java | 67 ++++ .../alops/system/mapper/EquTypeMapper.java | 5 + .../system/mapper/ScheduleRulesMapper.java | 9 +- .../alops/system/mapper/SysRoleMapper.java | 3 + .../system/service/IAlertLaunchService.java | 3 +- .../system/service/IAlertMessageService.java | 5 +- .../system/service/IAlertRuleService.java | 13 +- .../system/service/IAlertSenderService.java | 1 + .../service/IDictAlarmParamService.java | 2 +- .../alops/system/service/IEquBaseService.java | 18 +- .../system/service/IEquSupplierService.java | 62 ++++ .../alops/system/service/IQuartzService.java | 12 + .../system/service/IScheduleRulesService.java | 9 +- .../alops/system/service/ISysRoleService.java | 3 + .../system/service/MemoryToolService.java | 1 + .../service/impl/AlertLaunchServiceImpl.java | 153 ++++++-- .../service/impl/AlertMessageServiceImpl.java | 19 +- .../service/impl/AlertRuleServiceImpl.java | 122 +++++- .../service/impl/AlertSenderServiceImpl.java | 12 +- .../impl/ConvertRawValueServiceImpl.java | 4 +- .../impl/DictAlarmParamServiceImpl.java | 4 +- .../service/impl/EquBaseServiceImpl.java | 51 ++- .../service/impl/EquSupplierServiceImpl.java | 99 +++++ .../service/impl/EquTypeServiceImpl.java | 5 +- .../service/impl/MemoryToolServiceImpl.java | 2 + .../system/service/impl/QuartzService.java | 105 ++++++ .../impl/ScheduleRulesServiceImpl.java | 349 +++++++++++++++--- .../system/service/impl/SnmpServiceImpl.java | 4 +- .../service/impl/SysRoleServiceImpl.java | 8 +- .../mapper/system/AlertMessageMapper.xml | 100 +++-- .../system/AlertRuleConditionMapper.xml | 22 ++ .../mapper/system/AlertRuleMapper.xml | 66 ++-- .../mapper/system/DictAlarmParamMapper.xml | 1 - .../resources/mapper/system/EquBaseMapper.xml | 219 ++++++----- .../mapper/system/EquGatherMapper.xml | 1 + .../mapper/system/EquInterfaceMapper.xml | 1 + .../resources/mapper/system/EquManuMapper.xml | 8 + .../mapper/system/EquRoutingMapper.xml | 1 + .../mapper/system/EquSupplierMapper.xml | 92 +++++ .../resources/mapper/system/EquTypeMapper.xml | 9 + .../mapper/system/EquVeneerMapper.xml | 1 + .../resources/mapper/system/EquVlanMapper.xml | 1 + .../mapper/system/InternalMessageMapper.xml | 1 + .../mapper/system/ScheduleRulesMapper.xml | 64 ++-- .../resources/mapper/system/SysRoleMapper.xml | 14 + 79 files changed, 2464 insertions(+), 943 deletions(-) create mode 100644 ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquSupplierController.java create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/EquSupplier.java create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/dto/AlertDto.java create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/RolePickerVo.java create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/dropDownVo.java create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/domain/vo/imageVo.java create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/job/GatherJob.java create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/mapper/EquSupplierMapper.java create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IEquSupplierService.java create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/IQuartzService.java create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/EquSupplierServiceImpl.java create mode 100644 ALOps_sys_backend/alops-system/src/main/java/com/alops/system/service/impl/QuartzService.java create mode 100644 ALOps_sys_backend/alops-system/src/main/resources/mapper/system/EquSupplierMapper.xml 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 cd4ed9bc..9db1ac4c 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,8 +1,8 @@ package com.alops.web.controller.equManagement; -import java.util.HashMap; +import java.io.IOException; import java.util.List; -import java.util.Map; +import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import com.alops.common.annotation.Log; @@ -15,111 +15,186 @@ import com.alops.system.domain.EquBase; import com.alops.system.domain.dto.EquBaseQueryDto; import com.alops.system.domain.vo.queryEquBaseVO; import com.alops.system.service.IEquBaseService; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.http.MediaType; 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.*; +import org.springframework.web.multipart.MultipartFile; /** * 设备基本信息Controller * * @author ruoyi - * @date 2025-08-01 + * @date 2025-09-19 */ @RestController -@RequestMapping("/equipment") +@RequestMapping("/device/files") public class EquBaseController extends BaseController { @Autowired private IEquBaseService equBaseService; + + /** * 查询设备基本信息列表 */ - @PreAuthorize("@ss.hasPermi('equipment:base:queryByVO')") - @GetMapping("/queryByVO") - @ApiOperation("查询符合参数设备信息") - public AjaxResult list(EquBaseQueryDto equBaseQueryDto ) { + @PreAuthorize("@ss.hasPermi('device:files:list')") + @PostMapping("/list") + @ApiOperation("查询多个设备信息") + public TableDataInfo list(@RequestBody EquBaseQueryDto equBase) + { startPage(); - List list = equBaseService.selectEquBaseList(equBaseQueryDto); - TableDataInfo tableDataInfo = getDataTable(list); - Map data = new HashMap<>(); - data.put("total", tableDataInfo.getTotal()); - data.put("rows", tableDataInfo.getRows()); - return AjaxResult.success("查询成功", data); + List list = equBaseService.selectEquBaseList(equBase); + return getDataTable(list); } -// @PreAuthorize("@ss.hasPermi('equipment:base:list')") -// @GetMapping("/list") -// public TableDataInfo list(EquBase equBase) +// /** +// * 导出设备基本信息列表 +// */ +// @PreAuthorize("@ss.hasPermi('device:files:export')") +// @Log(title = "设备基本信息", businessType = BusinessType.EXPORT) +// @PostMapping("/export") +// public void export(HttpServletResponse response, EquBase equBase) // { -// startPage(); // List list = equBaseService.selectEquBaseList(equBase); -// return getDataTable(list); +// ExcelUtil util = new ExcelUtil(EquBase.class); +// util.exportExcel(response, list, "设备基本信息数据"); // } - /** - * 导出设备基本信息列表 - */ -// @PreAuthorize("@ss.hasPermi('equipment:base:export')") -// @Log(title = "设备档案", businessType = BusinessType.EXPORT) -// @PostMapping("/export") -//// public void export(HttpServletResponse response, EquBaseQueryDto equBaseQueryDto) -//// { -//// List list = equBaseService.selectEquBaseList(equBaseQueryDto); -//// ExcelUtil util = new ExcelUtil(EquBase.class); -//// util.exportExcel(response, list, "设备基本信息数据"); -//// } - /** * 获取设备基本信息详细信息 */ - @PreAuthorize("@ss.hasPermi('equipment:base:query')") + @PreAuthorize("@ss.hasPermi('device:files:query')") @GetMapping(value = "/{id}") + @ApiOperation("查询单个设备信息") public AjaxResult getInfo(@PathVariable("id") String id) { return success(equBaseService.selectEquBaseById(id)); } /** - * 新增设备基本信息 + * 根据设备ID返回图片流 + * 前端直接 */ - @PreAuthorize("@ss.hasPermi('equipment:base:add')") - @Log(title = "设备档案", businessType = BusinessType.INSERT) - @PostMapping("/add") - @ApiOperation("新增设备信息") - public AjaxResult add(@RequestBody EquBase equBase) + + @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(); + + + 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") + @ApiOperation("厂商下拉表") + public AjaxResult getManufacture() { + + return success(equBaseService.selectEquManu()); + } + + + //供应商下拉表 + @PreAuthorize("@ss.hasPermi('device:files:querySupplier')") + @GetMapping( "/supplier") + @ApiOperation("供应商下拉表") + public AjaxResult getSupplier() + { + + return success(equBaseService.selectEquSupp()); + } + //设备类型下拉表 + @PreAuthorize("@ss.hasPermi('device:files:queryEquType')") + @GetMapping( "/equType") + @ApiOperation("设备类型下拉表") + public AjaxResult getEquType() + { + + return success(equBaseService.selectEquType()); + } + + + @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 { + + // 处理图片 + if (file != null && !file.isEmpty()) { + equBase.setEquImage(file.getBytes()); + } + + // 调用 Service 插入数据库 return toAjax(equBaseService.insertEquBase(equBase)); } /** * 修改设备基本信息 */ - @PreAuthorize("@ss.hasPermi('equipment:base:edit')") - @Log(title = "设备档案", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody EquBase equBase) - { + @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 + } + + // 调用 Service 插入数据库 return toAjax(equBaseService.updateEquBase(equBase)); } /** * 删除设备基本信息 */ - @PreAuthorize("@ss.hasPermi('equipment:base:remove')") - @Log(title = "设备档案", businessType = BusinessType.DELETE) + @PreAuthorize("@ss.hasPermi('device:files:remove')") + @Log(title = "设备基本信息", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") + @ApiOperation("删除设备档案信息") public AjaxResult remove(@PathVariable String[] ids) { return toAjax(equBaseService.deleteEquBaseByIds(ids)); } } + + 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 new file mode 100644 index 00000000..2c1f7112 --- /dev/null +++ b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/equManagement/EquSupplierController.java @@ -0,0 +1,105 @@ +package com.alops.web.controller.equManagement; + +import java.util.List; +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.poi.ExcelUtil; +import com.alops.system.domain.EquSupplier; +import com.alops.system.service.IEquSupplierService; +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; + +/** + * 【请填写功能名称】Controller + * + * @author ruoyi + * @date 2025-09-19 + */ +@RestController +@RequestMapping("/system/supplier") +public class EquSupplierController extends BaseController +{ + @Autowired + private IEquSupplierService equSupplierService; + + /** + * 查询【请填写功能名称】列表 + */ + @PreAuthorize("@ss.hasPermi('system:supplier:list')") + @GetMapping("/list") + public TableDataInfo list(EquSupplier equSupplier) + { + startPage(); + List list = equSupplierService.selectEquSupplierList(equSupplier); + return getDataTable(list); + } + + /** + * 导出【请填写功能名称】列表 + */ + @PreAuthorize("@ss.hasPermi('system:supplier:export')") + @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, EquSupplier equSupplier) + { + List list = equSupplierService.selectEquSupplierList(equSupplier); + ExcelUtil util = new ExcelUtil(EquSupplier.class); + util.exportExcel(response, list, "【请填写功能名称】数据"); + } + + /** + * 获取【请填写功能名称】详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:supplier:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") String id) + { + return success(equSupplierService.selectEquSupplierById(id)); + } + + /** + * 新增【请填写功能名称】 + */ + @PreAuthorize("@ss.hasPermi('system:supplier:add')") + @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody EquSupplier equSupplier) + { + return toAjax(equSupplierService.insertEquSupplier(equSupplier)); + } + + /** + * 修改【请填写功能名称】 + */ + @PreAuthorize("@ss.hasPermi('system:supplier:edit')") + @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody EquSupplier equSupplier) + { + return toAjax(equSupplierService.updateEquSupplier(equSupplier)); + } + + /** + * 删除【请填写功能名称】 + */ + @PreAuthorize("@ss.hasPermi('system:supplier:remove')") + @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable String[] ids) + { + return toAjax(equSupplierService.deleteEquSupplierByIds(ids)); + } +} 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 c17a66cb..19a76650 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 @@ -12,18 +12,14 @@ import com.alops.common.enums.BusinessType; import com.alops.common.utils.poi.ExcelUtil; import com.alops.system.domain.ScheduleRules; import com.alops.system.domain.vo.Code; +import com.alops.system.mapper.ScheduleRulesMapper; import com.alops.system.service.IScheduleRulesService; import io.swagger.annotations.ApiOperation; +import org.apache.ibatis.annotations.Mapper; +import org.quartz.SchedulerException; 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 @@ -32,33 +28,55 @@ import org.springframework.web.bind.annotation.RestController; * @date 2025-08-03 */ @RestController -@RequestMapping("/equipmentRule") +@RequestMapping("/device/deviceInformation") public class ScheduleRulesController extends BaseController { @Autowired private IScheduleRulesService scheduleRulesService; + @Mapper + private ScheduleRulesMapper scheduleRulesMapper; /** * 立即执行按钮 */ - @PreAuthorize("@ss.hasPermi('equipment:rules:list')") - @GetMapping("/protoCollect") - @ApiOperation("立即执行") - public AjaxResult protoCollect() throws ExecutionException, InterruptedException { - // 调用 Service 层执行采集,返回业务状态码 - int code = scheduleRulesService.executeImmediately(); - - // 根据返回码生成 AjaxResult - if(code == Code.SUCCESS){ - return AjaxResult.success("采集完成"); - } else if(code == Code.PARTIAL){ - return AjaxResult.warn("部分设备采集失败"); - } else { - return AjaxResult.error("采集失败"); - } + +// public AjaxResult protoCollect() throws ExecutionException, InterruptedException { +// +// +// // 调用 Service 层执行采集,返回业务状态码 +// int code = scheduleRulesService.executeImmediately(); +// +// // 根据返回码生成 AjaxResult +// if(code == Code.SUCCESS){ +// return AjaxResult.success("采集完成"); +// } else if(code == Code.PARTIAL){ +// return AjaxResult.warn("部分设备采集失败"); +// } else { +// return AjaxResult.error("采集失败"); +// } +// } + @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); + + } else { + // 固定时间/按频率:异步处理异常 + scheduleRulesService.executeRule(newRule); + + return AjaxResult.success("任务已调度成功,异常会通过站内信/邮件通知"); + } + } + + /** * 查询定时采集规则列表 */ @@ -71,65 +89,66 @@ public class ScheduleRulesController extends BaseController return getDataTable(list); } - /** - * 导出定时采集规则列表 - */ - @PreAuthorize("@ss.hasPermi('equipment:rules:export')") - @Log(title = "定时采集规则", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, ScheduleRules scheduleRules) - { - List list = scheduleRulesService.selectScheduleRulesList(scheduleRules); - ExcelUtil util = new ExcelUtil(ScheduleRules.class); - util.exportExcel(response, list, "定时采集规则数据"); - } - +// /** +// * 导出定时采集规则列表 +// */ +// @PreAuthorize("@ss.hasPermi('equipment:rules:export')") +// @Log(title = "定时采集规则", businessType = BusinessType.EXPORT) +// @PostMapping("/export") +// public void export(HttpServletResponse response, ScheduleRules scheduleRules) +// { +// List list = scheduleRulesService.selectScheduleRulesList(scheduleRules); +// ExcelUtil util = new ExcelUtil(ScheduleRules.class); +// util.exportExcel(response, list, "定时采集规则数据"); +// } +// /** * 获取定时采集规则详细信息 */ - @PreAuthorize("@ss.hasPermi('equipment:rules:query')") - @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { - return success(scheduleRulesService.selectScheduleRulesById(id)); - } - - - - /** - * 新增定时采集规则 - */ - @PreAuthorize("@ss.hasPermi('equipment:rules:add')") - @Log(title = "定时采集规则", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody ScheduleRules scheduleRules) - { - return toAjax(scheduleRulesService.insertScheduleRules(scheduleRules)); - } - - - - /** - * 修改定时采集规则 - */ - @PreAuthorize("@ss.hasPermi('equipment:rules:edit')") - @Log(title = "定时采集规则", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody ScheduleRules scheduleRules) - { - return toAjax(scheduleRulesService.updateScheduleRules(scheduleRules)); - } - - - /** - * 删除定时采集规则 - */ - @PreAuthorize("@ss.hasPermi('equipment:rules:remove')") - @Log(title = "定时采集规则", businessType = BusinessType.DELETE) - @DeleteMapping("rule/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) + @PreAuthorize("@ss.hasPermi('device:deviceInformation:query')") + @GetMapping(value = "/queryRule") + @ApiOperation("获取规则") + public AjaxResult getInfo() { - return toAjax(scheduleRulesService.deleteScheduleRulesByIds(ids)); + return success(scheduleRulesService.selectScheduleRuleByMaxTime()); } +// +// +// +// /** +// * 新增定时采集规则 +// */ +// @PreAuthorize("@ss.hasPermi('equipment:rules:add')") +// @Log(title = "定时采集规则", businessType = BusinessType.INSERT) +// @PostMapping +// public AjaxResult add(@RequestBody ScheduleRules scheduleRules) +// { +// return toAjax(scheduleRulesService.insertScheduleRules(scheduleRules)); +// } +// +// +// +// /** +// * 修改定时采集规则 +// */ +// @PreAuthorize("@ss.hasPermi('equipment:rules:edit')") +// @Log(title = "定时采集规则", businessType = BusinessType.UPDATE) +// @PutMapping +// public AjaxResult edit(@RequestBody ScheduleRules scheduleRules) +// { +// return toAjax(scheduleRulesService.updateScheduleRules(scheduleRules)); +// } +// +// +// /** +// * 删除定时采集规则 +// */ +// @PreAuthorize("@ss.hasPermi('equipment:rules:remove')") +// @Log(title = "定时采集规则", businessType = BusinessType.DELETE) +// @DeleteMapping("rule/{ids}") +// public AjaxResult remove(@PathVariable Long[] ids) +// { +// return toAjax(scheduleRulesService.deleteScheduleRulesByIds(ids)); +// } } 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 091f3b6e..3e36b3ee 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,6 +1,7 @@ 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; @@ -8,9 +9,13 @@ 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.service.IAlertLaunchService; 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; @@ -29,80 +34,120 @@ import org.springframework.web.bind.annotation.RestController; * @date 2025-09-04 */ @RestController -@RequestMapping("/system/message") +@RequestMapping("/inMonitoring/alertMessage") public class AlertMessageController extends BaseController { @Autowired private IAlertMessageService alertMessageService; + @Autowired + private IAlertLaunchService iAlertLaunchService; - + //立即预警方法 + //1.拿到预警规则,拿到查询语句(如果是change执行change的方法)和预警规则表的东西,进行查询,查询组成一个内从实体 + //2.根据每次预警模版,+进行对应填入,根据预警方式发送信息,再存入预警信息实体类 + //{设备id:{} 报错:{预警名称} 返回实体{自己看} } + //3.批量存入预警信息数据库 /** - * 查询预警信息统计列表 + * 立即执行预警(带规则 ID 列表) */ - @PreAuthorize("@ss.hasPermi('system:message:list')") - @GetMapping("/list") - public TableDataInfo list(AlertMessage alertMessage) - { - startPage(); - List list = alertMessageService.selectAlertMessageList(alertMessage); - return getDataTable(list); - } +// @PreAuthorize("@ss.hasPermi('equipment:rules:execute')") +// @ApiOperation("立即执行预警") +// @Log(title = "【立即执行预警】", businessType = BusinessType.DELETE) +// @PostMapping("/executeImmediate") +// public AjaxResult executeImmediate(@RequestBody Map> paramMap) { +// try { +// List ruleIds = paramMap.get("ruleIds"); +// if (ruleIds == null || ruleIds.isEmpty()) { +// return AjaxResult.error("请选择至少一条规则"); +// } +// +// iAlertLaunchService.executeImmediateAlerts(); // 调用 Service 执行 +// return AjaxResult.success("立即预警任务已触发,存入成功,请查看"); +// +// } catch (Exception e) { +// e.printStackTrace(); +// return AjaxResult.error("执行立即预警失败: " + e.getMessage()); +// } +// +// } /** - * 导出 预警信息列表 + * 修改预警信息 */ - @PreAuthorize("@ss.hasPermi('system:message:export')") - @Log(title = "故障统计", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, AlertMessage alertMessage) + @PreAuthorize("@ss.hasPermi('inMonitoring:alertMessage:edit')") + @Log(title = "修改预警信息", businessType = BusinessType.UPDATE) + @PutMapping("/editAlertMessage") + @ApiOperation("修改预警信息") + public AjaxResult edit(@RequestBody AlertMessage alertMessage) { - List list = alertMessageService.selectAlertMessageList(alertMessage); - ExcelUtil util = new ExcelUtil(AlertMessage.class); - util.exportExcel(response, list, "故障统计数据"); + return AjaxResult.success("修改成功",alertMessageService.updateAlertMessage(alertMessage)); } /** - * 获取预警信息 + * 查询预警信息统计列表 */ - @PreAuthorize("@ss.hasPermi('system:message:query')") - @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { - return success(alertMessageService.selectAlertMessageById(id)); - } + @PreAuthorize("@ss.hasPermi('inMonitoring:alertMessage:list')") + @GetMapping ("/list") + @ApiOperation("查询预警信息") + @Log(title = "查询预警信息", businessType = BusinessType.UPDATE) - /** - * 新增预警信息 - */ - @PreAuthorize("@ss.hasPermi('system:message:add')") - @Log(title = "故障统计", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody AlertMessage alertMessage) + public TableDataInfo list( @RequestBody AlertDto alertMessage) { - return toAjax(alertMessageService.insertAlertMessage(alertMessage)); - } - - /** - * 修改预警信息 - */ - @PreAuthorize("@ss.hasPermi('system:message:edit')") - @Log(title = "故障统计", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody AlertMessage alertMessage) - { - return toAjax(alertMessageService.updateAlertMessage(alertMessage)); + startPage(); + List list = alertMessageService.selectAlertMessageList(alertMessage); + return getDataTable(list); } /** * 删除预警信息 */ @PreAuthorize("@ss.hasPermi('system:message:remove')") - @Log(title = "故障统计", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") + @ApiOperation("删除预警信息") + @Log(title = "删除预警信息", businessType = BusinessType.UPDATE) + @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(alertMessageService.deleteAlertMessageByIds(ids)); } + +// /** +// * 导出 预警信息列表 +// */ +// @PreAuthorize("@ss.hasPermi('system:message:export')") +// @Log(title = "故障统计", businessType = BusinessType.EXPORT) +// @PostMapping("/export") +// public void export(HttpServletResponse response, AlertDto alertMessage) +// { +// List list = alertMessageService.selectAlertMessageList(alertMessage); +// ExcelUtil util = new ExcelUtil(AlertMessage.class); +// util.exportExcel(response, list, "故障统计数据"); +// } + + +// /** +// * 获取预警信息 +// */ +// @PreAuthorize("@ss.hasPermi('system:message:query')") +// @GetMapping(value = "/{id}") +// +// public AjaxResult getInfo(@PathVariable("id") Long id) +// { +// return success(alertMessageService.selectAlertMessageById(id)); +// } + +// /** +// * 新增预警信息 +// */ +// @PreAuthorize("@ss.hasPermi('system:message:add')") +// @Log(title = "故障统计", businessType = BusinessType.INSERT) +// @PostMapping +// public AjaxResult add(@RequestBody AlertMessage alertMessage) +// { +// return toAjax(alertMessageService.insertAlertMessage(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 4f30da13..9aaa44de 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 @@ -14,18 +14,12 @@ import com.alops.system.domain.AlertRule; import com.alops.system.domain.dto.AlertRuleAddDto; import com.alops.system.service.IAlertLaunchService; import com.alops.system.service.IAlertRuleService; +import com.alops.system.service.IDictAlarmParamService; import com.sun.jna.platform.win32.Winspool; 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 @@ -34,30 +28,33 @@ import org.springframework.web.bind.annotation.RestController; * @date 2025-09-04 */ @RestController -@RequestMapping("/system/rule") -public class AlertRuleController extends BaseController -{ +@RequestMapping("/inMonitoring/alertRule") +public class AlertRuleController extends BaseController { @Autowired private IAlertRuleService alertRuleService; @Autowired - private IAlertLaunchService iAlertLaunchService; + private IDictAlarmParamService dictAlarmParamService; + //增加预警规则,生成对应的sql语句存入方法(只能针对个体表,表之间不能共同构成预警,特殊符号的规则只能有一个查询条件) - //1.拿到 //预警名称,预警级别,预警对应的表格,预警方式,预警的到站方 预警规则,预警模版 内容描述 启用状态,创建人 + //1.拿到 //预警名称,预警级别,预警对应的表格,预警方式,预警的到站方 预警规则,预警模版 内容描述 启用状态,创建人 //+好几个规则条件实体类 //2.生成sql语句 //如果是如果是equ_gather直接根据组成条件构成查询语句, //如果是其他表格除去组成条件构成的语句+通过equ_garher_id关联到equ_gather表,搜索出实体外+设备id和设备类型 - //3.然后存入预警规则和预警规则条件表 + //3.然后存入预警规则和预警规则条件表 /** * 新增预警规则 */ - @PreAuthorize("@ss.hasPermi('equipment:rules:add')") + @PreAuthorize("@ss.hasPermi('inMonitoring:alertRule:add')") @ApiOperation("增加预警规则") - @PostMapping("/add") + @Log(title = "【增加预警规则】", businessType = BusinessType.DELETE) + @PostMapping("/addRule") public AjaxResult addRule(@RequestBody AlertRuleAddDto dto) { try { + + AlertRule alertRule = alertRuleService.saveRule(dto); return AjaxResult.success("预警规则新增成功", alertRule); } catch (Exception e) { @@ -66,99 +63,109 @@ public class AlertRuleController extends BaseController } } - - //立即预警方法 - //1.拿到预警规则,拿到查询语句(如果是change执行change的方法)和预警规则表的东西,进行查询,查询组成一个内从实体 - //2.根据每次预警模版,+进行对应填入,根据预警方式发送信息,再存入预警信息实体类 - //{设备id:{} 报错:{预警名称} 返回实体{自己看} } - //3.批量存入预警信息数据库 - /** - * 立即执行预警(带规则 ID 列表) + * 修改预警规则 */ - @PreAuthorize("@ss.hasPermi('equipment:rules:execute')") - @ApiOperation("立即执行预警") - @PostMapping("/executeImmediate") - public AjaxResult executeImmediate(@RequestBody Map> paramMap) { + @PreAuthorize("@ss.hasPermi('inMonitoring:alertRule:edit')") + @ApiOperation("修改预警规则") + @Log(title = "【修改预警规则】", businessType = BusinessType.DELETE) + @PostMapping("/editRule") + public AjaxResult editRule(@RequestBody AlertRuleAddDto dto) { try { - List ruleIds = paramMap.get("ruleIds"); - if (ruleIds == null || ruleIds.isEmpty()) { - return AjaxResult.error("请选择至少一条规则"); - } - - iAlertLaunchService.executeImmediateAlerts(ruleIds); // 调用 Service 执行 - return AjaxResult.success("立即预警任务已触发,存入成功,请查看"); + AlertRule alertRule = alertRuleService.updateRule(dto); + return AjaxResult.success("预警规则修改成功", alertRule); } catch (Exception e) { e.printStackTrace(); - return AjaxResult.error("执行立即预警失败: " + e.getMessage()); + return AjaxResult.error("新增预警修改失败: " + e.getMessage()); } } /** - * 查询【请填写功能名称】列表 + * 查询预警列表(不涉及规则条件)(另外是搜索查询,不涉及时间和创建人) */ - @PreAuthorize("@ss.hasPermi('system:rule:list')") + @PreAuthorize("@ss.hasPermi('inMonitoring:alertRule:list')") @GetMapping("/list") - public TableDataInfo list(AlertRule alertRule) - { + @Log(title = "【查询预警规则】", businessType = BusinessType.DELETE) + @ApiOperation("查询预警规则") + public TableDataInfo list(AlertRule alertRule) { startPage(); List list = alertRuleService.selectAlertRuleList(alertRule); - return getDataTable(list); - } + return getDataTable(list); - /** - * 导出【请填写功能名称】列表 - */ - @PreAuthorize("@ss.hasPermi('system:rule:export')") - @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, AlertRule alertRule) - { - List list = alertRuleService.selectAlertRuleList(alertRule); - ExcelUtil util = new ExcelUtil(AlertRule.class); - util.exportExcel(response, list, "【请填写功能名称】数据"); } + /** - * 获取【请填写功能名称】详细信息 + * 查询预警列表(涉及规则条件)(用于修改是获得单独页面) */ - @PreAuthorize("@ss.hasPermi('system:rule:query')") + @PreAuthorize("@ss.hasPermi('inMonitoring:alertRule:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { - return success(alertRuleService.selectAlertRuleById(id)); + @ApiOperation("查询预警详细规则") + @Log(title = "【查询预警详细规则】", businessType = BusinessType.DELETE) + public AjaxResult getInfo(@PathVariable("id") Long id) { + return success(alertRuleService.selectDetailAlertRuleById(id)); } /** - * 新增【请填写功能名称】 + * 删除【请填写功能名称】 */ - @PreAuthorize("@ss.hasPermi('system:rule:add')") - @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody AlertRule alertRule) - { - return toAjax(alertRuleService.insertAlertRule(alertRule)); - } + @PreAuthorize("@ss.hasPermi('inMonitoring:alertRule:remove')") + @Log(title = "【删除预警功能】", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + @ApiOperation("删除预警规则") + public AjaxResult remove(@PathVariable Long[] ids) { + return AjaxResult.success("删除成功", alertRuleService.deleteAlertRuleByIds(ids)); + - /** - * 修改【请填写功能名称】 - */ - @PreAuthorize("@ss.hasPermi('system:rule:edit')") - @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody AlertRule alertRule) - { - return toAjax(alertRuleService.updateAlertRule(alertRule)); } - /** - * 删除【请填写功能名称】 - */ - @PreAuthorize("@ss.hasPermi('system:rule:remove')") - @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { - return toAjax(alertRuleService.deleteAlertRuleByIds(ids)); + +// /** +// * 导出【请填写功能名称】列表 +// */ +// @PreAuthorize("@ss.hasPermi('inMonitoring:alertRule:export')") +// @Log(title = "【导出预警规则】", businessType = BusinessType.EXPORT) +// @PostMapping("/export") +// @ApiOperation("导出预警规则") +// public void export(HttpServletResponse response, AlertRule alertRule) { +// List list = alertRuleService.selectAlertRuleList(alertRule); +// ExcelUtil util = new ExcelUtil(AlertRule.class); +// util.exportExcel(response, list, "导出预警规则数据"); +// } + + + + @ApiOperation("获取预警参数") + @PreAuthorize("@ss.hasPermi('inMonitoring:alertRule:byTable')") + @GetMapping("/byTable") + @Log(title = "【获取预警参数】", businessType = BusinessType.EXPORT) + public AjaxResult getParamsByTableName() { + return AjaxResult.success("获取预警参数成功",dictAlarmParamService.getParamsByTableName()); } } + + + +// /** +// * 新增【请填写功能名称】 +// */ +// @PreAuthorize("@ss.hasPermi('system:rule:add')") +// @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT) +// @PostMapping +// public AjaxResult add(@RequestBody AlertRule alertRule) +// { +// return toAjax(alertRuleService.insertAlertRule(alertRule)); +// } + +// /** +// * 修改【请填写功能名称】 +// */ +// @PreAuthorize("@ss.hasPermi('system:rule:edit')") +// @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE) +// @PutMapping +// public AjaxResult edit(@RequestBody AlertRule alertRule) +// { +// return toAjax(alertRuleService.updateAlertRule(alertRule)); +// } + + diff --git a/ALOps_sys_backend/alops-common/src/main/java/com/alops/common/utils/html/EscapeUtil.java b/ALOps_sys_backend/alops-common/src/main/java/com/alops/common/utils/html/EscapeUtil.java index 6d2405da..de1a5485 100644 --- a/ALOps_sys_backend/alops-common/src/main/java/com/alops/common/utils/html/EscapeUtil.java +++ b/ALOps_sys_backend/alops-common/src/main/java/com/alops/common/utils/html/EscapeUtil.java @@ -58,7 +58,17 @@ public class EscapeUtil */ public static String clean(String content) { - return new HTMLFilter().filter(content); + if (StringUtils.isBlank(content)) { + return null; + } + // 跑一遍 HTMLFilter(去掉真正危险的标签,比如 - // 初始化设备类型统计图表 - const typeChart = echarts.init(document.getElementById('typeChart')); - typeChart.setOption({ - title: { text: '设备类型统计', subtext: '按设备类型', left: 'center' }, - tooltip: { trigger: 'item' }, - series: [ - { - name: '设备类型', - type: 'pie', - radius: '50%', - data: [ - { value: 44, name: '自主房屋' }, - { value: 33, name: '出租房屋' }, - { value: 11, name: '空置房屋' }, - { value: 11, name: '其他' }, - ], - }, - ], - }); + \ No newline at end of file + diff --git a/ALOps_sys_fe/alops-ui/src/views/index_v1.vue b/ALOps_sys_fe/alops-ui/src/views/index_v1.vue deleted file mode 100644 index d2d2ec63..00000000 --- a/ALOps_sys_fe/alops-ui/src/views/index_v1.vue +++ /dev/null @@ -1,98 +0,0 @@ - - - - - From 705a2f6ddf2cfdde1c925d2ccf943f811e9f9eb4 Mon Sep 17 00:00:00 2001 From: Wangxin Date: Wed, 24 Sep 2025 15:57:54 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E3=80=90web=E3=80=91=20=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../alops-ui/src/views/dashboard/digital.vue | 40 ++ .../src/views/device/deviceSupplier/index.vue | 449 ++++++++++++++++++ 2 files changed, 489 insertions(+) create mode 100644 ALOps_sys_fe/alops-ui/src/views/dashboard/digital.vue create mode 100644 ALOps_sys_fe/alops-ui/src/views/device/deviceSupplier/index.vue diff --git a/ALOps_sys_fe/alops-ui/src/views/dashboard/digital.vue b/ALOps_sys_fe/alops-ui/src/views/dashboard/digital.vue new file mode 100644 index 00000000..cbbf3c69 --- /dev/null +++ b/ALOps_sys_fe/alops-ui/src/views/dashboard/digital.vue @@ -0,0 +1,40 @@ + + + diff --git a/ALOps_sys_fe/alops-ui/src/views/device/deviceSupplier/index.vue b/ALOps_sys_fe/alops-ui/src/views/device/deviceSupplier/index.vue new file mode 100644 index 00000000..2a1cefef --- /dev/null +++ b/ALOps_sys_fe/alops-ui/src/views/device/deviceSupplier/index.vue @@ -0,0 +1,449 @@ + + + \ No newline at end of file