Files
lingniu-vehicle-ingest/protocol-gb32960
kkfluous 4d8dd54e59 refactor(gb32960): extract channelRead0 command branches into private methods
把 Gb32960ChannelHandler.channelRead0 的 140 行 if/else-if 级联拆成按 CommandType
的 switch 分派到 7 个独立私有方法:

- handleVehicleLogin       (0x01)
- handleVehicleLogout      (0x04)
- handlePlatformLogin      (0x05,返回 boolean 表示是否继续 dispatch)
- handlePlatformLogout     (0x06)
- handleReportOrHeartbeat  (0x02/0x03/0x07)
- handleTimeCalibration    (0x08)
- logOtherFrame            (其它命令的调试日志)

同时抽出 eventOrNow(msg) 静态 helper,消除 6 处
"msg.header().eventTime() != null ? msg.header().eventTime() : Instant.now()"
的重复。

纯重构,语义零变化:ACK 写入顺序、PlatformLogin 鉴权失败短路、日志 tag、VIN 白名单
预检都保持原行为。全模块 41 tests + 全仓 E2E 全绿,无回归。

channelRead0 从 140 行收敛到约 45 行,每个分支处理器 20~40 行并带 §6.3.2 规范注释,
未来新增命令或调整 ack 时序只动对应私有方法。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 15:41:59 +08:00
..