diff --git a/langguanApi.xml b/langguanApi.xml
index a539827..c5c27f9 100644
--- a/langguanApi.xml
+++ b/langguanApi.xml
@@ -97,6 +97,21 @@
需要解密的字符串
解密后的字符串
+
+
+ export data
+
+
+
+
+
+
+
+ add alert
+
+
+
+
@@ -879,6 +894,36 @@
id
+
+
+ deviceId
+
+
+
+
+ deviceName
+
+
+
+
+ organizedName
+
+
+
+
+ keyword
+
+
+
+
+ standard
+
+
+
+
+ deviceValue
+
+
台账
@@ -1550,19 +1595,27 @@
注册日期
-
+
新加
-
+
首页数据,最近7天的
+
+
+ 导出数据
+
+
+
+
+
分页取数据
@@ -1723,6 +1776,19 @@
+
+
+ //获取最新的数据
+
+
+
+
+
+
+ 导出数据
+
+
+
新加
@@ -1914,7 +1980,7 @@
HomeService
-
+
HomeService
diff --git a/langguanApi/Controllers/AlertController.cs b/langguanApi/Controllers/AlertController.cs
new file mode 100644
index 0000000..d97b87f
--- /dev/null
+++ b/langguanApi/Controllers/AlertController.cs
@@ -0,0 +1,44 @@
+using langguanApi.Model;
+using langguanApi.Service;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+
+namespace langguanApi.Controllers
+{
+ [Route("api/[controller]")]
+ [ApiController]
+ public class AlertController : ControllerBase
+ {
+ private readonly AlertService _alertService;
+ public AlertController(AlertService alertService)
+ {
+ _alertService = alertService;
+ }
+ ///
+ /// export data 默认最近7天数据
+ ///
+ ///
+ ///
+ ///
+ [HttpGet("export")]
+ public async Task export(DateTime? start, DateTime? end)
+ {
+ start = start.HasValue ? start.Value.Date : DateTime.Now.AddDays(-7);
+ end = end.HasValue ? end.Value.Date.AddDays(1) : DateTime.Now.Date.AddDays(1);
+ var alerts = await _alertService.ExportData(start, end);
+ return File(alerts, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+ $"{start.Value.ToString("yyyy-MM-dd")}-{end.Value.ToString("yyyy-MM-dd")}_设备报警.xlsx");
+ }
+ ///
+ /// add alert
+ ///
+ ///
+ ///
+ [HttpPost("TestAdd")]
+ public async Task TestAdd(AddAlertDto input)
+ {
+ var result = await _alertService.Add(input);
+ return Ok(result);
+ }
+ }
+}
diff --git a/langguanApi/Model/Alert.cs b/langguanApi/Model/Alert.cs
index 35fa78c..3af781f 100644
--- a/langguanApi/Model/Alert.cs
+++ b/langguanApi/Model/Alert.cs
@@ -10,4 +10,14 @@
public string AlertType { get; set; }
public string AlertContent { get; set; }
}
+ public class AddAlertDto
+ {
+ public string DeviceId { get; set; }
+ public string DeviceMn { get; set; }
+ public string deviceName { get; set; }
+ public string DeviceType { get; set; }
+ public string DeviceStatus { get; set; }
+ public string AlertType { get; set; }
+ public string AlertContent { get; set; }
+ }
}
diff --git a/langguanApi/Model/Entity/Detection.cs b/langguanApi/Model/Entity/Detection.cs
new file mode 100644
index 0000000..738434c
--- /dev/null
+++ b/langguanApi/Model/Entity/Detection.cs
@@ -0,0 +1,30 @@
+namespace langguanApi.Model.Entity
+{
+ public class Detection : BaseModel
+ {
+ ///
+ /// deviceId
+ ///
+ public string DeviceId { get; set; }
+ ///
+ /// deviceName
+ ///
+ public string DeviceName { get; set; }
+ ///
+ /// organizedName
+ ///
+ public string OrganizedName { get; set; }
+ ///
+ /// keyword
+ ///
+ public string keyword { get; set; }
+ ///
+ /// standard
+ ///
+ public string Standard { get; set; }
+ ///
+ /// deviceValue
+ ///
+ public string deviceValue { get; set; }
+ }
+}
diff --git a/langguanApi/Service/AlertService.cs b/langguanApi/Service/AlertService.cs
index ce099b2..eeac91e 100644
--- a/langguanApi/Service/AlertService.cs
+++ b/langguanApi/Service/AlertService.cs
@@ -2,6 +2,7 @@
using langguanApi.Model;
using langguanApi.Model.Dto;
using langguanApi.Model.Entity;
+using Mapster;
using Npoi.Mapper;
using System.Linq.Expressions;
@@ -18,11 +19,12 @@ namespace langguanApi.Service
///
///
///
- public async Task Add(Alert input)
+ public async Task Add(AddAlertDto input)
{
if (input != null)
{
- await base.CreateAsync(input);
+ var entity = input.Adapt();
+ await base.CreateAsync(entity);
return new ApiResult { code = 0, msg = "" };
}
return new ApiResult { code = -1, msg = "" }; ;
@@ -31,28 +33,45 @@ namespace langguanApi.Service
/// 首页数据,最近7天的
///
///
- public async Task