Browse Source

调整胎心统计时间越界调整

master
H Vs 2 months ago
parent
commit
6f2baebd56
1 changed files with 24 additions and 15 deletions
  1. +24
    -15
      HealthMonitor.WebApi/Worker.cs

+ 24
- 15
HealthMonitor.WebApi/Worker.cs View File

@@ -2475,19 +2475,20 @@ namespace HealthMonitor.WebApi


try try
{ {
var CalNow = DateTime.Now;
var during = TimeSpan.FromSeconds(300); //5分钟
//var CalNow = DateTime.Now;
//var during = TimeSpan.FromSeconds(300); //5分钟


var c = 0; var c = 0;
while (true) 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 segmentStatStartTime = boundaryStatStartTime.AddMinutes(c * INTERVAL_FHR);
var segmentStatEndTime = segmentStatStartTime.AddMinutes(INTERVAL_FHR); var segmentStatEndTime = segmentStatStartTime.AddMinutes(INTERVAL_FHR);
@@ -2495,12 +2496,18 @@ namespace HealthMonitor.WebApi
var statStartTime = segmentStatStartTime; var statStartTime = segmentStatStartTime;
var statEndTime = segmentStatEndTime; 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 var segmentPhr = normalPhr
.Where(i => i.LastUpdate <= statEndTime && i.LastUpdate >= statStartTime) .Where(i => i.LastUpdate <= statEndTime && i.LastUpdate >= statStartTime)
.ToList(); .ToList();
if (segmentPhr.Count == 0) 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))}"); _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(); var sampleTime = DateTimeUtil.ConvertToTimeStamp(segmentStatStartTime).ToString();
sampleTime = sampleTime.Length > 10 ? sampleTime.Substring(0, 10) : sampleTime; 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")} ,胎心已处理"); _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")) if (statEndTime.ToString("yyyyMMddHHmm") == boundaryStatEndTime.ToString("yyyyMMddHHmm"))
{ {
@@ -2702,11 +2711,11 @@ namespace HealthMonitor.WebApi
break; break;
} }


if (statEndTime>= boundaryStatEndTime)
{
_logger.LogInformation($"{heartRate.Serialno} 时间边界,迭代完成跳出循环 ");
break;
}
//if (statEndTime>= boundaryStatEndTime)
//{
// _logger.LogInformation($"{heartRate.Serialno} 时间边界,迭代完成跳出循环 ");
// break;
//}


} }


Loading…
Cancel
Save