|
|
@@ -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<HisGpsFetalHeartRate> _hisFetalHeartApiClient; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PregnancyHeartRateResolver(ILogger<PregnancyHeartRateResolver> logger, |
|
|
|
HttpHelper httpHelper, EtcdService serviceEtcd, DeviceCacheManager deviceCacheMgr, IotApiService iotApiService, TDengineService serviceDengine) |
|
|
|
HttpHelper httpHelper, EtcdService serviceEtcd, DeviceCacheManager deviceCacheMgr, |
|
|
|
IotApiService iotApiService, TDengineService serviceDengine, GpsLocationHistoryAccessorClient<HisGpsFetalHeartRate> 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); |
|
|
|
} |
|
|
|