Преглед на файлове

调整日志

datasub12_fetal_heart_rate_0
H Vs преди 3 месеца
родител
ревизия
d4a5f1032c
променени са 4 файла, в които са добавени 32 реда и са изтрити 17 реда
  1. +20
    -5
      HealthMonitor.Service/Biz/db/TDengineService.cs
  2. +6
    -6
      HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs
  3. +1
    -1
      HealthMonitor.WebApi/Controllers/HealthMonitor/HmFetalController.cs
  4. +5
    -5
      HealthMonitor.WebApi/Worker.cs

+ 20
- 5
HealthMonitor.Service/Biz/db/TDengineService.cs Целия файл

@@ -27,6 +27,7 @@ using TDengineTMQ;
using HealthMonitor.Service.Cache;
using System.Text.RegularExpressions;
using Etcdserverpb;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;

namespace HealthMonitor.Service.Biz.db
{
@@ -824,16 +825,30 @@ namespace HealthMonitor.Service.Biz.db
}


public async Task<int> DeleteAllBySerialNoCMDAsync<T>(string serialNo) where T : class
public async Task DeleteAllBySerialNoCMDAsync<T>(string serialNo) where T : class
{
var records = await GetBySerialNoAsync<T>(serialNo, 365);

var stbName = typeof(T)
.GetCustomAttribute<STableAttribute>()?
.STableName;
var endTime=DateTime.Now;
var startTime = DateTime.Now.AddYears(-1);
var sql = $"DELETE FROM {stbName} WHERE ts >= '{startTime:yyyy-MM-dd HH:mm:ss}' AND ts <= '{endTime:yyyy-MM-dd HH:mm:ss}' AND serialno='{serialNo}'";
return await _clientSqlSugar.Ado.ExecuteCommandAsync(sql);

var tasks = records.Select(async r =>
{
Type modelType = typeof(T);
PropertyInfo timestampProperty = typeof(T).GetProperty("Timestamp")!;
object timestampValue = timestampProperty.GetValue(r)!;
var ts = ((DateTime)timestampValue);
var startTimestamp = ts.ToString("yyyy-MM-dd HH:mm:ss.fff");
var endTimestamp = ts.AddMilliseconds(1).ToString("yyyy-MM-dd HH:mm:ss.fff");
var sql = $"DELETE FROM {stbName} WHERE ts >= '{startTimestamp}' AND ts < '{endTimestamp}'";
var res= await _clientSqlSugar.Ado.ExecuteCommandAsync(sql);
Console.WriteLine(res);
});
await Task.WhenAll(tasks);
}


#endregion

#region 胎心算法


+ 6
- 6
HealthMonitor.Service/Resolver/PregnancyHeartRateResolver.cs Целия файл

@@ -295,7 +295,7 @@ namespace HealthMonitor.Service.Resolver
}
#endregion
}
// 高频心率结束或常心率
// 高频心率结束或常心率
else
{
var phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno);
@@ -435,17 +435,17 @@ namespace HealthMonitor.Service.Resolver

_logger.LogInformation($"{heartRate.Serialno} 超时结束高频心率状态 timeDiffInSeconds {timeDiffInSeconds},highFreqSampleInterval:{highFreqSampleInterval},高频状态持续{(firstTwoPhr[1] - phrFreqstatus!.LastUpdate).TotalSeconds} 秒");

// 计算本次常心率的胎心数据
// 计算本次常心率的胎心数据
//await CalculateNormalFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, intervalFHR, commonPHR);
// 使用延后计算
var fhrScheduleKey = $"health_monitor/schedule_push/cal_fetal_heart_rate/imei/{heartRate.Serialno}";
var fhrScheduleTTL = 60;
await SetIntervalTriggerAsync(fhrScheduleKey, heartRate.Serialno, fhrScheduleTTL, heartRate);
}
// 常心率
// 常心率
else
{
// 计算本次常心率的胎心数据
// 计算本次常心率的胎心数据
//await CalculateNormalFetalHeartRateAsync(heartRate, upperAlarmThreshold, lowerAlarmThreshold, intervalFHR, commonPHR);
// 使用延后计算
var fhrScheduleKey = $"health_monitor/schedule_push/cal_fetal_heart_rate/imei/{heartRate.Serialno}";
@@ -472,7 +472,7 @@ namespace HealthMonitor.Service.Resolver

}
/// <summary>
/// 常心率计算胎心数据
/// 常心率计算胎心数据
/// </summary>
/// <param name="heartRate"></param>
/// <param name="upperAlarmThreshold"></param>
@@ -570,7 +570,7 @@ namespace HealthMonitor.Service.Resolver
var isAbnormal = fetalHeartRate > upperAlarmThreshold ? 1 : (fetalHeartRate < lowerAlarmThreshold ? 2 : 0);
var phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno);
if (phrFreqstatus == null) isAbnormal = 0;
var statsusDesc = (phrFreqstatus == null) ? "常" : "高频";
var statsusDesc = (phrFreqstatus == null) ? "常" : "高频";
_logger.LogInformation($"{heartRate.Serialno} 在 {statsusDesc} 状态,生成胎心值:{fetalHeartRate},统计周期:{statStartTime.ToString("yyyy-MM-dd HH:mm:ss")}----{statEndTime.ToString("yyyy-MM-dd HH:mm:ss")}");
//if (!isFreq)
//{


