瀏覽代碼

调整血压解释器

datasub12_previous
H Vs 11 月之前
父節點
當前提交
e54a0f0cfb
共有 1 個檔案被更改,包括 54 行新增42 行删除
  1. +54
    -42
      HealthMonitor.Service/Resolver/BloodpressResolver.cs

+ 54
- 42
HealthMonitor.Service/Resolver/BloodpressResolver.cs 查看文件

@@ -196,53 +196,52 @@ namespace HealthMonitor.Service.Resolver
var systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} ");
var diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and diastolic_value < {diastolicRefValue}");

//
if (systolicAvg.Equals(0) || diastolicAvg.Equals(0))
{
_logger.LogWarning("平均值为0不保存");
_logger.LogWarning($"{bp.Serialno} 历史数据{startTime}---{endTime}除最大值和最小值和异常值的平均值为0,使用测试量当做平均值");
systolicAvg = bp.SystolicValue;
diastolicAvg = bp.DiastolicValue;
systolicInc = (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)! > 0? (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!:0;
diastolicInc = (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)! >0? (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!:0;
//systolicInc = (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)! > 0? (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!:0;
//diastolicInc = (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)! >0? (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!:0;
// 初始化 remark
remarkFlag = await _serviceIotWebApi.UpdatePersonRemarksAsync(bp.Serialno, (int)systolicRefValue!, (int)diastolicRefValue!, systolicInc, diastolicInc).ConfigureAwait(false);
if (remarkFlag)
{
// 下推
BloodPressCalibrationConfigModel bpIncData = new()
{
Imei = bp.Serialno,
SystolicRefValue = (int)systolicRefValue!, //收缩压标定值,值为0 表示不生效
DiastolicRefValue = (int)diastolicRefValue!, //舒张压标定值,值为0表示不生效
SystolicIncValue = systolicInc, //收缩压显示增量,值为0 表示不生效
DiastolicIncValue = diastolicInc //舒张压显示增量,值为0 表示不生效
};
// 下发 IOT 增量值
var flagIot = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false);
if (flagIot)
{
#region 保存下推记录 stb_hm_bp_push_ref_inc_value
sql = $"INSERT INTO health_monitor.hm_bp_push_ref_inc_value_{bp.Serialno.Substring(bp.Serialno.Length - 2)} " +
$"USING health_monitor.stb_hm_bp_push_ref_inc_value " +
$"TAGS ('{bp.Serialno.Substring(bp.Serialno.Length - 2)}') " +
$"VALUES(" +
$"'{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}'," +
$"'{bp.Serialno}'," +
$"{systolicRefValue}," +
$"{diastolicRefValue}," +
$"{systolicInc}," +
$"{diastolicInc}," +
$"{true})";
_serviceTDengine.ExecuteInsertSQL(sql);
#endregion
}
}
//// 初始化 remark
//remarkFlag = await _serviceIotWebApi.UpdatePersonRemarksAsync(bp.Serialno, (int)systolicRefValue!, (int)diastolicRefValue!, systolicInc, diastolicInc).ConfigureAwait(false);
//if (remarkFlag)
//{
// // 下推
// BloodPressCalibrationConfigModel bpIncData = new()
// {
// Imei = bp.Serialno,
// SystolicRefValue = (int)systolicRefValue!, //收缩压标定值,值为0 表示不生效
// DiastolicRefValue = (int)diastolicRefValue!, //舒张压标定值,值为0表示不生效
// SystolicIncValue = systolicInc, //收缩压显示增量,值为0 表示不生效
// DiastolicIncValue = diastolicInc //舒张压显示增量,值为0 表示不生效
// };
// // 下发 IOT 增量值
// var flagIot = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false);
// if (flagIot)
// {
// #region 保存下推记录 stb_hm_bp_push_ref_inc_value
// sql = $"INSERT INTO health_monitor.hm_bp_push_ref_inc_value_{bp.Serialno.Substring(bp.Serialno.Length - 2)} " +
// $"USING health_monitor.stb_hm_bp_push_ref_inc_value " +
// $"TAGS ('{bp.Serialno.Substring(bp.Serialno.Length - 2)}') " +
// $"VALUES(" +
// $"'{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}'," +
// $"'{bp.Serialno}'," +
// $"{systolicRefValue}," +
// $"{diastolicRefValue}," +
// $"{systolicInc}," +
// $"{diastolicInc}," +
// $"{true})";
// _serviceTDengine.ExecuteInsertSQL(sql);
// #endregion
// }
//}

return;
//return;
}


//var systolicAvg = _serviceTDengine.GetAvgExceptMaxMinValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} ");
//var diastolicAvg = _serviceTDengine.GetAvgExceptMaxMinValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and diastolic_value < {diastolicRefValue}");

@@ -291,6 +290,9 @@ namespace HealthMonitor.Service.Resolver
// 发送到 设置设备血压标定参数

#endregion


#region 初始化 gps_persoon remarks
// 初始化 remark
remarkFlag = await _serviceIotWebApi.UpdatePersonRemarksAsync(bp.Serialno, (int)systolicRefValue!, (int)diastolicRefValue!, systolicInc, diastolicInc).ConfigureAwait(false);
if (remarkFlag)
@@ -327,6 +329,11 @@ namespace HealthMonitor.Service.Resolver
}
}

#endregion
/** 取消
// 注册定时下发事件
// 获取当前时间
//DateTime sNow = DateTime.Now;
@@ -366,7 +373,9 @@ namespace HealthMonitor.Service.Resolver

//var result = JsonConvert.SerializeObject(data);
//var result = bp.Serialno;
*/

#region 定时下发触发器
var key = $"health_moniter/schedule_push/imei/{bp.Serialno}";
var schedule_push = await _serviceEtcd.GetValAsync(key).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(schedule_push))
@@ -443,7 +452,10 @@ namespace HealthMonitor.Service.Resolver

}


#endregion
/** 取消
//// 生效
//if (DateTime.Now.Hour == 1)
//{
@@ -473,7 +485,7 @@ namespace HealthMonitor.Service.Resolver
// _logger.LogInformation($"将 {JsonConvert.SerializeObject(data)}发送到 {url} 并且返回 {JsonConvert.SerializeObject(result)}");
//}

*/
}




Loading…
取消
儲存