|
|
@@ -366,12 +366,12 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
//.Where(i => i.PregnancyHeartRate < triggerHighFreqLow || i.PregnancyHeartRate > triggerHighFreqHigh) |
|
|
|
.Select(i => i.PregnancyHeartRate).Average(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FreqStatsEnd = firstTwoPhr[1]; |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 高频状态已经持续{(FreqStatsEnd - phrFreqstatus!.LastUpdate).TotalSeconds} 秒,超过约定的 {highFreqSampleTimes} 秒,即将结束高频状态,将下发指令"); |
|
|
|
//计算高频 |
|
|
|
await SaveAndPushFetalHeartRateAsync(heartRate, commonPHR, upperAlarmThreshold, lowerAlarmThreshold, avgPhr, DateTimeUtil.ConvertToTimeStamp(phrFreqstatus!.LastUpdate).ToString(), phrFreqstatus!.LastUpdate, FreqStatsEnd); |
|
|
|
|
|
|
|
|
|
|
|
// 计算本次常规心率的胎心数据(高频结束后,实时处理) |
|
|
|
await CalculateNormalFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, intervalFHR, commonPHR); |
|
|
|
} |
|
|
@@ -458,11 +458,48 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
{ |
|
|
|
// 计算本次常规心率的胎心数据 |
|
|
|
//await CalculateNormalFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, intervalFHR, commonPHR); |
|
|
|
|
|
|
|
// 本次心率可能是高频心率的首条,所以要使用本次常规心率延后计算胎心率 |
|
|
|
var fhrScheduleKey = $"health_monitor/schedule_push/cal_fetal_heart_rate/imei/{heartRate.Serialno}"; |
|
|
|
var fhrScheduleTTL = 30; |
|
|
|
await SetIntervalTriggerAsync(fhrScheduleKey, heartRate.Serialno, fhrScheduleTTL, heartRate); |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 延时50秒,判断当前数据是否为高频首条"); |
|
|
|
//var fhrScheduleKey = $"health_monitor/schedule_push/cal_fetal_heart_rate/imei/{heartRate.Serialno}"; |
|
|
|
//var fhrScheduleTTL = 30; |
|
|
|
//await SetIntervalTriggerAsync(fhrScheduleKey, heartRate.Serialno, fhrScheduleTTL, heartRate); |
|
|
|
//_logger.LogInformation($"{heartRate.Serialno} 延时50秒,判断当前数据是否为高频首条"); |
|
|
|
|
|
|
|
// 本次心率可能是高频心率的首条,所以要使用本次常规心率延后计算胎心率 查询30秒后是否有高频缓存 |
|
|
|
Thread thread = new(async () => |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
#region 休眠2秒 |
|
|
|
var startTime = DateTime.Now; |
|
|
|
var highFreqSampleInterval2 = (int)watchConfig!["highFreqSampleInterval"]!+5; |
|
|
|
var during = TimeSpan.FromSeconds(highFreqSampleInterval2); |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
if (DateTime.Now - startTime > during) |
|
|
|
{ |
|
|
|
break; |
|
|
|
} |
|
|
|
await Task.Delay(TimeSpan.FromSeconds(1)); |
|
|
|
} |
|
|
|
#endregion |
|
|
|
var phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno); |
|
|
|
_logger.LogInformation($"phrFreqstatus==null:{phrFreqstatus == null}"); |
|
|
|
_logger.LogInformation($"phrFreqstatus.LastUpdate < heartRate.LastUpdate:{phrFreqstatus?.LastUpdate < heartRate.LastUpdate}"); |
|
|
|
if (phrFreqstatus==null || phrFreqstatus.LastUpdate < heartRate.LastUpdate) |
|
|
|
{ |
|
|
|
await CalculateNormalFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, intervalFHR, commonPHR); |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 计算常规心率"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
|
|
|
|
_logger.LogError($"处理延时计算异常:{ex.Message}, {ex.StackTrace}"); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|