From 3ec3e0c1913bc902dbbcaeae2959897df6212ec2 Mon Sep 17 00:00:00 2001
From: hutongqing <hutongqing@hnkhzn.com>
Date: 星期四, 28 十一月 2024 15:41:23 +0800
Subject: [PATCH] 更新
---
WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/BasicInfo/RouterController.cs | 82 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 79 insertions(+), 3 deletions(-)
diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/BasicInfo/RouterController.cs b/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/BasicInfo/RouterController.cs
index 14bf1bb..f356951 100644
--- a/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/BasicInfo/RouterController.cs
+++ b/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/BasicInfo/RouterController.cs
@@ -1,10 +1,23 @@
锘縰sing Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.DataProtection.KeyManagement;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
+using Quartz.Util;
+using SqlSugar;
+using System.ComponentModel;
+using System.Reflection;
+using WIDESEAWCS_Common;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseController;
-using WIDESEAWCS_IBasicInfoService;
+using WIDESEAWCS_Core.Enums;
+using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_DTO.BasicInfo;
using WIDESEAWCS_Model.Models;
+using WIDESEAWCS_QuartzJob.Models;
+using WIDESEAWCS_QuartzJob.Repository;
+using WIDESEAWCS_QuartzJob.Service;
namespace WIDESEAWCS_Server.Controllers.BasicInfo
{
@@ -12,8 +25,12 @@
[ApiController]
public class RouterController : ApiBaseController<IRouterService, Dt_Router>
{
- public RouterController(IRouterService service) : base(service)
+ private readonly IDeviceInfoRepository _deviceInfoRepository;
+ private readonly IDeviceProtocolRepository _deviceProtocolRepository;
+ public RouterController(IRouterService service, IDeviceInfoRepository deviceInfoRepository, IDeviceProtocolRepository deviceProtocolRepository) : base(service)
{
+ _deviceInfoRepository = deviceInfoRepository;
+ _deviceProtocolRepository = deviceProtocolRepository;
}
[HttpPost, Route("QueryRoutes"), AllowAnonymous]
@@ -31,7 +48,66 @@
[HttpPost, Route("GetAllWholeRouters"), AllowAnonymous]
public WebResponseContent GetAllWholeRouters()
{
- return Service.GetAllWholeRouters();
+ WebResponseContent content = new();
+ try
+ {
+ List<object> dynamics = Service.GetAllWholeRouters();
+
+ content = WebResponseContent.Instance.OK(data: dynamics);
+ }
+ catch (Exception ex)
+ {
+ content = WebResponseContent.Instance.Error(ex.Message);
+ }
+ return content; }
+
+ [HttpPost, Route("GetBaseRouterInfo"), AllowAnonymous]
+ public WebResponseContent GetBaseRouterInfo()
+ {
+ try
+ {
+ #region 鑾峰彇璺敱绫诲瀷
+ List<object> routerTypes = new List<object>();
+ Type routerType = typeof(RouterInOutType);
+ List<int> routerIndexs = Enum.GetValues(typeof(RouterInOutType)).Cast<int>().ToList();
+ int routerIndex = 0;
+ foreach (var item in routerIndexs)
+ {
+ FieldInfo? fieldInfo = routerType.GetField(((RouterInOutType)item).ToString());
+ DescriptionAttribute? description = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
+ if (description != null)
+ {
+ routerTypes.Add(new { key = item.ToString(), value = description.Description });
+ }
+ else
+ {
+ routerTypes.Add(new { key = item.ToString(), value = item.ToString() });
+ }
+ routerIndex++;
+ }
+ #endregion
+
+ #region 鑾峰彇璁惧缂栧彿
+ object deviceCodes = _deviceProtocolRepository.QueryData(x => true).GroupBy(x => x.DeviceChildCode).Select(x => new { key = x.Key, value = x.Key }).ToList();
+
+ object areaInfos = Enum.GetNames(typeof(AreaInfo)).Select(x => new { key = x, value = x }).ToList();
+
+
+ #endregion
+
+ return WebResponseContent.Instance.OK(data: new { routerTypes, deviceCodes, areaInfos });
+ }
+ catch (Exception ex)
+ {
+ return WebResponseContent.Instance.Error(ex.Message);
+ }
+
+ }
+
+ [HttpPost, Route("AddRouters"), AllowAnonymous]
+ public WebResponseContent AddRouters([FromBody] List<RoutersAddDTO> routersAddDTOs, int routerType)
+ {
+ return Service.AddRouters(routersAddDTOs, routerType);
}
}
}
--
Gitblit v1.9.3