fix: 修复停复机操作未同步轮询卡缓存导致卡无法实际停机的问题
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled

多处修改 network_status 的代码只更新了 DB 而未失效轮询缓存(polling:card:{id}),
导致轮询系统持续读取旧缓存值,跳过 Gateway 停机调用。

修复方式:DB 更新后立即 Del 轮询缓存 key,下次轮询自动从 DB 重建。

涉及文件:
- StopResumeService: CheckAndStopCard/resumeSingleCard/ManualStopCard/ManualStartCard
- iot_card/Service: RefreshCardDataFromGateway(通过 OnCardStatusChanged 回调)
- device/Service: StopDevice/StartDevice
This commit is contained in:
2026-03-31 19:59:35 +08:00
parent 58eb047433
commit 1c6f8ed07b
3 changed files with 36 additions and 0 deletions

View File

@@ -872,6 +872,7 @@ func (s *Service) StopDevice(ctx context.Context, deviceID uint) (*dto.DeviceSus
continue
}
s.invalidatePollingCardCache(card.ID)
successCount++
}
@@ -973,6 +974,7 @@ func (s *Service) StartDevice(ctx context.Context, deviceID uint) error {
continue
}
s.invalidatePollingCardCache(card.ID)
successCount++
}
@@ -989,3 +991,10 @@ func (s *Service) StartDevice(ctx context.Context, deviceID uint) error {
return nil
}
func (s *Service) invalidatePollingCardCache(cardID uint) {
if s.redis == nil {
return
}
_ = s.redis.Del(context.Background(), constants.RedisPollingCardInfoKey(cardID)).Err()
}