Sfoglia il codice sorgente

修改remark

datasub12_previous
H Vs 1 anno fa
parent
commit
8c9d878816
2 ha cambiato i file con 128 aggiunte e 1 eliminazioni
  1. +63
    -0
      HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs
  2. +65
    -1
      HealthMonitor.WebApi/Worker.cs

+ 63
- 0
HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs Vedi File

@@ -3,6 +3,7 @@ using Grpc.Core;
using HealthMonitor.Common;
using HealthMonitor.Common.helper;
using HealthMonitor.Core.Dal;
using HealthMonitor.Core.Pipeline;
using HealthMonitor.Service.Biz.db;
using HealthMonitor.Service.Cache;
using HealthMonitor.Service.Etcd;
@@ -10,12 +11,15 @@ using HealthMonitor.Service.Resolver;
using HealthMonitor.Util.Entities.HealthMonitor;
using HealthMonitor.WebApi.Configs;
using HealthMonitor.WebApi.Model.Request;
using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;

@@ -74,6 +78,9 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
DateTime endTime = DateTime.Now; //测试
DateTime startTime = endTime - ts;




var last = await _serviceTDengine.GetLastAsync("stb_hm_bp_push_ref_inc_value", $"serialno='{imei}' order by ts desc");
if (last?.Count != 0)
{
@@ -82,6 +89,62 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
startTime = newTs;
}
}
// 读数据库,remark为空就写commandValue,更新缓存
else
{
#region 初始化remark
var dataServiceBaseUrl = $"https://id.ssjlai.com/data";
var DataServicePersionGet = $"{dataServiceBaseUrl}/api/GpsCard/GpsPerson/GetFirst";
List<KeyValuePair<string, string>> Dataheaders = new()
{
new KeyValuePair<string, string>("requestId", $"{imei}")
};
var dataPersion = new
{
filters = new List<object>() { new { key = "serialno", value = $"{imei}", valueType = "string", @operator = "Equal" } },
orderBys = new List<object>() { new { key = "serialno", isDesc = true } }
};
var res = await _httpHelper.HttpToPostAsync(DataServicePersionGet, dataPersion, Dataheaders).ConfigureAwait(false);
var resObj = JsonConvert.DeserializeObject(res!) as JToken;
var remark = resObj?["remarks"]?.ToString();
// 修改数据库
if (string.IsNullOrWhiteSpace(remark))
{
var newRemarkData = new
{
imei,
time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
commandValue = new
{
systolicCalibrationValue = systolicRefValue, //收缩压标定值,值为0 表示不生效
diastolicCalibrationValue = diastolicRefValue, //舒张压标定值,值为0表示不生效
systolicIncValue = 0, //收缩压显示增量,值为0 表示不生效
diastolicIncValue = 0 //舒张压显示增量,值为0 表示不生效
}
};
resObj!["remarks"] = $"is_blood_press:{JsonConvert.SerializeObject(newRemarkData)}|";
var DataServicePersionUpdate = $"{dataServiceBaseUrl}/api/GpsCard/GpsPerson/Update";
var resUpdate = await _httpHelper.HttpToPostAsync(DataServicePersionUpdate, resObj, Dataheaders).ConfigureAwait(false);
_logger.LogInformation($"更新Person数据库|{resUpdate}");

//更新缓存
List<KeyValuePair<string, string>> headersCache = new()
{
new KeyValuePair<string, string>("AuthKey", "key1")
};

var cacheUrl = $"http://id.ssjlai.com/webapi/api/Device/UpdatePersonInfoCache?imei={imei}";
var updateCache = await _httpHelper.HttpToGetAsync(cacheUrl, headersCache);
_logger.LogInformation($"更新Person缓存|{updateCache}");
}

#endregion



}


var lastBP = await _serviceTDengine.GetLastAsync("stb_hm_bloodpress", $"serialno='{imei}' order by ts desc");



+ 65
- 1
HealthMonitor.WebApi/Worker.cs Vedi File

@@ -154,7 +154,9 @@ namespace HealthMonitor.WebApi
var schedule_push = await _serviceEtcd.GetValAsync(key).ConfigureAwait(false);
if (string.IsNullOrWhiteSpace(schedule_push))
{
var startTime=DateTime.Now;

var startTime =DateTime.Now;
// 下发增量值
#region 定时下发增量值
var last= await _serviceTDengine.GetLastAsync("stb_hm_bloodpress_stats_inc", $"serialno='{imeiDel}' order by last_update desc");
@@ -170,6 +172,62 @@ namespace HealthMonitor.WebApi
var systolic_inc_value = last?[10];
var diastolic_inc_value = last?[17];

#region 判断是否初始化remark
var imei = imeiDel;
// 判断是否初始化remark
var last_push = await _serviceTDengine.GetLastAsync("stb_hm_bp_push_ref_inc_value", $"serialno='{imei}' order by ts desc");
if (last_push?.Count == 0)
{
var dataServiceBaseUrl = $"https://id.ssjlai.com/data";
var DataServicePersionGet = $"{dataServiceBaseUrl}/api/GpsCard/GpsPerson/GetFirst";
List<KeyValuePair<string, string>> Dataheaders = new()
{
new KeyValuePair<string, string>("requestId", $"{imei}")
};
var dataPersion = new
{
filters = new List<object>() { new { key = "serialno", value = $"{imei}", valueType = "string", @operator = "Equal" } },
orderBys = new List<object>() { new { key = "serialno", isDesc = true } }
};
var resRef = await _httpHelper.HttpToPostAsync(DataServicePersionGet, dataPersion, Dataheaders).ConfigureAwait(false);
var resObj = JsonConvert.DeserializeObject(resRef!) as JToken;
var remark = resObj?["remarks"]?.ToString();

// 修改数据库
if (string.IsNullOrWhiteSpace(remark))
{
var newRemarkData = new
{
imei,
time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
commandValue = new
{
systolicCalibrationValue = systolic_ref_value, //收缩压标定值,值为0 表示不生效
diastolicCalibrationValue = diastolic_ref_value, //舒张压标定值,值为0表示不生效
systolicIncValue = 0, //收缩压显示增量,值为0 表示不生效
diastolicIncValue = 0 //舒张压显示增量,值为0 表示不生效
}
};
resObj!["remarks"] = $"is_blood_press:{JsonConvert.SerializeObject(newRemarkData)}|";
var DataServicePersionUpdate = $"{dataServiceBaseUrl}/api/GpsCard/GpsPerson/Update";
var resUpdate = await _httpHelper.HttpToPostAsync(DataServicePersionUpdate, resObj, Dataheaders).ConfigureAwait(false);
_logger.LogInformation($"更新Person数据库|{resUpdate}");

//更新缓存
List<KeyValuePair<string, string>> headersCache = new()
{
new KeyValuePair<string, string>("AuthKey", "key1")
};

var cacheUrl = $"http://id.ssjlai.com/webapi/api/Device/UpdatePersonInfoCache?imei={imei}";
var updateCache = await _httpHelper.HttpToGetAsync(cacheUrl, headersCache);
_logger.LogInformation($"更新Person缓存|{updateCache}");
}
}

#endregion


var bpData = new
{
imei = imeiDel,
@@ -213,6 +271,10 @@ namespace HealthMonitor.WebApi

// 注册下次下推
var endTime = DateTime.Now;



#if DEBUG


@@ -277,6 +339,8 @@ namespace HealthMonitor.WebApi
var result = JsonConvert.SerializeObject(data);
await _serviceEtcd.PutValAsync(key, result, ttl, false).ConfigureAwait(false);
#endif


}
else
{


Loading…
Annulla
Salva