From 15f1d6ad5ea19303fa8533c76d394ec3a873d061 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 27 三月 2026 14:16:44 +0800
Subject: [PATCH] refactor(IRouterService): 去掉多余 public 修饰符并新增7个方法签名

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs
index fe6e7d2..731bd19 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs
@@ -321,16 +321,6 @@
                 if (directRoute != null)
                     return directRoute;
 
-                //// 濡傛灉娌℃湁鐩存帴璺敱锛屼娇鐢ㄦ煡鎵剧畻娉曟壘鍒版湞鍚戠粓鐐圭殑璺敱
-                //List<Dt_Router> allRouters = BaseDal.QueryData(x => x.InOutType == routeType);
-                //foreach (var route in routes)
-                //{
-                //    // 妫�鏌ヤ粠杩欎釜璺敱鐨勪笅涓�涓綅缃槸鍚﹁兘鍒拌揪缁堢偣
-                //    var pathToEnd = FindRoutesInMemory(route.NextPosi, endPosi, allRouters, routeType);
-                //    if (pathToEnd.Count > 0)
-                //        return route;
-                //}
-
                 // 濡傛灉閮戒笉鑳藉埌杈剧粓鐐癸紝杩斿洖绗竴涓矾鐢�
                 return routes.FirstOrDefault();
             }
@@ -419,9 +409,9 @@
                     // 杩斿洖鍘婚噸鍚庣殑浣嶇疆鍒楄〃
                     return positions.GroupBy(x => x).Select(x => x.Key).ToList();
                 }
-                catch
+                catch (Exception ex)
                 {
-
+                    ConsoleHelper.WriteErrorLine($"RouterService.QueryAllPositions 鏌ヨ澶辫触: {ex.Message}");
                 }
                 finally
                 {
@@ -440,8 +430,10 @@
         public List<object> GetAllWholeRouters()
         {
             List<object> data = new List<object>();
-            // 鏌ヨ鎵�鏈夎矾鐢�
-            List<Dt_Router> allRouters = BaseDal.QueryData(x => true);
+            // 浠庣紦瀛樺姞杞藉叆鍙g被鍨嬪拰鍑哄彛绫诲瀷鐨勫叏閲忚矾鐢辨暟鎹苟鍚堝苟
+            List<Dt_Router> inRouters = GetAllRoutersFromCache(RouterInOutType.In.ObjToInt());
+            List<Dt_Router> outRouters = GetAllRoutersFromCache(RouterInOutType.Out.ObjToInt());
+            List<Dt_Router> allRouters = inRouters.Concat(outRouters).ToList();
             // 鏌ヨ鎵�鏈夌粨鏉熺殑璺敱锛屽苟鎸塈d鎺掑簭
             List<Dt_Router> dt_Routers = allRouters.Where(x => x.IsEnd).OrderBy(x => x.Id).ToList();
 
@@ -612,6 +604,20 @@
 
                 // 娣诲姞鏂扮殑璺敱淇℃伅
                 BaseDal.AddData(routers);
+
+                // 閲嶆柊鏌ヨ鍏ㄩ噺璺敱锛堟鏃舵墠鍖呭惈鏂板鐨勮矾鐢憋級锛屽啀鍐欏叆缂撳瓨
+                List<Dt_Router> updatedRouters = BaseDal.QueryData(x => x.InOutType == routerType);
+                string cacheKey = $"Router:AllRouters:{(routerType == RouterInOutType.In.ObjToInt() ? "In" : "Out")}";
+
+                try
+                {
+                    _cacheService.AddOrUpdate(cacheKey, updatedRouters);
+                }
+                catch
+                {
+                    // 缂撳瓨鏇存柊澶辫触鏃堕潤榛樺拷鐣ワ紝涓嬫鏌ヨ浼氫粠DB鑷姩閲嶅缓缂撳瓨
+                }
+
                 content = WebResponseContent.Instance.OK();
             }
             catch (Exception ex)

--
Gitblit v1.9.3