From e3fcdb8383dd4b178a1b1ce6098f30bc2b62a879 Mon Sep 17 00:00:00 2001 From: H Vs Date: Tue, 21 Nov 2023 18:53:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HealthMonitor.Service/Biz/IotWebApiService.cs | 6 ++++-- HealthMonitor.Service/Cache/PersonCacheManager.cs | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/HealthMonitor.Service/Biz/IotWebApiService.cs b/HealthMonitor.Service/Biz/IotWebApiService.cs index 842541b..9e1c1f6 100644 --- a/HealthMonitor.Service/Biz/IotWebApiService.cs +++ b/HealthMonitor.Service/Biz/IotWebApiService.cs @@ -204,7 +204,7 @@ namespace HealthMonitor.Service.Biz }; var person = await _gpsPersonApiClient.GetFirstAsync(condition, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false); // 若remark为空,更新person remark字段 - if (string.IsNullOrWhiteSpace(person?.Remarks)) + if (!string.IsNullOrWhiteSpace(person?.Remarks)) { var newRemarkData = new { @@ -219,13 +219,15 @@ namespace HealthMonitor.Service.Biz } }; person!.Remarks = $"is_blood_press:{JsonConvert.SerializeObject(newRemarkData)}|"; - await _gpsPersonApiClient.UpdateAsync(person, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false); + //await _gpsPersonApiClient.UpdateAsync(person, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false); _logger.LogInformation($"更新Person remarks字段|{person.Remarks}"); // 更新缓存 var personCache = await _personCacheMgr.GetDeviceGpsPersonCacheObjectBySerialNoAsync(new Guid().ToString(), imei).ConfigureAwait(false); + if (personCache != null) { + //personCache.Person.Remarks = person!.Remarks; personCache["person"]!["remarks"] = person!.Remarks; bool cacheFlag= await _personCacheMgr.UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(personCache, imei); diff --git a/HealthMonitor.Service/Cache/PersonCacheManager.cs b/HealthMonitor.Service/Cache/PersonCacheManager.cs index e176481..bc51bd4 100644 --- a/HealthMonitor.Service/Cache/PersonCacheManager.cs +++ b/HealthMonitor.Service/Cache/PersonCacheManager.cs @@ -3,6 +3,7 @@ using HealthMonitor.Model.Cache; using HealthMonitor.Model.Config; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; @@ -123,14 +124,14 @@ namespace HealthMonitor.Service.Cache /// /// /// - public async Task GetDeviceGpsPersonCacheObjectBySerialNoAsync(string messageId, string sn) + public async Task GetDeviceGpsPersonCacheObjectBySerialNoAsync(string messageId, string sn) { if (string.IsNullOrWhiteSpace(sn)) return null; try { var person = await RedisHelperDb7.HGetAsync(CACHE_HASH_KEY_GPSDEVICEPERSON, sn).ConfigureAwait(false); - return person; + return (JObject?)JsonConvert.DeserializeObject(person); } catch (Exception ex) { @@ -146,7 +147,7 @@ namespace HealthMonitor.Service.Cache /// /// /// - public async Task UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(JToken person, string sn) + public async Task UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(JObject person, string sn) { var flag = false; if (string.IsNullOrWhiteSpace(sn)) return flag;