From a8a91fe04ecb71298c9e2ba398fb60a9354c1c85 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 2 Apr 2026 15:14:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20RealtimeStatus=20?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=90=8E=E6=9C=AA=E5=9B=9E=E5=86=99=20DB=20?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=20Resolve=20=E6=8E=A5=E5=8F=A3=E5=9C=A8?= =?UTF-8?q?=E7=BA=BF=E7=8A=B6=E6=80=81=E4=B8=8D=E5=90=8C=E6=AD=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/service/asset/service.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/service/asset/service.go b/internal/service/asset/service.go index d679945..aba2284 100644 --- a/internal/service/asset/service.go +++ b/internal/service/asset/service.go @@ -356,6 +356,10 @@ func (s *Service) fetchDeviceGatewayInfo(ctx context.Context, deviceID uint) *dt return &dto.DeviceGatewayInfo{GatewayMsg: &msg} } + // 实时状态成功后异步回写 DB,保持 Resolve 接口的缓存与 Gateway 同步 + // 使用 context.Background() 避免请求结束后 ctx 取消导致写入失败 + go s.updateDeviceFromSyncInfo(context.Background(), deviceID, syncResp) + return mapSyncRespToDeviceGatewayInfo(syncResp) }