|
|
@@ -3,6 +3,7 @@ using Grpc.Core; |
|
|
|
using HealthMonitor.Common; |
|
|
|
using HealthMonitor.Common.helper; |
|
|
|
using HealthMonitor.Core.Dal; |
|
|
|
using HealthMonitor.Core.Pipeline; |
|
|
|
using HealthMonitor.Service.Biz.db; |
|
|
|
using HealthMonitor.Service.Cache; |
|
|
|
using HealthMonitor.Service.Etcd; |
|
|
@@ -10,12 +11,15 @@ using HealthMonitor.Service.Resolver; |
|
|
|
using HealthMonitor.Util.Entities.HealthMonitor; |
|
|
|
using HealthMonitor.WebApi.Configs; |
|
|
|
using HealthMonitor.WebApi.Model.Request; |
|
|
|
using Microsoft.AspNetCore.DataProtection.KeyManagement; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.AspNetCore.Mvc.ViewFeatures; |
|
|
|
using Microsoft.EntityFrameworkCore.Metadata; |
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Internal; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
|
|
|
@@ -74,6 +78,9 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor |
|
|
|
DateTime endTime = DateTime.Now; //测试 |
|
|
|
DateTime startTime = endTime - ts; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var last = await _serviceTDengine.GetLastAsync("stb_hm_bp_push_ref_inc_value", $"serialno='{imei}' order by ts desc"); |
|
|
|
if (last?.Count != 0) |
|
|
|
{ |
|
|
@@ -82,6 +89,62 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor |
|
|
|
startTime = newTs; |
|
|
|
} |
|
|
|
} |
|
|
|
// 读数据库,remark为空就写commandValue,更新缓存 |
|
|
|
else |
|
|
|
{ |
|
|
|
#region 初始化remark |
|
|
|
var dataServiceBaseUrl = $"https://id.ssjlai.com/data"; |
|
|
|
var DataServicePersionGet = $"{dataServiceBaseUrl}/api/GpsCard/GpsPerson/GetFirst"; |
|
|
|
List<KeyValuePair<string, string>> Dataheaders = new() |
|
|
|
{ |
|
|
|
new KeyValuePair<string, string>("requestId", $"{imei}") |
|
|
|
}; |
|
|
|
var dataPersion = new |
|
|
|
{ |
|
|
|
filters = new List<object>() { new { key = "serialno", value = $"{imei}", valueType = "string", @operator = "Equal" } }, |
|
|
|
orderBys = new List<object>() { new { key = "serialno", isDesc = true } } |
|
|
|
}; |
|
|
|
var res = await _httpHelper.HttpToPostAsync(DataServicePersionGet, dataPersion, Dataheaders).ConfigureAwait(false); |
|
|
|
var resObj = JsonConvert.DeserializeObject(res!) as JToken; |
|
|
|
var remark = resObj?["remarks"]?.ToString(); |
|
|
|
|
|
|
|
// 修改数据库 |
|
|
|
if (string.IsNullOrWhiteSpace(remark)) |
|
|
|
{ |
|
|
|
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 表示不生效 |
|
|
|
} |
|
|
|
}; |
|
|
|
resObj!["remarks"] = $"is_blood_press:{JsonConvert.SerializeObject(newRemarkData)}|"; |
|
|
|
var DataServicePersionUpdate = $"{dataServiceBaseUrl}/api/GpsCard/GpsPerson/Update"; |
|
|
|
var resUpdate = await _httpHelper.HttpToPostAsync(DataServicePersionUpdate, resObj, Dataheaders).ConfigureAwait(false); |
|
|
|
_logger.LogInformation($"更新Person数据库|{resUpdate}"); |
|
|
|
|
|
|
|
//更新缓存 |
|
|
|
List<KeyValuePair<string, string>> headersCache = new() |
|
|
|
{ |
|
|
|
new KeyValuePair<string, string>("AuthKey", "key1") |
|
|
|
}; |
|
|
|
|
|
|
|
var cacheUrl = $"http://id.ssjlai.com/webapi/api/Device/UpdatePersonInfoCache?imei={imei}"; |
|
|
|
var updateCache = await _httpHelper.HttpToGetAsync(cacheUrl, headersCache); |
|
|
|
_logger.LogInformation($"更新Person缓存|{updateCache}"); |
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var lastBP = await _serviceTDengine.GetLastAsync("stb_hm_bloodpress", $"serialno='{imei}' order by ts desc"); |
|
|
|
|
|
|
|