|
|
@@ -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} -- 血压数据插入失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |