feat: 添加对 Kafka CurrentStatusrestart 值支持,更新 G5 入库逻辑及相关测试

This commit is contained in:
2026-03-18 09:47:33 +08:00
parent 1329eca99e
commit 381080fee0
9 changed files with 97 additions and 16 deletions

View File

@@ -0,0 +1,13 @@
# Change: add restart current_status mapping
## Why
上游 Kafka 的 `CurrentStatus` 新增了 `restart` 值。现有处理逻辑仍按 `on/off` 处理,导致 `restart` 在入库时无法被正确标记为 3。
## What Changes
- 让 Kafka 解析链路接受 `CurrentStatus=restart`
- 将 G5 入库链路中的 `current_status=restart` 映射为 `3`
- 更新相关测试与 OpenSpec 说明,确保 `restart` 是受支持状态。
## Impact
- Affected specs: `openspec/specs/onoffline/spec.md`
- Affected code: `src/processor/index.js`, `src/db/g5DatabaseManager.js`, `tests/processor.test.js`

View File

@@ -0,0 +1,14 @@
## MODIFIED Requirements
### Requirement: 重启数据处理
系统 SHALL 在 `CurrentStatus``restart` 时将 `current_status` 保留为 `restart`,并在 G5 入库链路中映射为 `3`
#### Scenario: restart 状态写入
- **GIVEN** Kafka 消息中的 `CurrentStatus``restart`
- **WHEN** 消息被处理并写入数据库
- **THEN** 普通入库链路保留 `restart`G5 入库链路将其写入为 `3`
#### Scenario: 其他状态保持原样
- **GIVEN** Kafka 消息中的 `CurrentStatus``on``off`
- **WHEN** 消息被处理并写入数据库
- **THEN** 系统按既有规则处理该状态值

View File

@@ -0,0 +1,10 @@
## 1. Implementation
- [x] 1.1 Update Kafka row building logic to preserve `restart` as a valid `current_status` value.
- [x] 1.2 Update G5 database mapping so `restart` maps to `3`.
- [x] 1.3 Update processor tests for the `restart` case.
- [x] 1.4 Update OpenSpec requirements for supported current status values.
## 2. Validation
- [x] 2.1 Run `npm run test`.
- [x] 2.2 Run `npm run build`.
- [x] 2.3 Run `openspec validate add-restart-current-status-mapping --strict`.

View File

@@ -12,12 +12,17 @@
- **THEN** current_status 等于 CurrentStatus (截断至 255 字符)
### Requirement: 重启数据处理
系统 SHALL 在 RebootReason 非空时强制 current_status 为 on
系统 SHALL 在 `CurrentStatus``restart` 时将 `current_status` 保留为 `restart`,并在 G5 入库链路中映射为 `3`
#### Scenario: 重启数据写入
- **GIVEN** RebootReason 为非空值
- **WHEN** 消息被处理
- **THEN** current_status 等于 on
#### Scenario: restart 状态写入
- **GIVEN** Kafka 消息中的 `CurrentStatus``restart`
- **WHEN** 消息被处理并写入数据库
- **THEN** 普通入库链路保留 `restart`G5 入库链路将其写入为 `3`
#### Scenario: 其他状态保持原样
- **GIVEN** Kafka 消息中的 `CurrentStatus``on``off`
- **WHEN** 消息被处理并写入数据库
- **THEN** 系统按既有规则处理该状态值
### Requirement: 空值保留
系统 SHALL 保留上游空值,不对字段进行补 0。