feat(import): 用 Excel 格式替换 CSV 导入
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m33s

- 删除 CSV 解析代码,新增 Excel 解析器 (excelize)

- 更新 IoT 卡和设备导入任务处理器

- 更新 API 路由文档和前端接入指南

- 归档变更到 openspec/changes/archive/

- 同步 delta specs 到 main specs
This commit is contained in:
2026-01-31 14:13:02 +08:00
parent 62708892ec
commit d309951493
24 changed files with 2279 additions and 589 deletions

View File

@@ -91,24 +91,26 @@ func registerDeviceRoutes(router fiber.Router, handler *admin.DeviceHandler, imp
Register(devices, doc, groupPath, "POST", "/import", importHandler.Import, RouteSpec{
Summary: "批量导入设备",
Description: `仅平台用户可操作。
Description: `仅平台用户可操作。文件格式已从 CSV 升级为 Excel (.xlsx)。
### 完整导入流程
1. **获取上传 URL**: 调用 ` + "`POST /api/admin/storage/upload-url`" + `
2. **上传 CSV 文件**: 使用预签名 URL 上传文件到对象存储
2. **上传 Excel 文件**: 使用预签名 URL 上传文件到对象存储
3. **调用本接口**: 使用返回的 ` + "`file_key`" + ` 提交导入任务
### CSV 文件格式
### Excel 文件格式
必须包含列(首行为表头):
- ` + "`device_no`" + `: 设备号(必填,唯一)
- ` + "`device_name`" + `: 设备名称
- ` + "`device_model`" + `: 设备型号
- ` + "`device_type`" + `: 设备
- ` + "`max_sim_slots`" + `: 最大插槽数默认4
- ` + "`manufacturer`" + `: 制造商
- ` + "`iccid_1`" + ` ~ ` + "`iccid_4`" + `: 绑定的卡 ICCID卡必须已存在且未绑定`,
- 文件格式:仅支持 .xlsx (Excel 2007+)
- 必须包含列(首行为表头):
- ` + "`device_no`" + `: 设备号(必填,唯一)
- ` + "`device_name`" + `: 设备名称
- ` + "`device_model`" + `: 设备型
- ` + "`device_type`" + `: 设备类型
- ` + "`max_sim_slots`" + `: 最大插槽数默认4
- ` + "`manufacturer`" + `: 制造商
- ` + "`iccid_1`" + ` ~ ` + "`iccid_4`" + `: 绑定的卡 ICCID卡必须已存在且未绑定
- 列格式:设置为文本格式(避免长数字被转为科学记数法)`,
Tags: []string{"设备管理"},
Input: new(dto.ImportDeviceRequest),
Output: new(dto.ImportDeviceResponse),