Update: Refactor to absolute imports, fix QPS limits, and enhance Gitea sync with SQLite support
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
# DESIGN - 数据库增强与缺失条码提示
|
||||
|
||||
## 1. 架构设计
|
||||
|
||||
### 1.1 数据库层扩展
|
||||
在 `app/core/db/product_db.py` 中增加对 `missing_barcodes` 表的管理。
|
||||
|
||||
```sql
|
||||
CREATE TABLE IF NOT EXISTS missing_barcodes (
|
||||
barcode TEXT PRIMARY KEY,
|
||||
name TEXT DEFAULT '',
|
||||
last_seen TEXT,
|
||||
source_file TEXT,
|
||||
count INTEGER DEFAULT 1
|
||||
);
|
||||
```
|
||||
|
||||
### 1.2 逻辑层流程
|
||||
在 `ExcelProcessor` 处理商品数据时,增加比对逻辑:
|
||||
1. 提取条码。
|
||||
2. 调用 `ProductDatabase.is_barcode_exists(barcode)`。
|
||||
3. 若不存在:
|
||||
- 记录到 `missing_barcodes` 表。
|
||||
- 将该条码加入“本次文件缺失列表”。
|
||||
4. 文件处理结束前,若“本次文件缺失列表”不为空,调用 UI 层的弹窗通知。
|
||||
|
||||
## 2. 核心组件交互
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
participant P as ExcelProcessor
|
||||
participant DB as ProductDatabase
|
||||
participant UI as MainWindow/DialogUtils
|
||||
|
||||
P->>DB: get_memory(barcode)
|
||||
alt 条码不存在
|
||||
DB-->>P: None
|
||||
P->>DB: record_missing_barcode(barcode, name, file)
|
||||
P->>P: Add to missing_list
|
||||
end
|
||||
|
||||
Note over P: 文件处理即将完成
|
||||
|
||||
rect rgb(200, 220, 255)
|
||||
P->>UI: show_warning("以下条码缺失: ...")
|
||||
end
|
||||
```
|
||||
|
||||
## 3. 接口定义
|
||||
|
||||
### ProductDatabase 类新增方法:
|
||||
- `record_missing_barcode(barcode, name, source_file)`: 插入或更新缺失条码记录。
|
||||
- `get_missing_barcodes(limit=100)`: 获取最近的缺失条码记录。
|
||||
|
||||
### UI 提示逻辑:
|
||||
- 修改 `app/services/order_service.py` 中的 `process_order` 或相关方法,在处理流程中捕获缺失条码并触发 UI 回调。
|
||||
|
||||
## 4. DB 查看器实现
|
||||
更新 `check_db.py`,使用 `tabulate` (如果安装了) 或简单的格式化输出打印所有表内容。
|
||||
增加参数支持:`python check_db.py --table missing_barcodes`。
|
||||
Reference in New Issue
Block a user