|
|
@@ -16,6 +16,7 @@ using TelpoDataService.Util; |
|
|
|
using TelpoDataService.Util.Clients; |
|
|
|
using TelpoDataService.Util.Models; |
|
|
|
using TelpoDataService.Util.QueryObjects; |
|
|
|
using HealthMonitor.Service.Cache; |
|
|
|
|
|
|
|
namespace HealthMonitor.Service.Biz |
|
|
|
{ |
|
|
@@ -23,17 +24,18 @@ namespace HealthMonitor.Service.Biz |
|
|
|
{ |
|
|
|
private readonly ServiceConfig _configService; |
|
|
|
private readonly ILogger<IotWebApiService> _logger; |
|
|
|
|
|
|
|
private readonly PersonCacheManager _personCacheMgr; |
|
|
|
|
|
|
|
private readonly HttpHelper _httpHelper = default!; |
|
|
|
|
|
|
|
private readonly GpsCardAccessorClient<GpsPerson> _gpsPersonApiClient; |
|
|
|
|
|
|
|
public IotWebApiService(ILogger<IotWebApiService> logger, HttpHelper httpHelper, GpsCardAccessorClient<GpsPerson> gpsPersonApiClient, IOptions<ServiceConfig> optConfigService) |
|
|
|
public IotWebApiService(ILogger<IotWebApiService> logger, HttpHelper httpHelper, GpsCardAccessorClient<GpsPerson> gpsPersonApiClient, IOptions<ServiceConfig> optConfigService, PersonCacheManager personCacheMgr) |
|
|
|
{ |
|
|
|
_configService = optConfigService.Value; |
|
|
|
_httpHelper=httpHelper; |
|
|
|
_logger = logger; |
|
|
|
_logger = logger; |
|
|
|
_personCacheMgr = personCacheMgr; |
|
|
|
_gpsPersonApiClient = gpsPersonApiClient; |
|
|
|
} |
|
|
|
/// <summary> |
|
|
@@ -80,7 +82,7 @@ namespace HealthMonitor.Service.Biz |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** 取消 |
|
|
|
/// <summary> |
|
|
|
/// 更新 gps_person remark和缓存 |
|
|
|
/// </summary> |
|
|
@@ -107,36 +109,63 @@ namespace HealthMonitor.Service.Biz |
|
|
|
|
|
|
|
}; |
|
|
|
var person = await _gpsPersonApiClient.GetFirstAsync(condition, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false); |
|
|
|
// 若remark为空,更新person remark字段 |
|
|
|
if (string.IsNullOrWhiteSpace(person?.Remarks)) |
|
|
|
//// 若remark为空,更新person remark字段 |
|
|
|
//if (string.IsNullOrWhiteSpace(person?.Remarks)) |
|
|
|
//{ |
|
|
|
// var newRemarkData = new |
|
|
|
// { |
|
|
|
// imei, |
|
|
|
// time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
|
|
|
// commandValue = new |
|
|
|
// { |
|
|
|
// systolicCalibrationValue = systolicRefValue, //收缩压标定值,值为0 表示不生效 |
|
|
|
// diastolicCalibrationValue = diastolicRefValue, //舒张压标定值,值为0表示不生效 |
|
|
|
// systolicIncValue = 0, //收缩压显示增量,值为0 表示不生效 |
|
|
|
// diastolicIncValue = 0 //舒张压显示增量,值为0 表示不生效 |
|
|
|
// } |
|
|
|
// }; |
|
|
|
// person!.Remarks = $"is_blood_press:{JsonConvert.SerializeObject(newRemarkData)}|"; |
|
|
|
// await _gpsPersonApiClient.UpdateAsync(person, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false); |
|
|
|
// _logger.LogInformation($"更新Person remarks字段|{person.Remarks}"); |
|
|
|
|
|
|
|
// // 更新缓存 |
|
|
|
// var url = $"{_configService.IotWebApiUrl}Device/UpdatePersonInfoCache?imei={imei}"; |
|
|
|
// List<KeyValuePair<string, string>> headers = new() |
|
|
|
// { |
|
|
|
// new KeyValuePair<string, string>("AuthKey", "key1") |
|
|
|
// }; |
|
|
|
// var res = await _httpHelper.HttpToGetAsync(url, headers).ConfigureAwait(false); |
|
|
|
// _logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)},响应:{res}"); |
|
|
|
// var resJToken = JsonConvert.DeserializeObject(res ?? string.Empty) as JToken; |
|
|
|
// flag = resJToken?["message"]?.ToString().Equals("ok") ?? false; |
|
|
|
//} |
|
|
|
|
|
|
|
var newRemarkData = new |
|
|
|
{ |
|
|
|
var newRemarkData = new |
|
|
|
imei, |
|
|
|
time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
|
|
|
commandValue = new |
|
|
|
{ |
|
|
|
imei, |
|
|
|
time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), |
|
|
|
commandValue = new |
|
|
|
{ |
|
|
|
systolicCalibrationValue = systolicRefValue, //收缩压标定值,值为0 表示不生效 |
|
|
|
diastolicCalibrationValue = diastolicRefValue, //舒张压标定值,值为0表示不生效 |
|
|
|
systolicIncValue = 0, //收缩压显示增量,值为0 表示不生效 |
|
|
|
diastolicIncValue = 0 //舒张压显示增量,值为0 表示不生效 |
|
|
|
} |
|
|
|
}; |
|
|
|
person!.Remarks = $"is_blood_press:{JsonConvert.SerializeObject(newRemarkData)}|"; |
|
|
|
await _gpsPersonApiClient.UpdateAsync(person, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false); |
|
|
|
_logger.LogInformation($"更新Person remarks字段|{person.Remarks}"); |
|
|
|
|
|
|
|
// 更新缓存 |
|
|
|
var url = $"{_configService.IotWebApiUrl}Device/UpdatePersonInfoCache?imei={imei}"; |
|
|
|
List<KeyValuePair<string, string>> headers = new() |
|
|
|
systolicCalibrationValue = systolicRefValue, //收缩压标定值,值为0 表示不生效 |
|
|
|
diastolicCalibrationValue = diastolicRefValue, //舒张压标定值,值为0表示不生效 |
|
|
|
systolicIncValue = 0, //收缩压显示增量,值为0 表示不生效 |
|
|
|
diastolicIncValue = 0 //舒张压显示增量,值为0 表示不生效 |
|
|
|
} |
|
|
|
}; |
|
|
|
person!.Remarks = $"is_blood_press:{JsonConvert.SerializeObject(newRemarkData)}|"; |
|
|
|
await _gpsPersonApiClient.UpdateAsync(person, new RequestHeader() { RequestId = $"{imei}" }).ConfigureAwait(false); |
|
|
|
_logger.LogInformation($"更新Person remarks字段|{person.Remarks}"); |
|
|
|
|
|
|
|
// 更新缓存 |
|
|
|
var url = $"{_configService.IotWebApiUrl}Device/UpdatePersonInfoCache?imei={imei}"; |
|
|
|
List<KeyValuePair<string, string>> headers = new() |
|
|
|
{ |
|
|
|
new KeyValuePair<string, string>("AuthKey", "key1") |
|
|
|
}; |
|
|
|
var res = await _httpHelper.HttpToGetAsync(url, headers).ConfigureAwait(false); |
|
|
|
_logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)},响应:{res}"); |
|
|
|
var resJToken = JsonConvert.DeserializeObject(res ?? string.Empty) as JToken; |
|
|
|
flag = resJToken?["message"]?.ToString().Equals("ok") ?? false; |
|
|
|
} |
|
|
|
var res = await _httpHelper.HttpToGetAsync(url, headers).ConfigureAwait(false); |
|
|
|
_logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)},响应:{res}"); |
|
|
|
var resJToken = JsonConvert.DeserializeObject(res ?? string.Empty) as JToken; |
|
|
|
flag = resJToken?["message"]?.ToString().Equals("ok") ?? false; |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
@@ -144,7 +173,8 @@ namespace HealthMonitor.Service.Biz |
|
|
|
} |
|
|
|
return flag; |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// 初次开通更新 gps_person remark和对应的缓存 |
|
|
|
/// </summary> |
|
|
@@ -193,15 +223,36 @@ namespace HealthMonitor.Service.Biz |
|
|
|
_logger.LogInformation($"更新Person remarks字段|{person.Remarks}"); |
|
|
|
|
|
|
|
// 更新缓存 |
|
|
|
var url = $"{_configService.IotWebApiUrl}Device/UpdatePersonInfoCache?imei={imei}"; |
|
|
|
List<KeyValuePair<string, string>> headers = new() |
|
|
|
var personCache = await _personCacheMgr.GetDeviceGpsPersonCacheObjectBySerialNoAsync(new Guid().ToString(), imei).ConfigureAwait(false); |
|
|
|
if (personCache != null) |
|
|
|
{ |
|
|
|
new KeyValuePair<string, string>("AuthKey", "key1") |
|
|
|
}; |
|
|
|
var res = await _httpHelper.HttpToGetAsync(url, headers).ConfigureAwait(false); |
|
|
|
_logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)},响应:{res}"); |
|
|
|
var resJToken = JsonConvert.DeserializeObject(res ?? string.Empty) as JToken; |
|
|
|
flag = resJToken?["message"]?.ToString().Equals("ok") ?? false; |
|
|
|
//personCache.Person.Remarks = person!.Remarks; |
|
|
|
personCache["person"]!["remarks"] = person!.Remarks; |
|
|
|
bool cacheFlag= await _personCacheMgr.UpdateDeviceGpsPersonCacheObjectBySerialNoAsync(personCache, imei); |
|
|
|
|
|
|
|
// flag = true; |
|
|
|
if (cacheFlag) |
|
|
|
{ |
|
|
|
flag = true; |
|
|
|
_logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)}成功,{JsonConvert.SerializeObject(personCache)}"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
flag = false; |
|
|
|
_logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)}失败,{JsonConvert.SerializeObject(personCache)}"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//var url = $"{_configService.IotWebApiUrl}Device/UpdatePersonInfoCache?imei={imei}"; |
|
|
|
//List<KeyValuePair<string, string>> headers = new() |
|
|
|
//{ |
|
|
|
// new KeyValuePair<string, string>("AuthKey", "key1") |
|
|
|
//}; |
|
|
|
//var res = await _httpHelper.HttpToGetAsync(url, headers).ConfigureAwait(false); |
|
|
|
//_logger.LogInformation($"{imei} 更新缓存{nameof(UpdatePersonRemarksAsync)},响应:{res}"); |
|
|
|
//var resJToken = JsonConvert.DeserializeObject(res ?? string.Empty) as JToken; |
|
|
|
//flag = resJToken?["message"]?.ToString().Equals("ok") ?? false; |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|