|
|
@@ -651,14 +651,55 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
|
|
|
|
// 推送到api/v1/open/OpenIot/SetFetalHeartRateConfig |
|
|
|
// 推送最后一条常规心率计算的胎心数据到iot设备 |
|
|
|
#region 推送最后一条常规心率计算的胎心数据到iot设备 |
|
|
|
|
|
|
|
// 高频(<=12)-常规 |
|
|
|
var lastPhr = await _serviceTDengine.GetLastAsync<PregnancyHeartRateModel>(heartRate.Serialno); |
|
|
|
if (lastPhr.MessageId == heartRate.MessageId && phrFreqstatus == null) |
|
|
|
{ |
|
|
|
await _serviceIotApi.SetFetalHeartRateConfig(heartRate.Serialno, fetalHeartRate, sampleTime, isAbnormal); |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 推送最后一条常规心率计算的胎心数据到iot设备"); |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 推送最后一条常规心率计算的胎心数据到iot设备,高频(<=12)-常规"); |
|
|
|
} |
|
|
|
// 高频(13)-常规-高频(13) |
|
|
|
if (phrFreqstatus != null) |
|
|
|
{ |
|
|
|
var phr = await _serviceTDengine.GetBySerialNoAsync<PregnancyHeartRateModel>(heartRate.Serialno, 1); |
|
|
|
phr = phr.OrderByDescending(i => i.LastUpdate).ToList(); |
|
|
|
// 获取高频数据 |
|
|
|
var freqCollection = new List<PregnancyHeartRateModel>(); |
|
|
|
PregnancyHeartRateModel? previousItem = null; |
|
|
|
foreach (var item in phr) |
|
|
|
{ |
|
|
|
if (previousItem != null) |
|
|
|
{ |
|
|
|
var timeNextDiff = (previousItem!.LastUpdate - item.LastUpdate).TotalSeconds; |
|
|
|
if (timeNextDiff <= 60) |
|
|
|
{ |
|
|
|
freqCollection.Add(item); |
|
|
|
} |
|
|
|
} |
|
|
|
// 高频最后一条 |
|
|
|
if (lastPhr.MessageId==item.MessageId) |
|
|
|
{ |
|
|
|
freqCollection.Add(item); |
|
|
|
} |
|
|
|
|
|
|
|
previousItem = item; |
|
|
|
} |
|
|
|
//去除高频 |
|
|
|
foreach (var item in freqCollection) |
|
|
|
{ |
|
|
|
phr.Remove(item); |
|
|
|
} |
|
|
|
lastPhr = phr.FirstOrDefault(); |
|
|
|
if (lastPhr?.MessageId == heartRate.MessageId) |
|
|
|
{ |
|
|
|
await _serviceIotApi.SetFetalHeartRateConfig(heartRate.Serialno, fetalHeartRate, sampleTime, isAbnormal); |
|
|
|
_logger.LogInformation($"{heartRate.Serialno} 推送最后一条常规心率计算的胎心数据到iot设备,高频(13)-常规-高频(13)"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion |
|
|
|
var device = await _deviceCacheMgr.GetDeviceBySerialNoAsync(heartRate.Serialno).ConfigureAwait(false); |
|
|
|
var fhrMsgId = $"{heartRate.Serialno}-{sampleTime}-{Guid.NewGuid().ToString("D")[^3..]}"; |
|
|
|
var fhrMsgTime = DateTimeUtil.GetDateTimeFromUnixTimeMilliseconds(long.Parse(sampleTime.Length < 13 ? sampleTime.PadRight(13, '0') : sampleTime)).ToString("yyyy-MM-dd HH:mm:ss"); |
|
|
|