diff --git a/HealthMonitor.Service/Resolver/BloodpressResolver.cs b/HealthMonitor.Service/Resolver/BloodpressResolver.cs index e6ec8fe..19fa25a 100644 --- a/HealthMonitor.Service/Resolver/BloodpressResolver.cs +++ b/HealthMonitor.Service/Resolver/BloodpressResolver.cs @@ -179,10 +179,10 @@ namespace HealthMonitor.Service.Resolver // 如果hm_bp_config_manual_calibration存在数据,使用最新数据 // - var systolicAggregate = await _serviceTDengine.GetAggregateValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{bp.Serialno}'"); - var diastolicAggregate = await _serviceTDengine.GetAggregateValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{bp.Serialno}'"); - //var systolicAggregate = _serviceTDengine.GetAggregateValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{bp.Serialno}'"); - //var diastolicAggregate = _serviceTDengine.GetAggregateValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{bp.Serialno}'"); + var systolicAggregate = await _serviceTDengine.GetAggregateValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{bp.Serialno}'"); + var diastolicAggregate = await _serviceTDengine.GetAggregateValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{bp.Serialno}'"); + //var systolicAggregate = _serviceTDengine.GetAggregateValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{bp.Serialno}'"); + //var diastolicAggregate = _serviceTDengine.GetAggregateValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{bp.Serialno}'"); // 最大值 var systolicMax = systolicAggregate.Max; @@ -197,8 +197,8 @@ namespace HealthMonitor.Service.Resolver // 计算去除最大值和最小值和异常值的平均值 - var systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} "); - var diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{bp.Serialno}' and diastolic_value < {diastolicRefValue}"); + var systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} "); + var diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{bp.Serialno}' and diastolic_value < {diastolicRefValue}"); // if (systolicAvg.Equals(0) || diastolicAvg.Equals(0)) @@ -246,8 +246,8 @@ namespace HealthMonitor.Service.Resolver //return; } - //var systolicAvg = _serviceTDengine.GetAvgExceptMaxMinValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} "); - //var diastolicAvg = _serviceTDengine.GetAvgExceptMaxMinValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{bp.Serialno}' and diastolic_value < {diastolicRefValue}"); + //var systolicAvg = _serviceTDengine.GetAvgExceptMaxMinValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} "); + //var diastolicAvg = _serviceTDengine.GetAvgExceptMaxMinValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{bp.Serialno}' and diastolic_value < {diastolicRefValue}"); // 增量值=(标定值-平均值)* 0.25 systolicInc = systolicAvg.Equals(0M) ? 0 : (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!; diff --git a/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs b/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs index 1ece231..85ed19d 100644 --- a/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs +++ b/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs @@ -181,8 +181,8 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor else { // 平均值: 计算去除最大值 MAX和最小值 MIN 和异常值 ABN 的平均值 - systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}' and systolic_value < {systolicRefValue} "); - diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}' and diastolic_value < {diastolicRefValue}"); + systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}' and systolic_value < {systolicRefValue} "); + diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}' and diastolic_value < {diastolicRefValue}"); // 数据异常,不修改增量值 if (systolicAvg.Equals(0) || diastolicAvg.Equals(0)) @@ -225,7 +225,7 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor endTime = DateTime.Now;//newTs; startTime = newTs;//DateTime.Now; - int count = await _serviceTDengine.GetCount("stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}' "); + int count = await _serviceTDengine.GetCount("stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}' "); // B.1.1 设备已经被重新设置, 从重置的ts 到 now 没有测量数据,inc=0 if (count.Equals(0)) { @@ -236,8 +236,8 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor else { // 平均值: 计算去除最大值 MAX和最小值 MIN 和异常值 ABN 的平均值 - systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}' and systolic_value < {systolicRefValue} "); - diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}' and diastolic_value < {diastolicRefValue}"); + systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}' and systolic_value < {systolicRefValue} "); + diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}' and diastolic_value < {diastolicRefValue}"); // 数据异常,不修改增量值 if (systolicAvg.Equals(0) || diastolicAvg.Equals(0)) @@ -272,12 +272,12 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor startTime = newTs; // 最大值,最小值 - var systolicAggregate = await _serviceTDengine.GetAggregateValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}'"); - var diastolicAggregate = await _serviceTDengine.GetAggregateValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}'"); + var systolicAggregate = await _serviceTDengine.GetAggregateValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}'"); + var diastolicAggregate = await _serviceTDengine.GetAggregateValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}'"); // 平均值: 计算去除最大值 MAX和最小值 MIN 和异常值 ABN 的平均值 - systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}' and systolic_value < {systolicRefValue} "); - diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}' and diastolic_value < {diastolicRefValue}"); + systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}' and systolic_value < {systolicRefValue} "); + diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}' and diastolic_value < {diastolicRefValue}"); // 偏移参数 //var avgOffset = 0.25M; //var systolicAvgOffset = avgOffset; @@ -295,7 +295,7 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor if (systolicAvg.Equals(0) || diastolicAvg.Equals(0)) { _logger.LogInformation("B.2.1 曾经下推过断言有测量记录,数据异常,平均值为0"); - _logger.LogInformation($"{imei}本次计算结果\n{startTime:yyyy-MM-dd HH:mm:ss:fff}--{endTime:yyyy-MM-dd HH:mm:ss:fff}" + + _logger.LogInformation($"{imei}本次计算结果\n{startTime:yyyy-MM-dd HH:mm:ss.fff}--{endTime:yyyy-MM-dd HH:mm:ss.fff}" + $"\n systolic:REF:{systolicRefValue} - Inc:{systolicInc} - AVG:{systolicAvg} - MAX:{systolicAggregate.Max} - MIN: {systolicAggregate.Min} " + $"\n diastolic:REF:{diastolicRefValue} - Inc:{diastolicInc} - AVG:{diastolicAvg} - MAX:{diastolicAggregate.Max} - MIN: {diastolicAggregate.Min}"); _logger.LogInformation($"上次下发的增量值:systolic:{(int)lastPush![4]}--diastolic:{(int)lastPush![5]}"); @@ -354,10 +354,10 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor //if (total >= 4) if (lastBP?.Count != 0) { - //var systolicAggregate = await _serviceTDengine.GetAggregateValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}'"); - //var diastolicAggregate = await _serviceTDengine.GetAggregateValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}'"); - //var systolicAggregate = _serviceTDengine.GetAggregateValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{bp.Serialno}'"); - //var diastolicAggregate = _serviceTDengine.GetAggregateValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{bp.Serialno}'"); + //var systolicAggregate = await _serviceTDengine.GetAggregateValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}'"); + //var diastolicAggregate = await _serviceTDengine.GetAggregateValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}'"); + //var systolicAggregate = _serviceTDengine.GetAggregateValue("systolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{bp.Serialno}'"); + //var diastolicAggregate = _serviceTDengine.GetAggregateValue("diastolic_value", "hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{bp.Serialno}'"); //// 最大值 //var systolicMax = systolicAggregate.Max; @@ -368,8 +368,8 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor // 平均值: 计算去除最大值 MAX和最小值 MIN 和异常值 ABN 的平均值 - var systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}' and systolic_value < {systolicRefValue} "); - var diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss:fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss:fff}' and serialno='{imei}' and diastolic_value < {diastolicRefValue}"); + var systolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}' and systolic_value < {systolicRefValue} "); + var diastolicAvg = await _serviceTDengine.GetAvgExceptMaxMinValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-dd HH:mm:ss.fff}' and ts <='{endTime:yyyy-MM-dd HH:mm:ss.fff}' and serialno='{imei}' and diastolic_value < {diastolicRefValue}"); if (systolicAvg.Equals(0) || diastolicAvg.Equals(0)) {