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 a46fc713..e81c9be6 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.Anonymous; @@ -19,24 +19,21 @@ import com.alops.system.domain.dto.MonitorStatisticDto; import com.alops.system.domain.vo.EquMonitorVO; 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("/device/files") @@ -45,20 +42,19 @@ public class EquBaseController extends BaseController @Autowired private IEquBaseService equBaseService; + + /** * 查询设备基本信息列表 */ - @PreAuthorize("@ss.hasPermi('device:files: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); } /**查询设备监测信息列表(查询多台显示界面的单独信息)**/ @@ -108,27 +104,125 @@ public class EquBaseController extends BaseController return AjaxResult.success("查询成功", list); } + /** + * 获取设备基本信息详细信息 + */ + @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('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("/add") - @ApiOperation("新增设备信息") - public AjaxResult add(@RequestBody EquBase equBase) - { + @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('device:files:modify')") - @Log(title = "设备档案", businessType = BusinessType.UPDATE) + @PreAuthorize("@ss.hasPermi('device:files:edit')") + @Log(title = "设备基本信息", businessType = BusinessType.UPDATE) @PutMapping("/modify") - @ApiOperation("修改设备信息") - public AjaxResult edit(@RequestBody EquBase equBase) - { + @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)); } @@ -136,12 +230,14 @@ public class EquBaseController extends BaseController /** * 删除设备基本信息 */ - @PreAuthorize("@ss.hasPermi('device:files:delete')") - @Log(title = "设备档案", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - @ApiOperation("删除设备信息") + @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 index f2db9ecd..a5645cf1 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 @@ -4,6 +4,14 @@ import java.util.List; import javax.servlet.http.HttpServletResponse; import io.swagger.annotations.ApiOperation; +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; @@ -25,9 +33,9 @@ import com.alops.common.core.page.TableDataInfo; /** * 供应商功能Controller - * + * * @author ruoyi - * @date 2025-09-20 + * @date 2025-09-19 */ @RestController @RequestMapping("/device/supplier") 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 0921528d..ff795ab2 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,8 +9,11 @@ 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.domain.AlertRule; import com.alops.system.domain.EquInterface; import com.alops.system.domain.dto.AlertStatisticDto; @@ -33,18 +37,66 @@ 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('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('inMonitoring:alertMessage:edit')") + @Log(title = "修改预警信息", businessType = BusinessType.UPDATE) + @PutMapping("/editAlertMessage") + @ApiOperation("修改预警信息") + public AjaxResult edit(@RequestBody AlertMessage alertMessage) + { + return AjaxResult.success("修改成功",alertMessageService.updateAlertMessage(alertMessage)); + } /** * 查询预警信息统计列表 */ - @PreAuthorize("@ss.hasPermi('system:message:list')") - @GetMapping("/list") - public TableDataInfo list(AlertMessage alertMessage) + @PreAuthorize("@ss.hasPermi('inMonitoring:alertMessage:list')") + @GetMapping ("/list") + @ApiOperation("查询预警信息") + @Log(title = "查询预警信息", businessType = BusinessType.UPDATE) + + public TableDataInfo list( @RequestBody AlertDto alertMessage) { startPage(); List list = alertMessageService.selectAlertMessageList(alertMessage); @@ -78,60 +130,44 @@ public class AlertMessageController extends BaseController } - /** - * 导出 预警信息列表 - */ - @PreAuthorize("@ss.hasPermi('system:message:export')") - @Log(title = "故障统计", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, AlertMessage alertMessage) - { - List list = alertMessageService.selectAlertMessageList(alertMessage); - ExcelUtil util = new ExcelUtil(AlertMessage.class); - util.exportExcel(response, list, "故障统计数据"); - } - /** - * 获取预警信息 - */ - @PreAuthorize("@ss.hasPermi('system:message:query')") - @GetMapping(value = "/query") - public AjaxResult getInfo(Long id) - { - return success(alertMessageService.selectAlertMessageById(id)); - } + } +// /** +// * 导出 预警信息列表 +// */ +// @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)); +// } - /** - * 新增预警信息 - */ - @PreAuthorize("@ss.hasPermi('system:message:add')") - @Log(title = "故障统计", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody AlertMessage 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)); - } - /** - * 删除预警信息 - */ - @PreAuthorize("@ss.hasPermi('system:message:remove')") - @Log(title = "故障统计", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { - return toAjax(alertMessageService.deleteAlertMessageByIds(ids)); - } -} 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(去掉真正危险的标签,比如 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 diff --git a/ALOps_sys_fe/alops-ui/src/views/index.vue b/ALOps_sys_fe/alops-ui/src/views/index.vue index 88f6122d..4f703508 100644 --- a/ALOps_sys_fe/alops-ui/src/views/index.vue +++ b/ALOps_sys_fe/alops-ui/src/views/index.vue @@ -1,187 +1,300 @@ - // 初始化设备类型统计图表 - 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 @@ - - - - -