From 6b50b1598e122ef6f1b752e187919aeb77bf1c55 Mon Sep 17 00:00:00 2001 From: H Vs Date: Mon, 20 Nov 2023 23:20:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=BE=E7=BB=8F=E6=9C=89=E4=B8=8B=E5=8F=91?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=EF=BC=8C=E9=87=8D=E7=BD=AE=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=EF=BC=8C=E5=8F=96=E6=AD=A3=E5=B8=B8=E5=80=BC=E6=A0=87=E5=AE=9A?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Resolver/BloodpressResolver.cs | 39 +++++++++++-------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/HealthMonitor.Service/Resolver/BloodpressResolver.cs b/HealthMonitor.Service/Resolver/BloodpressResolver.cs index 6cd4457..bbeec90 100644 --- a/HealthMonitor.Service/Resolver/BloodpressResolver.cs +++ b/HealthMonitor.Service/Resolver/BloodpressResolver.cs @@ -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)!;