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; } + } +}