Bläddra i källkod

调整时间格式

datasub12_previous
H Vs 1 år sedan
förälder
incheckning
16fb93473b
3 ändrade filer med 25 tillägg och 25 borttagningar
  1. +1
    -1
      HealthMonitor.Service/Biz/db/TDengineService.cs
  2. +8
    -8
      HealthMonitor.Service/Resolver/BloodpressResolver.cs
  3. +16
    -16
      HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs

+ 1
- 1
HealthMonitor.Service/Biz/db/TDengineService.cs Visa fil

@@ -413,7 +413,7 @@ namespace HealthMonitor.Service.Biz.db


var sqlAvg = $"SELECT AVG({field}) FROM {_configTDengineService.DB}.{tbName} WHERE {condition} AND {field} < { (data.Count.Equals(0)? 0: data[0][0]) } and {field} > {(data.Count.Equals(0) ? 0 : data[0][1])}"; var sqlAvg = $"SELECT AVG({field}) FROM {_configTDengineService.DB}.{tbName} WHERE {condition} AND {field} < { (data.Count.Equals(0)? 0: data[0][0]) } and {field} > {(data.Count.Equals(0) ? 0 : data[0][1])}";
result = await GernalRestSqlResTextAsync(sqlAvg); result = await GernalRestSqlResTextAsync(sqlAvg);
_logger.LogInformation($"sqlAvg:{sql}");
_logger.LogInformation($"sqlAvg:{sqlAvg}");
res = JsonConvert.DeserializeObject<TDengineRestResBase>(result!); res = JsonConvert.DeserializeObject<TDengineRestResBase>(result!);
data = res?.Data!; data = res?.Data!;




+ 8
- 8
HealthMonitor.Service/Resolver/BloodpressResolver.cs Visa fil

@@ -179,10 +179,10 @@ namespace HealthMonitor.Service.Resolver
// 如果hm_bp_config_manual_calibration存在数据,使用最新数据 // 如果hm_bp_config_manual_calibration存在数据,使用最新数据


// //
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='{bp.Serialno}'");
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='{bp.Serialno}'");
//var systolicAggregate = _serviceTDengine.GetAggregateValue("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}'");
//var diastolicAggregate = _serviceTDengine.GetAggregateValue("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}'");
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; 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-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and serialno='{bp.Serialno}' and systolic_value < {systolicRefValue} ");
var 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='{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)) if (systolicAvg.Equals(0) || diastolicAvg.Equals(0))
@@ -246,8 +246,8 @@ namespace HealthMonitor.Service.Resolver


//return; //return;
} }
//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}");
//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 // 增量值=(标定值-平均值)* 0.25
systolicInc = systolicAvg.Equals(0M) ? 0 : (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!; systolicInc = systolicAvg.Equals(0M) ? 0 : (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!;


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

@@ -181,8 +181,8 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
else else
{ {
// 平均值: 计算去除最大值 MAX和最小值 MIN 和异常值 ABN 的平均值 // 平均值: 计算去除最大值 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}");
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)) if (systolicAvg.Equals(0) || diastolicAvg.Equals(0))
@@ -225,7 +225,7 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
endTime = DateTime.Now;//newTs; endTime = DateTime.Now;//newTs;
startTime = newTs;//DateTime.Now; startTime = newTs;//DateTime.Now;


int count = await _serviceTDengine.GetCount("stb_hm_bloodpress", $"ts>='{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}' and ts <='{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}' 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 // B.1.1 设备已经被重新设置, 从重置的ts 到 now 没有测量数据,inc=0
if (count.Equals(0)) if (count.Equals(0))
{ {
@@ -236,8 +236,8 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
else else
{ {
// 平均值: 计算去除最大值 MAX和最小值 MIN 和异常值 ABN 的平均值 // 平均值: 计算去除最大值 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}");
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)) if (systolicAvg.Equals(0) || diastolicAvg.Equals(0))
@@ -272,12 +272,12 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
startTime = newTs; 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}'");
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 的平均值 // 平均值: 计算去除最大值 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}");
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 avgOffset = 0.25M;
//var systolicAvgOffset = avgOffset; //var systolicAvgOffset = avgOffset;
@@ -295,7 +295,7 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
if (systolicAvg.Equals(0) || diastolicAvg.Equals(0)) if (systolicAvg.Equals(0) || diastolicAvg.Equals(0))
{ {
_logger.LogInformation("B.2.1 曾经下推过断言有测量记录,数据异常,平均值为0"); _logger.LogInformation("B.2.1 曾经下推过断言有测量记录,数据异常,平均值为0");
_logger.LogInformation($"{imei}本次计算结果\n{startTime:yyyy-MM-ddTHH:mm:ss.fffZ}--{endTime:yyyy-MM-ddTHH:mm:ss.fffZ}" +
_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 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}"); $"\n diastolic:REF:{diastolicRefValue} - Inc:{diastolicInc} - AVG:{diastolicAvg} - MAX:{diastolicAggregate.Max} - MIN: {diastolicAggregate.Min}");
_logger.LogInformation($"上次下发的增量值:systolic:{(int)lastPush![4]}--diastolic:{(int)lastPush![5]}"); _logger.LogInformation($"上次下发的增量值:systolic:{(int)lastPush![4]}--diastolic:{(int)lastPush![5]}");
@@ -354,10 +354,10 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
//if (total >= 4) //if (total >= 4)
if (lastBP?.Count != 0) if (lastBP?.Count != 0)
{ {
//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}'");
//var systolicAggregate = _serviceTDengine.GetAggregateValue("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}'");
//var diastolicAggregate = _serviceTDengine.GetAggregateValue("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}'");
//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; //var systolicMax = systolicAggregate.Max;
@@ -368,8 +368,8 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor




// 平均值: 计算去除最大值 MAX和最小值 MIN 和异常值 ABN 的平均值 // 平均值: 计算去除最大值 MAX和最小值 MIN 和异常值 ABN 的平均值
var 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} ");
var 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 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)) if (systolicAvg.Equals(0) || diastolicAvg.Equals(0))
{ {


Laddar…
Avbryt
Spara