|
|
@@ -4,6 +4,8 @@ using Google.Protobuf.WellKnownTypes; |
|
|
|
using HealthMonitor.Common; |
|
|
|
using HealthMonitor.Common.helper; |
|
|
|
using HealthMonitor.Core.Common.Extensions; |
|
|
|
using HealthMonitor.Model.Service; |
|
|
|
using HealthMonitor.Service.Biz; |
|
|
|
using HealthMonitor.Service.Biz.db; |
|
|
|
using HealthMonitor.Service.Etcd; |
|
|
|
using HealthMonitor.Service.Sub; |
|
|
@@ -27,14 +29,16 @@ namespace HealthMonitor.WebApi |
|
|
|
private readonly TDengineService _serviceTDengine; |
|
|
|
private readonly EtcdService _serviceEtcd; |
|
|
|
private readonly HttpHelper _httpHelper = default!; |
|
|
|
private readonly IotWebApiService _serviceIotWebApi; |
|
|
|
|
|
|
|
private CancellationTokenSource _tokenSource=default!; |
|
|
|
|
|
|
|
public Worker(ILogger<Worker> logger, IServiceProvider services, PackageProcess processor,TDengineDataSubcribe tdEngineDataSubcribe, TDengineService serviceDengine, HttpHelper httpHelper, EtcdService serviceEtcd) |
|
|
|
public Worker(ILogger<Worker> logger, IServiceProvider services, IotWebApiService iotWebApiService, PackageProcess processor,TDengineDataSubcribe tdEngineDataSubcribe, TDengineService serviceDengine, HttpHelper httpHelper, EtcdService serviceEtcd) |
|
|
|
{ |
|
|
|
_logger = logger; |
|
|
|
_tdEngineDataSubcribe = tdEngineDataSubcribe; |
|
|
|
_services = services; |
|
|
|
_serviceIotWebApi = iotWebApiService; |
|
|
|
_processor = processor; |
|
|
|
_serviceEtcd = serviceEtcd; |
|
|
|
_serviceTDengine = serviceDengine; |
|
|
@@ -173,8 +177,12 @@ namespace HealthMonitor.WebApi |
|
|
|
var diastolic_inc_value = last?[17]; |
|
|
|
|
|
|
|
#region 判断是否初始化remark |
|
|
|
var imei = imeiDel; |
|
|
|
|
|
|
|
|
|
|
|
// 判断是否初始化remark |
|
|
|
/** |
|
|
|
* |
|
|
|
var imei = imeiDel; |
|
|
|
var last_push = await _serviceTDengine.GetLastAsync("stb_hm_bp_push_ref_inc_value", $"serialno='{imei}' order by ts desc"); |
|
|
|
if (last_push?.Count == 0) |
|
|
|
{ |
|
|
@@ -224,33 +232,46 @@ namespace HealthMonitor.WebApi |
|
|
|
_logger.LogInformation($"更新Person缓存|{updateCache}"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
var bpData = new |
|
|
|
{ |
|
|
|
imei = imeiDel, |
|
|
|
//systolicCalibrationValue = last?[5], //收缩压标定值,值为0 表示不生效 |
|
|
|
//diastolicCalibrationValue = last?[12], //舒张压标定值,值为0表示不生效 |
|
|
|
//systolicIncValue = last?[10], //收缩压显示增量,值为0 表示不生效 |
|
|
|
//diastolicIncValue = last?[17] //舒张压显示增量,值为0 表示不生效 |
|
|
|
|
|
|
|
systolicCalibrationValue = systolic_ref_value, //收缩压标定值,值为0 表示不生效 |
|
|
|
diastolicCalibrationValue = diastolic_ref_value, //舒张压标定值,值为0表示不生效 |
|
|
|
systolicIncValue = systolic_inc_value, //收缩压显示增量,值为0 表示不生效 |
|
|
|
diastolicIncValue = diastolic_inc_value //舒张压显示增量,值为0 表示不生效 |
|
|
|
}; |
|
|
|
var str = JsonConvert.SerializeObject(bpData); |
|
|
|
var url = $"http://id.ssjlai.com/webapi/api/Command/SetBloodPressCalibrationConfig"; |
|
|
|
List<KeyValuePair<string, string>> headers = new() |
|
|
|
//var bpData = new |
|
|
|
//{ |
|
|
|
// imei = imeiDel, |
|
|
|
// //systolicCalibrationValue = last?[5], //收缩压标定值,值为0 表示不生效 |
|
|
|
// //diastolicCalibrationValue = last?[12], //舒张压标定值,值为0表示不生效 |
|
|
|
// //systolicIncValue = last?[10], //收缩压显示增量,值为0 表示不生效 |
|
|
|
// //diastolicIncValue = last?[17] //舒张压显示增量,值为0 表示不生效 |
|
|
|
|
|
|
|
// systolicCalibrationValue = systolic_ref_value, //收缩压标定值,值为0 表示不生效 |
|
|
|
// diastolicCalibrationValue = diastolic_ref_value, //舒张压标定值,值为0表示不生效 |
|
|
|
// systolicIncValue = systolic_inc_value, //收缩压显示增量,值为0 表示不生效 |
|
|
|
// diastolicIncValue = diastolic_inc_value //舒张压显示增量,值为0 表示不生效 |
|
|
|
//}; |
|
|
|
//var str = JsonConvert.SerializeObject(bpData); |
|
|
|
//var url = $"http://id.ssjlai.com/webapi/api/Command/SetBloodPressCalibrationConfig"; |
|
|
|
//List<KeyValuePair<string, string>> headers = new() |
|
|
|
//{ |
|
|
|
// new KeyValuePair<string, string>("AuthKey", "key1") |
|
|
|
//}; |
|
|
|
//var res = await _httpHelper.HttpToPostAsync(url, bpData, headers).ConfigureAwait(false); |
|
|
|
//_logger.LogInformation($"向{imeiDel}下发增量值数据:{str},响应:{res}"); |
|
|
|
//var resJToken = JsonConvert.DeserializeObject(res!) as JToken; |
|
|
|
|
|
|
|
|
|
|
|
//if (resJToken!["message"]!.ToString().Equals("ok")) |
|
|
|
|
|
|
|
BloodPressCalibrationConfigModel bpIncData = new() |
|
|
|
{ |
|
|
|
new KeyValuePair<string, string>("AuthKey", "key1") |
|
|
|
|
|
|
|
Imei = imeiDel, |
|
|
|
SystolicRefValue = SafeType.SafeInt(((int)systolic_ref_value!)), //收缩压标定值,值为0 表示不生效 |
|
|
|
DiastolicRefValue = SafeType.SafeInt(((int)diastolic_ref_value!)), //舒张压标定值,值为0表示不生效 |
|
|
|
SystolicIncValue = SafeType.SafeInt(((int)systolic_inc_value!)), //收缩压显示增量,值为0 表示不生效 |
|
|
|
DiastolicIncValue = SafeType.SafeInt(((int)diastolic_inc_value!)) //舒张压显示增量,值为0 表示不生效 |
|
|
|
}; |
|
|
|
var res = await _httpHelper.HttpToPostAsync(url, bpData, headers).ConfigureAwait(false); |
|
|
|
_logger.LogInformation($"向{imeiDel}下发增量值数据:{str},响应:{res}"); |
|
|
|
var resJToken = JsonConvert.DeserializeObject(res!) as JToken; |
|
|
|
if (resJToken!["message"]!.ToString().Equals("ok")) |
|
|
|
var pushedBP = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false); |
|
|
|
if (pushedBP) |
|
|
|
{ |
|
|
|
|
|
|
|
#region 保存下推记录 stb_hm_bp_push_ref_inc_value |
|
|
@@ -347,7 +368,6 @@ namespace HealthMonitor.WebApi |
|
|
|
_logger.LogInformation($"错误响应,没有下推数据"); |
|
|
|
} |
|
|
|
|
|
|
|
Console.WriteLine(str); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
@@ -356,7 +376,7 @@ namespace HealthMonitor.WebApi |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
//if (imeiDel.Equals("861281060086216")) |
|
|
|
//{ |
|
|
|
// var result = await _httpHelper.HttpToPostAsync(url, data, headers).ConfigureAwait(false); |
|
|
@@ -364,7 +384,7 @@ namespace HealthMonitor.WebApi |
|
|
|
// Console.WriteLine(str); |
|
|
|
|
|
|
|
//} |
|
|
|
Console.BackgroundColor = ConsoleColor.Black; |
|
|
|
//Console.BackgroundColor = ConsoleColor.Black; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|