diff --git a/docs/swagger.json b/docs/swagger.json index bcdcfcda..918ae413 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -141,6 +141,126 @@ } }, "/api/v1/alarm/threshold/area": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据过滤条件和分页参数查询区域阈值告警列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "告警管理" + ], + "summary": "批量查询区域阈值告警", + "parameters": [ + { + "type": "integer", + "description": "按区域主控ID过滤", + "name": "area_controller_id", + "in": "query" + }, + { + "enum": [ + "Debug", + "Info", + "Warn", + "Error", + "DPanic", + "Panic", + "Fatal" + ], + "type": "string", + "x-enum-varnames": [ + "DebugLevel", + "InfoLevel", + "WarnLevel", + "ErrorLevel", + "DPanicLevel", + "PanicLevel", + "FatalLevel" + ], + "description": "按告警等级过滤", + "name": "level", + "in": "query" + }, + { + "type": "string", + "description": "排序字段,例如 \"id DESC\"", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "page_size", + "in": "query" + }, + { + "enum": [ + "信号强度", + "电池电量", + "温度", + "湿度", + "重量" + ], + "type": "string", + "x-enum-comments": { + "SensorTypeBatteryLevel": "电池电量", + "SensorTypeHumidity": "湿度", + "SensorTypeSignalMetrics": "信号强度", + "SensorTypeTemperature": "温度", + "SensorTypeWeight": "重量" + }, + "x-enum-descriptions": [ + "信号强度", + "电池电量", + "温度", + "湿度", + "重量" + ], + "x-enum-varnames": [ + "SensorTypeSignalMetrics", + "SensorTypeBatteryLevel", + "SensorTypeTemperature", + "SensorTypeHumidity", + "SensorTypeWeight" + ], + "description": "按传感器类型过滤", + "name": "sensor_type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "成功获取区域阈值告警列表", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListAreaThresholdAlarmResponse" + } + } + } + ] + } + } + } + }, "post": { "security": [ { @@ -302,6 +422,126 @@ } }, "/api/v1/alarm/threshold/device": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据过滤条件和分页参数查询设备阈值告警列表", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "告警管理" + ], + "summary": "批量查询设备阈值告警", + "parameters": [ + { + "type": "integer", + "description": "按设备ID过滤", + "name": "device_id", + "in": "query" + }, + { + "enum": [ + "Debug", + "Info", + "Warn", + "Error", + "DPanic", + "Panic", + "Fatal" + ], + "type": "string", + "x-enum-varnames": [ + "DebugLevel", + "InfoLevel", + "WarnLevel", + "ErrorLevel", + "DPanicLevel", + "PanicLevel", + "FatalLevel" + ], + "description": "按告警等级过滤", + "name": "level", + "in": "query" + }, + { + "type": "string", + "description": "排序字段,例如 \"id DESC\"", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "page_size", + "in": "query" + }, + { + "enum": [ + "信号强度", + "电池电量", + "温度", + "湿度", + "重量" + ], + "type": "string", + "x-enum-comments": { + "SensorTypeBatteryLevel": "电池电量", + "SensorTypeHumidity": "湿度", + "SensorTypeSignalMetrics": "信号强度", + "SensorTypeTemperature": "温度", + "SensorTypeWeight": "重量" + }, + "x-enum-descriptions": [ + "信号强度", + "电池电量", + "温度", + "湿度", + "重量" + ], + "x-enum-varnames": [ + "SensorTypeSignalMetrics", + "SensorTypeBatteryLevel", + "SensorTypeTemperature", + "SensorTypeHumidity", + "SensorTypeWeight" + ], + "description": "按传感器类型过滤", + "name": "sensor_type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "成功获取设备阈值告警列表", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListDeviceThresholdAlarmResponse" + } + } + } + ] + } + } + } + }, "post": { "security": [ { @@ -5449,15 +5689,15 @@ "alarm_code": { "$ref": "#/definitions/models.AlarmCode" }, - "alarm_details": { - "type": "string" - }, "alarm_summary": { "type": "string" }, "id": { "type": "integer" }, + "json_details": { + "type": "string" + }, "level": { "$ref": "#/definitions/models.SeverityLevel" }, @@ -5495,6 +5735,20 @@ } } }, + "dto.ListAreaThresholdAlarmResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.AreaThresholdAlarmDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, "dto.ListDeviceCommandLogResponse": { "type": "object", "properties": { @@ -5509,6 +5763,20 @@ } } }, + "dto.ListDeviceThresholdAlarmResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.DeviceThresholdAlarmDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, "dto.ListFeedUsageRecordResponse": { "type": "object", "properties": { diff --git a/src/api/alarm.js b/src/api/alarm.js index 41c8303a..b7083941 100644 --- a/src/api/alarm.js +++ b/src/api/alarm.js @@ -58,6 +58,22 @@ import { Response, SeverityLevel, AlarmSourceType, Operator, AlarmCode, Notifica * @property {number} thresholds */ +/** + * @typedef {object} ListAreaThresholdAlarmResponse + * @property {Array} list + * @property {PaginationDTO} pagination + */ + +/** + * @typedef {object} AreaThresholdAlarmsParams + * @property {number} [area_controller_id] - 按区域主控ID过滤 + * @property {SeverityLevel} [level] - 按告警等级过滤 + * @property {string} [order_by] - 排序字段,例如 "id DESC" + * @property {number} [page] + * @property {number} [page_size] + * @property {SensorType} [sensor_type] - 按传感器类型过滤 + */ + /** * @typedef {object} UpdateAreaThresholdAlarmDTO * @property {Operator} operator - 新的操作符 @@ -84,6 +100,22 @@ import { Response, SeverityLevel, AlarmSourceType, Operator, AlarmCode, Notifica * @property {number} thresholds */ +/** + * @typedef {object} ListDeviceThresholdAlarmResponse + * @property {Array} list + * @property {PaginationDTO} pagination + */ + +/** + * @typedef {object} DeviceThresholdAlarmsParams + * @property {number} [device_id] - 按设备ID过滤 + * @property {SeverityLevel} [level] - 按告警等级过滤 + * @property {string} [order_by] - 排序字段,例如 "id DESC" + * @property {number} [page] + * @property {number} [page_size] + * @property {SensorType} [sensor_type] - 按传感器类型过滤 + */ + /** * @typedef {object} UpdateDeviceThresholdAlarmDTO * @property {Operator} operator - 新的操作符 @@ -147,6 +179,15 @@ export const getActiveAlarms = (params) => { return http.get('/api/v1/alarm/threshold/active-alarms', { params }); }; +/** + * 根据过滤条件和分页参数查询区域阈值告警列表 + * @param {AreaThresholdAlarmsParams} params - 查询参数 + * @returns {Promise} + */ +export const getAreaThresholdAlarms = (params) => { + return http.get('/api/v1/alarm/threshold/area', { params }); +}; + /** * 为指定的区域主控创建一个新的阈值告警规则 * @param {CreateAreaThresholdAlarmDTO} requestBody - 创建区域阈值告警请求体 @@ -184,6 +225,15 @@ export const deleteAreaThresholdAlarm = (task_id) => { return http.delete(`/api/v1/alarm/threshold/area/${task_id}`); }; +/** + * 根据过滤条件和分页参数查询设备阈值告警列表 + * @param {DeviceThresholdAlarmsParams} params - 查询参数 + * @returns {Promise} + */ +export const getDeviceThresholdAlarms = (params) => { + return http.get('/api/v1/alarm/threshold/device', { params }); +}; + /** * 为单个设备创建一个新的阈值告警规则 * @param {CreateDeviceThresholdAlarmDTO} requestBody - 创建设备阈值告警请求体 @@ -252,10 +302,12 @@ export const snoozeAlarm = (id, requestBody) => { export const AlarmApi = { getActiveAlarms, + getAreaThresholdAlarms, createAreaThresholdAlarm, getAreaThresholdAlarmById, updateAreaThresholdAlarm, deleteAreaThresholdAlarm, + getDeviceThresholdAlarms, createDeviceThresholdAlarm, getDeviceThresholdAlarmById, updateDeviceThresholdAlarm, diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index 302a80aa..c9e28981 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -17,7 +17,7 @@ :collapse="isCollapse" :collapse-transition="false" router - :default-openeds="['/device-management', '/monitor', '/pms']" + :default-openeds="['/device-management', '/monitor', '/pms', '/alarm']" > @@ -203,7 +203,18 @@ 告警中心 - + + + + + + + + + + + + @@ -344,7 +355,7 @@ export default { const activeMenu = computed(() => { const path = route.path; - if (path.startsWith('/monitor') || path.startsWith('/pms') || path.startsWith('/devices') || path.startsWith('/device-templates')) { + if (path.startsWith('/monitor') || path.startsWith('/pms') || path.startsWith('/devices') || path.startsWith('/device-templates') || path.startsWith('/alarms')) { return path; } return route.path; @@ -457,4 +468,4 @@ export default { font-size: 14px; border-top: 1px solid #eee; } - \ No newline at end of file + diff --git a/src/router/index.js b/src/router/index.js index 32ad2c28..fc2fc9bc 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -24,12 +24,16 @@ import TaskExecutionLogsView from '../views/monitor/TaskExecutionLogsView.vue'; import UserActionLogsView from '../views/monitor/UserActionLogsView.vue'; import WeighingBatchesView from '../views/monitor/WeighingBatchesView.vue'; import WeighingRecordsView from '../views/monitor/WeighingRecordsView.vue'; +import AlarmList from '../views/alarm/AlarmList.vue'; +import ThresholdAlarmList from '../views/alarm/ThresholdAlarmList.vue'; const routes = [ {path: '/', component: Home, meta: {requiresAuth: true, title: '系统首页'}}, {path: '/devices', component: DeviceList, meta: {requiresAuth: true, title: '设备管理'}}, {path: '/device-templates', component: DeviceTemplateList, meta: {requiresAuth: true, title: '设备模板管理'}}, {path: '/plans', component: PlanList, meta: {requiresAuth: true, title: '计划管理'}}, + {path: '/alarms', component: AlarmList, meta: {requiresAuth: true, title: '告警管理'}}, + {path: '/alarms/thresholds', component: ThresholdAlarmList, meta: {requiresAuth: true, title: '阈值告警配置'}}, {path: '/login', component: LoginForm}, {path: '/pms/farm-management', name: 'PigFarmManagement', component: PigFarmManagementView, meta: { requiresAuth: true, title: '栏舍管理' }}, {path: '/pms/batch-management', name: 'PigBatchManagement', component: PigBatchManagementView, meta: { requiresAuth: true, title: '猪群管理' }},