2026-07-02 15:53:30 +08:00
|
|
|
|
# 模块划分
|
|
|
|
|
|
|
|
|
|
|
|
> 所属模块:[架构概览](./概览.md)
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
## 1. 分层架构
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
| 层级 | 目录 | 职责 | 依赖 |
|
|
|
|
|
|
|------|------|------|------|
|
|
|
|
|
|
| CLI | `Gpulse.WCT.DataAnalyzer/Commands/` | 接收参数、流程调度、结果输出 | Application |
|
|
|
|
|
|
| Application | `Core/Application/` | 业务流程编排 | Domain, Infrastructure |
|
|
|
|
|
|
| Domain | `Core/Domain/Models/` | 实体定义,无行为 | 无 |
|
|
|
|
|
|
| Infrastructure | `Core/Infrastructure/` | 数据持久化、配置、安全 | Domain |
|
|
|
|
|
|
|
|
|
|
|
|
**依赖规则:**
|
|
|
|
|
|
|
|
|
|
|
|
- 上层可依赖下层,下层不可依赖上层
|
|
|
|
|
|
- Application 依 Domain 和 Infrastructure
|
|
|
|
|
|
- Infrastructure 依 Domain
|
|
|
|
|
|
- Domain 不依赖任何其他层
|
|
|
|
|
|
- 解析器之间不可互相调用
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
## 2. Application 模块职责
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
### 2.1 Parsing — 解析
|
|
|
|
|
|
|
|
|
|
|
|
| 类 | 职责 |
|
|
|
|
|
|
|----|------|
|
|
|
|
|
|
| `FileNameParser` | 从文件名提取场景信息(面板、硬件、软件、RX类型、日期、序号) |
|
|
|
|
|
|
| `QfodParser` | 解析 Qfod 格式日志行 → `QfodRecord` |
|
|
|
|
|
|
| `PlossParser` | 解析 Ploss 单行/两行格式日志 → `PlossRecord` |
|
|
|
|
|
|
|
|
|
|
|
|
### 2.2 LocalIngestion — 本地解析
|
|
|
|
|
|
|
|
|
|
|
|
| 类 | 职责 |
|
|
|
|
|
|
|----|------|
|
|
|
|
|
|
| `ParseService` | 协调解析流程:读取文件 → 解析 → 批量写入 local.db |
|
|
|
|
|
|
| `ScenarioService` | 创建/查询测试场景,并发安全 upsert |
|
|
|
|
|
|
| `DimensionService` | 维度表 get-or-create |
|
|
|
|
|
|
|
|
|
|
|
|
### 2.3 Publishing — 发布汇总
|
|
|
|
|
|
|
|
|
|
|
|
| 类 | 职责 |
|
|
|
|
|
|
|----|------|
|
|
|
|
|
|
| `AggregationService` | 读取 local.db → 按业务键分组计算 → upsert 到 release.db |
|
|
|
|
|
|
| `ThresholdCalculator` | 动态阈值计算 |
|
|
|
|
|
|
|
|
|
|
|
|
### 2.4 Exporting — 导出
|
|
|
|
|
|
|
|
|
|
|
|
| 类 | 职责 |
|
|
|
|
|
|
|----|------|
|
|
|
|
|
|
| `ExportService` | 导出 release.db 到固定 CSV,也支持 legacy Qfod/Ploss 导出 |
|
|
|
|
|
|
|
|
|
|
|
|
### 2.5 Administration — 管理
|
|
|
|
|
|
|
|
|
|
|
|
| 类 | 职责 |
|
|
|
|
|
|
|----|------|
|
|
|
|
|
|
| `StatsService` | 本地库统计查询 |
|
|
|
|
|
|
| `CleanService` | 软删除管理 |
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
## 3. Domain 实体
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
### 3.1 本地实体(local.db)
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
| 实体 | 表 | 说明 |
|
|
|
|
|
|
|------|----|------|
|
|
|
|
|
|
| `TxPanel` | tx_panel | TX 面板类型维度 |
|
|
|
|
|
|
| `TxHardware` | tx_hardware | TX 硬件版本维度 |
|
|
|
|
|
|
| `TxSoftware` | tx_software | TX 软件版本维度 |
|
|
|
|
|
|
| `RxType` | rx_type | RX 类型维度 |
|
|
|
|
|
|
| `TestScenario` | test_scenario | 测试场景(4 个维度外键 + 日期 + 序号) |
|
|
|
|
|
|
| `QfodRecord` | qfod_record | Qfod 检测数据 |
|
|
|
|
|
|
| `PlossRecord` | ploss_record | Ploss FOD 数据 |
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
关系:维度表 1:N TestScenario 1:N QfodRecord/PlossRecord(星型模型)
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
### 3.2 发布实体(release.db)
|
|
|
|
|
|
|
|
|
|
|
|
| 实体 | 表 | 唯一键 |
|
|
|
|
|
|
|------|----|--------|
|
|
|
|
|
|
| `ChargingParameterRecord` | charging_parameter | (car_factory, car_model, phone_brand, phone_model) |
|
|
|
|
|
|
|
|
|
|
|
|
**两个数据库不建立外键或导航属性关联。**
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
## 4. Infrastructure 模块
|
|
|
|
|
|
|
|
|
|
|
|
### 4.1 LocalData — 本地数据库
|
|
|
|
|
|
|
|
|
|
|
|
| 类 | 职责 |
|
|
|
|
|
|
|----|------|
|
|
|
|
|
|
| `WctMinerDbContext` | 本地解析库 EF Core 上下文 |
|
|
|
|
|
|
| `DbContextFactory` | 根据配置创建 SQLite/PostgreSQL 本地上下文 |
|
|
|
|
|
|
| `IDbContextFactory` | 工厂接口 |
|
|
|
|
|
|
| `SeedData` | 默认维度数据初始化 |
|
|
|
|
|
|
| `Configurations/*` | EF Core `IEntityTypeConfiguration` 实现 |
|
|
|
|
|
|
|
|
|
|
|
|
### 4.2 ReleaseData — 发布数据库
|
|
|
|
|
|
|
|
|
|
|
|
| 类 | 职责 |
|
|
|
|
|
|
|----|------|
|
|
|
|
|
|
| `ReleaseDbContext` | 发布库 EF Core 上下文 |
|
|
|
|
|
|
| `ReleaseDbContextFactory` | 创建发布库上下文 |
|
|
|
|
|
|
| `IReleaseDbContextFactory` | 工厂接口 |
|
|
|
|
|
|
| `Configurations/*` | 发布实体配置 |
|
|
|
|
|
|
|
|
|
|
|
|
### 4.3 Configuration
|
|
|
|
|
|
|
|
|
|
|
|
| 类 | 职责 |
|
|
|
|
|
|
|----|------|
|
|
|
|
|
|
| `AppSettings` | 应用配置 POCO |
|
|
|
|
|
|
|
|
|
|
|
|
### 4.4 Security
|
|
|
|
|
|
|
|
|
|
|
|
| 类 | 职责 |
|
|
|
|
|
|
|----|------|
|
|
|
|
|
|
| `PathValidator` | 路径安全校验(遍历保护、白名单、应用目录限制) |
|
|
|
|
|
|
| `SecurityConstants` | 安全常量 |
|
|
|
|
|
|
|
|
|
|
|
|
### 4.5 Extensions
|
|
|
|
|
|
|
|
|
|
|
|
| 类 | 职责 |
|
|
|
|
|
|
|----|------|
|
|
|
|
|
|
| `ServiceCollectionExtensions` | `AddDatabaseServices` / `AddApplicationServices` DI 注册 |
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
## 5. 依赖图
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
|
|
|
|
|
```mermaid
|
|
|
|
|
|
graph TD
|
2026-08-13 15:01:32 +08:00
|
|
|
|
CLI[CLI Commands] --> Parsing[Parsing]
|
|
|
|
|
|
CLI --> LocalIngestion[LocalIngestion]
|
|
|
|
|
|
CLI --> Publishing[Publishing]
|
|
|
|
|
|
CLI --> Exporting[Exporting]
|
|
|
|
|
|
CLI --> Admin[Administration]
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
LocalIngestion --> Parsing
|
|
|
|
|
|
LocalIngestion --> LocalData[LocalData]
|
|
|
|
|
|
Publishing --> LocalData
|
|
|
|
|
|
Publishing --> ReleaseData[ReleaseData]
|
|
|
|
|
|
Exporting --> LocalData
|
|
|
|
|
|
Exporting --> ReleaseData
|
|
|
|
|
|
Admin --> LocalData
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
LocalData --> Domain[Domain Models]
|
|
|
|
|
|
ReleaseData --> Domain
|
|
|
|
|
|
Parsing --> Domain
|
2026-07-02 18:13:56 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
subgraph Application
|
|
|
|
|
|
Parsing
|
|
|
|
|
|
LocalIngestion
|
|
|
|
|
|
Publishing
|
|
|
|
|
|
Exporting
|
|
|
|
|
|
Admin
|
2026-07-02 15:53:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
subgraph Domain
|
|
|
|
|
|
Domain
|
2026-07-02 15:53:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
subgraph Infrastructure
|
2026-08-13 15:01:32 +08:00
|
|
|
|
LocalData
|
|
|
|
|
|
ReleaseData
|
|
|
|
|
|
Configuration
|
|
|
|
|
|
Security
|
|
|
|
|
|
Extensions
|
2026-07-02 18:13:56 +08:00
|
|
|
|
end
|
2026-07-02 15:53:30 +08:00
|
|
|
|
```
|