Files
junhong_cmp_fiber/docs/批量回收设备脚本/功能总结.md
break 4aff9937e5
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 48s
临时批量回收设备脚本
2026-07-28 11:05:05 +08:00

22 lines
957 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 批量回收设备脚本功能总结
## 用途
生产环境尚未部署设备异步 CSV 批量任务时,使用 `scripts/batch_device_recall/batch_device_recall.py` 读取单列 IMEI/虚拟号 CSV并调用已经部署的后台设备接口完成回收。
## 安全边界
- 默认仅预演,显式传入 `--execute` 才会请求接口。
- 真实执行前通过 `GET /api/admin/devices` 精确解析全部标识;任何设备未找到、匹配不唯一或重复引用都会整批停止。
- 设备解析完成后按接口上限每批最多 100 台调用 `POST /api/admin/devices/recall`
- 不直接修改数据库,继续复用既有权限校验、设备与绑定卡归属同步、分配记录、审计日志和缓存失效逻辑。
- 回收请求不自动重试,避免服务端成功但客户端未收到响应时产生误判。
## 验证
运行:
```bash
python3 -m unittest scripts/batch_device_recall/test_batch_device_recall.py
```