From 27a7aadc453528566624f66a9ae04c9e15ee4d7a Mon Sep 17 00:00:00 2001 From: H Vs Date: Sat, 27 Jul 2024 11:20:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resolver/PregnancyHeartRateResolver.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs b/HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs index 7a9e61e..5ac7c95 100644 --- a/HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs +++ b/HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs @@ -513,7 +513,7 @@ namespace HealthMonitor.Service.Resolver // 正常心率 else { - _logger.LogInformation($"{heartRate.Serialno} 计算胎心数据"); + // 上15分钟的数据 // 获取当前时间 DateTime nowInterval = (DateTime)heartRate.LastUpdate!; @@ -542,11 +542,20 @@ namespace HealthMonitor.Service.Resolver var daysPhr = await _serviceTDengine.GetBySerialNoAsync(heartRate.Serialno, 7); + var normalPhrStatStartTime = nextInterval; + + var normalPhrStatEndTime = nextInterval.AddMinutes(-intervalFHR); + + _logger.LogInformation($"{heartRate.Serialno} 计算胎心数据, 周期:{normalPhrStatStartTime}-{normalPhrStatEndTime} "); var filteredPhr = daysPhr // 使用 last_update 下一刻 - .Where(i => i.LastUpdate <= nextInterval && i.LastUpdate >= nextInterval.AddMinutes(-intervalFHR)) + .Where(i => i.LastUpdate <= normalPhrStatStartTime && i.LastUpdate >= normalPhrStatEndTime) .ToList(); - + if (filteredPhr.Count == 0) + { + _logger.LogWarning($"{heartRate.Serialno} 周期:{normalPhrStatStartTime}-{normalPhrStatEndTime} 孕妇心率数据不足,{filteredPhr.Count}条记录"); + return; + } var phrValue = filteredPhr.Count == 1 ? filteredPhr.First().PregnancyHeartRate : filteredPhr.Average(i => i.PregnancyHeartRate);