From 17e4c7e3e7b3ef60d9da6de3b2a39a14a53c38a0 Mon Sep 17 00:00:00 2001
From: z8018 <1282578289@qq.com>
Date: 星期三, 12 三月 2025 14:11:33 +0800
Subject: [PATCH] 1

---
 WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/BasicInfo/RouterController.cs |   88 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 85 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..fabcc24 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,72 @@
         [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);
+        }
+
+        [HttpPost, Route("QueryNextRoutesByType"), AllowAnonymous]
+        public List<Dt_Router> QueryNextRoutes(string startPosi, string endPosi, int routeType)
+        {
+            return Service.QueryNextRoutes(startPosi, endPosi, routeType);
         }
     }
 }

--
Gitblit v1.9.3