fix: 修复停复机操作未同步轮询卡缓存导致卡无法实际停机的问题
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
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:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user