@@ -820,6 +820,18 @@ namespace HealthMonitor.Service.Biz.db | |||
return res; | |||
} | |||
public async Task<int> DeleteAllBySerialNoCMDAsync<T>(string serialNo) where T : class | |||
{ | |||
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); | |||
} | |||
#endregion | |||
#region 胎心算法 | |||
@@ -2,8 +2,11 @@ | |||
using HealthMonitor.Service.Biz; | |||
using HealthMonitor.Service.Biz.db; | |||
using HealthMonitor.WebApi.Configs; | |||
using HealthMonitor.WebApi.Controllers.Api; | |||
using HealthMonitor.WebApi.Model.Request; | |||
using Microsoft.AspNetCore.Mvc; | |||
using Microsoft.EntityFrameworkCore.Metadata; | |||
using SqlSugar.TDengine; | |||
namespace HealthMonitor.WebApi.Controllers.HealthMonitor | |||
{ | |||
@@ -99,5 +102,27 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor | |||
}; | |||
} | |||
[HttpPost] | |||
public async Task<ApiResponse<object>> CleanFetal([FromHeader] string requestId, [FromBody] BaseReq req) | |||
{ | |||
try | |||
{ | |||
// 删除孕妇心率 | |||
await _serviceTDengine.DeleteAllBySerialNoCMDAsync<PregnancyHeartRateModel>(req.Serialno); | |||
// 删除一般心率(建模数据) | |||
await _serviceTDengine.DeleteAllBySerialNoCMDAsync<PregnancyCommonHeartRateModel>(req.Serialno); | |||
var data = $"{req.Serialno} 清理胎心胎动建模数据成功"; | |||
return ApiResponse<object>.Success(data); | |||
} | |||
catch (Exception ex) | |||
{ | |||
_logger.LogError($"{req.Serialno} 清理胎心胎动数据异常; {ex.Message}\n {ex.InnerException} \n{ex.StackTrace}"); | |||
} | |||
return ApiResponse<object>.Fail(500, $"{req.Serialno} 清理胎心胎动数据异常"); | |||
} | |||
} | |||
} |
@@ -0,0 +1,10 @@ | |||
using Newtonsoft.Json; | |||
namespace HealthMonitor.WebApi.Model.Request | |||
{ | |||
public class BaseReq | |||
{ | |||
[JsonProperty("serialno")] | |||
public string Serialno { get; set; } = default!; | |||
} | |||
} |
@@ -441,11 +441,10 @@ namespace HealthMonitor.WebApi | |||
#region 胎动延时计算 | |||
var watchConfig = await _deviceCacheMgr.GetGpsDeviceWatchConfigCacheObjectBySerialNoAsync(imeiDel, "0067"); | |||
_logger.LogInformation($"触发胎动计算,设备配置{JsonConvert.SerializeObject(watchConfig)}"); | |||
var isFetalHeartEnable = watchConfig != null && (int)watchConfig["enabled"]! == 1; | |||
if (isFetalHeartEnable) | |||
{ | |||
var edoc = DateTimeUtil.ToDateTime(watchConfig!["EDOC"]!.ToString()); | |||
// 已经建模 | |||
var commonPHR = await _serviceTDengine.GetLastAsync<PregnancyCommonHeartRateModel>(imeiDel); | |||