From 6f2baebd56973ca869da0afeb182e90f683ab868 Mon Sep 17 00:00:00 2001 From: H Vs Date: Sat, 31 Aug 2024 23:13:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=83=8E=E5=BF=83=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=97=B6=E9=97=B4=E8=B6=8A=E7=95=8C=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HealthMonitor.WebApi/Worker.cs | 39 +++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/HealthMonitor.WebApi/Worker.cs b/HealthMonitor.WebApi/Worker.cs index 7507361..6e45830 100644 --- a/HealthMonitor.WebApi/Worker.cs +++ b/HealthMonitor.WebApi/Worker.cs @@ -2475,19 +2475,20 @@ namespace HealthMonitor.WebApi try { - var CalNow = DateTime.Now; - var during = TimeSpan.FromSeconds(300); //5分钟 + //var CalNow = DateTime.Now; + //var during = TimeSpan.FromSeconds(300); //5分钟 var c = 0; while (true) { - if (DateTime.Now - CalNow > during) - { - _logger.LogInformation($"{heartRate.Serialno} 超过1分钟,迭代完成跳出循环 "); - break; - } + //if (DateTime.Now - CalNow > during) + //{ + // _logger.LogInformation($"{heartRate.Serialno} 超过1分钟,迭代完成跳出循环 "); + // break; + //} + await Task.Delay(TimeSpan.FromSeconds(1)); var segmentStatStartTime = boundaryStatStartTime.AddMinutes(c * INTERVAL_FHR); var segmentStatEndTime = segmentStatStartTime.AddMinutes(INTERVAL_FHR); @@ -2495,12 +2496,18 @@ namespace HealthMonitor.WebApi var statStartTime = segmentStatStartTime; var statEndTime = segmentStatEndTime; - //_logger.LogInformation($"{heartRate.Serialno} 当前统计周期{statStartTime.ToString("yyyy-MM-dd HH:mm:ss")}-{statEndTime.ToString("yyyy-MM-dd HH:mm:ss")}"); + _logger.LogInformation($"{heartRate.Serialno} 当前统计周期{statStartTime.ToString("yyyy-MM-dd HH:mm:ss")}-{statEndTime.ToString("yyyy-MM-dd HH:mm:ss")}"); + + if (statEndTime > boundaryStatEndTime) + { + _logger.LogInformation($"{heartRate.Serialno} 超过时间边界,迭代完成跳出循环 "); + break; + } var segmentPhr = normalPhr .Where(i => i.LastUpdate <= statEndTime && i.LastUpdate >= statStartTime) .ToList(); - + if (segmentPhr.Count == 0) { // 跳出当次迭代,进入下次迭代 @@ -2510,6 +2517,8 @@ namespace HealthMonitor.WebApi _logger.LogInformation($"{heartRate.Serialno} 当前统计周期{statStartTime.ToString("yyyy-MM-dd HH:mm:ss")}-{statEndTime.ToString("yyyy-MM-dd HH:mm:ss")},对应的常规心率ID{string.Join(",", segmentPhr.Select(i=>i.MessageId))}"); + + var sampleTime = DateTimeUtil.ConvertToTimeStamp(segmentStatStartTime).ToString(); sampleTime = sampleTime.Length > 10 ? sampleTime.Substring(0, 10) : sampleTime; @@ -2694,7 +2703,7 @@ namespace HealthMonitor.WebApi { _logger.LogInformation($"{heartRate.Serialno},统计周期:{statStartTime.ToString("yyyy-MM-dd HH:mm:ss")}----{statEndTime.ToString("yyyy-MM-dd HH:mm:ss")} ,胎心已处理"); } - await Task.Delay(TimeSpan.FromSeconds(1)); + //await Task.Delay(TimeSpan.FromSeconds(1)); // 跳出循环 if (statEndTime.ToString("yyyyMMddHHmm") == boundaryStatEndTime.ToString("yyyyMMddHHmm")) { @@ -2702,11 +2711,11 @@ namespace HealthMonitor.WebApi break; } - if (statEndTime>= boundaryStatEndTime) - { - _logger.LogInformation($"{heartRate.Serialno} 时间边界,迭代完成跳出循环 "); - break; - } + //if (statEndTime>= boundaryStatEndTime) + //{ + // _logger.LogInformation($"{heartRate.Serialno} 时间边界,迭代完成跳出循环 "); + // break; + //} }