From 0c6034d59eff7027babcb60854fc4bd7ffc6dfea Mon Sep 17 00:00:00 2001 From: H Vs Date: Thu, 30 Nov 2023 10:12:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=A1=80=E5=8E=8B=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8E=A5=E6=94=B6=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthMonitor/HmBloodPressController.cs | 63 +++++++++++++++++++ .../HealthMonitor.WebApi.csproj | 2 +- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs diff --git a/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs b/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs new file mode 100644 index 0000000..735c9a8 --- /dev/null +++ b/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs @@ -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 _logger; + private readonly TDengineService _serviceTDengine; + private readonly TDengineServiceConfig _configTDengineService; + + public HmBloodPressController(TDengineService serviceDengine, IOptions configTDengineService, ILogger logger) + { + _serviceTDengine = serviceDengine; + _logger = logger; + _configTDengineService = configTDengineService.Value; + } + [HttpPost] + public async Task> 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.Success(model); + + + + } + catch (Exception ex) + { + _logger.LogInformation($"{model.Serialno} -- {model.MessageId} -- 血压数据插入失败; {ex.Message}\n {ex.InnerException} \n{ex.StackTrace}"); + + } + + return ApiResponse.Fail(500, $"{model.Serialno} -- {model.MessageId} -- 血压数据插入失败"); + } + } +} diff --git a/HealthMonitor.WebApi/HealthMonitor.WebApi.csproj b/HealthMonitor.WebApi/HealthMonitor.WebApi.csproj index 02e3c52..4ead961 100644 --- a/HealthMonitor.WebApi/HealthMonitor.WebApi.csproj +++ b/HealthMonitor.WebApi/HealthMonitor.WebApi.csproj @@ -11,7 +11,7 @@ - +