From de6190b40e9035b7f6c15b8e81d621779de6a1b8 Mon Sep 17 00:00:00 2001 From: H Vs Date: Fri, 1 Dec 2023 18:25:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E8=A1=80=E5=8E=8B=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthMonitor/HmBloodPressController.cs | 19 ++++++-- .../Model/Request/HmBloodPress.cs | 45 +++++++++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 HealthMonitor.WebApi/Model/Request/HmBloodPress.cs diff --git a/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs b/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs index 735c9a8..3d0f2f6 100644 --- a/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs +++ b/HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs @@ -28,10 +28,23 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor _configTDengineService = configTDengineService.Value; } [HttpPost] - public async Task> Add([FromBody] HisGpsBloodPress model, [FromHeader] string requestId) + public async Task> Add([FromBody] HmBloodPress reqModel, [FromHeader] string requestId) { try { + HisGpsBloodPress model = new HisGpsBloodPress() + { + BloodPressId = reqModel.BloodPressId, + DiastolicValue = reqModel.DiastolicValue, + IsDisplay = reqModel.IsDisplay, + MessageId = reqModel.MessageId, + Method = reqModel.Method, + Serialno = reqModel.Serialno, + SystolicValue = reqModel.SystolicValue, + CreateTime = DateTime.Parse(reqModel.CreateTime.ToString()), + LastUpdate = DateTime.Parse(reqModel.LastUpdate.ToString()), + + }; 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}'," + @@ -53,11 +66,11 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor } catch (Exception ex) { - _logger.LogInformation($"{model.Serialno} -- {model.MessageId} -- 血压数据插入失败; {ex.Message}\n {ex.InnerException} \n{ex.StackTrace}"); + _logger.LogInformation($"{reqModel.Serialno} -- {reqModel.MessageId} -- 血压数据插入失败; {ex.Message}\n {ex.InnerException} \n{ex.StackTrace}"); } - return ApiResponse.Fail(500, $"{model.Serialno} -- {model.MessageId} -- 血压数据插入失败"); + return ApiResponse.Fail(500, $"{reqModel.Serialno} -- {reqModel.MessageId} -- 血压数据插入失败"); } } } diff --git a/HealthMonitor.WebApi/Model/Request/HmBloodPress.cs b/HealthMonitor.WebApi/Model/Request/HmBloodPress.cs new file mode 100644 index 0000000..ada1f91 --- /dev/null +++ b/HealthMonitor.WebApi/Model/Request/HmBloodPress.cs @@ -0,0 +1,45 @@ +using Newtonsoft.Json; +using System.ComponentModel.DataAnnotations; +using System.Text.Json; + +namespace HealthMonitor.WebApi.Model.Request +{ + + public class HmBloodPress + { + [JsonProperty("bloodPressId")] + public string BloodPressId { get; set; } = default!; + [JsonProperty("messageId")] + public string MessageId { get; set; } = default!; + + [JsonProperty("serialno")] + public string Serialno { get; set; } = default!; + + [JsonProperty("systolicValue")] + public int SystolicValue { get; set; } + + [JsonProperty("diastolicValue")] + public int DiastolicValue { get; set; } + + [JsonProperty("lastUpdate")] + + public string LastUpdate { get; set; } = default!; + + [JsonProperty("createTime")] + + public string CreateTime { get; set; } = default!; + + [JsonProperty("method")] + public int? Method { get; set; } + + [JsonProperty("isDisplay")] + public int IsDisplay { get; set; } = 1; + + + //[JsonConverter(typeof(CustomDateTimeConverter))] + //public DateTime? LastUpdate { get; set; } + + //[JsonConverter(typeof(CustomDateTimeConverter))] + //public DateTime? CreateTime { get; set; } + } +}