174 lines
4.5 KiB
Markdown
174 lines
4.5 KiB
Markdown
# 模块划分
|
||
|
||
> 所属模块:[架构概览](./概览.md)
|
||
|
||
---
|
||
|
||
## 1. 分层架构
|
||
|
||
| 层级 | 目录 | 职责 | 依赖 |
|
||
|------|------|------|------|
|
||
| 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 不依赖任何其他层
|
||
- 解析器之间不可互相调用
|
||
|
||
---
|
||
|
||
## 2. Application 模块职责
|
||
|
||
### 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 — 管理
|
||
|
||
| 类 | 职责 |
|
||
|----|------|
|
||
| `CleanService` | 软删除管理 |
|
||
|
||
---
|
||
|
||
## 3. Domain 实体
|
||
|
||
### 3.1 本地实体(local.db)
|
||
|
||
| 实体 | 表 | 说明 |
|
||
|------|----|------|
|
||
| `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 数据 |
|
||
|
||
关系:维度表 1:N TestScenario 1:N QfodRecord/PlossRecord(星型模型)
|
||
|
||
### 3.2 发布实体(release.db)
|
||
|
||
| 实体 | 表 | 唯一键 |
|
||
|------|----|--------|
|
||
| `ChargingParameterRecord` | charging_parameter | (car_factory, car_model, phone_brand, phone_model) |
|
||
|
||
**两个数据库不建立外键或导航属性关联。**
|
||
|
||
---
|
||
|
||
## 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. 依赖图
|
||
|
||
```mermaid
|
||
graph TD
|
||
CLI[CLI Commands] --> Parsing[Parsing]
|
||
CLI --> LocalIngestion[LocalIngestion]
|
||
CLI --> Publishing[Publishing]
|
||
CLI --> Exporting[Exporting]
|
||
CLI --> Admin[Administration]
|
||
|
||
LocalIngestion --> Parsing
|
||
LocalIngestion --> LocalData[LocalData]
|
||
Publishing --> LocalData
|
||
Publishing --> ReleaseData[ReleaseData]
|
||
Exporting --> LocalData
|
||
Exporting --> ReleaseData
|
||
Admin --> LocalData
|
||
|
||
LocalData --> Domain[Domain Models]
|
||
ReleaseData --> Domain
|
||
Parsing --> Domain
|
||
|
||
subgraph Application
|
||
Parsing
|
||
LocalIngestion
|
||
Publishing
|
||
Exporting
|
||
Admin
|
||
end
|
||
|
||
subgraph Domain
|
||
Domain
|
||
end
|
||
|
||
subgraph Infrastructure
|
||
LocalData
|
||
ReleaseData
|
||
Configuration
|
||
Security
|
||
Extensions
|
||
end
|
||
``` |