|
@@ -140,7 +140,7 @@ namespace HealthMonitor.WebApi |
|
|
private void WatchEvents(WatchResponse response) |
|
|
private void WatchEvents(WatchResponse response) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
response.Events.ToList().ForEach(async e => |
|
|
|
|
|
|
|
|
response.Events.ToList<Mvccpb.Event>().ForEach(async e => |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
switch (e.Type.ToString()) |
|
|
switch (e.Type.ToString()) |
|
@@ -210,7 +210,7 @@ namespace HealthMonitor.WebApi |
|
|
if (lastHmBp?.Timestamp.AddDays(7) > DateTime.Now) |
|
|
if (lastHmBp?.Timestamp.AddDays(7) > DateTime.Now) |
|
|
{ |
|
|
{ |
|
|
// 计算增量值 |
|
|
// 计算增量值 |
|
|
condition= $"serialno='{imeiDel}' order by ts desc"; |
|
|
|
|
|
|
|
|
condition = $"serialno='{imeiDel}' order by ts desc"; |
|
|
var lastPushResponse = await _serviceTDengine.ExecuteSelectRestResponseAsync("stb_hm_bp_push_ref_inc_value", condition, field); |
|
|
var lastPushResponse = await _serviceTDengine.ExecuteSelectRestResponseAsync("stb_hm_bp_push_ref_inc_value", condition, field); |
|
|
if (lastPushResponse == null) |
|
|
if (lastPushResponse == null) |
|
|
{ |
|
|
{ |
|
@@ -233,26 +233,32 @@ namespace HealthMonitor.WebApi |
|
|
var hmBp = hmBpParser?.Select(); |
|
|
var hmBp = hmBpParser?.Select(); |
|
|
//if (hmBp?.ToList().Count < 2) |
|
|
//if (hmBp?.ToList().Count < 2) |
|
|
// 1. 判断数据样本数量 |
|
|
// 1. 判断数据样本数量 |
|
|
if(hmBpParser!.Rows < 5) |
|
|
|
|
|
|
|
|
if (hmBpParser!.Rows < 5) |
|
|
{ |
|
|
{ |
|
|
_logger.LogInformation($"{imeiDel} -- {nameof(Worker)} --{nameof(WatchEvents)} -- 统计定时下发,计算增量值的数据条目不足:{hmBpParser!.Rows} < 5"); |
|
|
_logger.LogInformation($"{imeiDel} -- {nameof(Worker)} --{nameof(WatchEvents)} -- 统计定时下发,计算增量值的数据条目不足:{hmBpParser!.Rows} < 5"); |
|
|
_logger.LogInformation($"{imeiDel} -- {nameof(Worker)} --{nameof(WatchEvents)} 没有足够的数据样本,不会定时下发"); |
|
|
_logger.LogInformation($"{imeiDel} -- {nameof(Worker)} --{nameof(WatchEvents)} 没有足够的数据样本,不会定时下发"); |
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// NewMethod(systolicRefValue, hmBpParser); |
|
|
|
|
|
|
|
|
// 最大值 |
|
|
// 最大值 |
|
|
systolicMax = (int)hmBpParser?.Select(i => i.SystolicValue).Max()!; |
|
|
|
|
|
diastolicMax = (int)hmBpParser?.Select(i => i.DiastolicValue).Max()!; |
|
|
|
|
|
// 最小值 |
|
|
|
|
|
systolicMin = (int)hmBpParser?.Select(i => i.SystolicValue).Min()!; |
|
|
|
|
|
diastolicMin = (int)hmBpParser?.Select(i => i.DiastolicValue).Min()!; |
|
|
|
|
|
|
|
|
|
|
|
systolicAvg = (int)(hmBpParser?.AverageAfterRemovingOneMinMaxRef(i => i.SystolicValue, SafeType.SafeInt(systolicRefValue!)))!; |
|
|
|
|
|
diastolicAvg = (int)(hmBpParser?.AverageAfterRemovingOneMinMaxRef(i => i.DiastolicValue, SafeType.SafeInt(diastolicRefValue!)))!; |
|
|
|
|
|
|
|
|
//systolicMax = (int)hmBpParser?.Select(i => i.SystolicValue).Max()!; |
|
|
|
|
|
//diastolicMax = (int)hmBpParser?.Select(i => i.DiastolicValue).Max()!; |
|
|
|
|
|
//// 最小值 |
|
|
|
|
|
//systolicMin = (int)hmBpParser?.Select(i => i.SystolicValue).Min()!; |
|
|
|
|
|
//diastolicMin = (int)hmBpParser?.Select(i => i.DiastolicValue).Min()!; |
|
|
|
|
|
|
|
|
|
|
|
//systolicAvg = (int)(hmBpParser?.AverageAfterRemovingOneMinMaxRef(i => i.SystolicValue, SafeType.SafeInt(systolicRefValue!)))!; |
|
|
|
|
|
//diastolicAvg = (int)(hmBpParser?.AverageAfterRemovingOneMinMaxRef(i => i.DiastolicValue, SafeType.SafeInt(diastolicRefValue!)))!; |
|
|
|
|
|
|
|
|
|
|
|
var avgs = _serviceTDengine.AverageAfterRemovingOneMinMaxRef(SafeType.SafeInt(systolicRefValue!), hmBpParser!); |
|
|
|
|
|
systolicAvg = (int)avgs[0]; |
|
|
|
|
|
diastolicAvg = (int)avgs[1]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 判断能否计算增量值 |
|
|
// 2. 判断能否计算增量值 |
|
|
if (systolicAvg.Equals(0) || diastolicAvg.Equals(0)) |
|
|
|
|
|
|
|
|
if (systolicAvg.Equals(0)) |
|
|
{ |
|
|
{ |
|
|
_logger.LogInformation($"{imeiDel}--{nameof(Worker)}--计算平均值" + |
|
|
_logger.LogInformation($"{imeiDel}--{nameof(Worker)}--计算平均值" + |
|
|
$"\n currentSystolicAvg:{systolicAvg} -- lastPushSystolicInc:{lastPushSystolicInc}" + |
|
|
$"\n currentSystolicAvg:{systolicAvg} -- lastPushSystolicInc:{lastPushSystolicInc}" + |
|
@@ -265,7 +271,7 @@ namespace HealthMonitor.WebApi |
|
|
var currentSystolicInc = (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!; |
|
|
var currentSystolicInc = (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!; |
|
|
var currentDiastolicInc = (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!; |
|
|
var currentDiastolicInc = (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 累计增量 |
|
|
// 累计增量 |
|
|
systolicInc = currentSystolicInc + lastPushSystolicInc; |
|
|
systolicInc = currentSystolicInc + lastPushSystolicInc; |
|
|
diastolicInc = currentDiastolicInc + lastPushDiastolicInc; |
|
|
diastolicInc = currentDiastolicInc + lastPushDiastolicInc; |
|
@@ -407,6 +413,26 @@ namespace HealthMonitor.WebApi |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void NewMethod(int systolicRefValue, ParseTDengineRestResponse<BloodPressureModel>? hmBpParser) |
|
|
|
|
|
{ |
|
|
|
|
|
var sortedList = hmBpParser?.Select(i => i) |
|
|
|
|
|
.Where(i => i.IsDisplay.Equals(true)) |
|
|
|
|
|
.OrderByDescending(i => i.SystolicValue) |
|
|
|
|
|
.ThenByDescending(i => i.DiastolicValue) |
|
|
|
|
|
.ToList(); |
|
|
|
|
|
// 去除最大值和最小值各一个(列表的头和尾) |
|
|
|
|
|
var trimmedList = sortedList? |
|
|
|
|
|
.Skip(1) |
|
|
|
|
|
.Take(sortedList.Count - 2) |
|
|
|
|
|
.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
// 去除异常值 |
|
|
|
|
|
var filteredList = trimmedList?.Where(bp => bp.SystolicValue < SafeType.SafeInt(systolicRefValue!)).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
var systolicAvg1 = filteredList?.Select(bp => bp.SystolicValue).Average(); |
|
|
|
|
|
var diastolicAvg1 = filteredList?.Select(bp => bp.DiastolicValue).Average(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// private void WatchEvents(WatchResponse response) |
|
|
// private void WatchEvents(WatchResponse response) |
|
|
// { |
|
|
// { |
|
|
|
|
|
|
|
|