Переглянути джерело

解析器非高频超30条才处理

datasub12_fetal_heart_rate
H Vs 3 місяці тому
джерело
коміт
1cad9c0e51
1 змінених файлів з 38 додано та 4 видалено
  1. +38
    -4
      HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs

+ 38
- 4
HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs Переглянути файл

@@ -152,8 +152,8 @@ namespace HealthMonitor.Service.Resolver
#endregion
//_logger.LogInformation($"{heartRate.Serialno} 触发定时建模");

// 高频心率采样间隔 highFreqSampleInterval = highFreqSampleInterval+5,增加5秒兼容(最小highFreqSampleInterval=60)
var highFreqSampleInterval = (int)watchConfig!["highFreqSampleInterval"]! >= 60 ? (int)watchConfig!["highFreqSampleInterval"]! + 5 : 60;
// 高频心率采样间隔 highFreqSampleInterval = highFreqSampleInterval 最小highFreqSampleInterval=60)
var highFreqSampleInterval = (int)watchConfig!["highFreqSampleInterval"]! >= 60 ? (int)watchConfig!["highFreqSampleInterval"]!:60;
// 触发高频监测的心率上限值
var triggerHighFreqHigh = (int)watchConfig["triggerHighFreqHigh"]!;
// 触发高频监测的心率下限值
@@ -179,8 +179,8 @@ namespace HealthMonitor.Service.Resolver
var phr = daysPhr
.Where(p => p.LastUpdate <= heartRate.LastUpdate)
.ToList();
if (phr.Count >= 30)
var nonFreqPhr = GetNonFreqPregnancyHeartRate(phr, highFreqSampleInterval);
if (nonFreqPhr.Count >= 30)
{
#region 定时计算胎动数据触发器两小时间隔开始
var fetalMovementKey = $"health_monitor/schedule_push/cal_fetal_movement/imei/{heartRate.Serialno}";
@@ -791,5 +791,39 @@ namespace HealthMonitor.Service.Resolver
}
}

/// <summary>
/// 去除高频数据
/// </summary>
/// <param name="phr"></param>
/// <returns></returns>
private static List<PregnancyHeartRateModel> GetNonFreqPregnancyHeartRate(List<PregnancyHeartRateModel> phr,int highFreqSampleInterval)
{
phr = phr.OrderByDescending(i => i.LastUpdate).ToList();
var result = new List<PregnancyHeartRateModel>();
PregnancyHeartRateModel? previousItem = null;

foreach (var item in phr)
{
if (previousItem != null)
{
var timeNextDiff =(previousItem!.LastUpdate - item.LastUpdate).TotalSeconds;
if (timeNextDiff > highFreqSampleInterval)
{
result.Add(previousItem);
}
}
previousItem = item;
}

// 添加上一个
if (previousItem != null)
{
result.Add(previousItem);
}

return result;
}


}
}

Завантаження…
Відмінити
Зберегти