Quellcode durchsuchen

增加血压数据接收接口

datasub12_previous
H Vs vor 1 Jahr
Ursprung
Commit
0c6034d59e
2 geänderte Dateien mit 64 neuen und 1 gelöschten Zeilen
  1. +63
    -0
      HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs
  2. +1
    -1
      HealthMonitor.WebApi/HealthMonitor.WebApi.csproj

+ 63
- 0
HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs Datei anzeigen

@@ -0,0 +1,63 @@
using HealthMonitor.Model.Config;
using HealthMonitor.Service.Biz.db;
using HealthMonitor.WebApi.Configs;
using HealthMonitor.WebApi.Controllers.Api;
using HealthMonitor.WebApi.Model.Request;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using TelpoDataService.Util.Entities.GpsCard;
using TelpoDataService.Util.Entities.GpsLocationHistory;

namespace HealthMonitor.WebApi.Controllers.HealthMonitor
{
[ApiExplorerSettings(GroupName = AppConsts.SWAGGER_DOC_HealthMonitor)]
[Produces("application/json")]
[Route("api/HealthMonitor/[controller]/[action]")]
[ApiController]
public class HmBloodPressController : ControllerBase
{
private readonly ILogger<HmBloodPressController> _logger;
private readonly TDengineService _serviceTDengine;
private readonly TDengineServiceConfig _configTDengineService;

public HmBloodPressController(TDengineService serviceDengine, IOptions<TDengineServiceConfig> configTDengineService, ILogger<HmBloodPressController> logger)
{
_serviceTDengine = serviceDengine;
_logger = logger;
_configTDengineService = configTDengineService.Value;
}
[HttpPost]
public async Task<ApiResponse<object>> Add([FromBody] HisGpsBloodPress model, [FromHeader] string requestId)
{
try
{
var serial_tail_no = model.Serialno.Substring(model.Serialno.Length - 2);
var sql = $"INSERT INTO {_configTDengineService.DB}.hm_bp_{serial_tail_no} USING {_configTDengineService.DB}.stb_hm_bloodpress TAGS ('{serial_tail_no}') VALUES(" +
$"'{model.LastUpdate:yyyy-MM-dd HH:mm:ss.fff}'," +
$"'{model.BloodPressId}'," +
$"'{model.MessageId}'," +
$"'{model.Serialno}'," +
$"{model.SystolicValue}," +
$"{model.DiastolicValue}," +
$"'{model.CreateTime:yyyy-MM-dd HH:mm:ss.fff}'," +
$"'{model.LastUpdate:yyyy-MM-dd HH:mm:ss.fff}'," +
$"{model.Method}," +
$"{model.IsDisplay == 1})";
var flag= await _serviceTDengine.GernalRestSql(sql);

if (flag) return ApiResponse<object>.Success(model);

}
catch (Exception ex)
{
_logger.LogInformation($"{model.Serialno} -- {model.MessageId} -- 血压数据插入失败; {ex.Message}\n {ex.InnerException} \n{ex.StackTrace}");
}

return ApiResponse<object>.Fail(500, $"{model.Serialno} -- {model.MessageId} -- 血压数据插入失败");
}
}
}

+ 1
- 1
HealthMonitor.WebApi/HealthMonitor.WebApi.csproj Datei anzeigen

@@ -11,7 +11,7 @@
<PackageReference Include="Serilog.Expressions" Version="3.4.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="TelpoDataService.Util" Version="1.6.9.16-beta1" />
<PackageReference Include="TelpoDataService.Util" Version="1.6.9.22-beta1" />
</ItemGroup>

<ItemGroup>


Laden…
Abbrechen
Speichern