docs: 完善数据模型设计
- 重命名 log_file 为 test_scenario(测试场景) - 拆分维度表:tx_panel、tx_hardware、tx_software、rx_type - 采用星型模型设计,消除数据冗余 - 为所有表添加软删除字段 is_deleted - 更新关系说明,包含全局查询过滤器配置 - 更新 ER 图和查询示例 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
78
docs/architecture/parser/概览.md
Normal file
78
docs/architecture/parser/概览.md
Normal file
@@ -0,0 +1,78 @@
|
||||
# 解析器设计
|
||||
|
||||
> 所属模块:[架构概览](../概览.md)
|
||||
|
||||
---
|
||||
|
||||
## 文档索引
|
||||
|
||||
| 文档 | 说明 |
|
||||
|------|------|
|
||||
| [Qfod 解析器](./Qfod解析器.md) | Qfod 格式日志解析设计 |
|
||||
| [Ploss 解析器](./Ploss解析器.md) | Ploss FOD 格式日志解析设计 |
|
||||
|
||||
---
|
||||
|
||||
## 通用接口定义
|
||||
|
||||
```csharp
|
||||
// Parsers/IParser.cs
|
||||
namespace WCTDataMiner.Parsers;
|
||||
|
||||
public interface IParser<TRecord>
|
||||
{
|
||||
/// <summary>
|
||||
/// 判断是否可以解析该行
|
||||
/// </summary>
|
||||
bool CanParse(string line);
|
||||
|
||||
/// <summary>
|
||||
/// 解析日志行
|
||||
/// </summary>
|
||||
ParseResult<TRecord> Parse(string line, int lineNumber, Guid logFileId);
|
||||
}
|
||||
|
||||
public record ParseResult<TRecord>
|
||||
{
|
||||
public bool IsSuccess { get; init; }
|
||||
public TRecord? Record { get; init; }
|
||||
public string? ErrorType { get; init; }
|
||||
public string? ErrorMessage { get; init; }
|
||||
|
||||
public static ParseResult<TRecord> Success(TRecord record) =>
|
||||
new() { IsSuccess = true, Record = record };
|
||||
|
||||
public static ParseResult<TRecord> Failure(string errorType, string errorMessage) =>
|
||||
new() { IsSuccess = false, ErrorType = errorType, ErrorMessage = errorMessage };
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 解析流程
|
||||
|
||||
```mermaid
|
||||
flowchart TD
|
||||
A[读取日志文件] --> B[逐行遍历]
|
||||
B --> C{判断行类型}
|
||||
C -->|Qfod| D[QfodParser.Parse]
|
||||
C -->|Ploss| E[PlossParser.Parse]
|
||||
C -->|其他| F[跳过]
|
||||
D --> G{解析成功?}
|
||||
E --> G
|
||||
G -->|成功| H[添加到记录列表]
|
||||
G -->|失败| I[记录到 ParseError]
|
||||
H --> J[批量保存到数据库]
|
||||
I --> J
|
||||
J --> K[输出解析报告]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 错误类型定义
|
||||
|
||||
| ErrorType | 说明 | 处理方式 |
|
||||
|-----------|------|----------|
|
||||
| FORMAT_MISMATCH | 行格式不匹配正则表达式 | 跳过该行,记录原始内容 |
|
||||
| TYPE_CONVERSION | 字段类型转换失败 | 跳过该行,记录错误字段 |
|
||||
| VALUE_OUT_OF_RANGE | 字段值超出有效范围 | 使用边界值或跳过 |
|
||||
Reference in New Issue
Block a user