From 3de39066b5894850d0f0dc311b60cc09f599a025 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期四, 26 二月 2026 14:30:06 +0800
Subject: [PATCH] 修复图片导入;重构路由和堆垛机命令
---
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs | 125 ++++++++++++++++++++++-------------------
1 files changed, 67 insertions(+), 58 deletions(-)
diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs
index 4bf89ae..3cdd283 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs
@@ -363,34 +363,24 @@
// 閬嶅巻鎵�鏈夌粨鏉熺殑璺敱
foreach (var item in dt_Routers)
{
- // 鑾峰彇褰撳墠璺敱鐨勫瓙璺敱
- string routes = $"{item.NextPosi},";
- // 鑾峰彇褰撳墠璺敱鐨勭埗璺敱
- string str = GetPreviousRoutes(item.StartPosi, allRouters, item.InOutType);
- // 濡傛灉鐖惰矾鐢变笉涓虹┖
- if (!string.IsNullOrEmpty(str))
+ // 鑾峰彇鎵�鏈夊彲鑳界殑瀹屾暣璺緞
+ List<List<string>> allPaths = GetAllPaths(item.StartPosi, item.NextPosi, allRouters, item.InOutType);
+
+ // 涓烘瘡鏉$嫭绔嬭矾寰勭敓鎴愮粨鏋�
+ foreach (var path in allPaths)
{
- // 鍘绘帀鏈�鍚庝竴涓�楀彿
- if (str.EndsWith(","))
- str = str.Substring(0, str.Length - 1);
- // 灏嗙埗璺敱娣诲姞鍒板瓙璺敱涓�
- routes += str;
- }
- // 濡傛灉褰撳墠璺敱鏄叆鍙�
- if (item.InOutType == RouterInOutType.In.ObjToInt())
- {
- // 灏嗗瓙璺敱鍙嶈浆骞舵坊鍔犲埌data涓�
- List<string> itemRouters = routes.Split(",").Reverse().ToList();
- object obj = new { type = RouterInOutType.In, routes = itemRouters };
- data.Add(obj);
- }
- // 濡傛灉褰撳墠璺敱鏄嚭鍙�
- else
- {
- // 灏嗗瓙璺敱鍙嶈浆骞舵坊鍔犲埌data涓�
- List<string> itemRouters = routes.Split(",").Reverse().ToList();
- object obj = new { type = RouterInOutType.Out, routes = itemRouters };
- data.Add(obj);
+ // 濡傛灉褰撳墠璺敱鏄叆鍙�
+ if (item.InOutType == RouterInOutType.In.ObjToInt())
+ {
+ object obj = new { type = RouterInOutType.In, routes = path };
+ data.Add(obj);
+ }
+ // 濡傛灉褰撳墠璺敱鏄嚭鍙�
+ else
+ {
+ object obj = new { type = RouterInOutType.Out, routes = path };
+ data.Add(obj);
+ }
}
}
@@ -398,42 +388,61 @@
return data;
}
- private string GetPreviousRoutes(string startPosi, List<Dt_Router> allRouters, int routerType)
+ /// <summary>
+ /// 鑾峰彇浠庤捣鐐瑰埌缁堢偣鐨勬墍鏈夊畬鏁磋矾寰�
+ /// </summary>
+ /// <param name="startPosi">褰撳墠璧峰浣嶇疆</param>
+ /// <param name="endPosi">缁堢偣浣嶇疆</param>
+ /// <param name="allRouters">鎵�鏈夎矾鐢辨暟鎹�</param>
+ /// <param name="routerType">璺敱绫诲瀷</param>
+ /// <returns>鎵�鏈夊畬鏁磋矾寰勫垪琛紝姣忔潯璺緞鏄粠璧风偣鍒扮粓鐐圭殑浣嶇疆鍒楄〃</returns>
+ private List<List<string>> GetAllPaths(string startPosi, string endPosi, List<Dt_Router> allRouters, int routerType)
{
- // 瀹氫箟涓�涓┖瀛楃涓瞨outers
- string routers = string.Empty;
- // 鍒ゆ柇startPosi鏄惁涓虹┖
- if (!string.IsNullOrEmpty(startPosi))
+ List<List<string>> result = new List<List<string>>();
+
+ // 浠庣粓鐐瑰紑濮嬪弽鍚戞煡鎵炬墍鏈夎矾寰�
+ List<List<string>> reversePaths = new List<List<string>>();
+ BuildReversePaths(startPosi, new List<string> { endPosi, startPosi }, allRouters, routerType, reversePaths);
+
+ // 灏嗗弽鍚戣矾寰勮浆涓烘鍚戯紙浠庤捣鐐瑰埌缁堢偣锛�
+ foreach (var reversePath in reversePaths)
{
- // 鍒ゆ柇routers鏄惁浠ラ�楀彿缁撳熬
- if (!routers.EndsWith(","))
- // 濡傛灉涓嶆槸锛屽垯灏唖tartPosi娣诲姞鍒皉outers涓紝骞跺湪鍚庨潰鍔犱笂閫楀彿
- routers += $"{startPosi},";
- else
- // 濡傛灉鏄紝鍒欏皢startPosi娣诲姞鍒皉outers涓�
- routers += $"{startPosi}";
+ result.Add(reversePath.AsEnumerable().Reverse().ToList());
}
- // 浠巃llRouters涓瓫閫夊嚭NextPosi绛変簬startPosi涓擨nOutType绛変簬routerType鐨勫厓绱狅紝骞惰浆鎹负List
- List<Dt_Router> preRouters = allRouters.Where(x => x.NextPosi == startPosi && x.InOutType == routerType).ToList();
- // 閬嶅巻preRouters涓殑姣忎釜鍏冪礌
- foreach (var item in preRouters)
+
+ return result;
+ }
+
+ /// <summary>
+ /// 閫掑綊鏋勫缓鍙嶅悜璺緞锛堜粠缁堢偣鍚戣捣鐐规煡鎵撅級
+ /// </summary>
+ /// <param name="currentStartPosi">褰撳墠鑺傜偣鐨勮捣濮嬩綅缃�</param>
+ /// <param name="currentPath">褰撳墠宸叉瀯寤虹殑璺緞锛堝弽鍚戯紝浠庣粓鐐瑰紑濮嬶級</param>
+ /// <param name="allRouters">鎵�鏈夎矾鐢辨暟鎹�</param>
+ /// <param name="routerType">璺敱绫诲瀷</param>
+ /// <param name="result">鏀堕泦鎵�鏈夊畬鏁磋矾寰�</param>
+ private void BuildReversePaths(string currentStartPosi, List<string> currentPath, List<Dt_Router> allRouters, int routerType, List<List<string>> result)
+ {
+ // 鏌ユ壘褰撳墠鑺傜偣鐨勫墠缃妭鐐癸紙NextPosi绛変簬褰撳墠StartPosi鐨勮矾鐢憋級
+ List<Dt_Router> preRouters = allRouters.Where(x => x.NextPosi == currentStartPosi && x.InOutType == routerType).ToList();
+
+ // 濡傛灉娌℃湁鍓嶇疆鑺傜偣锛岃鏄庡凡缁忓埌杈捐矾寰勮捣鐐癸紝淇濆瓨褰撳墠璺緞
+ if (preRouters.Count == 0)
{
- // 璋冪敤GetPreviousRoutes鏂规硶锛屼紶鍏tem.StartPosi銆乤llRouters鍜宺outerType锛屽苟灏嗚繑鍥炲�艰祴缁檚tr
- string str = GetPreviousRoutes(item.StartPosi, allRouters, routerType);
- // 鍒ゆ柇str鏄惁涓虹┖
- if (!string.IsNullOrEmpty(str))
- {
- // 鍒ゆ柇routers鏄惁浠ラ�楀彿缁撳熬
- if (routers.EndsWith(","))
- // 濡傛灉鏄紝鍒欏皢str娣诲姞鍒皉outers涓�
- routers += $"{str}";
- else
- // 濡傛灉涓嶆槸锛屽垯灏唖tr娣诲姞鍒皉outers涓紝骞跺湪鍚庨潰鍔犱笂閫楀彿
- routers += $"{str},";
- }
+ result.Add(new List<string>(currentPath));
+ return;
}
- // 杩斿洖routers
- return routers;
+
+ // 瀵规瘡涓墠缃妭鐐癸紝鍒涘缓鏂扮殑璺緞鍒嗘敮
+ foreach (var preRouter in preRouters)
+ {
+ // 鍒涘缓鏂扮殑璺緞鍓湰
+ List<string> newPath = new List<string>(currentPath);
+ newPath.Add(preRouter.StartPosi);
+
+ // 閫掑綊鏌ユ壘鍓嶇疆鑺傜偣
+ BuildReversePaths(preRouter.StartPosi, newPath, allRouters, routerType, result);
+ }
}
/// <summary>
--
Gitblit v1.9.3