diff --git a/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs b/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs index b57fc44..269f0f7 100644 --- a/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs +++ b/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs @@ -213,8 +213,8 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor // 增量值=(标定值-平均值)* 0.25 - systolicInc = systolicAvg.Equals(0M) ? 0 : (int)Math.Round((systolicRefValue - systolicAvg) * systolicAvgOffset)!; - diastolicInc = diastolicAvg.Equals(0M) ? 0 : (int)Math.Round((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!; + systolicInc = systolicAvg.Equals(0M) ? 0 : (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!; + diastolicInc = diastolicAvg.Equals(0M) ? 0 : (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!; _logger.LogInformation(" A.2 没有下推记录,有测量记录,正常计算增量值 ,增量值将正常下发"); // return await IotSetBloodPressCalibrationConfigResponseAsync(imei, systolicRefValue, diastolicRefValue, systolicInc, diastolicInc).ConfigureAwait(false); return await IotSetBloodPressCalibrationConfigResponseAsync(imei, systolicRefValue, diastolicRefValue, systolicInc, diastolicInc, systolicAvg, diastolicAvg, systolicAvgOffset, diastolicAvgOffset, startTime, endTime).ConfigureAwait(false); @@ -276,8 +276,8 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor //var systolicAvgOffset = avgOffset; //var diastolicAvgOffset = avgOffset; // 增量值=(标定值-平均值)* 0.25 - systolicInc = systolicAvg.Equals(0M) ? 0 : (int)Math.Round((systolicRefValue - systolicAvg) * systolicAvgOffset)!; - diastolicInc = diastolicAvg.Equals(0M) ? 0 : (int)Math.Round((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!; + systolicInc = systolicAvg.Equals(0M) ? 0 : (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)! + SafeType.SafeInt(lastPush![4]); ; + diastolicInc = diastolicAvg.Equals(0M) ? 0 : (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)! + SafeType.SafeInt(lastPush![5]); ; _logger.LogInformation("B.1.2 设备已经被重新设置, 从重置的ts 到 now 有测量数据 ,增量值将正常下发"); //return await IotSetBloodPressCalibrationConfigResponseAsync(imei, systolicRefValue, diastolicRefValue, systolicInc, diastolicInc).ConfigureAwait(false); return await IotSetBloodPressCalibrationConfigResponseAsync(imei, systolicRefValue, diastolicRefValue, systolicInc, diastolicInc, systolicAvg, diastolicAvg, systolicAvgOffset, diastolicAvgOffset, startTime, endTime).ConfigureAwait(false); @@ -311,8 +311,8 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor //systolicInc = systolicAvg.Equals(0M) ? 0 : (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!; //diastolicInc = diastolicAvg.Equals(0M) ? 0 : (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!; - systolicInc = (int)Math.Round((systolicRefValue - systolicAvg) * systolicAvgOffset)!; - diastolicInc = (int)Math.Round((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!; + systolicInc = (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)! + SafeType.SafeInt(lastPush![4]); ; + diastolicInc = (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)! + SafeType.SafeInt(lastPush![5]); ; // B.2.1 数据异常,将按最后一次测量值的offeset下发 if (systolicAvg.Equals(0) || diastolicAvg.Equals(0)) @@ -323,15 +323,15 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor $"\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 (systolicAvg.Equals(0)) + //{ + // systolicInc = (int)lastPush[4]; + //} - if (diastolicAvg.Equals(0)) - { - diastolicInc = (int)lastPush[5]; - } + //if (diastolicAvg.Equals(0)) + //{ + // diastolicInc = (int)lastPush[5]; + //} //return await IotSetBloodPressCalibrationConfigResponseAsync(model.Imei, systolicRefValue, diastolicRefValue, systolicInc, diastolicInc).ConfigureAwait(false); return await IotSetBloodPressCalibrationConfigResponseAsync(imei, systolicRefValue, diastolicRefValue, systolicInc, diastolicInc, systolicAvg, diastolicAvg, systolicAvgOffset, diastolicAvgOffset, startTime, endTime).ConfigureAwait(false); @@ -341,8 +341,8 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor { // 增量值=(标定值-平均值)* 0.25 - systolicInc = systolicAvg.Equals(0M) ? 0 : (int)Math.Round((systolicRefValue - systolicAvg) * systolicAvgOffset)!; - diastolicInc = diastolicAvg.Equals(0M) ? 0 : (int)Math.Round((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!; + systolicInc = systolicAvg.Equals(0M) ? 0 : (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)! + SafeType.SafeInt(lastPush![4]); + diastolicInc = diastolicAvg.Equals(0M) ? 0 : (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)! + SafeType.SafeInt(lastPush![5]); _logger.LogInformation("B.2.2 曾经下推过断言有测量记录,数据正常,按正常计算 ,增量值将正常下发"); return await IotSetBloodPressCalibrationConfigResponseAsync(imei, systolicRefValue, diastolicRefValue, systolicInc, diastolicInc,systolicAvg, diastolicAvg,systolicAvgOffset,diastolicAvgOffset,startTime,endTime).ConfigureAwait(false); }