From baf1f14a693172fe19bbea7fe4ce1daf57bb07d1 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 27 三月 2026 14:39:24 +0800
Subject: [PATCH] feat(RouterService): 新增 DeleteRouters 批量删除路由方法
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs | 64 ++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs
index e1249fc..1a04379 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs
@@ -107,6 +107,70 @@
}
/// <summary>
+ /// 鑾峰彇鍏ㄩ噺璺敱鏁伴噺锛堝叆鍙�+鍑哄彛鍚堣锛�
+ /// </summary>
+ public int GetRouterCount()
+ {
+ // 鍒嗗埆鑾峰彇鍏ュ彛绫诲瀷鍜屽嚭鍙g被鍨嬬殑璺敱鏁伴噺骞剁浉鍔�
+ int inCount = GetAllRoutersFromCache(RouterInOutType.In.ObjToInt()).Count;
+ int outCount = GetAllRoutersFromCache(RouterInOutType.Out.ObjToInt()).Count;
+ return inCount + outCount;
+ }
+
+ /// <summary>
+ /// 鑾峰彇鎸囧畾绫诲瀷璺敱鏁伴噺
+ /// </summary>
+ public int GetRouterCount(int routeType)
+ {
+ // 鑾峰彇鎸囧畾绫诲瀷鐨勫叏閲忚矾鐢辨暟鎹苟杩斿洖鏁伴噺
+ return GetAllRoutersFromCache(routeType).Count;
+ }
+
+ /// <summary>
+ /// 鎵归噺鍒犻櫎鎸囧畾ID鐨勮矾鐢憋紝鍒犻櫎鍚庡悓姝ユ竻闄ゅ搴旂被鍨嬬殑缂撳瓨
+ /// </summary>
+ /// <param name="routerIds">寰呭垹闄ょ殑璺敱ID鍒楄〃</param>
+ /// <returns>杩斿洖澶勭悊缁撴灉</returns>
+ public WebResponseContent DeleteRouters(List<long> routerIds)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ if (routerIds == null || routerIds.Count == 0)
+ {
+ return content = WebResponseContent.Instance.Error("寰呭垹闄ょ殑璺敱ID鍒楄〃涓嶈兘涓虹┖");
+ }
+
+ // 鏌ヨ寰呭垹闄よ矾鐢辩殑绫诲瀷锛堢敤浜庡悗缁竻闄ょ紦瀛橈級
+ var routersToDelete = BaseDal.QueryData(x => routerIds.Contains(x.Id));
+ if (routersToDelete.Count == 0)
+ {
+ return content = WebResponseContent.Instance.Error("鏈壘鍒板緟鍒犻櫎鐨勮矾鐢�");
+ }
+
+ // 璁板綍娑夊強鐨勭被鍨嬶紙鍘婚噸锛�
+ var affectedTypes = routersToDelete.Select(x => x.InOutType).Distinct().ToList();
+
+ // 鎵ц鎵归噺鍒犻櫎
+ BaseDal.DeleteData(routersToDelete);
+
+ // 娓呴櫎鍙楀奖鍝嶇被鍨嬬殑缂撳瓨
+ foreach (var routeType in affectedTypes)
+ {
+ string cacheKey = $"Router:AllRouters:{(routeType == RouterInOutType.In.ObjToInt() ? "In" : "Out")}";
+ _cacheService.Remove(cacheKey);
+ }
+
+ content = WebResponseContent.Instance.OK();
+ }
+ catch (Exception ex)
+ {
+ content = WebResponseContent.Instance.Error(ex.Message);
+ }
+ return content;
+ }
+
+ /// <summary>
/// 鏍规嵁璧风偣/褰撳墠浣嶇疆銆佺粓鐐硅幏鍙栦笅涓�涓瓙鑺傜偣銆�
/// </summary>
/// <param name="startPosi">璧风偣/褰撳墠浣嶇疆銆�</param>
--
Gitblit v1.9.3