Bläddra i källkod

调整手动校正B.2.1

datasub12_previous
H Vs 11 månader sedan
förälder
incheckning
70a86d8097
1 ändrade filer med 48 tillägg och 16 borttagningar
  1. +48
    -16
      HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs

+ 48
- 16
HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs Visa fil

@@ -140,6 +140,12 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
int diastolicInc;
int systolicAvg;
int diastolicAvg;

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

//int duration = 7;
long duration = 7 * 24 * 3600 * 1000;
TimeSpan ts = TimeSpan.FromMilliseconds(duration);
@@ -188,10 +194,10 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
// 数据正常
else
{
// 偏移参数
var avgOffset = 0.25M;
var systolicAvgOffset = avgOffset;
var diastolicAvgOffset = avgOffset;
//// 偏移参数
//var avgOffset = 0.25M;
//var systolicAvgOffset = avgOffset;
//var diastolicAvgOffset = avgOffset;


// 增量值=(标定值-平均值)* 0.25
@@ -243,10 +249,10 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
// 数据正常
else
{
// 偏移参数
var avgOffset = 0.25M;
var systolicAvgOffset = avgOffset;
var diastolicAvgOffset = avgOffset;
//// 偏移参数
//var avgOffset = 0.25M;
//var systolicAvgOffset = avgOffset;
//var diastolicAvgOffset = avgOffset;
// 增量值=(标定值-平均值)* 0.25
systolicInc = systolicAvg.Equals(0M) ? 0 : (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!;
diastolicInc = diastolicAvg.Equals(0M) ? 0 : (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!;
@@ -265,26 +271,52 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
endTime = DateTime.Now;
startTime = newTs;

// 最大值,最小值
var systolicAggregate = await _serviceTDengine.GetAggregateValueAsync("systolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{imei}'");
var diastolicAggregate = await _serviceTDengine.GetAggregateValueAsync("diastolic_value", "stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{imei}'");

// 平均值: 计算去除最大值 MAX和最小值 MIN 和异常值 ABN 的平均值
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='{imei}' and systolic_value < {systolicRefValue} ");
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='{imei}' and diastolic_value < {diastolicRefValue}");
// 偏移参数
//var avgOffset = 0.25M;
//var systolicAvgOffset = avgOffset;
//var diastolicAvgOffset = avgOffset;


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

systolicInc = (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!;
diastolicInc = (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!;

// B.2.1 数据异常,将按最后一次测量值的offeset下发
if (systolicAvg.Equals(0) || diastolicAvg.Equals(0))
{
_logger.LogInformation("B.2.1 曾经下推过断言有测量记录,数据异常,平均值为0,增量值将按0下发");
return await IotSetBloodPressCalibrationConfigResponseAsync(model.Imei, systolicRefValue, diastolicRefValue, 0, 0).ConfigureAwait(false);
_logger.LogInformation("B.2.1 曾经下推过断言有测量记录,数据异常,平均值为0");
_logger.LogInformation($"{imei}本次计算结果\n{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}--{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}" +
$"\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]}");

if (systolicAvg.Equals(0))
{
systolicInc = (int)lastPush[4];
}

if (diastolicAvg.Equals(0))
{
diastolicInc = (int)lastPush[5];
}

return await IotSetBloodPressCalibrationConfigResponseAsync(model.Imei, systolicRefValue, diastolicRefValue, systolicInc, diastolicInc).ConfigureAwait(false);

}
// B.2.2 数据正常,按正常计算
else
{
// 偏移参数
var avgOffset = 0.25M;
var systolicAvgOffset = avgOffset;
var diastolicAvgOffset = avgOffset;


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


Laddar…
Avbryt
Spara