Files
WCTDataMiner/docs/data-model/entities/Qfod记录.md
ssss 28cb2533a7 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>
2026-07-02 15:53:30 +08:00

132 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# qfod_record 实体
> 所属模块:[数据模型概览](../概览.md)
---
## 1. 表定义
**表名**`qfod_record`
**描述**:存储 Qfod 格式解析数据,对应日志格式 `X#:Q A->B C D E`
---
## 2. 字段定义
| 列名 | 类型 | 约束 | 说明 |
|------|------|------|------|
| id | UUID | PK, NOT NULL | 主键 |
| scenario_id | UUID | FK, NOT NULL | 关联测试场景 |
| charger_index | TINYINT | NOT NULL | 充电器索引0 或 1 |
| coil_index | TINYINT | NOT NULL | 线圈索引0、1、2 |
| delta_q | INT | NOT NULL | Q值变化量ΔQ = current_q - raw_q |
| current_q | FLOAT | NOT NULL | 当前实时 Q值 |
| raw_q | FLOAT | NOT NULL | 原始 Q值 |
| fod_type | TINYINT | NOT NULL | 异物类型编码 |
| is_deleted | BOOLEAN | NOT NULL, DEFAULT FALSE | 软删除标记 |
| created_at | TIMESTAMP | NOT NULL, DEFAULT NOW() | 创建时间 |
---
## 3. 外键
| 外键 | 引用表 | 说明 |
|------|--------|------|
| scenario_id | test_scenario.id | 关联测试场景(必需) |
---
## 4. 索引
| 索引名 | 字段 | 用途 |
|--------|------|------|
| idx_qfod_scenario | scenario_id | 按测试场景查询 |
| idx_qfod_charger_coil | (charger_index, coil_index) | 按检测通道查询 |
| idx_qfod_fod_type | fod_type | 按异物类型统计 |
| idx_qfod_delta_q | delta_q | 阈值分析 |
---
## 5. 约束
| 约束名 | 类型 | 定义 |
|--------|------|------|
| chk_qfod_charger | CHECK | charger_index IN (0, 1) |
| chk_qfod_coil | CHECK | coil_index IN (0, 1, 2) |
---
## 6. EF Core 模型
```csharp
// Models/QfodRecord.cs
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace WCTDataMiner.Models;
[Table("qfod_record")]
[Index(nameof(ScenarioId), Name = "idx_qfod_scenario")]
[Index(nameof(ChargerIndex), nameof(CoilIndex), Name = "idx_qfod_charger_coil")]
[Index(nameof(FodType), Name = "idx_qfod_fod_type")]
[Index(nameof(DeltaQ), Name = "idx_qfod_delta_q")]
public class QfodRecord
{
[Key]
[Column("id")]
public Guid Id { get; set; } = Guid.NewGuid();
[Required]
[Column("scenario_id")]
public Guid ScenarioId { get; set; }
[Required]
[Column("charger_index")]
public byte ChargerIndex { get; set; }
[Required]
[Column("coil_index")]
public byte CoilIndex { get; set; }
[Required]
[Column("delta_q")]
public int DeltaQ { get; set; }
[Required]
[Column("current_q")]
public float CurrentQ { get; set; }
[Required]
[Column("raw_q")]
public float RawQ { get; set; }
[Required]
[Column("fod_type")]
public byte FodType { get; set; }
[Required]
[Column("is_deleted")]
public bool IsDeleted { get; set; } = false;
[Required]
[Column("created_at")]
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
[ForeignKey(nameof(ScenarioId))]
public TestScenario Scenario { get; set; } = null!;
}
```
---
## 7. 检测通道组合
| ChargerIndex | CoilIndex | 检测通道 |
|--------------|-----------|----------|
| 0 | 0 | 充电器0-线圈0 |
| 0 | 1 | 充电器0-线圈1 |
| 0 | 2 | 充电器0-线圈2 |
| 1 | 0 | 充电器1-线圈0 |
| 1 | 1 | 充电器1-线圈1 |
| 1 | 2 | 充电器1-线圈2 |