From fb770fe912a43031ea21401733c18d29a1bef393 Mon Sep 17 00:00:00 2001 From: H Vs Date: Mon, 22 Jul 2024 14:59:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=88=B0=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthMonitor.Service.csproj | 2 +- .../Resolver/PregnancyHeartRateResolver.cs | 27 ++++++++++++++++++- .../HealthMonitor.WebApi.csproj | 2 +- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/HealthMonitor.Service/HealthMonitor.Service.csproj b/HealthMonitor.Service/HealthMonitor.Service.csproj index af17312..f2b0fc2 100644 --- a/HealthMonitor.Service/HealthMonitor.Service.csproj +++ b/HealthMonitor.Service/HealthMonitor.Service.csproj @@ -15,7 +15,7 @@ - + diff --git a/HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs b/HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs index 75436bf..efd218f 100644 --- a/HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs +++ b/HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs @@ -16,6 +16,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using TelpoDataService.Util.Clients; using TelpoDataService.Util.Entities.GpsLocationHistory; namespace HealthMonitor.Service.Resolver @@ -34,9 +35,13 @@ namespace HealthMonitor.Service.Resolver private readonly HttpHelper _httpHelper = default!; private readonly EtcdService _serviceEtcd; + private readonly GpsLocationHistoryAccessorClient _hisFetalHeartApiClient; + + public PregnancyHeartRateResolver(ILogger logger, - HttpHelper httpHelper, EtcdService serviceEtcd, DeviceCacheManager deviceCacheMgr, IotApiService iotApiService, TDengineService serviceDengine) + HttpHelper httpHelper, EtcdService serviceEtcd, DeviceCacheManager deviceCacheMgr, + IotApiService iotApiService, TDengineService serviceDengine, GpsLocationHistoryAccessorClient hisFetalHeartApiClient) { _logger = logger; _httpHelper = httpHelper; @@ -44,6 +49,7 @@ namespace HealthMonitor.Service.Resolver _serviceTDengine = serviceDengine; _deviceCacheMgr = deviceCacheMgr; _serviceIotApi = iotApiService; + _hisFetalHeartApiClient = hisFetalHeartApiClient; } public void SetResolveInfo(PackageMsgModel msg) @@ -271,6 +277,25 @@ namespace HealthMonitor.Service.Resolver var fetalHeartRate = SafeType.SafeInt(avgPhr * commonPHR?.StatModeAvgFprCoefficient!); var sampleTime = DateTimeUtil.ConvertToTimeStamp(DateTime.Now).ToString(); var isAbnormal = fetalHeartRate > upperAlarmThreshold ? 1 : (fetalHeartRate < lowerAlarmThreshold ? 2 : 0); + + // 保存到 数据服务 MySQL 数据库 + HisGpsFetalHeartRate gpsFetalHeartRate = new () + { + FetalHeartRateId = Guid.NewGuid().ToString("D"), + PersonId = commonPHR!.PersonId, + Serialno = heartRate.Serialno, + HeartRate = fetalHeartRate, + SampleTime = sampleTime, + IsAbnormal = isAbnormal, + StatStartTime = commonPHR.StatStartTime, + StatEndTime = commonPHR.StatEndTime, + CreateTime = DateTime.Now, + Method = 1, + IsDisplay = 1, + DeviceKey = commonPHR!.DeviceKey + }; + await _hisFetalHeartApiClient.AddAsync(gpsFetalHeartRate).ConfigureAwait(false); + // 推送到api/v1/open/OpenIot/SetFetalHeartRateConfig await _serviceIotApi.SetFetalHeartRateConfig(heartRate.Serialno, fetalHeartRate, sampleTime, isAbnormal); } diff --git a/HealthMonitor.WebApi/HealthMonitor.WebApi.csproj b/HealthMonitor.WebApi/HealthMonitor.WebApi.csproj index 4ead961..02c3c25 100644 --- a/HealthMonitor.WebApi/HealthMonitor.WebApi.csproj +++ b/HealthMonitor.WebApi/HealthMonitor.WebApi.csproj @@ -11,7 +11,7 @@ - +