diff --git a/HealthMonitor.WebApi/Worker.cs b/HealthMonitor.WebApi/Worker.cs index 4361269..b1a16e3 100644 --- a/HealthMonitor.WebApi/Worker.cs +++ b/HealthMonitor.WebApi/Worker.cs @@ -332,9 +332,12 @@ namespace HealthMonitor.WebApi _logger.LogInformation($"{imeiDel} 平常心率数据是批量上报,需要计算每条心率对应的胎心数据"); #region 计算每条心率对应的胎心数据 - //去除高频 - PregnancyHeartRateModel? previousItem = null; + + phr = phr.OrderByDescending(i => i.LastUpdate).ToList(); + // 获取高频数据 + var freqCollection = new List(); + PregnancyHeartRateModel? previousItem = null; foreach (var item in phr) { if (previousItem != null) @@ -342,11 +345,31 @@ namespace HealthMonitor.WebApi var timeNextDiff = (previousItem!.LastUpdate - item.LastUpdate).TotalSeconds; if (timeNextDiff <= highFreqSampleInterval) { - phr.Remove(item); + freqCollection.Add(item); } } previousItem = item; - }; + } + //去除高频 + foreach (var item in freqCollection) + { + phr.Remove(item); + } + + + // 排序并过滤高频数据 + //var previousItem = phr.OrderByDescending(i => i.LastUpdate).ToList().First(); + //phr = phr.Skip(1) + // .Where(item => + // { + // var timeNextDiff = (previousItem!.LastUpdate - item.LastUpdate).TotalSeconds; + // previousItem = item; + // return timeNextDiff > highFreqSampleInterval; + // }) + // .Prepend(previousItem) + // .OrderByDescending(i => i.LastUpdate) + // .ToList(); + var calFhrTasks = phr.Where(p => p.LastUpdate >= triggerHeartRate!.LastUpdate) .Select( async p => {