|
|
@@ -642,23 +642,22 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
if (string.IsNullOrWhiteSpace(schedule_push)) |
|
|
|
{ |
|
|
|
// 注册首次下推 |
|
|
|
#if DEBUG |
|
|
|
// await _serviceEtcd.PutValAsync(key, result, 60*1, false).ConfigureAwait(false); |
|
|
|
|
|
|
|
var interval = 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; |
|
|
|
// 计算距离下一个$interval天后的8点的时间间隔 |
|
|
|
DateTime nextRunTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute + 1, 58).AddDays(interval); |
|
|
|
DateTime nextRunTime = new DateTime(now.Year, now.Month, now.Day, 6, pushMin, pushSec).AddDays(interval); |
|
|
|
TimeSpan timeUntilNextRun = nextRunTime - now; |
|
|
|
|
|
|
|
// 如果当前时间已经超过了8点,将等待到明天后的8点 |
|
|
|
if (timeUntilNextRun < TimeSpan.Zero) |
|
|
|
{ |
|
|
|
timeUntilNextRun = timeUntilNextRun.Add(TimeSpan.FromMinutes(1)); |
|
|
|
nextRunTime += timeUntilNextRun; |
|
|
|
timeUntilNextRun = timeUntilNextRun.Add(TimeSpan.FromDays(1)); |
|
|
|
nextRunTime += TimeSpan.FromDays(1); |
|
|
|
} |
|
|
|
|
|
|
|
var ttl = (long)timeUntilNextRun.TotalSeconds; |
|
|
|
var data = new |
|
|
|
{ |
|
|
@@ -670,37 +669,6 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
var result = JsonConvert.SerializeObject(data); |
|
|
|
await _serviceEtcd.PutValAsync(key, result, ttl, false).ConfigureAwait(false); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
var interval = 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; |
|
|
|
// 计算距离下一个$interval天后的8点的时间间隔 |
|
|
|
DateTime nextRunTime = new DateTime(now.Year, now.Month, now.Day, 6, pushMin, pushSec).AddDays(interval); |
|
|
|
TimeSpan timeUntilNextRun = nextRunTime - now; |
|
|
|
|
|
|
|
|
|
|
|
if (timeUntilNextRun < TimeSpan.Zero) |
|
|
|
{ |
|
|
|
timeUntilNextRun = timeUntilNextRun.Add(TimeSpan.FromDays(1)); |
|
|
|
nextRunTime += TimeSpan.FromDays(1); |
|
|
|
} |
|
|
|
|
|
|
|
var ttl =(long)timeUntilNextRun.TotalSeconds; |
|
|
|
var data = new |
|
|
|
{ |
|
|
|
imei = heartRate.Serialno, |
|
|
|
create_time = now.ToString("yyyy-MM-dd HH:mm:ss"), |
|
|
|
ttl, |
|
|
|
next_run_time = nextRunTime.ToString("yyyy-MM-dd HH:mm:ss") |
|
|
|
}; |
|
|
|
var result = JsonConvert.SerializeObject(data); |
|
|
|
await _serviceEtcd.PutValAsync(key, result,ttl, false).ConfigureAwait(false); |
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|