Explorar el Código

曾经有下发记录,重置设备,取正常值标定值

datasub12_previous
H Vs hace 1 año
padre
commit
6b50b1598e
Se han modificado 1 ficheros con 23 adiciones y 16 borrados
  1. +23
    -16
      HealthMonitor.Service/Resolver/BloodpressResolver.cs

+ 23
- 16
HealthMonitor.Service/Resolver/BloodpressResolver.cs Ver fichero

@@ -120,7 +120,7 @@ namespace HealthMonitor.Service.Resolver

var bpRef = await _bpRefValCacheManager.GetBloodPressReferenceValueAsync(age, gender, isHypertension);

var last = await _serviceTDengine.GetLastAsync("stb_hm_bp_push_ref_inc_value", $"serialno='{bp.Serialno}' order by ts desc");
var lastPush = await _serviceTDengine.GetLastAsync("stb_hm_bp_push_ref_inc_value", $"serialno='{bp.Serialno}' order by ts desc");
//var ts = last?[0];
var systolicRefValue = bpRef?.Systolic;//?
var diastolicRefValue = bpRef?.Diastolic;//?
@@ -133,15 +133,31 @@ namespace HealthMonitor.Service.Resolver
var remarkFlag = false;

// 曾经有下发记录
if (last?.Count!=0)
if (lastPush?.Count!=0)
{
if (DateTime.TryParse(last?[0]!.ToString(), out DateTime newTs))
{
systolicRefValue = (int)last?[2]!;
diastolicRefValue = (int)last?[3]!;
// 重置设备,取正常值标定值
if (
(int)lastPush![2] == 0
&& (int)lastPush![3] == 0
&& (int)lastPush![4] == 0
&& (int)lastPush![5] == 0
)
{
systolicRefValue = bpRef?.Systolic;//?
diastolicRefValue = bpRef?.Diastolic;//?
}
// 取最后一条下推的标定值
else
{
systolicRefValue = (int)lastPush?[2]!;
diastolicRefValue = (int)lastPush?[3]!;
}

if (DateTime.TryParse(lastPush?[0]!.ToString(), out DateTime newTs))
{
duration = SafeType.SafeInt64(((DateTime)bp.LastUpdate! - newTs).TotalMilliseconds);
}
}

@@ -170,11 +186,8 @@ namespace HealthMonitor.Service.Resolver
// 最小值
var systolicMin = systolicAggregate.Min;
var diastolicMin = diastolicAggregate.Min;


// 偏移参数
var avgOffset = 0.25M;

var systolicAvgOffset = avgOffset;
var diastolicAvgOffset = avgOffset;

@@ -198,7 +211,6 @@ namespace HealthMonitor.Service.Resolver
// 下推
BloodPressCalibrationConfigModel bpIncData = new()
{

Imei = bp.Serialno,
SystolicRefValue = (int)systolicRefValue!, //收缩压标定值,值为0 表示不生效
DiastolicRefValue = (int)diastolicRefValue!, //舒张压标定值,值为0表示不生效
@@ -234,11 +246,6 @@ namespace HealthMonitor.Service.Resolver
//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}");






// 增量值=(标定值-平均值)* 0.25
systolicInc = systolicAvg.Equals(0M) ? 0 : (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!;
diastolicInc = diastolicAvg.Equals(0M) ? 0 : (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!;


Cargando…
Cancelar
Guardar