@@ -2,6 +2,7 @@ | |||
using HealthMonitor.Common.helper; | |||
using HealthMonitor.Model.Config; | |||
using HealthMonitor.Service.Biz.db.Dto; | |||
using HealthMonitor.Util.Models; | |||
using Microsoft.EntityFrameworkCore.Metadata.Internal; | |||
using Microsoft.Extensions.Logging; | |||
using Microsoft.Extensions.Options; | |||
@@ -472,5 +473,46 @@ namespace HealthMonitor.Service.Biz.db | |||
} | |||
#endregion | |||
/// <summary> | |||
/// 平均值算法(去除最大值,最小值和大于标定值的平均值) | |||
/// </summary> | |||
/// <param name="numToRemove"></param> | |||
/// <param name="collection"></param> | |||
/// <param name="max"></param> | |||
/// <param name="min"></param> | |||
/// <returns></returns> | |||
public static decimal AverageAfterRemovingOneMinMaxRef(List<int> collection, int max, int min,int refValue) | |||
{ | |||
collection.Remove(max); | |||
collection.Remove(min); | |||
collection.RemoveAll(_ => _ > refValue); | |||
if (collection.Count < 2) | |||
{ | |||
throw new ArgumentException($"数据集{collection.ToArray()},去掉一个最大值 {max}和一个最小值{min},异常值(大于标定值{refValue}),后数据值不足"); | |||
} | |||
return (decimal)collection.Average(x => x); | |||
//var values = ParseData.Select(valueSelector).ToList(); | |||
//collection = values.Select(i => (int)i).ToArray(); | |||
//if (values.Count <= 2) | |||
//{ | |||
// throw new ArgumentException("Not enough elements to remove."); | |||
//} | |||
//// Remove the specified number of minimum and maximum values | |||
////values.RemoveAll(_ => _ == values.Min()); | |||
////values.RemoveAll(_ => _ == values.Max()); | |||
//max = (int)values.Max(); | |||
//min = (int)values.Min(); | |||
//values.Remove(max); | |||
//values.Remove(min); | |||
//// Remove values less than the specified threshold | |||
//values.RemoveAll(_ => _ > numToRemove); | |||
//// Calculate and return the average of the remaining values | |||
//return values.Average(); | |||
} | |||
} | |||
} |
@@ -26,6 +26,7 @@ using HealthMonitor.Model.Service; | |||
using Microsoft.Extensions.Options; | |||
using HealthMonitor.Model.Config; | |||
using HealthMonitor.Model.Service.Mapper; | |||
using Mvccpb; | |||
namespace HealthMonitor.Service.Resolver | |||
{ | |||
@@ -157,7 +158,7 @@ namespace HealthMonitor.Service.Resolver | |||
systolicRefValue = bpRef!.Systolic;//? | |||
diastolicRefValue = bpRef!.Diastolic;//? | |||
#endregion | |||
_logger.LogInformation($"Person Remarks 值:{person?.Person.Remarks}"); | |||
if (string.IsNullOrWhiteSpace(person?.Person.Remarks)) | |||
{ | |||
#region 初始化计算增量值(个人血压信息) | |||
@@ -172,7 +173,7 @@ namespace HealthMonitor.Service.Resolver | |||
remarkFlag = await _serviceIotWebApi.UpdatePersonRemarksAsync(bp.Serialno, (int)systolicRefValue!, (int)diastolicRefValue!, systolicInc, diastolicInc).ConfigureAwait(false); | |||
if (remarkFlag) | |||
{ | |||
Console.WriteLine($"{nameof(BloodpressResolver)} 开启血压标定值下发: {_configBoodPressResolver.EnableBPRefPush}"); | |||
_logger.LogInformation($"{nameof(BloodpressResolver)} 开启血压标定值下发: {_configBoodPressResolver.EnableBPRefPush}"); | |||
// 启血压标定值下发开关 | |||
if (_configBoodPressResolver.EnableBPRefPush) | |||
{ | |||
@@ -277,7 +278,11 @@ namespace HealthMonitor.Service.Resolver | |||
var hmBpResponse = await _serviceTDengine.ExecuteSelectRestResponseAsync("stb_hm_bloodpress", condition); | |||
var hmBpParser = JsonConvert.DeserializeObject<ParseTDengineRestResponse<BloodPressureModel>>(hmBpResponse!); | |||
var hmBp = hmBpParser?.Select(); | |||
if (hmBp?.ToList().Count < 2) | |||
{ | |||
_logger.LogInformation($"{bp.Serialno} 数据值不足"); | |||
return; | |||
} | |||
// 最大值 | |||
systolicMax = (int)hmBpParser?.Select(i => i.SystolicValue).Max()!; | |||
diastolicMax = (int)hmBpParser?.Select(i => i.DiastolicValue).Max()!; | |||