实现列表查询活跃告警和历史告警

This commit is contained in:
2025-11-10 13:41:26 +08:00
parent b94aa6137c
commit 37f515d4a8
13 changed files with 1792 additions and 70 deletions

View File

@@ -23,6 +23,339 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/api/v1/alarm/threshold/active-alarms": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据过滤条件和分页参数查询活跃告警列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"告警管理"
],
"summary": "批量查询活跃告警",
"parameters": [
{
"type": "string",
"description": "告警触发时间范围 - 结束时间",
"name": "end_time",
"in": "query"
},
{
"type": "boolean",
"description": "按是否被忽略过滤",
"name": "is_ignored",
"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": "排序字段,例如 \"trigger_time DESC\"",
"name": "order_by",
"in": "query"
},
{
"type": "integer",
"name": "page",
"in": "query"
},
{
"type": "integer",
"name": "page_size",
"in": "query"
},
{
"type": "integer",
"description": "按告警来源ID过滤",
"name": "source_id",
"in": "query"
},
{
"enum": [
"普通设备",
"区域主控",
"系统"
],
"type": "string",
"x-enum-varnames": [
"AlarmSourceTypeDevice",
"AlarmSourceTypeAreaController",
"AlarmSourceTypeSystem"
],
"description": "按告警来源类型过滤",
"name": "source_type",
"in": "query"
},
{
"type": "string",
"description": "告警触发时间范围 - 开始时间",
"name": "trigger_time",
"in": "query"
}
],
"responses": {
"200": {
"description": "成功获取活跃告警列表",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.ListActiveAlarmResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/alarm/threshold/historical-alarms": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据过滤条件和分页参数查询历史告警列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"告警管理"
],
"summary": "批量查询历史告警",
"parameters": [
{
"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": "排序字段,例如 \"trigger_time DESC\"",
"name": "order_by",
"in": "query"
},
{
"type": "integer",
"name": "page",
"in": "query"
},
{
"type": "integer",
"name": "page_size",
"in": "query"
},
{
"type": "string",
"description": "告警解决时间范围 - 结束时间",
"name": "resolve_time_end",
"in": "query"
},
{
"type": "string",
"description": "告警解决时间范围 - 开始时间",
"name": "resolve_time_start",
"in": "query"
},
{
"type": "integer",
"description": "按告警来源ID过滤",
"name": "source_id",
"in": "query"
},
{
"enum": [
"普通设备",
"区域主控",
"系统"
],
"type": "string",
"x-enum-varnames": [
"AlarmSourceTypeDevice",
"AlarmSourceTypeAreaController",
"AlarmSourceTypeSystem"
],
"description": "按告警来源类型过滤",
"name": "source_type",
"in": "query"
},
{
"type": "string",
"description": "告警触发时间范围 - 结束时间",
"name": "trigger_time_end",
"in": "query"
},
{
"type": "string",
"description": "告警触发时间范围 - 开始时间",
"name": "trigger_time_start",
"in": "query"
}
],
"responses": {
"200": {
"description": "成功获取历史告警列表",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.ListHistoricalAlarmResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/alarm/threshold/{id}/cancel-snooze": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据告警ID取消对一个阈值告警的忽略状态",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"告警管理"
],
"summary": "取消忽略阈值告警",
"parameters": [
{
"type": "string",
"description": "告警ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "成功取消忽略告警",
"schema": {
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/api/v1/alarm/threshold/{id}/snooze": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据告警ID忽略一个活跃的阈值告警或更新其忽略时间",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"告警管理"
],
"summary": "忽略阈值告警",
"parameters": [
{
"type": "string",
"description": "告警ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "忽略告警请求体",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.SnoozeAlarmRequest"
}
}
],
"responses": {
"200": {
"description": "成功忽略告警",
"schema": {
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/api/v1/area-controllers": {
"get": {
"security": [
@@ -4170,6 +4503,50 @@ const docTemplate = `{
"CodeServiceUnavailable"
]
},
"dto.ActiveAlarmDTO": {
"type": "object",
"properties": {
"alarm_code": {
"$ref": "#/definitions/models.AlarmCode"
},
"alarm_details": {
"type": "string"
},
"alarm_summary": {
"type": "string"
},
"created_at": {
"type": "string"
},
"id": {
"type": "integer"
},
"ignored_until": {
"type": "string"
},
"is_ignored": {
"type": "boolean"
},
"last_notified_at": {
"type": "string"
},
"level": {
"$ref": "#/definitions/models.SeverityLevel"
},
"source_id": {
"type": "integer"
},
"source_type": {
"$ref": "#/definitions/models.AlarmSourceType"
},
"trigger_time": {
"type": "string"
},
"updated_at": {
"type": "string"
}
}
},
"dto.AreaControllerResponse": {
"type": "object",
"properties": {
@@ -4589,6 +4966,58 @@ const docTemplate = `{
}
}
},
"dto.HistoricalAlarmDTO": {
"type": "object",
"properties": {
"alarm_code": {
"$ref": "#/definitions/models.AlarmCode"
},
"alarm_details": {
"type": "string"
},
"alarm_summary": {
"type": "string"
},
"id": {
"type": "integer"
},
"level": {
"$ref": "#/definitions/models.SeverityLevel"
},
"resolve_method": {
"type": "string"
},
"resolve_time": {
"type": "string"
},
"resolved_by": {
"type": "integer"
},
"source_id": {
"type": "integer"
},
"source_type": {
"$ref": "#/definitions/models.AlarmSourceType"
},
"trigger_time": {
"type": "string"
}
}
},
"dto.ListActiveAlarmResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.ActiveAlarmDTO"
}
},
"pagination": {
"$ref": "#/definitions/dto.PaginationDTO"
}
}
},
"dto.ListDeviceCommandLogResponse": {
"type": "object",
"properties": {
@@ -4617,6 +5046,20 @@ const docTemplate = `{
}
}
},
"dto.ListHistoricalAlarmResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.HistoricalAlarmDTO"
}
},
"pagination": {
"$ref": "#/definitions/dto.PaginationDTO"
}
}
},
"dto.ListMedicationLogResponse": {
"type": "object",
"properties": {
@@ -4984,13 +5427,13 @@ const docTemplate = `{
"type": "integer"
},
"level": {
"$ref": "#/definitions/zapcore.Level"
"$ref": "#/definitions/models.SeverityLevel"
},
"message": {
"type": "string"
},
"notifier_type": {
"$ref": "#/definitions/notify.NotifierType"
"$ref": "#/definitions/models.NotifierType"
},
"status": {
"$ref": "#/definitions/models.NotificationStatus"
@@ -5882,7 +6325,7 @@ const docTemplate = `{
"description": "Type 指定要测试的通知渠道",
"allOf": [
{
"$ref": "#/definitions/notify.NotifierType"
"$ref": "#/definitions/models.NotifierType"
}
]
}
@@ -5911,6 +6354,19 @@ const docTemplate = `{
}
}
},
"dto.SnoozeAlarmRequest": {
"type": "object",
"required": [
"duration_minutes"
],
"properties": {
"duration_minutes": {
"description": "忽略时长,单位分钟",
"type": "integer",
"minimum": 1
}
}
},
"dto.SubPlanResponse": {
"type": "object",
"properties": {
@@ -6412,6 +6868,40 @@ const docTemplate = `{
}
}
},
"models.AlarmCode": {
"type": "string",
"enum": [
"温度阈值",
"湿度阈值",
"重量阈值",
"电池电量阈值",
"信号强度阈值",
"设备离线",
"区域主控离线"
],
"x-enum-varnames": [
"AlarmCodeTemperature",
"AlarmCodeHumidity",
"AlarmCodeWeight",
"AlarmCodeBatteryLevel",
"AlarmCodeSignalMetrics",
"AlarmCodeDeviceOffline",
"AlarmCodeAreaControllerOffline"
]
},
"models.AlarmSourceType": {
"type": "string",
"enum": [
"普通设备",
"区域主控",
"系统"
],
"x-enum-varnames": [
"AlarmSourceTypeDevice",
"AlarmSourceTypeAreaController",
"AlarmSourceTypeSystem"
]
},
"models.AuditStatus": {
"type": "string",
"enum": [
@@ -6522,6 +7012,21 @@ const docTemplate = `{
"NotificationStatusSkipped"
]
},
"models.NotifierType": {
"type": "string",
"enum": [
"邮件",
"企业微信",
"飞书",
"日志"
],
"x-enum-varnames": [
"NotifierTypeSMTP",
"NotifierTypeWeChat",
"NotifierTypeLark",
"NotifierTypeLog"
]
},
"models.PenStatus": {
"type": "string",
"enum": [
@@ -6805,6 +7310,27 @@ const docTemplate = `{
"SensorTypeWeight"
]
},
"models.SeverityLevel": {
"type": "string",
"enum": [
"Debug",
"Info",
"Warn",
"Error",
"DPanic",
"Panic",
"Fatal"
],
"x-enum-varnames": [
"DebugLevel",
"InfoLevel",
"WarnLevel",
"ErrorLevel",
"DPanicLevel",
"PanicLevel",
"FatalLevel"
]
},
"models.StockLogSourceType": {
"type": "string",
"enum": [
@@ -6830,10 +7356,12 @@ const docTemplate = `{
"计划分析",
"等待",
"下料",
"全量采集"
"全量采集",
"告警通知"
],
"x-enum-comments": {
"TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务",
"TaskTypeAlarmNotification": "告警通知任务",
"TaskTypeFullCollection": "新增的全量采集任务",
"TaskTypeReleaseFeedWeight": "下料口释放指定重量任务",
"TaskTypeWaiting": "等待任务"
@@ -6842,13 +7370,15 @@ const docTemplate = `{
"解析Plan的Task列表并添加到待执行队列的特殊任务",
"等待任务",
"下料口释放指定重量任务",
"新增的全量采集任务"
"新增的全量采集任务",
"告警通知任务"
],
"x-enum-varnames": [
"TaskPlanAnalysis",
"TaskTypeWaiting",
"TaskTypeReleaseFeedWeight",
"TaskTypeFullCollection"
"TaskTypeFullCollection",
"TaskTypeAlarmNotification"
]
},
"models.ValueDescriptor": {
@@ -6867,21 +7397,6 @@ const docTemplate = `{
}
}
},
"notify.NotifierType": {
"type": "string",
"enum": [
"邮件",
"企业微信",
"飞书",
"日志"
],
"x-enum-varnames": [
"NotifierTypeSMTP",
"NotifierTypeWeChat",
"NotifierTypeLark",
"NotifierTypeLog"
]
},
"repository.PlanTypeFilter": {
"type": "string",
"enum": [

View File

@@ -15,6 +15,339 @@
"version": "1.0"
},
"paths": {
"/api/v1/alarm/threshold/active-alarms": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据过滤条件和分页参数查询活跃告警列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"告警管理"
],
"summary": "批量查询活跃告警",
"parameters": [
{
"type": "string",
"description": "告警触发时间范围 - 结束时间",
"name": "end_time",
"in": "query"
},
{
"type": "boolean",
"description": "按是否被忽略过滤",
"name": "is_ignored",
"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": "排序字段,例如 \"trigger_time DESC\"",
"name": "order_by",
"in": "query"
},
{
"type": "integer",
"name": "page",
"in": "query"
},
{
"type": "integer",
"name": "page_size",
"in": "query"
},
{
"type": "integer",
"description": "按告警来源ID过滤",
"name": "source_id",
"in": "query"
},
{
"enum": [
"普通设备",
"区域主控",
"系统"
],
"type": "string",
"x-enum-varnames": [
"AlarmSourceTypeDevice",
"AlarmSourceTypeAreaController",
"AlarmSourceTypeSystem"
],
"description": "按告警来源类型过滤",
"name": "source_type",
"in": "query"
},
{
"type": "string",
"description": "告警触发时间范围 - 开始时间",
"name": "trigger_time",
"in": "query"
}
],
"responses": {
"200": {
"description": "成功获取活跃告警列表",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.ListActiveAlarmResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/alarm/threshold/historical-alarms": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据过滤条件和分页参数查询历史告警列表",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"告警管理"
],
"summary": "批量查询历史告警",
"parameters": [
{
"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": "排序字段,例如 \"trigger_time DESC\"",
"name": "order_by",
"in": "query"
},
{
"type": "integer",
"name": "page",
"in": "query"
},
{
"type": "integer",
"name": "page_size",
"in": "query"
},
{
"type": "string",
"description": "告警解决时间范围 - 结束时间",
"name": "resolve_time_end",
"in": "query"
},
{
"type": "string",
"description": "告警解决时间范围 - 开始时间",
"name": "resolve_time_start",
"in": "query"
},
{
"type": "integer",
"description": "按告警来源ID过滤",
"name": "source_id",
"in": "query"
},
{
"enum": [
"普通设备",
"区域主控",
"系统"
],
"type": "string",
"x-enum-varnames": [
"AlarmSourceTypeDevice",
"AlarmSourceTypeAreaController",
"AlarmSourceTypeSystem"
],
"description": "按告警来源类型过滤",
"name": "source_type",
"in": "query"
},
{
"type": "string",
"description": "告警触发时间范围 - 结束时间",
"name": "trigger_time_end",
"in": "query"
},
{
"type": "string",
"description": "告警触发时间范围 - 开始时间",
"name": "trigger_time_start",
"in": "query"
}
],
"responses": {
"200": {
"description": "成功获取历史告警列表",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.ListHistoricalAlarmResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/alarm/threshold/{id}/cancel-snooze": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据告警ID取消对一个阈值告警的忽略状态",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"告警管理"
],
"summary": "取消忽略阈值告警",
"parameters": [
{
"type": "string",
"description": "告警ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "成功取消忽略告警",
"schema": {
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/api/v1/alarm/threshold/{id}/snooze": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据告警ID忽略一个活跃的阈值告警或更新其忽略时间",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"告警管理"
],
"summary": "忽略阈值告警",
"parameters": [
{
"type": "string",
"description": "告警ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "忽略告警请求体",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.SnoozeAlarmRequest"
}
}
],
"responses": {
"200": {
"description": "成功忽略告警",
"schema": {
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/api/v1/area-controllers": {
"get": {
"security": [
@@ -4162,6 +4495,50 @@
"CodeServiceUnavailable"
]
},
"dto.ActiveAlarmDTO": {
"type": "object",
"properties": {
"alarm_code": {
"$ref": "#/definitions/models.AlarmCode"
},
"alarm_details": {
"type": "string"
},
"alarm_summary": {
"type": "string"
},
"created_at": {
"type": "string"
},
"id": {
"type": "integer"
},
"ignored_until": {
"type": "string"
},
"is_ignored": {
"type": "boolean"
},
"last_notified_at": {
"type": "string"
},
"level": {
"$ref": "#/definitions/models.SeverityLevel"
},
"source_id": {
"type": "integer"
},
"source_type": {
"$ref": "#/definitions/models.AlarmSourceType"
},
"trigger_time": {
"type": "string"
},
"updated_at": {
"type": "string"
}
}
},
"dto.AreaControllerResponse": {
"type": "object",
"properties": {
@@ -4581,6 +4958,58 @@
}
}
},
"dto.HistoricalAlarmDTO": {
"type": "object",
"properties": {
"alarm_code": {
"$ref": "#/definitions/models.AlarmCode"
},
"alarm_details": {
"type": "string"
},
"alarm_summary": {
"type": "string"
},
"id": {
"type": "integer"
},
"level": {
"$ref": "#/definitions/models.SeverityLevel"
},
"resolve_method": {
"type": "string"
},
"resolve_time": {
"type": "string"
},
"resolved_by": {
"type": "integer"
},
"source_id": {
"type": "integer"
},
"source_type": {
"$ref": "#/definitions/models.AlarmSourceType"
},
"trigger_time": {
"type": "string"
}
}
},
"dto.ListActiveAlarmResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.ActiveAlarmDTO"
}
},
"pagination": {
"$ref": "#/definitions/dto.PaginationDTO"
}
}
},
"dto.ListDeviceCommandLogResponse": {
"type": "object",
"properties": {
@@ -4609,6 +5038,20 @@
}
}
},
"dto.ListHistoricalAlarmResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.HistoricalAlarmDTO"
}
},
"pagination": {
"$ref": "#/definitions/dto.PaginationDTO"
}
}
},
"dto.ListMedicationLogResponse": {
"type": "object",
"properties": {
@@ -4976,13 +5419,13 @@
"type": "integer"
},
"level": {
"$ref": "#/definitions/zapcore.Level"
"$ref": "#/definitions/models.SeverityLevel"
},
"message": {
"type": "string"
},
"notifier_type": {
"$ref": "#/definitions/notify.NotifierType"
"$ref": "#/definitions/models.NotifierType"
},
"status": {
"$ref": "#/definitions/models.NotificationStatus"
@@ -5874,7 +6317,7 @@
"description": "Type 指定要测试的通知渠道",
"allOf": [
{
"$ref": "#/definitions/notify.NotifierType"
"$ref": "#/definitions/models.NotifierType"
}
]
}
@@ -5903,6 +6346,19 @@
}
}
},
"dto.SnoozeAlarmRequest": {
"type": "object",
"required": [
"duration_minutes"
],
"properties": {
"duration_minutes": {
"description": "忽略时长,单位分钟",
"type": "integer",
"minimum": 1
}
}
},
"dto.SubPlanResponse": {
"type": "object",
"properties": {
@@ -6404,6 +6860,40 @@
}
}
},
"models.AlarmCode": {
"type": "string",
"enum": [
"温度阈值",
"湿度阈值",
"重量阈值",
"电池电量阈值",
"信号强度阈值",
"设备离线",
"区域主控离线"
],
"x-enum-varnames": [
"AlarmCodeTemperature",
"AlarmCodeHumidity",
"AlarmCodeWeight",
"AlarmCodeBatteryLevel",
"AlarmCodeSignalMetrics",
"AlarmCodeDeviceOffline",
"AlarmCodeAreaControllerOffline"
]
},
"models.AlarmSourceType": {
"type": "string",
"enum": [
"普通设备",
"区域主控",
"系统"
],
"x-enum-varnames": [
"AlarmSourceTypeDevice",
"AlarmSourceTypeAreaController",
"AlarmSourceTypeSystem"
]
},
"models.AuditStatus": {
"type": "string",
"enum": [
@@ -6514,6 +7004,21 @@
"NotificationStatusSkipped"
]
},
"models.NotifierType": {
"type": "string",
"enum": [
"邮件",
"企业微信",
"飞书",
"日志"
],
"x-enum-varnames": [
"NotifierTypeSMTP",
"NotifierTypeWeChat",
"NotifierTypeLark",
"NotifierTypeLog"
]
},
"models.PenStatus": {
"type": "string",
"enum": [
@@ -6797,6 +7302,27 @@
"SensorTypeWeight"
]
},
"models.SeverityLevel": {
"type": "string",
"enum": [
"Debug",
"Info",
"Warn",
"Error",
"DPanic",
"Panic",
"Fatal"
],
"x-enum-varnames": [
"DebugLevel",
"InfoLevel",
"WarnLevel",
"ErrorLevel",
"DPanicLevel",
"PanicLevel",
"FatalLevel"
]
},
"models.StockLogSourceType": {
"type": "string",
"enum": [
@@ -6822,10 +7348,12 @@
"计划分析",
"等待",
"下料",
"全量采集"
"全量采集",
"告警通知"
],
"x-enum-comments": {
"TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务",
"TaskTypeAlarmNotification": "告警通知任务",
"TaskTypeFullCollection": "新增的全量采集任务",
"TaskTypeReleaseFeedWeight": "下料口释放指定重量任务",
"TaskTypeWaiting": "等待任务"
@@ -6834,13 +7362,15 @@
"解析Plan的Task列表并添加到待执行队列的特殊任务",
"等待任务",
"下料口释放指定重量任务",
"新增的全量采集任务"
"新增的全量采集任务",
"告警通知任务"
],
"x-enum-varnames": [
"TaskPlanAnalysis",
"TaskTypeWaiting",
"TaskTypeReleaseFeedWeight",
"TaskTypeFullCollection"
"TaskTypeFullCollection",
"TaskTypeAlarmNotification"
]
},
"models.ValueDescriptor": {
@@ -6859,21 +7389,6 @@
}
}
},
"notify.NotifierType": {
"type": "string",
"enum": [
"邮件",
"企业微信",
"飞书",
"日志"
],
"x-enum-varnames": [
"NotifierTypeSMTP",
"NotifierTypeWeChat",
"NotifierTypeLark",
"NotifierTypeLog"
]
},
"repository.PlanTypeFilter": {
"type": "string",
"enum": [

View File

@@ -53,6 +53,35 @@ definitions:
- CodeConflict
- CodeInternalError
- CodeServiceUnavailable
dto.ActiveAlarmDTO:
properties:
alarm_code:
$ref: '#/definitions/models.AlarmCode'
alarm_details:
type: string
alarm_summary:
type: string
created_at:
type: string
id:
type: integer
ignored_until:
type: string
is_ignored:
type: boolean
last_notified_at:
type: string
level:
$ref: '#/definitions/models.SeverityLevel'
source_id:
type: integer
source_type:
$ref: '#/definitions/models.AlarmSourceType'
trigger_time:
type: string
updated_at:
type: string
type: object
dto.AreaControllerResponse:
properties:
created_at:
@@ -340,6 +369,40 @@ definitions:
remarks:
type: string
type: object
dto.HistoricalAlarmDTO:
properties:
alarm_code:
$ref: '#/definitions/models.AlarmCode'
alarm_details:
type: string
alarm_summary:
type: string
id:
type: integer
level:
$ref: '#/definitions/models.SeverityLevel'
resolve_method:
type: string
resolve_time:
type: string
resolved_by:
type: integer
source_id:
type: integer
source_type:
$ref: '#/definitions/models.AlarmSourceType'
trigger_time:
type: string
type: object
dto.ListActiveAlarmResponse:
properties:
list:
items:
$ref: '#/definitions/dto.ActiveAlarmDTO'
type: array
pagination:
$ref: '#/definitions/dto.PaginationDTO'
type: object
dto.ListDeviceCommandLogResponse:
properties:
list:
@@ -358,6 +421,15 @@ definitions:
pagination:
$ref: '#/definitions/dto.PaginationDTO'
type: object
dto.ListHistoricalAlarmResponse:
properties:
list:
items:
$ref: '#/definitions/dto.HistoricalAlarmDTO'
type: array
pagination:
$ref: '#/definitions/dto.PaginationDTO'
type: object
dto.ListMedicationLogResponse:
properties:
list:
@@ -600,11 +672,11 @@ definitions:
id:
type: integer
level:
$ref: '#/definitions/zapcore.Level'
$ref: '#/definitions/models.SeverityLevel'
message:
type: string
notifier_type:
$ref: '#/definitions/notify.NotifierType'
$ref: '#/definitions/models.NotifierType'
status:
$ref: '#/definitions/models.NotificationStatus'
title:
@@ -1199,7 +1271,7 @@ definitions:
properties:
type:
allOf:
- $ref: '#/definitions/notify.NotifierType'
- $ref: '#/definitions/models.NotifierType'
description: Type 指定要测试的通知渠道
required:
- type
@@ -1219,6 +1291,15 @@ definitions:
time:
type: string
type: object
dto.SnoozeAlarmRequest:
properties:
duration_minutes:
description: 忽略时长,单位分钟
minimum: 1
type: integer
required:
- duration_minutes
type: object
dto.SubPlanResponse:
properties:
child_plan:
@@ -1558,6 +1639,34 @@ definitions:
weight:
type: number
type: object
models.AlarmCode:
enum:
- 温度阈值
- 湿度阈值
- 重量阈值
- 电池电量阈值
- 信号强度阈值
- 设备离线
- 区域主控离线
type: string
x-enum-varnames:
- AlarmCodeTemperature
- AlarmCodeHumidity
- AlarmCodeWeight
- AlarmCodeBatteryLevel
- AlarmCodeSignalMetrics
- AlarmCodeDeviceOffline
- AlarmCodeAreaControllerOffline
models.AlarmSourceType:
enum:
- 普通设备
- 区域主控
- 系统
type: string
x-enum-varnames:
- AlarmSourceTypeDevice
- AlarmSourceTypeAreaController
- AlarmSourceTypeSystem
models.AuditStatus:
enum:
- 成功
@@ -1646,6 +1755,18 @@ definitions:
- NotificationStatusSuccess
- NotificationStatusFailed
- NotificationStatusSkipped
models.NotifierType:
enum:
- 邮件
- 企业微信
- 飞书
- 日志
type: string
x-enum-varnames:
- NotifierTypeSMTP
- NotifierTypeWeChat
- NotifierTypeLark
- NotifierTypeLog
models.PenStatus:
enum:
- 空闲
@@ -1877,6 +1998,24 @@ definitions:
- SensorTypeTemperature
- SensorTypeHumidity
- SensorTypeWeight
models.SeverityLevel:
enum:
- Debug
- Info
- Warn
- Error
- DPanic
- Panic
- Fatal
type: string
x-enum-varnames:
- DebugLevel
- InfoLevel
- WarnLevel
- ErrorLevel
- DPanicLevel
- PanicLevel
- FatalLevel
models.StockLogSourceType:
enum:
- 采购入库
@@ -1899,9 +2038,11 @@ definitions:
- 等待
- 下料
- 全量采集
- 告警通知
type: string
x-enum-comments:
TaskPlanAnalysis: 解析Plan的Task列表并添加到待执行队列的特殊任务
TaskTypeAlarmNotification: 告警通知任务
TaskTypeFullCollection: 新增的全量采集任务
TaskTypeReleaseFeedWeight: 下料口释放指定重量任务
TaskTypeWaiting: 等待任务
@@ -1910,11 +2051,13 @@ definitions:
- 等待任务
- 下料口释放指定重量任务
- 新增的全量采集任务
- 告警通知任务
x-enum-varnames:
- TaskPlanAnalysis
- TaskTypeWaiting
- TaskTypeReleaseFeedWeight
- TaskTypeFullCollection
- TaskTypeAlarmNotification
models.ValueDescriptor:
properties:
multiplier:
@@ -1926,18 +2069,6 @@ definitions:
type:
$ref: '#/definitions/models.SensorType'
type: object
notify.NotifierType:
enum:
- 邮件
- 企业微信
- 飞书
- 日志
type: string
x-enum-varnames:
- NotifierTypeSMTP
- NotifierTypeWeChat
- NotifierTypeLark
- NotifierTypeLog
repository.PlanTypeFilter:
enum:
- 所有任务
@@ -1987,6 +2118,224 @@ info:
title: 猪场管理系统 API
version: "1.0"
paths:
/api/v1/alarm/threshold/{id}/cancel-snooze:
post:
consumes:
- application/json
description: 根据告警ID取消对一个阈值告警的忽略状态
parameters:
- description: 告警ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: 成功取消忽略告警
schema:
$ref: '#/definitions/controller.Response'
security:
- BearerAuth: []
summary: 取消忽略阈值告警
tags:
- 告警管理
/api/v1/alarm/threshold/{id}/snooze:
post:
consumes:
- application/json
description: 根据告警ID忽略一个活跃的阈值告警或更新其忽略时间
parameters:
- description: 告警ID
in: path
name: id
required: true
type: string
- description: 忽略告警请求体
in: body
name: request
required: true
schema:
$ref: '#/definitions/dto.SnoozeAlarmRequest'
produces:
- application/json
responses:
"200":
description: 成功忽略告警
schema:
$ref: '#/definitions/controller.Response'
security:
- BearerAuth: []
summary: 忽略阈值告警
tags:
- 告警管理
/api/v1/alarm/threshold/active-alarms:
get:
consumes:
- application/json
description: 根据过滤条件和分页参数查询活跃告警列表
parameters:
- description: 告警触发时间范围 - 结束时间
in: query
name: end_time
type: string
- description: 按是否被忽略过滤
in: query
name: is_ignored
type: boolean
- description: 按告警严重性等级过滤
enum:
- Debug
- Info
- Warn
- Error
- DPanic
- Panic
- Fatal
in: query
name: level
type: string
x-enum-varnames:
- DebugLevel
- InfoLevel
- WarnLevel
- ErrorLevel
- DPanicLevel
- PanicLevel
- FatalLevel
- description: 排序字段,例如 "trigger_time DESC"
in: query
name: order_by
type: string
- in: query
name: page
type: integer
- in: query
name: page_size
type: integer
- description: 按告警来源ID过滤
in: query
name: source_id
type: integer
- description: 按告警来源类型过滤
enum:
- 普通设备
- 区域主控
- 系统
in: query
name: source_type
type: string
x-enum-varnames:
- AlarmSourceTypeDevice
- AlarmSourceTypeAreaController
- AlarmSourceTypeSystem
- description: 告警触发时间范围 - 开始时间
in: query
name: trigger_time
type: string
produces:
- application/json
responses:
"200":
description: 成功获取活跃告警列表
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/dto.ListActiveAlarmResponse'
type: object
security:
- BearerAuth: []
summary: 批量查询活跃告警
tags:
- 告警管理
/api/v1/alarm/threshold/historical-alarms:
get:
consumes:
- application/json
description: 根据过滤条件和分页参数查询历史告警列表
parameters:
- description: 按告警严重性等级过滤
enum:
- Debug
- Info
- Warn
- Error
- DPanic
- Panic
- Fatal
in: query
name: level
type: string
x-enum-varnames:
- DebugLevel
- InfoLevel
- WarnLevel
- ErrorLevel
- DPanicLevel
- PanicLevel
- FatalLevel
- description: 排序字段,例如 "trigger_time DESC"
in: query
name: order_by
type: string
- in: query
name: page
type: integer
- in: query
name: page_size
type: integer
- description: 告警解决时间范围 - 结束时间
in: query
name: resolve_time_end
type: string
- description: 告警解决时间范围 - 开始时间
in: query
name: resolve_time_start
type: string
- description: 按告警来源ID过滤
in: query
name: source_id
type: integer
- description: 按告警来源类型过滤
enum:
- 普通设备
- 区域主控
- 系统
in: query
name: source_type
type: string
x-enum-varnames:
- AlarmSourceTypeDevice
- AlarmSourceTypeAreaController
- AlarmSourceTypeSystem
- description: 告警触发时间范围 - 结束时间
in: query
name: trigger_time_end
type: string
- description: 告警触发时间范围 - 开始时间
in: query
name: trigger_time_start
type: string
produces:
- application/json
responses:
"200":
description: 成功获取历史告警列表
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/dto.ListHistoricalAlarmResponse'
type: object
security:
- BearerAuth: []
summary: 批量查询历史告警
tags:
- 告警管理
/api/v1/area-controllers:
get:
description: 获取系统中所有区域主控的列表