|
@@ -183,36 +183,8 @@ namespace HealthMonitor.Service.Resolver |
|
|
var nonFreqPhr = GetNonFreqPregnancyHeartRate(phr, highFreqSampleInterval); |
|
|
var nonFreqPhr = GetNonFreqPregnancyHeartRate(phr, highFreqSampleInterval); |
|
|
if (nonFreqPhr.Count >= 30) |
|
|
if (nonFreqPhr.Count >= 30) |
|
|
{ |
|
|
{ |
|
|
#region 定时计算胎动数据触发器两小时间隔开始 |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
var fetalMovementKey = $"health_monitor/schedule_push/cal_fetal_movement/imei/{heartRate.Serialno}"; |
|
|
|
|
|
///// 计算 0 点秒数 |
|
|
|
|
|
var fetalMovementLastUpdate = (DateTime)heartRate.LastUpdate!; |
|
|
|
|
|
DateTime fmScheduleNow = DateTime.Now; |
|
|
|
|
|
// 小于两小时 |
|
|
|
|
|
if (fmScheduleNow > fetalMovementLastUpdate && (fmScheduleNow - fetalMovementLastUpdate).TotalHours <= 2) |
|
|
|
|
|
{ |
|
|
|
|
|
var rand = new Random(); |
|
|
|
|
|
var pushSec = rand.Next(59); |
|
|
|
|
|
int pushMin = int.TryParse(heartRate.Serialno.AsSpan(heartRate.Serialno.Length - 1), out pushMin) ? pushMin : 10; |
|
|
|
|
|
|
|
|
|
|
|
var scheduleHourDiff = SCHEDULE_HOUR |
|
|
|
|
|
.Where(h => h > fetalMovementLastUpdate.Hour) |
|
|
|
|
|
.OrderBy(h => h - fetalMovementLastUpdate.Hour) |
|
|
|
|
|
.FirstOrDefault() - fetalMovementLastUpdate.Hour; |
|
|
|
|
|
var scheduleTime = fetalMovementLastUpdate.AddHours(scheduleHourDiff); |
|
|
|
|
|
|
|
|
|
|
|
DateTime nextRunTime = new(scheduleTime.Year, scheduleTime.Month, scheduleTime.Day, scheduleTime.Hour, pushMin, pushSec); |
|
|
|
|
|
TimeSpan timeUntilNextRun = nextRunTime - fmScheduleNow; |
|
|
|
|
|
var ttl = (long)timeUntilNextRun.TotalSeconds; |
|
|
|
|
|
|
|
|
|
|
|
await SetIntervalTriggerAsync(fetalMovementKey, heartRate.Serialno, ttl, heartRate); |
|
|
|
|
|
} |
|
|
|
|
|
*/ |
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
#region 定时计算胎动数据触发器两小时间隔开始(奇数小时计算) |
|
|
#region 定时计算胎动数据触发器两小时间隔开始(奇数小时计算) |
|
|
|
|
|
/** |
|
|
var fetalMovementKey = $"health_monitor/schedule_push/cal_fetal_movement/imei/{heartRate.Serialno}"; |
|
|
var fetalMovementKey = $"health_monitor/schedule_push/cal_fetal_movement/imei/{heartRate.Serialno}"; |
|
|
var rand = new Random(); |
|
|
var rand = new Random(); |
|
|
var pushSec = rand.Next(59); |
|
|
var pushSec = rand.Next(59); |
|
@@ -254,9 +226,50 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
|
|
|
|
|
await SetIntervalTriggerAsync(fetalMovementKey, heartRate.Serialno, ttl, heartRate); |
|
|
await SetIntervalTriggerAsync(fetalMovementKey, heartRate.Serialno, ttl, heartRate); |
|
|
_logger.LogInformation($"{heartRate.Serialno}-{heartRate.MessageId} 创建计划统计胎动时间{scheduledDateTime.ToString("yyyy-MM-dd HH:mm:ss")}"); |
|
|
_logger.LogInformation($"{heartRate.Serialno}-{heartRate.MessageId} 创建计划统计胎动时间{scheduledDateTime.ToString("yyyy-MM-dd HH:mm:ss")}"); |
|
|
|
|
|
*/ |
|
|
#endregion |
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 定时计算胎动数据触发器每小时间隔开始,延时一个小时计算 |
|
|
|
|
|
///当前时间是的0~1小时返回2小时 , |
|
|
|
|
|
///当前时间是的1~2小时返回3小时 ,如此类推, |
|
|
|
|
|
///当前时间是的21~22小时返回23小时 |
|
|
|
|
|
///当前时间是的23~0小时返回次日1小时 |
|
|
|
|
|
|
|
|
|
|
|
var fetalMovementKey = $"health_monitor/schedule_push/cal_fetal_movement/imei/{heartRate.Serialno}"; |
|
|
|
|
|
var rand = new Random(); |
|
|
|
|
|
var pushSec = rand.Next(59); |
|
|
|
|
|
int pushMin = int.TryParse(heartRate.Serialno.AsSpan(heartRate.Serialno.Length - 1), out pushMin) ? pushMin : 10; |
|
|
|
|
|
|
|
|
|
|
|
DateTime fmScheduleNow = DateTime.Now; |
|
|
|
|
|
int hour = fmScheduleNow.Hour; |
|
|
|
|
|
int selectedScheduleHour=DateTimeUtil.GetNextHour(fmScheduleNow.Hour); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTime scheduledDateTime = new DateTime( |
|
|
|
|
|
fmScheduleNow.Year, |
|
|
|
|
|
fmScheduleNow.Month, |
|
|
|
|
|
fmScheduleNow.Day, |
|
|
|
|
|
selectedScheduleHour, |
|
|
|
|
|
pushMin, |
|
|
|
|
|
pushSec |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// 跨天 |
|
|
|
|
|
if (selectedScheduleHour == 1) |
|
|
|
|
|
{ |
|
|
|
|
|
scheduledDateTime = scheduledDateTime.AddDays(1); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TimeSpan timeUntilNextRun = scheduledDateTime - fmScheduleNow; |
|
|
|
|
|
var ttl = (long)timeUntilNextRun.TotalSeconds; |
|
|
|
|
|
|
|
|
|
|
|
await SetIntervalTriggerAsync(fetalMovementKey, heartRate.Serialno, ttl, heartRate); |
|
|
|
|
|
_logger.LogInformation($"{heartRate.Serialno}-{heartRate.MessageId} 创建计划统计胎动时间{scheduledDateTime.ToString("yyyy-MM-dd HH:mm:ss")}"); |
|
|
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 计算胎心数据(按心率时间LastUpdate) |
|
|
#region 计算胎心数据(按心率时间LastUpdate) |
|
|
var commonPHR = await _serviceTDengine.GetLastAsync<PregnancyCommonHeartRateModel>(heartRate.Serialno); |
|
|
var commonPHR = await _serviceTDengine.GetLastAsync<PregnancyCommonHeartRateModel>(heartRate.Serialno); |
|
|