|
|
@@ -231,6 +231,7 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
|
|
|
|
|
|
|
|
#region 定时计算胎动数据触发器每小时间隔开始,延时一个小时计算 |
|
|
|
/* |
|
|
|
///当前时间是的0~1小时返回2小时 , |
|
|
|
///当前时间是的1~2小时返回3小时 ,如此类推, |
|
|
|
///当前时间是的21~22小时返回23小时 |
|
|
@@ -245,8 +246,6 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
int hour = fmScheduleNow.Hour; |
|
|
|
int selectedScheduleHour=DateTimeUtil.GetNextHour(fmScheduleNow.Hour); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DateTime scheduledDateTime = new DateTime( |
|
|
|
fmScheduleNow.Year, |
|
|
|
fmScheduleNow.Month, |
|
|
@@ -267,6 +266,67 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
|
|
|
|
await SetIntervalTriggerAsync(fetalMovementKey, heartRate.Serialno, ttl, heartRate); |
|
|
|
_logger.LogInformation($"{heartRate.Serialno}-{heartRate.MessageId} 创建计划统计胎动时间{scheduledDateTime.ToString("yyyy-MM-dd HH:mm:ss")}"); |
|
|
|
*/ |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
#region 定时计算胎动数据触发器每小时间隔开始,延时一个小时计算 |
|
|
|
///当前时间是的0~1小时返回2小时 , |
|
|
|
///当前时间是的1~2小时返回3小时 ,如此类推, |
|
|
|
///当前时间是的21~22小时返回23小时 |
|
|
|
///当前时间是的23~0小时返回次日1小时 |
|
|
|
// lastUpdate默认奇数 // lastUpdate偶数小时 |
|
|
|
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 = DateTime.Now.Date |
|
|
|
.AddHours(selectedScheduleHour) |
|
|
|
.AddMinutes(pushMin) |
|
|
|
.AddSeconds(pushSec); |
|
|
|
|
|
|
|
// 当前时间与lastUpdate的时间差小于2小时,sample_time采集时间与计划计算时间最长是2小时 |
|
|
|
if (scheduledDateTime.Subtract((DateTime)heartRate.LastUpdate!).TotalHours <= 2) |
|
|
|
{ |
|
|
|
|
|
|
|
if (((DateTime)heartRate.LastUpdate).Hour % 2 == 0) |
|
|
|
{ |
|
|
|
// lastUpdate偶数小时 |
|
|
|
fetalMovementKey = $"health_monitor/schedule_push/cal_fetal_movement/imei/{heartRate.Serialno}/even_hour"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// lastUpdate奇数小时 |
|
|
|
fetalMovementKey = $"health_monitor/schedule_push/cal_fetal_movement/imei/{heartRate.Serialno}/odd_hour"; |
|
|
|
} |
|
|
|
} |
|
|
|
// sample_time采集时间与计划计算时间最长是2小时,次日上报引起 |
|
|
|
else |
|
|
|
{ |
|
|
|
_logger.LogWarning($"iot 上报延迟,sample_time采集时间与计划计算时间超过2小时"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 跨天 |
|
|
|
if (selectedScheduleHour == 1 || selectedScheduleHour == 0) |
|
|
|
{ |
|
|
|
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 |
|
|
|
|
|
|
|