From 0f33ee46b4062005e715ae69e6fd657ecdf55c06 Mon Sep 17 00:00:00 2001 From: H Vs Date: Wed, 24 Jul 2024 10:12:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4edoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HealthMonitor.Service/Biz/IotApiService.cs | 40 +++++++++++-------- .../Biz/db/TDengineService.cs | 9 +++-- HealthMonitor.WebApi/Worker.cs | 5 ++- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/HealthMonitor.Service/Biz/IotApiService.cs b/HealthMonitor.Service/Biz/IotApiService.cs index 02d9ae3..70b0545 100644 --- a/HealthMonitor.Service/Biz/IotApiService.cs +++ b/HealthMonitor.Service/Biz/IotApiService.cs @@ -295,23 +295,29 @@ namespace HealthMonitor.Service.Biz }; - var data = new - { - imeis = new string[] { serialno }, - enabled = (int)watchConfig["enabled"]!, - interval= (int)watchConfig["interval"]!, - triggerHighFreqHigh = maxValue == 0 ? (int)watchConfig["triggerHighFreqHigh"]! : maxValue, - triggerHighFreqLow = minValue == 0 ? (int)watchConfig["triggerHighFreqLow"]! : minValue, - highFreqSampleTimes = (int)watchConfig["highFreqSampleTimes"]!, - highFreqSampleInterval = (int)watchConfig["highFreqSampleInterval"]!, - stopHighFreqSampleCount = (int)watchConfig["stopHighFreqSampleCount"]!, - mode = modeStatus, - edoc = watchConfig["EDOC"]!, - vibrateEnabled = (int)watchConfig["vibrateEnabled"]!, - lcdEnabled = (int)watchConfig["lcdEnabled"]!, - upperAlarmThreshold = (int)watchConfig["upperAlarmThreshold"]!, - lowerAlarmThreshold = (int)watchConfig["lowerAlarmThreshold"]! - }; + //var data = new + //{ + // imeis = new string[] { serialno }, + // enabled = (int)watchConfig["enabled"]!, + // interval= (int)watchConfig["interval"]!, + // triggerHighFreqHigh = maxValue == 0 ? (int)watchConfig["triggerHighFreqHigh"]! : maxValue, + // triggerHighFreqLow = minValue == 0 ? (int)watchConfig["triggerHighFreqLow"]! : minValue, + // highFreqSampleTimes = (int)watchConfig["highFreqSampleTimes"]!, + // highFreqSampleInterval = (int)watchConfig["highFreqSampleInterval"]!, + // stopHighFreqSampleCount = (int)watchConfig["stopHighFreqSampleCount"]!, + // mode = modeStatus, + // edoc = watchConfig["EDOC"]!, + // vibrateEnabled = (int)watchConfig["vibrateEnabled"]!, + // lcdEnabled = (int)watchConfig["lcdEnabled"]!, + // upperAlarmThreshold = (int)watchConfig["upperAlarmThreshold"]!, + // lowerAlarmThreshold = (int)watchConfig["lowerAlarmThreshold"]! + //}; + watchConfig["mode"] = modeStatus; + watchConfig["triggerHighFreqHigh"] = maxValue == 0 ? (int)watchConfig["triggerHighFreqHigh"]! : maxValue; + watchConfig["triggerHighFreqLow"] = minValue == 0 ? (int)watchConfig["triggerHighFreqLow"]! : minValue; + + var data = watchConfig; + var setUrl = $"{_configService.IotCore}/SetFetalConfig"; _logger.LogInformation($"{setUrl} 请求 {JsonConvert.SerializeObject(JsonConvert.SerializeObject(data))}"); var res = await _httpHelper.HttpToPostAsync(setUrl, data, headers).ConfigureAwait(false); diff --git a/HealthMonitor.Service/Biz/db/TDengineService.cs b/HealthMonitor.Service/Biz/db/TDengineService.cs index ec89221..a6c1b57 100644 --- a/HealthMonitor.Service/Biz/db/TDengineService.cs +++ b/HealthMonitor.Service/Biz/db/TDengineService.cs @@ -972,12 +972,13 @@ namespace HealthMonitor.Service.Biz.db { return null; } - long.TryParse(watchConfig["EDOC"]!.ToString(), out long edoc); + // long.TryParse(watchConfig["EDOC"]!.ToString(), out long edoc); // "EDOC": "1720860180652",当前时间 - (EDOC - 280) days =怀孕时间 - edoc = edoc.ToString().Length == 10 ? edoc * 1000 : edoc; - int pregnancyWeek = (DateTime.Now-DateTimeUtil.GetDateTimeFromUnixTimeMilliseconds(edoc).AddDays(-280)).Days / 7; + //edoc = edoc.ToString().Length == 10 ? edoc * 1000 : edoc; + var edoc = DateTimeUtil.ToDateTime(watchConfig["EDOC"]!.ToString()); + int pregnancyWeek = (DateTime.Now- edoc.AddDays(-280)).Days / 7; - _logger.LogInformation($"IMEI {serialNo},EDOC:{edoc},NOW:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},SinceNOW:{DateTimeUtil.GetDateTimeFromUnixTimeMilliseconds(edoc).AddDays(-280).ToString("yyyy-MM-dd HH:mm:ss")},怀孕周数 {pregnancyWeek}"); + _logger.LogInformation($"IMEI {serialNo},EDOC:{edoc},NOW:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")},SinceNOW:{edoc.AddDays(-280).ToString("yyyy-MM-dd HH:mm:ss")},怀孕周数 {pregnancyWeek}"); float statMaxValueFprCoefficient = 0f; float statMinValueFprCoefficient = 0f; diff --git a/HealthMonitor.WebApi/Worker.cs b/HealthMonitor.WebApi/Worker.cs index 1d2bd00..4317b10 100644 --- a/HealthMonitor.WebApi/Worker.cs +++ b/HealthMonitor.WebApi/Worker.cs @@ -351,9 +351,10 @@ namespace HealthMonitor.WebApi //在餐后时间段(8:00~10:00,12:00~14:00,18:00~20:00,22:00~24:00)取中间值。其他时间段取正常起始值 bool isInTimeRanges = IsNowInTimeRanges(); - long.TryParse(watchConfig!["EDOC"]!.ToString(), out long edoc); + //long.TryParse(watchConfig!["EDOC"]!.ToString(), out long edoc); + var edoc = DateTimeUtil.ToDateTime(watchConfig!["EDOC"]!.ToString()); - int pregnancyWeeks = (DateTime.Now - DateTimeUtil.GetDateTimeFromUnixTimeMilliseconds(edoc).AddDays(-280)).Days / 7; + int pregnancyWeeks = (DateTime.Now -edoc.AddDays(-280)).Days / 7; if (pregnancyWeeks >= 12 && pregnancyWeeks <= 50) { var fetalMovementMap = _mgrFetalMovementNormalValueRangeCache.GetFetalMovements();