From 8d9b95fd302a0989d68baa847ed0fdeb55d9c59c Mon Sep 17 00:00:00 2001 From: H Vs Date: Thu, 1 Aug 2024 16:05:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0mockMode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HealthMonitor/HmFetalController.cs | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 HealthMonitor.WebApi/Controllers/HealthMonitor/HmFetalController.cs diff --git a/HealthMonitor.WebApi/Controllers/HealthMonitor/HmFetalController.cs b/HealthMonitor.WebApi/Controllers/HealthMonitor/HmFetalController.cs new file mode 100644 index 0000000..1405642 --- /dev/null +++ b/HealthMonitor.WebApi/Controllers/HealthMonitor/HmFetalController.cs @@ -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 _logger; + + public HmFetalController(IotApiService IotApiService, TDengineService serviceDengine, ILogger logger) + { + _logger = logger; + _serviceTDengine = serviceDengine; + _serviceIotApi = IotApiService; + } + + + [HttpGet] + public async Task GetMode(string sn) + { + var res= await _serviceTDengine.GetBySerialNoAsync(sn); + return View(res); + } + + //[HttpPost] + //public async Task SetMockMode([FromBody] PregnancyCommonHeartRateModel pchr) + //{ + // await _serviceTDengine.InsertAsync("hm_pchr", pchr); + + // await _serviceIotApi.SetFetalConfig(pchr.SerialNumber, 1, pchr.MaxValue, pchr.MinValue); + + // return View(pchr); + //} + + [HttpPost] + public async Task SetMockMode([FromBody] string sn, int mockMax,int mockMin,string remark="mock") + { + var res= await _serviceTDengine.GetBySerialNoAsync(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("hm_pchr", pchr); + var flag=await _serviceIotApi.SetFetalConfig(pchr.SerialNumber, 1, pchr.MaxValue, pchr.MinValue); + return View(new { + flag, + pchr + }); + } + + } +}