Sfoglia il codice sorgente

webapi iot日志

datasub12_previous
H Vs 8 mesi fa
parent
commit
40244c8f66
5 ha cambiato i file con 78 aggiunte e 8 eliminazioni
  1. +15
    -0
      HealthMonitor.Model/Service/BloodPressCalibrationConfigModelReponse.cs
  2. +44
    -0
      HealthMonitor.Service/Biz/IotWebApiService.cs
  3. +7
    -2
      HealthMonitor.Service/Resolver/BloodpressResolver.cs
  4. +8
    -4
      HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs
  5. +4
    -2
      HealthMonitor.WebApi/Worker.cs

+ 15
- 0
HealthMonitor.Model/Service/BloodPressCalibrationConfigModelReponse.cs Vedi File

@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HealthMonitor.Model.Service
{
public class BloodPressCalibrationConfigModelReponse
{
public bool Flag { get; set; }

public string Message { get; set; } = default!;
}
}

+ 44
- 0
HealthMonitor.Service/Biz/IotWebApiService.cs Vedi File

@@ -83,6 +83,50 @@ namespace HealthMonitor.Service.Biz

}


public async Task<BloodPressCalibrationConfigModelReponse> SetBloodPressCalibrationConfig2Async(BloodPressCalibrationConfigModel bpsCalibrationConfig)
{
BloodPressCalibrationConfigModelReponse response = new BloodPressCalibrationConfigModelReponse();
response.Flag = false;
response.Message = string.Empty;
#if DEBUG
//var flag = true;
response.Flag=true;
#else
//systolicCalibrationValue = 0, //收缩压标定值,值为0 表示不生效
//diastolicCalibrationValue 0, //舒张压标定值,值为0表示不生效
//systolicIncValue = 0, //收缩压显示增量,值为0 表示不生效
//diastolicIncValue = 0 //舒张压显示增量,值为0 表示不生效

// var flag = false;
try
{
var url = $"{_configService.IotWebApiUrl}Command/SetBloodPressCalibrationConfig";
List<KeyValuePair<string, string>> headers = new()
{
new KeyValuePair<string, string>("AuthKey", "key1")
};
var res = await _httpHelper.HttpToPostAsync(url, bpsCalibrationConfig, headers).ConfigureAwait(false);
_logger.LogInformation($"向{bpsCalibrationConfig.Imei}下发增量值数据:{JsonConvert.SerializeObject(bpsCalibrationConfig)},响应:{res}");
var resJToken = JsonConvert.DeserializeObject(res ?? string.Empty) as JToken;
//response.Flag= resJToken?["message"]?.ToString().Equals("ok") ?? false;
response.Flag = Convert.ToBoolean(resJToken?["succeed"]?.ToString());
if (!response.Flag)
{
response.Message = resJToken?["message"]?.ToString()!;
}
}
catch (Exception ex)
{
_logger.LogError($"{nameof(SetBloodPressCalibrationConfigAsync)} 下发血压增量值异常:{ex.Message}, {ex.StackTrace}");

}

#endif

return response;
}
/** 取消
/// <summary>
/// 更新 gps_person remark和缓存


+ 7
- 2
HealthMonitor.Service/Resolver/BloodpressResolver.cs Vedi File

@@ -189,7 +189,10 @@ namespace HealthMonitor.Service.Resolver
DiastolicIncValue = diastolicInc //舒张压显示增量,值为0 表示不生效
};
// 下发 IOT 增量值
var flagIot = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false);
//var flagIot = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false);

var response = await _serviceIotWebApi.SetBloodPressCalibrationConfig2Async(bpIncData).ConfigureAwait(false);
var flagIot = response.Flag;
if (flagIot)
{
startTime = (DateTime)bp.LastUpdate!;
@@ -267,7 +270,9 @@ namespace HealthMonitor.Service.Resolver
DiastolicIncValue = diastolicInc //舒张压显示增量,值为0 表示不生效
};
// 下发 IOT 增量值
var flagIot = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false);
//var flagIot = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false);
var response = await _serviceIotWebApi.SetBloodPressCalibrationConfig2Async(bpIncData).ConfigureAwait(false);
var flagIot = response.Flag;
if (flagIot)
{
startTime = (DateTime)bp.LastUpdate!;


+ 8
- 4
HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressConfigManualCalibrationController.cs Vedi File

@@ -276,7 +276,9 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
DiastolicIncValue = diastolicInc //舒张压显示增量,值为0 表示不生效
};
// 下发 IOT 增量值
var flagIot = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false);
// var flagIot = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false);
var response = await _serviceIotWebApi.SetBloodPressCalibrationConfig2Async(bpIncData).ConfigureAwait(false);
var flagIot = response.Flag;
if (flagIot)
{
#region 保存下推记录 stb_hm_bp_push_ref_inc_value
@@ -300,7 +302,7 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
}
else
{
return ApiResponse<object>.Fail(500, "业务出错!下发指令失败");
return ApiResponse<object>.Fail(500, $"业务出错!下发指令失败:{response.Message}");
}
}

@@ -316,7 +318,9 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
DiastolicIncValue = diastolicInc //舒张压显示增量,值为0 表示不生效
};
// 下发 IOT 增量值
var flagIot = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false);
//var flagIot = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false);
var response = await _serviceIotWebApi.SetBloodPressCalibrationConfig2Async(bpIncData).ConfigureAwait(false);
var flagIot = response.Flag;
if (flagIot)
{
#region 保存下推记录 stb_hm_bp_push_ref_inc_value
@@ -347,7 +351,7 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
}
else
{
return ApiResponse<object>.Fail(500, "业务出错!下发指令失败");
return ApiResponse<object>.Fail(500, $"业务出错!下发指令失败:{response.Message}");
}
}
}


+ 4
- 2
HealthMonitor.WebApi/Worker.cs Vedi File

@@ -97,7 +97,7 @@ namespace HealthMonitor.WebApi
_logger.LogInformation("------_tdEngineDataSubcribe");
while (!_tokenSource.IsCancellationRequested)
{
Console.WriteLine("test");
_tdEngineDataSubcribe.BeginListen(_tokenSource.Token);
}
}, TaskCreationOptions.LongRunning);
@@ -361,7 +361,9 @@ namespace HealthMonitor.WebApi
SystolicIncValue = SafeType.SafeInt(((int)systolicInc!)), //收缩压显示增量,值为0 表示不生效
DiastolicIncValue = SafeType.SafeInt(((int)diastolicInc!)) //舒张压显示增量,值为0 表示不生效
};
var pushedBP = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false);
//var pushedBP = await _serviceIotWebApi.SetBloodPressCalibrationConfigAsync(bpIncData).ConfigureAwait(false);
var response = await _serviceIotWebApi.SetBloodPressCalibrationConfig2Async(bpIncData).ConfigureAwait(false);
var pushedBP = response.Flag;
if (pushedBP)
{
#region 保存下推记录 stb_hm_bp_push_ref_inc_value


Loading…
Annulla
Salva