|
|
@@ -188,8 +188,50 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor |
|
|
|
$" and is_display = true"; |
|
|
|
var hmBpResponse = await _serviceTDengine.ExecuteSelectRestResponseAsync("stb_hm_bloodpress", condition); |
|
|
|
var hmBpParser = JsonConvert.DeserializeObject<ParseTDengineRestResponse<BloodPressureModel>>(hmBpResponse!); |
|
|
|
|
|
|
|
if (hmBpParser!.Rows.Equals(0)) |
|
|
|
if (hmBpParser!.Rows > 5) |
|
|
|
{ |
|
|
|
systolicAvg = (int)(hmBpParser?.AverageAfterRemovingOneMinMaxRef(i => i.SystolicValue, SafeType.SafeInt(systolicRefValue!)))!; |
|
|
|
diastolicAvg = (int)(hmBpParser?.AverageAfterRemovingOneMinMaxRef(i => i.DiastolicValue, SafeType.SafeInt(diastolicRefValue!)))!; |
|
|
|
|
|
|
|
// 平均值为0,说明数据不足,不能计算增量值 |
|
|
|
// 数据不足等同进行初始化,只下发标定值,增量值为0;remarks恢复到未校准状态,需要基于第一个测量值生成增量值。 |
|
|
|
if (systolicAvg.Equals(0) || diastolicAvg.Equals(0)) |
|
|
|
{ |
|
|
|
_logger.LogInformation($"测量数据样本不足,将进行标定值初始,只下发标定值,增量值为0;remarks恢复到未校准状态。"); |
|
|
|
// 重置设备 |
|
|
|
var statNow = DateTime.Now; |
|
|
|
await IotSetBloodPressCalibrationConfigResponseAsync(imei, 0, 0, 0, 0, 0, 0, 0, 0, statNow, statNow).ConfigureAwait(false); |
|
|
|
_logger.LogInformation($"1.测量数据样本不足,重置设备"); |
|
|
|
|
|
|
|
var initRemarksFlag = await _serviceIotWebApi.UpdatePersonRemarksAsync(imei, 0, 0, 0, 0, true).ConfigureAwait(false); |
|
|
|
if (initRemarksFlag) |
|
|
|
{ |
|
|
|
_logger.LogInformation($"2.测量数据样本不足,remarks恢复到未校准状态(remarks设置为空),成功"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_logger.LogInformation($"2.测量数据样本不足,remarks恢复到未校准状态(remarks设置为空),失败"); |
|
|
|
} |
|
|
|
_logger.LogInformation($"3.测量数据样本不足,只下发手动标定值systolicRefValue:{systolicRefValue} -- diastolicRefValue:{diastolicRefValue},增量值为0"); |
|
|
|
statNow = DateTime.Now.AddSeconds(3); |
|
|
|
return await IotSetBloodPressCalibrationConfigResponseAsync(imei, systolicRefValue, diastolicRefValue, 0, 0, 0, 0, 0, 0, statNow, statNow).ConfigureAwait(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 增量值=(标定值-平均值)* 0.25 |
|
|
|
var currentSystolicInc = (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!; |
|
|
|
var currentDiastolicInc = (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!; |
|
|
|
|
|
|
|
// 累计增量 |
|
|
|
systolicInc = currentSystolicInc + lastPushSystolicInc; |
|
|
|
diastolicInc = currentDiastolicInc + lastPushDiastolicInc; |
|
|
|
_logger.LogInformation($"{imei}--{nameof(Put)}--计算增量值" + |
|
|
|
$"\n systolicInc:{systolicInc}-- currentSystolicInc:{currentSystolicInc} -- lastPushSystolicInc:{lastPushSystolicInc}" + |
|
|
|
$"\n diastolicInc:{diastolicInc} --currentDiastolicInc:{currentDiastolicInc} -- lastPushDiastolicInc:{lastPushDiastolicInc}"); |
|
|
|
_logger.LogInformation($"{imei},手工校准,发给设备的绝对增量值=(上次绝对增量值+新数据的增量值)"); |
|
|
|
return await IotSetBloodPressCalibrationConfigResponseAsync(imei, systolicRefValue, diastolicRefValue, systolicInc, diastolicInc, systolicAvg, diastolicAvg, systolicAvgOffset, diastolicAvgOffset, startTime, endTime).ConfigureAwait(false); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_logger.LogInformation($"没有符合条件的测试量数据,将进行标定值初始,只下发标定值,增量值为0;remarks恢复到未校准状态。"); |
|
|
|
var statNow = DateTime.Now; |
|
|
@@ -210,48 +252,6 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor |
|
|
|
return await IotSetBloodPressCalibrationConfigResponseAsync(imei, systolicRefValue, diastolicRefValue, 0, 0, 0, 0, 0, 0, statNow, statNow).ConfigureAwait(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
systolicAvg = (int)(hmBpParser?.AverageAfterRemovingOneMinMaxRef(i => i.SystolicValue, SafeType.SafeInt(systolicRefValue!)))!; |
|
|
|
diastolicAvg = (int)(hmBpParser?.AverageAfterRemovingOneMinMaxRef(i => i.DiastolicValue, SafeType.SafeInt(diastolicRefValue!)))!; |
|
|
|
|
|
|
|
// 平均值为0,说明数据不足,不能计算增量值 |
|
|
|
// 数据不足等同进行初始化,只下发标定值,增量值为0;remarks恢复到未校准状态,需要基于第一个测量值生成增量值。 |
|
|
|
if (systolicAvg.Equals(0)|| diastolicAvg.Equals(0)) |
|
|
|
{ |
|
|
|
_logger.LogInformation($"测量数据样本不足,将进行标定值初始,只下发标定值,增量值为0;remarks恢复到未校准状态。"); |
|
|
|
// 重置设备 |
|
|
|
var statNow=DateTime.Now; |
|
|
|
await IotSetBloodPressCalibrationConfigResponseAsync(imei, 0, 0, 0, 0, 0, 0, 0, 0, statNow, statNow).ConfigureAwait(false); |
|
|
|
_logger.LogInformation($"1.测量数据样本不足,重置设备"); |
|
|
|
|
|
|
|
var initRemarksFlag = await _serviceIotWebApi.UpdatePersonRemarksAsync(imei, 0, 0, 0, 0, true).ConfigureAwait(false); |
|
|
|
if (initRemarksFlag) |
|
|
|
{ |
|
|
|
_logger.LogInformation($"2.测量数据样本不足,remarks恢复到未校准状态(remarks设置为空),成功"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
_logger.LogInformation($"2.测量数据样本不足,remarks恢复到未校准状态(remarks设置为空),失败"); |
|
|
|
} |
|
|
|
_logger.LogInformation($"3.测量数据样本不足,只下发手动标定值systolicRefValue:{systolicRefValue} -- diastolicRefValue:{diastolicRefValue},增量值为0"); |
|
|
|
statNow = DateTime.Now.AddSeconds(3); |
|
|
|
return await IotSetBloodPressCalibrationConfigResponseAsync(imei, systolicRefValue, diastolicRefValue, 0, 0, 0, 0, 0, 0, statNow, statNow).ConfigureAwait(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 增量值=(标定值-平均值)* 0.25 |
|
|
|
var currentSystolicInc = (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!; |
|
|
|
var currentDiastolicInc = (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!; |
|
|
|
|
|
|
|
// 累计增量 |
|
|
|
systolicInc = currentSystolicInc + lastPushSystolicInc; |
|
|
|
diastolicInc = currentDiastolicInc + lastPushDiastolicInc; |
|
|
|
_logger.LogInformation($"{imei}--{nameof(Put)}--计算增量值" + |
|
|
|
$"\n systolicInc:{systolicInc }-- currentSystolicInc:{currentSystolicInc} -- lastPushSystolicInc:{lastPushSystolicInc}" + |
|
|
|
$"\n diastolicInc:{diastolicInc} --currentDiastolicInc:{currentDiastolicInc} -- lastPushDiastolicInc:{lastPushDiastolicInc}"); |
|
|
|
_logger.LogInformation($"{imei},手工校准,发给设备的绝对增量值=(上次绝对增量值+新数据的增量值)"); |
|
|
|
return await IotSetBloodPressCalibrationConfigResponseAsync(imei, systolicRefValue, diastolicRefValue, systolicInc, diastolicInc, systolicAvg, diastolicAvg, systolicAvgOffset, diastolicAvgOffset, startTime, endTime).ConfigureAwait(false); |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
} |
|
|
|