From 569e91c63636345391f741df049c9374a141a434 Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期一, 26 八月 2024 08:57:33 +0800 Subject: [PATCH] 添加路由新建配置,重新导出种子数据 --- WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/BasicInfo/RouterController.cs | 80 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 78 insertions(+), 2 deletions(-) diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/BasicInfo/RouterController.cs b/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/BasicInfo/RouterController.cs index 14bf1bb..9b3923b 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_Core.Enums; +using WIDESEAWCS_Core.Helper; +using WIDESEAWCS_DTO.BasicInfo; using WIDESEAWCS_IBasicInfoService; using WIDESEAWCS_Model.Models; +using WIDESEAWCS_QuartzJob.Models; +using WIDESEAWCS_QuartzJob.Repository; 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<dynamic> 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