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 5f3d6fbd..e17e40fd 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 @@ -86,6 +86,7 @@ public class EquBaseController extends BaseController // 调用职责单一的 Service 方法 return success(equBaseService.selectLatestEquMonitorInfo(id)); } + /** * 获取设备指定时间段内的历史监控信息 * @param equBaseQueryDto 查询对象,包含设备ID、开始时间和结束时间 @@ -131,34 +132,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 { +// /** +// * 根据设备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); +// } +// } - 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") @@ -192,46 +194,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/exceptionController/AlertMessageController.java b/ALOps_sys_backend/alops-admin/src/main/java/com/alops/web/controller/exceptionController/AlertMessageController.java index 51756ee8..340f7196 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 @@ -21,14 +21,7 @@ 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 @@ -92,11 +85,10 @@ public class AlertMessageController extends BaseController * 查询预警信息统计列表 */ @PreAuthorize("@ss.hasPermi('inMonitoring:alertMessage:list')") - @PostMapping ("/list") + @GetMapping ("/list") @ApiOperation("查询预警信息") @Log(title = "查询预警信息", businessType = BusinessType.UPDATE) - - public TableDataInfo list( @RequestBody AlertDto alertMessage) + 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..8a7dfce0 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 @@ -69,7 +69,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); 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 1c4c3eb0..52ce8d3f 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 @@ -55,6 +55,8 @@ public class EquBase @Excel(name = "设备类型 id") private String equType; + + public EquType getEquTypeVO() { return equTypeVO; } @@ -114,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) 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 3a29e035..10d15e95 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 @@ -28,7 +28,7 @@ public class MonitorLastDto { private String inCharge; private int failureFrequency; private int warranty; - private Blob equImage; + private String equImage; // equ_type private String equType; 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..4c30a6ef 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 @@ -88,6 +88,10 @@ public class queryEquBaseVO { @Excel(name = "累积故障次数") private String deviceLevel; + @Excel(name = "设备图片") + private String equImage; + + public void setId(String id) { 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 8834d9c0..a3860a73 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 @@ -111,8 +111,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" b.create_date AS createDate, b.status AS status, b.device_level AS deviceLevel, - g.health AS health - + g.health AS health, + b.equ_image AS equImage @@ -358,7 +358,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{createDate}, #{equNumber}, COALESCE(#{status,jdbcType=INTEGER}, 0), - #{equImage,jdbcType=BLOB}, + #{equImage}, COALESCE(#{failureFrequency,jdbcType=BIGINT}, 0), COALESCE(#{gatherFrequency,jdbcType=BIGINT}, 0), #{deviceLevel}, diff --git a/ALOps_sys_fe/alops-ui/public/index.html b/ALOps_sys_fe/alops-ui/public/index.html index 925455ca..ec69afcf 100644 --- a/ALOps_sys_fe/alops-ui/public/index.html +++ b/ALOps_sys_fe/alops-ui/public/index.html @@ -6,6 +6,7 @@ + <%= webpackConfig.name %> diff --git a/ALOps_sys_fe/alops-ui/src/views/index.vue b/ALOps_sys_fe/alops-ui/src/views/index.vue index 64031b5a..d35b56a4 100644 --- a/ALOps_sys_fe/alops-ui/src/views/index.vue +++ b/ALOps_sys_fe/alops-ui/src/views/index.vue @@ -1,94 +1,127 @@ - - - - - - 预警信息统计 - - - 预警总数 - - - - 预警总数 - - - - 预警总数 - - - - 预警总数 - - - - 预警总数 - - - - 预警总数 - + + + + + + + + + 预警信息统计1 + + + + 预警总数 + {{ totalAlerts }} + 系统检测到的预警总数 + + + 当前预警 + {{ activeAlerts }} + 需要处理的预警数量 + + + 已处理 + {{ resolvedAlerts }} + 已解决的预警数量 + + + - - 预警总数 - + + + + + + 检测设备信息 + + + + + + + + {{ device.name }} + {{ device.description }} + + + {{ device.status === 'warning' ? '预警中' : '正常' }} + + + + - - 预警总数 - + + + + + + 设备预警信息 + + + + + + + + {{ alert.deviceName }} + + 预警时间: {{ alert.time }} + 设备位置: {{ alert.location }} + 预警信息: {{ alert.message }} + + + + {{ alert.level === 1 ? '等级1' : '等级0' }} + + + + - - 预警总数 - - - - - - - - 检测设备信息 - - - - - 设备预警信息 - - - - - - - 预警时间:{{ alert.time }} - - - 设备名称:{{ alert.deviceName }} - - - 设备位置:{{ alert.deviceLocation }} - - - 预警等级:{{ alert.level }} - - - 预警信息:{{ alert.message }} - - - 预警状态:{{ alert.status }} - - - + + + + + + 设备状态监控 + 最后更新: {{ lastUpdate }} + + + + + + {{ header }} + + + + + {{ device.name }} + {{ device.location }} + + + {{ device.cpuUsage }}% + + + + {{ device.memoryUsage }}% + + {{ device.temperature }}°C + + + + + {{ device.health }}% + + {{ device.uptime }} + {{ device.collectionTime }} + + + + - - - - - 设备状态监控 - - - + @@ -100,25 +133,6 @@ import PieChart from './dashboard/PieChart' import BarChart from './dashboard/BarChart' import digital from './dashboard/digital' -const lineChartData = { - newVisitis: { - expectedData: [100, 120, 161, 134, 105, 160, 165], - actualData: [120, 82, 91, 154, 162, 140, 145] - }, - messages: { - expectedData: [200, 192, 120, 144, 160, 130, 140], - actualData: [180, 160, 151, 106, 145, 150, 130] - }, - purchases: { - expectedData: [80, 100, 121, 104, 105, 90, 100], - actualData: [120, 90, 100, 138, 142, 130, 130] - }, - shoppings: { - expectedData: [130, 140, 141, 142, 145, 150, 160], - actualData: [120, 82, 91, 154, 162, 140, 130] - } -} - export default { name: 'Index', components: { @@ -131,178 +145,395 @@ export default { }, data() { return { - lineChartData: lineChartData.newVisitis, - scrollConfig:{ - header: ['设备名称', '设备位置', 'CPU使用率','内存使用率','温度', '健康度', '设备运行时长','采集时间'], - data: [ - ['行1列1', '行1列2', '行1列3', '行1列4', '行1列5', '行1列6','行1列7', '行1列8'], - ['行2列1', '行2列2', '行2列3', '行2列4', '行2列5', '行2列6','行2列7', '行2列8'], - ['行3列1', '行3列2', '行3列3', '行3列4', '行3列5', '行3列6','行3列7', '行3列8'], - ['行4列1', '行4列2', '行4列3', '行4列4', '行4列5', '行4列6','行4列7', '行4列8'], - ['行5列1', '行5列2', '行5列3', '行5列4', '行5列5', '行5列6','行5列7', '行5列8'], - ['行6列1', '行6列2', '行6列3', '行6列4', '行6列5', '行6列6','行6列7', '行6列8'], - ['行7列1', '行7列2', '行7列3', '行7列4', '行7列5', '行7列6','行7列7', '行7列8'], - ['行8列1', '行8列2', '行8列3', '行8列4', '行8列5', '行8列6','行8列7', '行8列8'], - ['行9列1', '行9列2', '行9列3', '行9列4', '行9列5', '行9列6','行9列7', '行9列8'], - ['行10列1', '行10列2', '行10列3', '行10列4', '行10列5', '行10列6','行10列7', '行10列8'] - ], - headerBGC:'#f8f8f9', - headerHeight:60, - oddRowBGC:'#f5f7fa', - evenRowBGC:'#fff', - }, + totalAlerts: 111, + activeAlerts: 42, + resolvedAlerts: 69, + lastUpdate: new Date().toLocaleString(), + devices: [ + { id: 1, name: 'Forecasts', description: '预测分析系统', status: 'normal', icon: 'fas fa-chart-line' }, + { id: 2, name: 'Gold', description: '核心处理单元', status: 'warning', icon: 'fas fa-server' }, + { id: 3, name: 'Industries', description: '工业控制系统', status: 'normal', icon: 'fas fa-industry' } + ], alerts: [ - { - time: '2021-10-16 14:54:11', - deviceName: 'PLC远程监控系统', - deviceLocation: '污水处理监控系统', - level: 1, - message: '2#电机运行状态等于1', - status: '触发值: 1' - }, - { - time: '2021-10-16 14:54:04', - deviceName: 'PLC远程监控系统', - deviceLocation: '污水处理监控系统', - level: 0, - message: '2#电机运行状态报警恢复', - status: '触发值: 0' - }, - { - time: '2021-10-16 14:54:11', - deviceName: 'PLC远程监控系统', - deviceLocation: '污水处理监控系统', - level: 1, - message: '2#电机运行状态等于1', - status: '触发值: 1' - }, - { - time: '2021-10-16 14:54:04', - deviceName: 'PLC远程监控系统', - deviceLocation: '污水处理监控系统', - level: 0, - message: '2#电机运行状态报警恢复', - status: '触发值: 0' - }, - // 可以继续添加更多预警信息 + { + id: 1, + deviceName: 'PLC远程监控系统', + time: '2021-10-16 14:54:11', + location: '污水处理监控系统', + message: '2#电机运行状态等于1', + level: 1, + status: 'warning', + icon: 'fas fa-exclamation-circle' + }, + { + id: 2, + deviceName: 'PLC远程监控系统', + time: '2021-10-16 14:54:04', + location: '污水处理监控系统', + message: '2#电机运行状态报警恢复', + level: 0, + status: 'normal', + icon: 'fas fa-check-circle' + } + ], + tableHeaders: ['设备名称', '设备位置', 'CPU使用率', '内存使用率', '温度', '健康度', '设备运行时长', '采集时间'], + deviceStatus: [ + { + id: 1, + name: 'PLC控制系统', + location: '主控室A区', + cpuUsage: 45, + memoryUsage: 62, + temperature: 42, + health: 85, + uptime: '125天8小时', + collectionTime: '2021-10-16 15:20:00' + }, + { + id: 2, + name: '数据采集器', + location: '污水处理区', + cpuUsage: 78, + memoryUsage: 85, + temperature: 58, + health: 65, + uptime: '89天12小时', + collectionTime: '2021-10-16 15:22:00' + }, + { + id: 3, + name: '监控服务器', + location: '数据中心', + cpuUsage: 32, + memoryUsage: 45, + temperature: 38, + health: 92, + uptime: '210天3小时', + collectionTime: '2021-10-16 15:25:00' + }, + { + id: 4, + name: '网络交换机', + location: '通信机房', + cpuUsage: 15, + memoryUsage: 28, + temperature: 35, + health: 95, + uptime: '156天7小时', + collectionTime: '2021-10-16 15:18:00' + } ] } }, methods: { - handleSetLineChartData(type) { - this.lineChartData = lineChartData[type] + getCpuStatus(usage) { + if (usage < 50) return 'status-indicator status-good'; + if (usage < 80) return 'status-indicator status-warning'; + return 'status-indicator status-critical'; }, - getLevelColor(level) { - const levelColors = { - 0: 'green', - 1: 'orange', - 2: 'red' - }; - return levelColors[level] || 'black'; // 默认颜色 + getMemoryStatus(usage) { + if (usage < 60) return 'status-indicator status-good'; + if (usage < 85) return 'status-indicator status-warning'; + return 'status-indicator status-critical'; + }, + getHealthStatus(health) { + if (health >= 80) return 'health-good'; + if (health >= 60) return 'health-warning'; + return 'health-critical'; } } }