|
|
@@ -122,11 +122,11 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
DateTime endTime = DateTime.Now; //测试 |
|
|
|
DateTime startTime = DateTime.Now; |
|
|
|
// 最后一次下发值 |
|
|
|
int lastPushSystolicInc = 0; |
|
|
|
int lastPushDiastolicInc = 0; |
|
|
|
//int lastPushSystolicInc = 0; |
|
|
|
//int lastPushDiastolicInc = 0; |
|
|
|
|
|
|
|
bool remarkFlag = false; |
|
|
|
long duration = 7 * 24 * 3600 * 1000; |
|
|
|
//long duration = 7 * 24 * 3600 * 1000; |
|
|
|
string sql = string.Empty; |
|
|
|
|
|
|
|
#region 获取个人信息 |
|
|
@@ -135,7 +135,7 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
//验证这个信息是否存在 |
|
|
|
if (person == null || person?.Person.BornDate == null) |
|
|
|
{ |
|
|
|
_logger.LogWarning("验证个人信息,找不到个人信息,跳过此消息"); |
|
|
|
_logger.LogWarning($"{bp.Serialno}--{bp.MessageId}验证个人信息,找不到个人信息,跳过此消息"); |
|
|
|
return; |
|
|
|
} |
|
|
|
// 验证年龄是否在范围 (2 - 120) |
|
|
@@ -226,7 +226,8 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
#region 正常计算增量值 |
|
|
|
#region (暂时取消)正常计算增量值 |
|
|
|
/** |
|
|
|
// var lastPush = await _serviceTDengine.GetLastAsync("stb_hm_bp_push_ref_inc_value", $"serialno='{bp.Serialno}' order by ts desc"); |
|
|
|
|
|
|
|
var lastPushResponse = await _serviceTDengine.ExecuteSelectRestResponseAsync("stb_hm_bp_push_ref_inc_value", $"serialno='{bp.Serialno}' order by ts desc", "last_row(*)"); |
|
|
@@ -304,47 +305,7 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
|
|
|
|
systolicAvg = bp.SystolicValue; |
|
|
|
diastolicAvg = bp.DiastolicValue; |
|
|
|
/* |
|
|
|
systolicInc = (int)((systolicRefValue - systolicAvg) * systolicAvgOffset)!; |
|
|
|
diastolicInc = (int)((diastolicRefValue - diastolicAvg) * diastolicAvgOffset)!; |
|
|
|
|
|
|
|
// 初始化 remark |
|
|
|
remarkFlag = await _serviceIotWebApi.UpdatePersonRemarksAsync(bp.Serialno, (int)systolicRefValue!, (int)diastolicRefValue!, systolicInc, diastolicInc).ConfigureAwait(false); |
|
|
|
if (remarkFlag) |
|
|
|
{ |
|
|
|
// 下推 |
|
|
|
BloodPressCalibrationConfigModel bpIncData = new() |
|
|
|
{ |
|
|
|
Imei = bp.Serialno, |
|
|
|
SystolicRefValue = (int)systolicRefValue!, //收缩压标定值,值为0 表示不生效 |
|
|
|
DiastolicRefValue = (int)diastolicRefValue!, //舒张压标定值,值为0表示不生效 |
|
|
|
SystolicIncValue = systolicInc, //收缩压显示增量,值为0 表示不生效 |
|
|
|
DiastolicIncValue = diastolicInc //舒张压显示增量,值为0 表示不生效 |
|
|
|
}; |
|
|
|
// 下发 IOT 增量值 |
|
|
|
var flagIot = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false); |
|
|
|
if (flagIot) |
|
|
|
{ |
|
|
|
#region 保存下推记录 stb_hm_bp_push_ref_inc_value |
|
|
|
sql = $"INSERT INTO health_monitor.hm_bp_push_ref_inc_value_{bp.Serialno.Substring(bp.Serialno.Length - 2)} " + |
|
|
|
$"USING health_monitor.stb_hm_bp_push_ref_inc_value " + |
|
|
|
$"TAGS ('{bp.Serialno.Substring(bp.Serialno.Length - 2)}') " + |
|
|
|
$"VALUES(" + |
|
|
|
$"'{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}'," + |
|
|
|
$"'{bp.Serialno}'," + |
|
|
|
$"{systolicRefValue}," + |
|
|
|
$"{diastolicRefValue}," + |
|
|
|
$"{systolicInc}," + |
|
|
|
$"{diastolicInc}," + |
|
|
|
$"{true})"; |
|
|
|
|
|
|
|
_serviceTDengine.ExecuteInsertSQL(sql); |
|
|
|
#endregion |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
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}"); |
|
|
@@ -356,45 +317,47 @@ namespace HealthMonitor.Service.Resolver |
|
|
|
// 累计增量 |
|
|
|
systolicInc = currentSystolicInc + lastPushSystolicInc; |
|
|
|
diastolicInc = currentDiastolicInc + lastPushDiastolicInc; |
|
|
|
*/ |
|
|
|
#endregion |
|
|
|
} |
|
|
|
|
|
|
|
#region 插入BP增量值 hm_bloodpress_stats_inc |
|
|
|
#region (暂时取消)插入BP增量值 hm_bloodpress_stats_inc |
|
|
|
// 自动建表 |
|
|
|
sql = $"INSERT INTO health_monitor.hm_bp_stats_inc_{bp.Serialno.Substring(bp.Serialno.Length - 2)} " + |
|
|
|
$"USING health_monitor.stb_hm_bloodpress_stats_inc " + |
|
|
|
$"TAGS ('{bp.Serialno.Substring(bp.Serialno.Length - 2)}') " + |
|
|
|
$"VALUES(" + |
|
|
|
$"'{bp.LastUpdate:yyyy-MM-dd HH:mm:ss.fff}'," + |
|
|
|
$"'{bp.BloodPressId}'," + |
|
|
|
$"'{bp.MessageId}'," + |
|
|
|
$"'{bp.Serialno}'," + |
|
|
|
$"{bp.SystolicValue}," + |
|
|
|
$"{systolicRefValue}," + |
|
|
|
$"{systolicAvg}," + |
|
|
|
$"{systolicMax}," + |
|
|
|
$"{systolicMin}," + |
|
|
|
$"{systolicAvgOffset}," + |
|
|
|
$"{systolicInc}," + |
|
|
|
$"{bp.DiastolicValue}," + |
|
|
|
$"{diastolicRefValue}," + |
|
|
|
$"{diastolicAvg}," + |
|
|
|
$"{diastolicMax}," + |
|
|
|
$"{diastolicMin}," + |
|
|
|
$"{diastolicAvgOffset}," + |
|
|
|
$"{diastolicInc}," + |
|
|
|
$"{gender}," + |
|
|
|
$"{age}," + |
|
|
|
$"{height}," + |
|
|
|
$"{weight}," + |
|
|
|
$"'{bp.LastUpdate:yyyy-MM-dd HH:mm:ss.fff}'," + |
|
|
|
$"{duration}," + |
|
|
|
$"'{startTime:yyyy-MM-dd HH:mm:ss.fff}'," + |
|
|
|
$"'{endTime:yyyy-MM-dd HH:mm:ss.fff}'," + |
|
|
|
$"'{string.Empty}'," + |
|
|
|
$"{isHypertension})"; |
|
|
|
|
|
|
|
_serviceTDengine.ExecuteInsertSQL(sql); |
|
|
|
/** sql = $"INSERT INTO health_monitor.hm_bp_stats_inc_{bp.Serialno.Substring(bp.Serialno.Length - 2)} " + |
|
|
|
$"USING health_monitor.stb_hm_bloodpress_stats_inc " + |
|
|
|
$"TAGS ('{bp.Serialno.Substring(bp.Serialno.Length - 2)}') " + |
|
|
|
$"VALUES(" + |
|
|
|
$"'{bp.LastUpdate:yyyy-MM-dd HH:mm:ss.fff}'," + |
|
|
|
$"'{bp.BloodPressId}'," + |
|
|
|
$"'{bp.MessageId}'," + |
|
|
|
$"'{bp.Serialno}'," + |
|
|
|
$"{bp.SystolicValue}," + |
|
|
|
$"{systolicRefValue}," + |
|
|
|
$"{systolicAvg}," + |
|
|
|
$"{systolicMax}," + |
|
|
|
$"{systolicMin}," + |
|
|
|
$"{systolicAvgOffset}," + |
|
|
|
$"{systolicInc}," + |
|
|
|
$"{bp.DiastolicValue}," + |
|
|
|
$"{diastolicRefValue}," + |
|
|
|
$"{diastolicAvg}," + |
|
|
|
$"{diastolicMax}," + |
|
|
|
$"{diastolicMin}," + |
|
|
|
$"{diastolicAvgOffset}," + |
|
|
|
$"{diastolicInc}," + |
|
|
|
$"{gender}," + |
|
|
|
$"{age}," + |
|
|
|
$"{height}," + |
|
|
|
$"{weight}," + |
|
|
|
$"'{bp.LastUpdate:yyyy-MM-dd HH:mm:ss.fff}'," + |
|
|
|
$"{duration}," + |
|
|
|
$"'{startTime:yyyy-MM-dd HH:mm:ss.fff}'," + |
|
|
|
$"'{endTime:yyyy-MM-dd HH:mm:ss.fff}'," + |
|
|
|
$"'{string.Empty}'," + |
|
|
|
$"{isHypertension})"; |
|
|
|
|
|
|
|
_serviceTDengine.ExecuteInsertSQL(sql); |
|
|
|
*/ |
|
|
|
// 发送到 设置设备血压标定参数 |
|
|
|
|
|
|
|
#endregion |
|
|
|