# CLI 命令参考 > 共 24 个子命令,基于 click 框架,通过 `certflow [options]` 调用。 > 入口:`src/certflow/cli/__init__.py`、`__main__.py`、`base_command.py`。 > 统一初始化:`base_command.py` 的 `get_cli_db_manager()` / `get_cli_session()`(含 WebDAV 同步)。 ## 命令索引 | 命令 | 功能 | 状态 | |------|------|------| | `import-sales-plan` | 导入销售计划 Excel | ✅ | | `auto-number` | 自动编号 | ✅ | | `print-cert` | 生成合格证记录 | ✅ | | `export-excel` | 导出 Excel | ✅ | | `export-access` | 导出 Access(仅 Windows) | 🟡 | | `quick-query` | 快速查询 | ✅ | | `stats` | 多维度统计 | ✅ | | `mark-shipped` | 标记已发货 | ✅ | | `record-shipment` | 记录发货信息 | ✅ | | `set-year-month` | 设置编号年月前缀 | ✅ | | `batch-update` | 批量更新字段 | ✅ | | `grade-import` | 导入材质牌号 | ✅ | | `import-certs` | 导入合格证清单 | ✅ | | `copy-cert-info` | 复制合同信息到合格证字段 | ✅ | | `check-consistency` | 检查数据一致性 | ✅ | | `clean-duplicates` | 清理重复记录 | ✅ | | `backfill-supply-type` | 回填供货类型 | ✅ | | `db-backup` | 数据库备份 | ✅ | | `db-sync` | WebDAV 同步(push/pull/status) | ✅ | | `db-reset` | 数据库重置 | ✅ | | `bom` | BOM 零件牌号管理 | ✅ | | `report-gen` | 生成报告(质保书/试压/材质) | ✅ | | `watch` | 监控文件夹自动导入 | ✅ | | `serve` | Web 界面(占位,未实现) | 🔴 | ## 详细参数 ### import-sales-plan ```bash certflow import-sales-plan [--scope all|new] [--month YYYYMM] \ [--header-row N] [--start-row N] [--end-row N] \ [--col-map k=v,...] [--collision skip|overwrite|merge] [--dry-run] ``` 对齐 GUI 全部参数。 ### auto-number ```bash certflow auto-number [--month YYYYMM] [--prefix PREFIX] [--filter "..."] ``` ### print-cert ```bash certflow print-cert [--filter "product_code not null and cert_done=0"] ``` 生成合格证:将已编号(product_code 非空)且未生成合格证的记录写入 certificate 表。 ### export-excel ```bash certflow export-excel --filter "status=已发货" --out ./output/plan.xlsx ``` ### export-access ```bash certflow export-access --out ./SignDB.mdb ``` 🟡 依赖 Windows Access 驱动,非 Windows 不可用。 ### quick-query ```bash certflow quick-query --status 待生产 --month 202608 ``` ### stats ```bash certflow stats --by status # 按状态 certflow stats --by customer # 按客户 certflow stats --by supply_type # 按供货类型 certflow stats --by month # 按月份 ``` ### mark-shipped / record-shipment ```bash certflow mark-shipped --plan-no CF2026080001 certflow record-shipment --plan-no CF2026080001 --date 2026-08-04 --carrier SF ``` ### set-year-month ```bash certflow set-year-month 202608 ``` ### batch-update ```bash certflow batch-update --field supply_type --value make --filter "status=待生产" ``` ### grade-import ```bash certflow grade-import material_grades.csv ``` ### import-certs ```bash certflow import-certs cert_list.xlsx ``` ### copy-cert-info ```bash certflow copy-cert-info --plan-no CF2026080001 ``` ### check-consistency ```bash certflow check-consistency ``` ### clean-duplicates ```bash certflow clean-duplicates [--dry-run] ``` ### backfill-supply-type ```bash certflow backfill-supply-type ``` ### db-backup ```bash certflow db-backup --out ./backup/certflow_$(date +%Y%m%d).db ``` ### db-sync ```bash certflow db-sync push certflow db-sync pull certflow db-sync status ``` ### db-reset ```bash certflow db-reset --force certflow db-reset --baseline ./database/baseline.db --force ``` ### bom ```bash certflow bom list certflow bom add certflow bom remove ``` ### report-gen ```bash certflow report-gen --type warranty --sample 10 certflow report-gen --type pressure --plan-no CF2026080001 certflow report-gen --type material --filter "..." ``` ### watch ```bash certflow watch --dir ./incoming --pattern "*.xlsx" ``` watchdog 监控目录,新文件出现自动导入。 ### serve 🔴 ```bash certflow serve --host 127.0.0.1 --port 8080 ``` **未实现**:`certflow.web` 模块不存在,输出"Web 模块尚未实现"。详见 [`08-todo.md`](./08-todo.md) T0-1。 ## 全局选项 | 选项 | 说明 | |------|------| | `--help` | 显示帮助 | | `--verbose` / `-v` | 详细日志(部分命令支持) | 所有命令共享 `get_cli_db_manager()` 初始化的数据库(含 WebDAV 同步),确保 CLI 与 GUI 数据一致。