Browse Source

调整

datasub12_previous
H Vs 1 year ago
parent
commit
e3fcdb8383
2 changed files with 8 additions and 5 deletions
  1. +4
    -2
      HealthMonitor.Service/Biz/IotWebApiService.cs
  2. +4
    -3
      HealthMonitor.Service/Cache/PersonCacheManager.cs

+ 4
- 2
HealthMonitor.Service/Biz/IotWebApiService.cs View File

@@ -204,7 +204,7 @@ namespace HealthMonitor.Service.Biz
}; };
var person = await _gpsPersonApiClient.GetFirstAsync(condition, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false); var person = await _gpsPersonApiClient.GetFirstAsync(condition, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false);
// 若remark为空,更新person remark字段 // 若remark为空,更新person remark字段
if (string.IsNullOrWhiteSpace(person?.Remarks))
if (!string.IsNullOrWhiteSpace(person?.Remarks))
{ {
var newRemarkData = new var newRemarkData = new
{ {
@@ -219,13 +219,15 @@ namespace HealthMonitor.Service.Biz
} }
}; };
person!.Remarks = $"is_blood_press:{JsonConvert.SerializeObject(newRemarkData)}|"; 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}"); _logger.LogInformation($"更新Person remarks字段|{person.Remarks}");


// 更新缓存 // 更新缓存
var personCache = await _personCacheMgr.GetDeviceGpsPersonCacheObjectBySerialNoAsync(new Guid().ToString(), imei).ConfigureAwait(false); var personCache = await _personCacheMgr.GetDeviceGpsPersonCacheObjectBySerialNoAsync(new Guid().ToString(), imei).ConfigureAwait(false);
if (personCache != null) if (personCache != null)
{ {
//personCache.Person.Remarks = person!.Remarks; //personCache.Person.Remarks = person!.Remarks;
personCache["person"]!["remarks"] = person!.Remarks; personCache["person"]!["remarks"] = person!.Remarks;
bool cacheFlag= await _personCacheMgr.UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(personCache, imei); bool cacheFlag= await _personCacheMgr.UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(personCache, imei);


+ 4
- 3
HealthMonitor.Service/Cache/PersonCacheManager.cs View File

@@ -3,6 +3,7 @@ using HealthMonitor.Model.Cache;
using HealthMonitor.Model.Config; using HealthMonitor.Model.Config;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -123,14 +124,14 @@ namespace HealthMonitor.Service.Cache
/// <param name="messageId"></param> /// <param name="messageId"></param>
/// <param name="sn"></param> /// <param name="sn"></param>
/// <returns></returns> /// <returns></returns>
public async Task<JToken?> GetDeviceGpsPersonCacheObjectBySerialNoAsync(string messageId, string sn)
public async Task<JObject?> GetDeviceGpsPersonCacheObjectBySerialNoAsync(string messageId, string sn)
{ {
if (string.IsNullOrWhiteSpace(sn)) return null; if (string.IsNullOrWhiteSpace(sn)) return null;


try try
{ {
var person = await RedisHelperDb7.HGetAsync(CACHE_HASH_KEY_GPSDEVICEPERSON, sn).ConfigureAwait(false); var person = await RedisHelperDb7.HGetAsync(CACHE_HASH_KEY_GPSDEVICEPERSON, sn).ConfigureAwait(false);
return person;
return (JObject?)JsonConvert.DeserializeObject(person);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -146,7 +147,7 @@ namespace HealthMonitor.Service.Cache
/// <param name="person"></param> /// <param name="person"></param>
/// <param name="sn"></param> /// <param name="sn"></param>
/// <returns></returns> /// <returns></returns>
public async Task<bool> UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(JToken person, string sn)
public async Task<bool> UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(JObject person, string sn)
{ {
var flag = false; var flag = false;
if (string.IsNullOrWhiteSpace(sn)) return flag; if (string.IsNullOrWhiteSpace(sn)) return flag;


Loading…
Cancel
Save