Просмотр исходного кода

兼容血压请求模型

datasub12_previous
H Vs 1 год назад
Родитель
Сommit
de6190b40e
2 измененных файлов: 61 добавлений и 3 удалений
  1. +16
    -3
      HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs
  2. +45
    -0
      HealthMonitor.WebApi/Model/Request/HmBloodPress.cs

+ 16
- 3
HealthMonitor.WebApi/Controllers/HealthMonitor/HmBloodPressController.cs Просмотреть файл

@@ -28,10 +28,23 @@ namespace HealthMonitor.WebApi.Controllers.HealthMonitor
_configTDengineService = configTDengineService.Value;
}
[HttpPost]
public async Task<ApiResponse<object>> Add([FromBody] HisGpsBloodPress model, [FromHeader] string requestId)
public async Task<ApiResponse<object>> 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<object>.Fail(500, $"{model.Serialno} -- {model.MessageId} -- 血压数据插入失败");
return ApiResponse<object>.Fail(500, $"{reqModel.Serialno} -- {reqModel.MessageId} -- 血压数据插入失败");
}
}
}

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

Загрузка…
Отмена
Сохранить