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
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
|
{
|
|
|
|
|
|
"Database": {
|
|
|
|
|
|
"Type": "sqlite",
|
2026-08-13 15:01:32 +08:00
|
|
|
|
"LocalPath": "./data/database/local.db",
|
|
|
|
|
|
"ReleasePath": "./data/database/release.db"
|
2026-07-02 15:53:30 +08:00
|
|
|
|
},
|
|
|
|
|
|
"Parser": {
|
|
|
|
|
|
"BatchSize": 1000
|
|
|
|
|
|
},
|
|
|
|
|
|
"Paths": {
|
|
|
|
|
|
"LogDir": "./data/logs",
|
|
|
|
|
|
"OutputDir": "./data/output"
|
2026-08-13 15:01:32 +08:00
|
|
|
|
},
|
|
|
|
|
|
"Aggregation": {
|
|
|
|
|
|
"TxPanelMappings": {
|
|
|
|
|
|
"single-mold": "奇瑞",
|
|
|
|
|
|
"dual-rapid": "智己"
|
|
|
|
|
|
},
|
|
|
|
|
|
"CarModelMappings": {
|
|
|
|
|
|
"L6": "L6",
|
|
|
|
|
|
"CM3": "CM3"
|
|
|
|
|
|
}
|
2026-07-02 15:53:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
## 2. 配置类定义
|
|
|
|
|
|
|
|
|
|
|
|
```csharp
|
2026-08-13 15:01:32 +08:00
|
|
|
|
// Infrastructure/Configuration/AppSettings.cs
|
|
|
|
|
|
namespace Gpulse.WCT.DataAnalyzer.Core.Infrastructure.Configuration;
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
|
|
|
|
|
public class AppSettings
|
|
|
|
|
|
{
|
|
|
|
|
|
public DatabaseSettings Database { get; set; } = new();
|
|
|
|
|
|
public ParserSettings Parser { get; set; } = new();
|
|
|
|
|
|
public PathSettings Paths { get; set; } = new();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class DatabaseSettings
|
|
|
|
|
|
{
|
|
|
|
|
|
public string Type { get; set; } = "sqlite";
|
2026-08-13 15:01:32 +08:00
|
|
|
|
public string LocalPath { get; set; } = "./data/database/local.db";
|
|
|
|
|
|
public string ReleasePath { get; set; } = "./data/database/release.db";
|
|
|
|
|
|
|
2026-07-02 15:53:30 +08:00
|
|
|
|
// PostgreSQL 配置(可选)
|
|
|
|
|
|
public string? Host { get; set; }
|
|
|
|
|
|
public int Port { get; set; } = 5432;
|
|
|
|
|
|
public string? Name { get; set; }
|
|
|
|
|
|
public string? User { get; set; }
|
|
|
|
|
|
public string? Password { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ParserSettings
|
|
|
|
|
|
{
|
|
|
|
|
|
public int BatchSize { get; set; } = 1000;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class PathSettings
|
|
|
|
|
|
{
|
|
|
|
|
|
public string LogDir { get; set; } = "./data/logs";
|
|
|
|
|
|
public string OutputDir { get; set; } = "./data/output";
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
## 3. 数据库配置说明
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
### 双数据库路径
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
| 配置键 | 默认值 | 说明 |
|
|
|
|
|
|
|--------|--------|------|
|
|
|
|
|
|
| `Database:LocalPath` | `./data/database/local.db` | 本地解析库 |
|
|
|
|
|
|
| `Database:ReleasePath` | `./data/database/release.db` | 正式发布库 |
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
两个数据库独立配置,可以位于不同路径,也可以使用不同类型的数据库。
|
|
|
|
|
|
|
|
|
|
|
|
### 兼容旧配置
|
|
|
|
|
|
|
|
|
|
|
|
`Database:Path` 仍然作为 local 数据库的 fallback 路径,推荐使用 `Database:LocalPath`。
|
|
|
|
|
|
|
|
|
|
|
|
### PostgreSQL 支持
|
|
|
|
|
|
|
|
|
|
|
|
当 `Database:Type` 设为 `postgresql` 时,local 和 release 都可以使用独立的 PostgreSQL 连接:
|
|
|
|
|
|
|
|
|
|
|
|
```json
|
2026-07-02 15:53:30 +08:00
|
|
|
|
{
|
2026-08-13 15:01:32 +08:00
|
|
|
|
"Database": {
|
|
|
|
|
|
"Type": "postgresql",
|
|
|
|
|
|
"Host": "localhost",
|
|
|
|
|
|
"Port": 5432,
|
|
|
|
|
|
"Name": "wct_local",
|
|
|
|
|
|
"User": "wct_user",
|
|
|
|
|
|
"Password": "...",
|
|
|
|
|
|
"ReleaseHost": "db-server",
|
|
|
|
|
|
"ReleaseName": "wct_charging_parameters",
|
|
|
|
|
|
"ReleaseUser": "wct_release",
|
|
|
|
|
|
"ReleasePassword": "..."
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
2026-07-02 15:53:30 +08:00
|
|
|
|
|
2026-08-13 15:01:32 +08:00
|
|
|
|
Release 数据库的 PostgreSQL 配置前缀为 `Release*`,未设置时回退到 local 的对应配置。
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
## 4. 聚合配置
|
|
|
|
|
|
|
|
|
|
|
|
| 配置键 | 说明 |
|
|
|
|
|
|
|--------|------|
|
|
|
|
|
|
| `Aggregation:TxPanelMappings` | TxPanel 名称 → 车厂名称的映射表 |
|
|
|
|
|
|
| `Aggregation:CarModelMappings` | TxHardware 版本 → 车型名称的映射表 |
|
|
|
|
|
|
|
|
|
|
|
|
未配置映射时,直接使用 TxPanel.Name 和 TxHardware.Version 作为最终值。手机品牌/型号从 RxType.Name 自动拆分(分隔符 `/_:`)。
|