|
|
@@ -1,4 +1,5 @@ |
|
|
|
using Etcdserverpb; |
|
|
|
using Google.Protobuf.WellKnownTypes; |
|
|
|
using HealthMonitor.Common; |
|
|
|
using HealthMonitor.Common.helper; |
|
|
|
using HealthMonitor.Model.Service.Mapper; |
|
|
@@ -693,17 +694,36 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
// 推送到api/v1/open/OpenIot/SetFetalHeartRateConfig |
|
|
|
await _serviceIotApi.SetFetalHeartRateConfig(heartRate.Serialno, fetalHeartRate, sampleTime, isAbnormal); |
|
|
|
|
|
|
|
// 推送到微信 |
|
|
|
|
|
|
|
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"); |
|
|
|
// 胎心数据推送到第三方 |
|
|
|
var topic = "topic.push.third"; |
|
|
|
var fhrThridMsg = new |
|
|
|
{ |
|
|
|
messageId = fhrMsgId, |
|
|
|
topic = topic, |
|
|
|
time = fhrMsgTime, |
|
|
|
data=new { |
|
|
|
imei = heartRate.Serialno, |
|
|
|
value= fetalHeartRate, |
|
|
|
isAbnormal, |
|
|
|
type= "fetalHeart" |
|
|
|
} |
|
|
|
}; |
|
|
|
await _serviceMqProcess.ProcessIMEIEventMessageAsync(fhrMsgId, topic, 31,fhrThridMsg).ConfigureAwait(false); |
|
|
|
|
|
|
|
// 胎心数据推送到微信 |
|
|
|
if (isAbnormal != 0) |
|
|
|
{ |
|
|
|
var device = await _deviceCacheMgr.GetDeviceBySerialNoAsync(heartRate.Serialno).ConfigureAwait(false); |
|
|
|
var fhrMsgId = $"{heartRate.Serialno}-{sampleTime}-{Guid.NewGuid().ToString("D")[^3..]}"; |
|
|
|
var topic = "topic.push.wx"; |
|
|
|
|
|
|
|
topic = "topic.push.wx"; |
|
|
|
var fhrMsg = new |
|
|
|
{ |
|
|
|
messageId = fhrMsgId, |
|
|
|
topic = topic, |
|
|
|
time = DateTimeUtil.GetDateTimeFromUnixTimeMilliseconds(long.Parse(sampleTime.Length < 13 ? sampleTime.PadRight(13, '0') : sampleTime)).ToString("yyyy-MM-dd HH:mm:ss"), |
|
|
|
time = fhrMsgTime, |
|
|
|
data = new |
|
|
|
{ |
|
|
|
deviceId = device?.DeviceId, |
|
|
@@ -719,140 +739,6 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async Task SaveAndPushFreqFetalHeartRateAsync(HisGpsHeartRate heartRate, int upperAlarmThreshold, int lowerAlarmThreshold, double avgPhr, string sampleTime) |
|
|
|
{ |
|
|
|
var commonPHR = await _serviceTDengine.InitPregnancyCommonHeartRateModeAsync(heartRate.Serialno); |
|
|
|
if (commonPHR != null) |
|
|
|
{ |
|
|
|
// 保存到TDengine数据库 |
|
|
|
await _serviceTDengine.InsertAsync<PregnancyCommonHeartRateModel>("hm_pchr", commonPHR); |
|
|
|
// 计算胎心=孕妇心率*系数 |
|
|
|
var fetalHeartRate = SafeType.SafeInt(avgPhr * commonPHR?.StatModeAvgFprCoefficient!); |
|
|
|
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.Length > 10 ? sampleTime.Substring(0, 10) : 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); |
|
|
|
|
|
|
|
// 推送到微信 |
|
|
|
if (isAbnormal != 0) |
|
|
|
{ |
|
|
|
var device = await _deviceCacheMgr.GetDeviceBySerialNoAsync(heartRate.Serialno).ConfigureAwait(false); |
|
|
|
var fhrMsgId = $"{heartRate.Serialno}-{sampleTime}-{Guid.NewGuid().ToString("D")[^3..]}"; |
|
|
|
var topic = "topic.push.wx"; |
|
|
|
var fhrMsg = new |
|
|
|
{ |
|
|
|
messageId = fhrMsgId, |
|
|
|
topic = topic, |
|
|
|
time = DateTimeUtil.GetDateTimeFromUnixTimeMilliseconds(long.Parse(sampleTime.Length < 13 ? sampleTime.PadRight(13, '0') : sampleTime)).ToString("yyyy-MM-dd HH:mm:ss"), |
|
|
|
data = new |
|
|
|
{ |
|
|
|
deviceId = device?.DeviceId, |
|
|
|
imei = heartRate.Serialno, |
|
|
|
alarmTypeId = 12, |
|
|
|
alarmDeviceName = heartRate.Serialno, |
|
|
|
alarmRemarks = JsonConvert.SerializeObject(new { fetalHeartValue = fetalHeartRate, isAbnormal = isAbnormal }), |
|
|
|
address = string.Empty, |
|
|
|
deviceKey = device?.DeviceId |
|
|
|
} |
|
|
|
}; |
|
|
|
await _serviceMqProcess.ProcessIMEIEventMessageAsync(fhrMsgId, topic, fhrMsg).ConfigureAwait(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// |
|
|
|
/// </summary> |
|
|
|
/// <param name="heartRate"></param> |
|
|
|
/// <param name="upperAlarmThreshold"></param> |
|
|
|
/// <param name="lowerAlarmThreshold"></param> |
|
|
|
/// <param name="avgPhr"></param> |
|
|
|
/// <param name="sampleTime"></param> |
|
|
|
/// <returns></returns> |
|
|
|
private async Task SaveAndPushFreqFetalHeartRate2Async(HisGpsHeartRate heartRate, int upperAlarmThreshold, int lowerAlarmThreshold, double avgPhr, string sampleTime) |
|
|
|
{ |
|
|
|
var commonPHR = await _serviceTDengine.GetLastAsync<PregnancyCommonHeartRateModel>(heartRate.Serialno); |
|
|
|
if (commonPHR != null) |
|
|
|
{ |
|
|
|
// 保存到TDengine数据库 |
|
|
|
//await _serviceTDengine.InsertAsync<PregnancyCommonHeartRateModel>("hm_pchr", commonPHR); |
|
|
|
// 计算胎心=孕妇心率*系数 |
|
|
|
var fetalHeartRate = SafeType.SafeInt(avgPhr * commonPHR?.StatModeAvgFprCoefficient!); |
|
|
|
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.Length > 10 ? sampleTime.Substring(0, 10) : 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); |
|
|
|
|
|
|
|
// 推送到微信 |
|
|
|
if (isAbnormal != 0) |
|
|
|
{ |
|
|
|
var device = await _deviceCacheMgr.GetDeviceBySerialNoAsync(heartRate.Serialno).ConfigureAwait(false); |
|
|
|
var fhrMsgId = $"{heartRate.Serialno}-{sampleTime}-{Guid.NewGuid().ToString("D")[^3..]}"; |
|
|
|
var topic = "topic.push.wx"; |
|
|
|
var fhrMsg = new |
|
|
|
{ |
|
|
|
messageId = fhrMsgId, |
|
|
|
topic = topic, |
|
|
|
time = DateTimeUtil.GetDateTimeFromUnixTimeMilliseconds(long.Parse(sampleTime.Length < 13 ? sampleTime.PadRight(13, '0') : sampleTime)).ToString("yyyy-MM-dd HH:mm:ss"), |
|
|
|
data = new |
|
|
|
{ |
|
|
|
deviceId = device?.DeviceId, |
|
|
|
imei = heartRate.Serialno, |
|
|
|
alarmTypeId = 12, |
|
|
|
alarmDeviceName = heartRate.Serialno, |
|
|
|
alarmRemarks = JsonConvert.SerializeObject(new { fetalHeartValue = fetalHeartRate, isAbnormal = isAbnormal }), |
|
|
|
address = string.Empty, |
|
|
|
deviceKey = device?.DeviceId |
|
|
|
} |
|
|
|
}; |
|
|
|
await _serviceMqProcess.ProcessIMEIEventMessageAsync(fhrMsgId, topic, fhrMsg).ConfigureAwait(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private async Task SetIntervalTriggerAsync(string key,string imei, long interval) |
|
|
|
{ |
|
|
|
// var key = $"health_monitor/schedule_push/{type}/imei/{imei}"; |
|
|
|