Quellcode durchsuchen

增加mockMode

datasub12_fetal_heart_rate_0
H Vs vor 8 Monaten
Ursprung
Commit
8d9b95fd30
1 geänderte Dateien mit 68 neuen und 0 gelöschten Zeilen
  1. +68
    -0
      HealthMonitor.WebApi/Controllers/HealthMonitor/HmFetalController.cs

+ 68
- 0
HealthMonitor.WebApi/Controllers/HealthMonitor/HmFetalController.cs Datei anzeigen

@@ -0,0 +1,68 @@
using HealthMonitor.Model.Service.Mapper;
using HealthMonitor.Service.Biz;
using HealthMonitor.Service.Biz.db;
using HealthMonitor.WebApi.Configs;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Metadata;

namespace HealthMonitor.WebApi.Controllers.HealthMonitor
{
[ApiExplorerSettings(GroupName = AppConsts.SWAGGER_DOC_HealthMonitor)]
[Produces("application/json")]
[Route("api/HealthMonitor/[controller]/[action]")]
public class HmFetalController : Controller
{
private readonly TDengineService _serviceTDengine;
private readonly IotApiService _serviceIotApi;

private readonly ILogger<HmFetalController> _logger;

public HmFetalController(IotApiService IotApiService, TDengineService serviceDengine, ILogger<HmFetalController> logger)
{
_logger = logger;
_serviceTDengine = serviceDengine;
_serviceIotApi = IotApiService;
}


[HttpGet]
public async Task<IActionResult> GetMode(string sn)
{
var res= await _serviceTDengine.GetBySerialNoAsync<PregnancyCommonHeartRateModel>(sn);
return View(res);
}

//[HttpPost]
//public async Task<IActionResult> SetMockMode([FromBody] PregnancyCommonHeartRateModel pchr)
//{
// await _serviceTDengine.InsertAsync<PregnancyCommonHeartRateModel>("hm_pchr", pchr);

// await _serviceIotApi.SetFetalConfig(pchr.SerialNumber, 1, pchr.MaxValue, pchr.MinValue);

// return View(pchr);
//}

[HttpPost]
public async Task<IActionResult> SetMockMode([FromBody] string sn, int mockMax,int mockMin,string remark="mock")
{
var res= await _serviceTDengine.GetBySerialNoAsync<PregnancyCommonHeartRateModel>(sn);
var pchr = res.FirstOrDefault();

if (pchr == null)
{
return View("NULL");
}
pchr.MaxValue = mockMax;
pchr.MinValue = mockMin;
pchr.Remark = remark;
pchr.Timestamp = DateTime.Now;
await _serviceTDengine.InsertAsync<PregnancyCommonHeartRateModel>("hm_pchr", pchr);
var flag=await _serviceIotApi.SetFetalConfig(pchr.SerialNumber, 1, pchr.MaxValue, pchr.MinValue);
return View(new {
flag,
pchr
});
}

}
}

Laden…
Abbrechen
Speichern