From bf7afb4df82fcc56a4477eba3d3a7ff64ef42d1f Mon Sep 17 00:00:00 2001 From: dev02 Date: Tue, 10 Jan 2023 16:05:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Ealarm=20card?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/DashboardController.cs | 24 +++++++++++++++++++ FrontendWebApi/Models/AlarmRecord.cs | 13 +++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/FrontendWebApi/ApiControllers/DashboardController.cs b/FrontendWebApi/ApiControllers/DashboardController.cs index 7cc76f5..5e6d4ff 100644 --- a/FrontendWebApi/ApiControllers/DashboardController.cs +++ b/FrontendWebApi/ApiControllers/DashboardController.cs @@ -1,11 +1,13 @@ using FrontendWebApi.Models; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Logging; using NPOI.SS.Formula.Functions; using Repository.BackendRepository.Interface; using Repository.FrontendRepository.Interface; using System; +using System.Collections.Generic; using System.Data.SqlTypes; using System.IO; using System.Threading.Tasks; @@ -42,5 +44,27 @@ namespace FrontendWebApi.ApiControllers } return Ok(apiResult); } + + [HttpPost] + [Route("api/AlarmCard")] + public async Task>>> AlarmCard() + { + ApiResult> apiResult = new ApiResult>(); + try + { + var sqlString = $@"select * from v_alarm where isOpen = 1"; + var result = await backendRepository.GetAllAsync(sqlString); + + apiResult.Data = result; + apiResult.Code = "0000"; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + return Ok(apiResult); + } + return Ok(apiResult); + } } } diff --git a/FrontendWebApi/Models/AlarmRecord.cs b/FrontendWebApi/Models/AlarmRecord.cs index 25e3f0d..9a71033 100644 --- a/FrontendWebApi/Models/AlarmRecord.cs +++ b/FrontendWebApi/Models/AlarmRecord.cs @@ -1,4 +1,5 @@ -using System; +using NPOI.Util; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -56,4 +57,14 @@ namespace FrontendWebApi.Models public byte IsSolve { get;set;} public byte IsAck { get;set;} } + + public class VAlarmRecord + { + public DateTime timestamp { get; set; } + public int id { get; set; } + public int priority { get; set; } + public string alarmClass_txt { get; set; } + public string device_name { get; set; } + public string errMsg { get; set; } + } }