+ 1
- 1
HealthMonitor.WebApi/Controllers/HealthMonitor/HmFetalController.cs Целия файл

@@ -110,7 +110,7 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
// 删除孕妇心率
await _serviceTDengine.DeleteAllBySerialNoCMDAsync<PregnancyHeartRateModel>(req.Serialno);
// 删除一般心率(建模数据)
await _serviceTDengine.DeleteAllBySerialNoCMDAsync<PregnancyCommonHeartRateModel>(req.Serialno);
// await _serviceTDengine.DeleteAllBySerialNoCMDAsync<PregnancyCommonHeartRateModel>(req.Serialno);

var data = $"{req.Serialno} 清理胎心胎动建模数据成功";
return ApiResponse<object>.Success(data);


+ 5
- 5
HealthMonitor.WebApi/Worker.cs Целия файл

@@ -274,7 +274,7 @@ namespace HealthMonitor.WebApi
using (_logger.BeginScope(new Dictionary<string, object> { ["RequestId"] = triggerHeartRate?.MessageId! }))
{
var watchConfig = await _deviceCacheMgr.GetGpsDeviceWatchConfigCacheObjectBySerialNoAsync(imeiDel, "0067");
_logger.LogInformation($"触发常心率计算胎心");
_logger.LogInformation($"触发常心率计算胎心");
var isFetalHeartEnable = watchConfig != null && (int)watchConfig["enabled"]! == 1;

if (isFetalHeartEnable)
@@ -327,10 +327,10 @@ namespace HealthMonitor.WebApi
#endregion
}
// 不在高频状态状态,但触发孕妇心率与最后一条孕妇心率不一致,
// 常心率数据是批量上报,需要计算每条心率对应的胎心数据
// 常心率数据是批量上报,需要计算每条心率对应的胎心数据
else
{
_logger.LogInformation($"{imeiDel} 常心率数据是批量上报,需要计算每条心率对应的胎心数据");
_logger.LogInformation($"{imeiDel} 常心率数据是批量上报,需要计算每条心率对应的胎心数据");

#region 计算每条心率对应的胎心数据

@@ -1075,7 +1075,7 @@ namespace HealthMonitor.WebApi
var isAbnormal = fetalHeartRate > upperAlarmThreshold ? 1 : (fetalHeartRate < lowerAlarmThreshold ? 2 : 0);
var phrFreqstatus = await _deviceCacheMgr.GetPregnancyHeartRateFreqStatusAsync(heartRate.Serialno);
if (phrFreqstatus == null) isAbnormal = 0;
var statsusDesc = (phrFreqstatus == null) ? $"MSG ID: {heartRate.MessageId} 常" : "高频";
var statsusDesc = (phrFreqstatus == null) ? $"MSG ID: {heartRate.MessageId} 常" : "高频";
_logger.LogInformation($"{heartRate.Serialno} 在 {statsusDesc} 状态,生成胎心值:{fetalHeartRate},统计周期:{statStartTime.ToString("yyyy-MM-dd HH:mm:ss")}----{statEndTime.ToString("yyyy-MM-dd HH:mm:ss")}");
//if (!isFreq)
//{
@@ -1101,7 +1101,7 @@ namespace HealthMonitor.WebApi
await _hisFetalHeartApiClient.AddAsync(gpsFetalHeartRate).ConfigureAwait(false);

// 推送到api/v1/open/OpenIot/SetFetalHeartRateConfig
// 推送最后一条常心率到iot设备
// 推送最后一条常心率计算的胎心数据到iot设备
var lastPhr = await _serviceTDengine.GetLastAsync<PregnancyHeartRateModel>(heartRate.Serialno);
if (lastPhr.MessageId== heartRate.MessageId)
{


Loading…
Отказ
Запис