|
@@ -18,7 +18,10 @@ using System.Linq; |
|
|
using System.Text; |
|
|
using System.Text; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using TelpoDataService.Util.Clients; |
|
|
using TelpoDataService.Util.Clients; |
|
|
|
|
|
using TelpoDataService.Util.Entities.GpsCard; |
|
|
using TelpoDataService.Util.Entities.GpsLocationHistory; |
|
|
using TelpoDataService.Util.Entities.GpsLocationHistory; |
|
|
|
|
|
using TelpoDataService.Util.Models; |
|
|
|
|
|
using TelpoDataService.Util.QueryObjects; |
|
|
|
|
|
|
|
|
namespace HealthMonitor.Service.Resolver |
|
|
namespace HealthMonitor.Service.Resolver |
|
|
{ |
|
|
{ |
|
@@ -37,12 +40,20 @@ namespace HealthMonitor.Service.Resolver |
|
|
private readonly EtcdService _serviceEtcd; |
|
|
private readonly EtcdService _serviceEtcd; |
|
|
|
|
|
|
|
|
private readonly GpsLocationHistoryAccessorClient<HisGpsFetalHeartRate> _hisFetalHeartApiClient; |
|
|
private readonly GpsLocationHistoryAccessorClient<HisGpsFetalHeartRate> _hisFetalHeartApiClient; |
|
|
|
|
|
private readonly GpsLocationHistoryAccessorClient<HisGpsFetalMovement> _hisFetalMovementApiClient; |
|
|
|
|
|
|
|
|
|
|
|
private readonly FetalMovementNormalValueRangeCacheManager _mgrFetalMovementNormalValueRangeCache; |
|
|
|
|
|
|
|
|
|
|
|
private readonly FetalMovementCacheManager _mgrFetalMovement; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PregnancyHeartRateResolver(ILogger<PregnancyHeartRateResolver> logger, |
|
|
public PregnancyHeartRateResolver(ILogger<PregnancyHeartRateResolver> logger, |
|
|
HttpHelper httpHelper, EtcdService serviceEtcd, DeviceCacheManager deviceCacheMgr, |
|
|
HttpHelper httpHelper, EtcdService serviceEtcd, DeviceCacheManager deviceCacheMgr, |
|
|
IotApiService iotApiService, TDengineService serviceDengine, GpsLocationHistoryAccessorClient<HisGpsFetalHeartRate> hisFetalHeartApiClient) |
|
|
|
|
|
|
|
|
IotApiService iotApiService, TDengineService serviceDengine, FetalMovementNormalValueRangeCacheManager fetalMovementNormalValueRangeCacheMgr, |
|
|
|
|
|
GpsLocationHistoryAccessorClient<HisGpsFetalHeartRate> hisFetalHeartApiClient, |
|
|
|
|
|
FetalMovementCacheManager fetalMovementCacheManager, |
|
|
|
|
|
GpsLocationHistoryAccessorClient<HisGpsFetalMovement> hisFetalMovementApiClient |
|
|
|
|
|
) |
|
|
{ |
|
|
{ |
|
|
_logger = logger; |
|
|
_logger = logger; |
|
|
_httpHelper = httpHelper; |
|
|
_httpHelper = httpHelper; |
|
@@ -51,6 +62,9 @@ namespace HealthMonitor.Service.Resolver |
|
|
_deviceCacheMgr = deviceCacheMgr; |
|
|
_deviceCacheMgr = deviceCacheMgr; |
|
|
_serviceIotApi = iotApiService; |
|
|
_serviceIotApi = iotApiService; |
|
|
_hisFetalHeartApiClient = hisFetalHeartApiClient; |
|
|
_hisFetalHeartApiClient = hisFetalHeartApiClient; |
|
|
|
|
|
_hisFetalMovementApiClient = hisFetalMovementApiClient; |
|
|
|
|
|
_mgrFetalMovementNormalValueRangeCache = fetalMovementNormalValueRangeCacheMgr; |
|
|
|
|
|
_mgrFetalMovement = fetalMovementCacheManager; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void SetResolveInfo(PackageMsgModel msg) |
|
|
public void SetResolveInfo(PackageMsgModel msg) |
|
@@ -100,6 +114,8 @@ namespace HealthMonitor.Service.Resolver |
|
|
var upperAlarmThreshold = (int)watchConfig["upperAlarmThreshold"]!; |
|
|
var upperAlarmThreshold = (int)watchConfig["upperAlarmThreshold"]!; |
|
|
// 告警下限阀值 |
|
|
// 告警下限阀值 |
|
|
var lowerAlarmThreshold = (int)watchConfig["lowerAlarmThreshold"]!; |
|
|
var lowerAlarmThreshold = (int)watchConfig["lowerAlarmThreshold"]!; |
|
|
|
|
|
// EDOC |
|
|
|
|
|
var edoc = DateTimeUtil.ToDateTime(watchConfig!["EDOC"]!.ToString()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var phr = await _serviceTDengine.GetBySerialNoAsync<PregnancyHeartRateModel>(heartRate.Serialno, 7); |
|
|
var phr = await _serviceTDengine.GetBySerialNoAsync<PregnancyHeartRateModel>(heartRate.Serialno, 7); |
|
@@ -200,12 +216,13 @@ namespace HealthMonitor.Service.Resolver |
|
|
} |
|
|
} |
|
|
#endregion |
|
|
#endregion |
|
|
|
|
|
|
|
|
#region 计算胎心数据 |
|
|
|
|
|
|
|
|
#region 计算胎心和胎动数据 |
|
|
var commonPHR = await _serviceTDengine.GetLastAsync<PregnancyCommonHeartRateModel>(heartRate.Serialno); |
|
|
var commonPHR = await _serviceTDengine.GetLastAsync<PregnancyCommonHeartRateModel>(heartRate.Serialno); |
|
|
if (commonPHR != null) |
|
|
if (commonPHR != null) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
#region 计算胎心数据 |
|
|
#region 计算胎心数据 |
|
|
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 计算胎心数据 "); |
|
|
// 上15分钟的数据 |
|
|
// 上15分钟的数据 |
|
|
// 获取当前时间 |
|
|
// 获取当前时间 |
|
|
DateTime nowQuarter = (DateTime)heartRate.LastUpdate!; |
|
|
DateTime nowQuarter = (DateTime)heartRate.LastUpdate!; |
|
@@ -246,8 +263,8 @@ namespace HealthMonitor.Service.Resolver |
|
|
var fetalHeartRate = SafeType.SafeInt(qarterPhrValue * commonPHR?.StatModeAvgFprCoefficient!); |
|
|
var fetalHeartRate = SafeType.SafeInt(qarterPhrValue * commonPHR?.StatModeAvgFprCoefficient!); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isAbnormal = fetalHeartRate > upperAlarmThreshold ? 1 : (fetalHeartRate < lowerAlarmThreshold ? 2 : 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fetalHeartRateIsAbnormal = fetalHeartRate > upperAlarmThreshold ? 1 : (fetalHeartRate < lowerAlarmThreshold ? 2 : 0); |
|
|
|
|
|
fetalHeartRateIsAbnormal = 0;// 不是高频数据,按正常值 |
|
|
HisGpsFetalHeartRate gpsFetalHeartRate = new() |
|
|
HisGpsFetalHeartRate gpsFetalHeartRate = new() |
|
|
{ |
|
|
{ |
|
|
FetalHeartRateId = Guid.NewGuid().ToString("D"), |
|
|
FetalHeartRateId = Guid.NewGuid().ToString("D"), |
|
@@ -255,7 +272,7 @@ namespace HealthMonitor.Service.Resolver |
|
|
Serialno = heartRate.Serialno, |
|
|
Serialno = heartRate.Serialno, |
|
|
HeartRate = fetalHeartRate, |
|
|
HeartRate = fetalHeartRate, |
|
|
SampleTime = sampleTime.Length > 10 ? sampleTime.Substring(0, 10) : sampleTime, |
|
|
SampleTime = sampleTime.Length > 10 ? sampleTime.Substring(0, 10) : sampleTime, |
|
|
IsAbnormal = isAbnormal, |
|
|
|
|
|
|
|
|
IsAbnormal = fetalHeartRateIsAbnormal, |
|
|
StatStartTime = filteredPhr.OrderBy(i => i.LastUpdate).First().LastUpdate, |
|
|
StatStartTime = filteredPhr.OrderBy(i => i.LastUpdate).First().LastUpdate, |
|
|
StatEndTime = filteredPhr.OrderBy(i => i.LastUpdate).Last().LastUpdate, |
|
|
StatEndTime = filteredPhr.OrderBy(i => i.LastUpdate).Last().LastUpdate, |
|
|
CreateTime = DateTime.Now, |
|
|
CreateTime = DateTime.Now, |
|
@@ -267,14 +284,112 @@ namespace HealthMonitor.Service.Resolver |
|
|
await _hisFetalHeartApiClient.AddAsync(gpsFetalHeartRate).ConfigureAwait(false); |
|
|
await _hisFetalHeartApiClient.AddAsync(gpsFetalHeartRate).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
// 推送到api/v1/open/OpenIot/SetFetalHeartRateConfig |
|
|
// 推送到api/v1/open/OpenIot/SetFetalHeartRateConfig |
|
|
await _serviceIotApi.SetFetalHeartRateConfig(heartRate.Serialno, fetalHeartRate, sampleTime, isAbnormal); |
|
|
|
|
|
|
|
|
await _serviceIotApi.SetFetalHeartRateConfig(heartRate.Serialno, fetalHeartRate, sampleTime, fetalHeartRateIsAbnormal); |
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
#region 计算胎动数据 |
|
|
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 计算胎动数据 "); |
|
|
|
|
|
|
|
|
|
|
|
var fetalMovementNow = (DateTime)heartRate.LastUpdate!; |
|
|
|
|
|
|
|
|
|
|
|
var midNight = new DateTime(fetalMovementNow.Year, fetalMovementNow.Month, fetalMovementNow.Day, 0, 0, 0); |
|
|
|
|
|
|
|
|
|
|
|
TimeSpan fetalMovementTS = fetalMovementNow - midNight; |
|
|
|
|
|
|
|
|
|
|
|
// 当天每隔2小时的段数,取整数部分 |
|
|
|
|
|
int segmentCount = (int)(fetalMovementTS.TotalHours / 2); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < segmentCount; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
// 每两小时 |
|
|
|
|
|
var fetalMovementSampleTime = DateTimeUtil.ConvertToTimeStamp(midNight.AddHours(2 * i)).ToString()[..10]; |
|
|
|
|
|
|
|
|
|
|
|
// 统计开始时间 |
|
|
|
|
|
var statStartTime = midNight.AddHours(2 * i); |
|
|
|
|
|
// 统计结束时间 |
|
|
|
|
|
var statEndTime = midNight.AddHours(2 * (i+1)); |
|
|
|
|
|
|
|
|
|
|
|
//var isFetalMovementExist = await _hisFetalMovementApiClient.GetFirstAsync(param, heartRate.Serialno[^2..], null, new RequestHeader { RequestId = Guid.NewGuid().ToString("D") }); |
|
|
|
|
|
var isFetalMovementExisted = await _mgrFetalMovement.FetalMovementIsExistedAsync(heartRate.Serialno, fetalMovementSampleTime); |
|
|
|
|
|
|
|
|
|
|
|
if (!isFetalMovementExisted) |
|
|
|
|
|
{ |
|
|
|
|
|
/// 开始计算 |
|
|
|
|
|
var phrRange = phr.Where(i => i.LastUpdate >= statStartTime && i.LastUpdate<= statEndTime) |
|
|
|
|
|
.OrderByDescending(i => i.LastUpdate) |
|
|
|
|
|
.Select(i => i.LastUpdate) |
|
|
|
|
|
.ToList(); |
|
|
|
|
|
|
|
|
|
|
|
if (phrRange.Count >= 2) |
|
|
|
|
|
{ |
|
|
|
|
|
var duringMins = Math.Abs((phrRange.First()- statStartTime).TotalMinutes); |
|
|
|
|
|
//在餐后时间段(8:00~10:00,12:00~14:00,18:00~20:00,22:00~24:00)取中间值。其他时间段取正常起始值 |
|
|
|
|
|
bool isInTimeRanges = IsLastUpdateInTimeRanges(fetalMovementNow); |
|
|
|
|
|
|
|
|
|
|
|
int pregnancyWeeks = (DateTime.Now - edoc.AddDays(-280)).Days / 7; |
|
|
|
|
|
if (pregnancyWeeks >= 12 && pregnancyWeeks <= 50) |
|
|
|
|
|
{ |
|
|
|
|
|
var fetalMovementMap = _mgrFetalMovementNormalValueRangeCache.GetFetalMovements(); |
|
|
|
|
|
|
|
|
|
|
|
var fetalMovementMapValue = isInTimeRanges ? fetalMovementMap |
|
|
|
|
|
.Where(i => |
|
|
|
|
|
i.PregnancyPeriod![0] <= pregnancyWeeks && |
|
|
|
|
|
i.PregnancyPeriod[1] >= pregnancyWeeks) |
|
|
|
|
|
.Select(i => i.MedianMovement) |
|
|
|
|
|
.FirstOrDefault() |
|
|
|
|
|
: |
|
|
|
|
|
fetalMovementMap |
|
|
|
|
|
.Where(i => |
|
|
|
|
|
i.PregnancyPeriod![0] <= pregnancyWeeks && |
|
|
|
|
|
i.PregnancyPeriod[1] >= pregnancyWeeks) |
|
|
|
|
|
.Select(i => i.InitialMovement) |
|
|
|
|
|
.FirstOrDefault() |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
var fetalMovementValue = (fetalMovementMapValue * duringMins * 2) / 120; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 四舍五入 |
|
|
|
|
|
var fetalMovement = (int)Math.Round(fetalMovementValue, 0, MidpointRounding.AwayFromZero); |
|
|
|
|
|
// _logger.LogInformation($"{heartRate.Serialno} segmentCountIndex: {i} -- fetalMovementSampleTime:{fetalMovementSampleTime}|{midNight.AddHours(2 * i).ToString("yyyy-MM-dd HH:mm:ss")} -- statStartTime: {statStartTime} -- statEndTime: {statEndTime}-- isFetalMovementExisted: {isFetalMovementExisted} "); |
|
|
|
|
|
|
|
|
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 胎动数据采样时间:{fetalMovementSampleTime}|{midNight.AddHours(2 * i).ToString("yyyy-MM-dd HH:mm:ss")}, 采样周期:{statStartTime}-{statEndTime}, 原始胎动值:{fetalMovementMapValue}, 佩戴时间 :{duringMins}|{statStartTime}-{phrRange.First()}, 胎动计算值:{fetalMovementValue}, 胎动最终值:{fetalMovement}"); |
|
|
|
|
|
|
|
|
|
|
|
// 获取胎心数据状态与胎动数据状态一致 |
|
|
|
|
|
var feltalMovementIsAbnormal = fetalHeartRateIsAbnormal; |
|
|
|
|
|
// 推送到api/v1/open/OpenIot/SetFetalMovementConfig |
|
|
|
|
|
|
|
|
|
|
|
await _serviceIotApi.SetFetalMovementConfig(heartRate.Serialno, fetalMovement, fetalMovementSampleTime, feltalMovementIsAbnormal); |
|
|
|
|
|
|
|
|
|
|
|
// 保存到MySQL数据库 |
|
|
|
|
|
HisGpsFetalMovement fm = new() |
|
|
|
|
|
{ |
|
|
|
|
|
FetalMovementId = Guid.NewGuid().ToString("D"), |
|
|
|
|
|
PersonId = commonPHR!.PersonId, |
|
|
|
|
|
Serialno = heartRate.Serialno, |
|
|
|
|
|
CreateTime = DateTime.Now, |
|
|
|
|
|
IsAbnormal = feltalMovementIsAbnormal, |
|
|
|
|
|
FetalMovementValue = fetalMovement, |
|
|
|
|
|
SampleTime = fetalMovementSampleTime, |
|
|
|
|
|
Method = 1, |
|
|
|
|
|
IsDisplay = 1, |
|
|
|
|
|
DeviceKey = commonPHR!.DeviceKey |
|
|
|
|
|
}; |
|
|
|
|
|
await _hisFetalMovementApiClient.AddAsync(fm).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
// 设置入库缓存记录 |
|
|
|
|
|
await _mgrFetalMovement.SetFetalMovementAsync(heartRate.Serialno, fetalMovementSampleTime); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
#endregion |
|
|
#endregion |
|
|
} |
|
|
} |
|
|
#endregion |
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 定时计算胎心数据触发器 {interval} 秒后 |
|
|
#region 定时计算胎心数据触发器 {interval} 秒后 |
|
|
//var fetalKey = $"health_monitor/schedule_push/cal_fetal_heart_rate/imei/{heartRate.Serialno}"; |
|
|
//var fetalKey = $"health_monitor/schedule_push/cal_fetal_heart_rate/imei/{heartRate.Serialno}"; |
|
|
//await SetIntervalTriggerAsync(fetalKey, heartRate.Serialno, 60 * 15); |
|
|
//await SetIntervalTriggerAsync(fetalKey, heartRate.Serialno, 60 * 15); |
|
@@ -303,43 +418,22 @@ namespace HealthMonitor.Service.Resolver |
|
|
#endregion |
|
|
#endregion |
|
|
|
|
|
|
|
|
#region 定时计算胎动数据触发器 0 点开始 |
|
|
#region 定时计算胎动数据触发器 0 点开始 |
|
|
var fetalMovementKey = $"health_monitor/schedule_push/cal_fetal_movement/imei/{heartRate.Serialno}"; |
|
|
|
|
|
/// 计算 0 点秒数 |
|
|
|
|
|
DateTime now = DateTime.Now; |
|
|
|
|
|
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 nextRunTime = new (now.Year, now.Month, now.Day, 0, pushMin, pushSec); |
|
|
|
|
|
TimeSpan timeUntilNextRun = nextRunTime - now; |
|
|
|
|
|
if (timeUntilNextRun < TimeSpan.Zero) |
|
|
|
|
|
{ |
|
|
|
|
|
timeUntilNextRun = timeUntilNextRun.Add(TimeSpan.FromDays(1)); |
|
|
|
|
|
nextRunTime += timeUntilNextRun; |
|
|
|
|
|
} |
|
|
|
|
|
var ttl = (long)timeUntilNextRun.TotalSeconds; |
|
|
|
|
|
|
|
|
|
|
|
await SetIntervalTriggerAsync(fetalMovementKey, heartRate.Serialno, ttl); |
|
|
|
|
|
|
|
|
|
|
|
//var scheduleFetalMovementPush = await _serviceEtcd.GetValAsync(fetalMovementKey).ConfigureAwait(false); |
|
|
|
|
|
//if (string.IsNullOrWhiteSpace(scheduleFetalMovementPush)) |
|
|
|
|
|
|
|
|
//var fetalMovementKey = $"health_monitor/schedule_push/cal_fetal_movement/imei/{heartRate.Serialno}"; |
|
|
|
|
|
///// 计算 0 点秒数 |
|
|
|
|
|
//DateTime now = DateTime.Now; |
|
|
|
|
|
//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 nextRunTime = new (now.Year, now.Month, now.Day, 0, pushMin, pushSec); |
|
|
|
|
|
//TimeSpan timeUntilNextRun = nextRunTime - now; |
|
|
|
|
|
//if (timeUntilNextRun < TimeSpan.Zero) |
|
|
//{ |
|
|
//{ |
|
|
// var fetalMovementInterval = 60 * 15; |
|
|
|
|
|
// var fetalMovementNow = DateTime.Now; |
|
|
|
|
|
// var fetalMovementTimeNextRun = fetalMovementNow.Add(TimeSpan.FromSeconds(fetalMovementInterval)); |
|
|
|
|
|
// var fetalMovementTTL = fetalMovementInterval; |
|
|
|
|
|
// var data = new |
|
|
|
|
|
// { |
|
|
|
|
|
// imei = heartRate.Serialno, |
|
|
|
|
|
// create_time = fetalMovementNow.ToString("yyyy-MM-dd HH:mm:ss"), |
|
|
|
|
|
// fetalMovementTTL, |
|
|
|
|
|
// next_run_time = fetalMovementTimeNextRun.ToString("yyyy-MM-dd HH:mm:ss") |
|
|
|
|
|
// }; |
|
|
|
|
|
// var result = JsonConvert.SerializeObject(data); |
|
|
|
|
|
|
|
|
|
|
|
// await _serviceEtcd.PutValAsync(fetalKey, result, fetalMovementTTL, false).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// timeUntilNextRun = timeUntilNextRun.Add(TimeSpan.FromDays(1)); |
|
|
|
|
|
// nextRunTime += timeUntilNextRun; |
|
|
//} |
|
|
//} |
|
|
|
|
|
//var ttl = (long)timeUntilNextRun.TotalSeconds; |
|
|
|
|
|
|
|
|
|
|
|
//await SetIntervalTriggerAsync(fetalMovementKey, heartRate.Serialno, ttl); |
|
|
#endregion |
|
|
#endregion |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -473,5 +567,37 @@ namespace HealthMonitor.Service.Resolver |
|
|
await _serviceEtcd.PutValAsync(key, result, interval, false).ConfigureAwait(false); |
|
|
await _serviceEtcd.PutValAsync(key, result, interval, false).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static bool IsNowInTimeRanges() |
|
|
|
|
|
{ |
|
|
|
|
|
var now = DateTime.Now.TimeOfDay; |
|
|
|
|
|
|
|
|
|
|
|
var timeRanges = new List<(TimeSpan Start, TimeSpan End)> |
|
|
|
|
|
{ |
|
|
|
|
|
// 8:00~10:00,12:00~14:00,18:00~20:00,22:00~24:00 |
|
|
|
|
|
(new TimeSpan(8, 0, 0), new TimeSpan(10, 0, 0)), |
|
|
|
|
|
(new TimeSpan(12, 0, 0), new TimeSpan(14, 0, 0)), |
|
|
|
|
|
(new TimeSpan(18, 0, 0), new TimeSpan(20, 0, 0)), |
|
|
|
|
|
(new TimeSpan(22, 0, 0), new TimeSpan(24, 0, 0)) |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return timeRanges.Any(range => now >= range.Start && now <= range.End); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static bool IsLastUpdateInTimeRanges(DateTime lastUpdate) |
|
|
|
|
|
{ |
|
|
|
|
|
var now = lastUpdate.TimeOfDay; |
|
|
|
|
|
|
|
|
|
|
|
var timeRanges = new List<(TimeSpan Start, TimeSpan End)> |
|
|
|
|
|
{ |
|
|
|
|
|
// 8:00~10:00,12:00~14:00,18:00~20:00,22:00~24:00 |
|
|
|
|
|
(new TimeSpan(8, 0, 0), new TimeSpan(10, 0, 0)), |
|
|
|
|
|
(new TimeSpan(12, 0, 0), new TimeSpan(14, 0, 0)), |
|
|
|
|
|
(new TimeSpan(18, 0, 0), new TimeSpan(20, 0, 0)), |
|
|
|
|
|
(new TimeSpan(22, 0, 0), new TimeSpan(24, 0, 0)) |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
return timeRanges.Any(range => now >= range.Start && now <= range.End); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |