更新swag

This commit is contained in:
2025-12-07 18:08:22 +08:00
parent 1f06688237
commit 534446931d
3 changed files with 339 additions and 21 deletions

View File

@@ -208,12 +208,14 @@
"电池电量",
"温度",
"湿度",
"重量"
"重量",
"在线状态"
],
"type": "string",
"x-enum-comments": {
"SensorTypeBatteryLevel": "电池电量",
"SensorTypeHumidity": "湿度",
"SensorTypeOnlineStatus": "在线状态",
"SensorTypeSignalMetrics": "信号强度",
"SensorTypeTemperature": "温度",
"SensorTypeWeight": "重量"
@@ -223,14 +225,16 @@
"电池电量",
"温度",
"湿度",
"重量"
"重量",
"在线状态"
],
"x-enum-varnames": [
"SensorTypeSignalMetrics",
"SensorTypeBatteryLevel",
"SensorTypeTemperature",
"SensorTypeHumidity",
"SensorTypeWeight"
"SensorTypeWeight",
"SensorTypeOnlineStatus"
],
"description": "按传感器类型过滤",
"name": "sensor_type",
@@ -489,12 +493,14 @@
"电池电量",
"温度",
"湿度",
"重量"
"重量",
"在线状态"
],
"type": "string",
"x-enum-comments": {
"SensorTypeBatteryLevel": "电池电量",
"SensorTypeHumidity": "湿度",
"SensorTypeOnlineStatus": "在线状态",
"SensorTypeSignalMetrics": "信号强度",
"SensorTypeTemperature": "温度",
"SensorTypeWeight": "重量"
@@ -504,14 +510,16 @@
"电池电量",
"温度",
"湿度",
"重量"
"重量",
"在线状态"
],
"x-enum-varnames": [
"SensorTypeSignalMetrics",
"SensorTypeBatteryLevel",
"SensorTypeTemperature",
"SensorTypeHumidity",
"SensorTypeWeight"
"SensorTypeWeight",
"SensorTypeOnlineStatus"
],
"description": "按传感器类型过滤",
"name": "sensor_type",
@@ -1011,6 +1019,86 @@
}
}
},
"/api/v1/area-controllers/ota/progress/{taskId}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据任务ID查询指定OTA升级任务的当前进度",
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "查询OTA升级进度",
"parameters": [
{
"type": "string",
"description": "OTA任务ID",
"name": "taskId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.OtaUpgradeProgressResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/area-controllers/ota/tasks/{taskId}/stop": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据任务ID请求停止一个正在进行的OTA升级任务",
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "停止OTA升级任务",
"parameters": [
{
"type": "string",
"description": "OTA任务ID",
"name": "taskId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/api/v1/area-controllers/{id}": {
"get": {
"security": [
@@ -1145,6 +1233,62 @@
}
}
},
"/api/v1/area-controllers/{id}/ota/start": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "为指定的区域主控上传固件并启动一个OTA升级任务",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "启动区域主控OTA升级",
"parameters": [
{
"type": "string",
"description": "区域主控ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "file",
"description": "固件压缩包文件",
"name": "firmware_file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.OtaUpgradeResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/device-templates": {
"get": {
"security": [
@@ -3812,6 +3956,7 @@
},
{
"enum": [
7,
-1,
0,
1,
@@ -3821,12 +3966,12 @@
5,
-1,
5,
6,
7
6
],
"type": "integer",
"format": "int32",
"x-enum-varnames": [
"_numLevels",
"DebugLevel",
"InfoLevel",
"WarnLevel",
@@ -3836,8 +3981,7 @@
"FatalLevel",
"_minLevel",
"_maxLevel",
"InvalidLevel",
"_numLevels"
"InvalidLevel"
],
"name": "level",
"in": "query"
@@ -6881,6 +7025,9 @@
"created_at": {
"type": "string"
},
"firmware_version": {
"type": "string"
},
"id": {
"type": "integer"
},
@@ -8233,6 +8380,36 @@
}
}
},
"dto.OtaUpgradeProgressResponse": {
"type": "object",
"properties": {
"current_stage": {
"description": "当前阶段",
"allOf": [
{
"$ref": "#/definitions/models.OTATaskStatus"
}
]
},
"message": {
"description": "状态消息",
"type": "string"
},
"task_id": {
"description": "OTA 升级任务ID",
"type": "integer"
}
}
},
"dto.OtaUpgradeResponse": {
"type": "object",
"properties": {
"task_id": {
"description": "OTA 升级任务ID",
"type": "integer"
}
}
},
"dto.PaginationDTO": {
"type": "object",
"properties": {
@@ -10149,9 +10326,11 @@
"models.AIModel": {
"type": "string",
"enum": [
"None",
"Gemini"
],
"x-enum-varnames": [
"AI_MODEL_NONE",
"AI_MODEL_GEMINI"
]
},
@@ -10314,6 +10493,61 @@
"NotifierTypeLog"
]
},
"models.OTATaskStatus": {
"type": "string",
"enum": [
"待开始",
"进行中",
"成功",
"版本已是最新",
"准备升级失败",
"预检失败",
"下载或校验失败",
"固件回滚",
"超时",
"平台内部错误",
"手动停止"
],
"x-enum-comments": {
"OTATaskStatusAlreadyUpToDate": "设备报告版本已是最新,未执行升级",
"OTATaskStatusFailedDownload": "设备报告文件下载或校验失败 (包括清单文件和固件文件)",
"OTATaskStatusFailedPreCheck": "设备报告升级前检查失败 (如拒绝降级、准备分区失败)",
"OTATaskStatusFailedPreparation": "平台在解压、生成清单等文件操作阶段发生错误",
"OTATaskStatusFailedRollback": "新固件启动失败,设备自动回滚",
"OTATaskStatusInProgress": "任务已下发,设备正在处理",
"OTATaskStatusPending": "任务已创建,等待下发",
"OTATaskStatusPlatformError": "平台处理过程中发生的非设备报告错误",
"OTATaskStatusStopped": "手动停止",
"OTATaskStatusSuccess": "设备报告升级成功,新固件已运行",
"OTATaskStatusTimedOut": "平台在超时后仍未收到最终报告"
},
"x-enum-descriptions": [
"任务已创建,等待下发",
"任务已下发,设备正在处理",
"设备报告升级成功,新固件已运行",
"设备报告版本已是最新,未执行升级",
"平台在解压、生成清单等文件操作阶段发生错误",
"设备报告升级前检查失败 (如拒绝降级、准备分区失败)",
"设备报告文件下载或校验失败 (包括清单文件和固件文件)",
"新固件启动失败,设备自动回滚",
"平台在超时后仍未收到最终报告",
"平台处理过程中发生的非设备报告错误",
"手动停止"
],
"x-enum-varnames": [
"OTATaskStatusPending",
"OTATaskStatusInProgress",
"OTATaskStatusSuccess",
"OTATaskStatusAlreadyUpToDate",
"OTATaskStatusFailedPreparation",
"OTATaskStatusFailedPreCheck",
"OTATaskStatusFailedDownload",
"OTATaskStatusFailedRollback",
"OTATaskStatusTimedOut",
"OTATaskStatusPlatformError",
"OTATaskStatusStopped"
]
},
"models.Operator": {
"type": "string",
"enum": [
@@ -10584,11 +10818,13 @@
"电池电量",
"温度",
"湿度",
"重量"
"重量",
"在线状态"
],
"x-enum-comments": {
"SensorTypeBatteryLevel": "电池电量",
"SensorTypeHumidity": "湿度",
"SensorTypeOnlineStatus": "在线状态",
"SensorTypeSignalMetrics": "信号强度",
"SensorTypeTemperature": "温度",
"SensorTypeWeight": "重量"
@@ -10598,14 +10834,16 @@
"电池电量",
"温度",
"湿度",
"重量"
"重量",
"在线状态"
],
"x-enum-varnames": [
"SensorTypeSignalMetrics",
"SensorTypeBatteryLevel",
"SensorTypeTemperature",
"SensorTypeHumidity",
"SensorTypeWeight"
"SensorTypeWeight",
"SensorTypeOnlineStatus"
]
},
"models.SeverityLevel": {
@@ -10673,10 +10911,12 @@
"等待",
"下料",
"全量采集",
"心跳检测",
"告警通知",
"通知刷新",
"设备阈值检查",
"区域阈值检查"
"区域阈值检查",
"OTA升级检查任务"
],
"x-enum-comments": {
"TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务",
@@ -10684,7 +10924,9 @@
"TaskTypeAreaCollectorThresholdCheck": "区域阈值检查任务",
"TaskTypeDeviceThresholdCheck": "设备阈值检查任务",
"TaskTypeFullCollection": "新增的全量采集任务",
"TaskTypeHeartbeat": "区域主控心跳检测任务",
"TaskTypeNotificationRefresh": "通知刷新任务",
"TaskTypeOTACheck": "OTA升级超时检查任务",
"TaskTypeReleaseFeedWeight": "下料口释放指定重量任务",
"TaskTypeWaiting": "等待任务"
},
@@ -10693,20 +10935,24 @@
"等待任务",
"下料口释放指定重量任务",
"新增的全量采集任务",
"区域主控心跳检测任务",
"告警通知任务",
"通知刷新任务",
"设备阈值检查任务",
"区域阈值检查任务"
"区域阈值检查任务",
"OTA升级超时检查任务"
],
"x-enum-varnames": [
"TaskPlanAnalysis",
"TaskTypeWaiting",
"TaskTypeReleaseFeedWeight",
"TaskTypeFullCollection",
"TaskTypeHeartbeat",
"TaskTypeAlarmNotification",
"TaskTypeNotificationRefresh",
"TaskTypeDeviceThresholdCheck",
"TaskTypeAreaCollectorThresholdCheck"
"TaskTypeAreaCollectorThresholdCheck",
"TaskTypeOTACheck"
]
},
"models.ValueDescriptor": {
@@ -10742,6 +10988,7 @@
"type": "integer",
"format": "int32",
"enum": [
7,
-1,
0,
1,
@@ -10751,10 +10998,10 @@
5,
-1,
5,
6,
7
6
],
"x-enum-varnames": [
"_numLevels",
"DebugLevel",
"InfoLevel",
"WarnLevel",
@@ -10764,8 +11011,7 @@
"FatalLevel",
"_minLevel",
"_maxLevel",
"InvalidLevel",
"_numLevels"
"InvalidLevel"
]
}
},

View File

@@ -8,6 +8,7 @@ import { Response } from '../enums';
* @property {string} network_id
* @property {string} location
* @property {string} status
* @property {string} firmware_version
* @property {object} properties
* @property {string} created_at
* @property {string} updated_at
@@ -29,6 +30,18 @@ import { Response } from '../enums';
* @property {object} [properties]
*/
/**
* @typedef {object} OtaUpgradeResponse
* @property {number} task_id - OTA 升级任务ID
*/
/**
* @typedef {object} OtaUpgradeProgressResponse
* @property {number} task_id - OTA 升级任务ID
* @property {string} current_stage - 当前阶段
* @property {string} message - 状态消息
*/
/**
* 获取系统中所有区域主控的列表
* @returns {Promise<Array<AreaControllerResponse>>}
@@ -74,10 +87,47 @@ export const deleteAreaController = (id) => {
return http.delete(`/api/v1/area-controllers/${id}`);
};
/**
* 为指定的区域主控上传固件并启动一个OTA升级任务
* @param {string} id - 区域主控ID
* @param {File} firmwareFile - 固件压缩包文件
* @returns {Promise<OtaUpgradeResponse>}
*/
export const startOtaUpdate = (id, firmwareFile) => {
const formData = new FormData();
formData.append('firmware_file', firmwareFile);
return http.post(`/api/v1/area-controllers/${id}/ota/start`, formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
});
};
/**
* 根据任务ID查询指定OTA升级任务的当前进度
* @param {string} taskId - OTA任务ID
* @returns {Promise<OtaUpgradeProgressResponse>}
*/
export const getOtaProgress = (taskId) => {
return http.get(`/api/v1/area-controllers/ota/progress/${taskId}`);
};
/**
* 根据任务ID请求停止一个正在进行的OTA升级任务
* @param {string} taskId - OTA任务ID
* @returns {Promise<Response>}
*/
export const stopOtaTask = (taskId) => {
return http.post(`/api/v1/area-controllers/ota/tasks/${taskId}/stop`);
};
export const AreaControllerApi = {
list: getAreaControllers,
create: createAreaController,
getById: getAreaControllerById,
update: updateAreaController,
delete: deleteAreaController,
startOta: startOtaUpdate,
getOtaProgress: getOtaProgress,
stopOta: stopOtaTask,
};

View File

@@ -252,6 +252,7 @@ export const SensorType = {
TEMPERATURE: '温度',
HUMIDITY: '湿度',
WEIGHT: '重量',
ONLINE_STATUS: '在线状态',
};
/**
@@ -263,10 +264,12 @@ export const TaskType = {
WAITING: '等待', // 等待任务
RELEASE_FEED_WEIGHT: '下料', // 下料口释放指定重量任务
FULL_COLLECTION: '全量采集', // 新增的全量采集任务
HEARTBEAT: '心跳检测', // 区域主控心跳检测任务
ALARM_NOTIFICATION: '告警通知', // 告警通知任务
NOTIFICATION_REFRESH: '通知刷新', // 通知刷新任务
DEVICE_THRESHOLD_CHECK: '设备阈值检查', // 设备阈值检查任务
AREA_COLLECTOR_THRESHOLD_CHECK: '区域阈值检查', // 区域阈值检查任务
OTA_CHECK: 'OTA升级检查任务', // OTA升级超时检查任务
};
/**
@@ -335,7 +338,8 @@ export const AlarmSourceType = {
* @enum {string}
*/
export const AIModel = {
GEMINI: 'Gemini',
AI_MODEL_NONE: 'None',
AI_MODEL_GEMINI: 'Gemini',
};
/**
@@ -364,3 +368,21 @@ export const SeverityLevel = {
PANIC: 'panic',
FATAL: 'fatal',
};
/**
* OTA任务状态
* @enum {string}
*/
export const OTATaskStatus = {
PENDING: '待开始', // 任务已创建,等待下发
IN_PROGRESS: '进行中', // 任务已下发,设备正在处理
SUCCESS: '成功', // 设备报告升级成功,新固件已运行
ALREADY_UP_TO_DATE: '版本已是最新', // 设备报告版本已是最新,未执行升级
FAILED_PREPARATION: '准备升级失败', // 平台在解压、生成清单等文件操作阶段发生错误
FAILED_PRE_CHECK: '预检失败', // 设备报告升级前检查失败 (如拒绝降级、准备分区失败)
FAILED_DOWNLOAD: '下载或校验失败', // 设备报告文件下载或校验失败 (包括清单文件和固件文件)
FAILED_ROLLBACK: '固件回滚', // 新固件启动失败,设备自动回滚
TIMED_OUT: '超时', // 平台在超时后仍未收到最终报告
PLATFORM_ERROR: '平台内部错误', // 平台处理过程中发生的非设备报告错误
STOPPED: '手动停止', // 手动停止
};