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 @@ - +