From 7c926c1e3ade5158e6b1b0b805cd1b9c142e4b6c Mon Sep 17 00:00:00 2001 From: 肖洋 <cathay_xy@163.com> Date: 星期六, 21 十二月 2024 09:45:33 +0800 Subject: [PATCH] 更新代码以使用SqlSugarScope替代SqlSugarClient,并添加生产产线属性 --- Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs | 89 +++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 87 insertions(+), 2 deletions(-) diff --git a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs index b389354..a60279f 100644 --- a/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs +++ b/Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/Service/RouterService.cs @@ -30,12 +30,74 @@ /// <param name="startPosi">璧风偣/褰撳墠浣嶇疆銆�</param> /// <param name="endPosi">缁堢偣銆�</param> /// <returns>杩斿洖璺敱瀹炰綋闆嗗悎銆�</returns> + //public List<Dt_Router> QueryNextRoutes(string startPosi, string endPosi) + //{ + // //todo 鏂规硶闇�浼樺寲 + // List<Dt_Router> routers = new List<Dt_Router>(); + // try + // { + // List<Dt_Router> dt_Routers = BaseDal.QueryData(x => x.NextPosi == endPosi || x.ChildPosi == endPosi, new Dictionary<string, OrderByType> { { nameof(Dt_Router.IsEnd), OrderByType.Desc } }); + // if (dt_Routers.Count > 0) + // { + // foreach (var item in dt_Routers) + // { + // if (item.StartPosi == startPosi && !routers.Any(x => x.Id == item.Id)) + // { + // routers.Add(item); + // } + // else + // { + // List<Dt_Router> tempRouters = QueryNextRoutes(startPosi, item.StartPosi); + // foreach (var router in tempRouters) + // { + // if (router.StartPosi == startPosi && !routers.Any(x => x.Id == router.Id)) + // { + // routers.Add(router); + // } + // } + // } + // } + // } + // else + // { + // throw new Exception($"璇ヨ矾寰勬湭閰嶇疆鎴栭厤缃敊璇�,璇锋鏌ヨ澶囪矾鐢变俊鎭�,璧风偣:銆恵startPosi}銆�,缁堢偣:銆恵endPosi}銆�"); + // } + // } + // catch (Exception ex) + // { + // //throw new Exception(ex.Message); + // //璁板綍閿欒淇℃伅 + // } + // return routers; + //} + + /// <summary> + /// 鏍规嵁璧风偣/褰撳墠浣嶇疆銆佺粓鐐硅幏鍙栦笅涓�涓瓙鑺傜偣銆� + /// </summary> + /// <param name="startPosi">璧风偣/褰撳墠浣嶇疆銆�</param> + /// <param name="endPosi">缁堢偣銆�</param> + /// <returns>杩斿洖璺敱瀹炰綋闆嗗悎銆�</returns> public List<Dt_Router> QueryNextRoutes(string startPosi, string endPosi) { - //todo 鏂规硶闇�浼樺寲 + // 鐢ㄤ簬璁板綍宸茬粡璁块棶杩囩殑璧风偣鍜岀粓鐐圭粍鍚堬紝閬垮厤閲嶅璁块棶杩涘叆姝诲惊鐜� + HashSet<string> visitedRoutes = new HashSet<string>(); + return QueryNextRoutesInternal(startPosi, endPosi, visitedRoutes); + } + + private List<Dt_Router> QueryNextRoutesInternal(string startPosi, string endPosi, HashSet<string> visitedRoutes) + { List<Dt_Router> routers = new List<Dt_Router>(); try { + // 鏋勫缓涓�涓敮涓�鏍囪瘑褰撳墠璧风偣鍜岀粓鐐圭粍鍚堢殑瀛楃涓� + string routeKey = $"{startPosi}_{endPosi}"; + if (visitedRoutes.Contains(routeKey)) + { + // 濡傛灉宸茬粡璁块棶杩囷紝鐩存帴杩斿洖绌哄垪琛紝閬垮厤閲嶅杩涘叆鐩稿悓鐨勯�掑綊鍒嗘敮 + return routers; + } + visitedRoutes.Add(routeKey); + List<Dt_Router> dt_Routers = BaseDal.QueryData(x => x.NextPosi == endPosi || x.ChildPosi == endPosi, new Dictionary<string, OrderByType> { { nameof(Dt_Router.IsEnd), OrderByType.Desc } }); if (dt_Routers.Count > 0) { @@ -47,7 +109,7 @@ } else { - List<Dt_Router> tempRouters = QueryNextRoutes(startPosi, item.StartPosi); + List<Dt_Router> tempRouters = QueryNextRoutesInternal(startPosi, item.StartPosi, visitedRoutes); foreach (var router in tempRouters) { if (router.StartPosi == startPosi && !routers.Any(x => x.Id == router.Id)) @@ -65,6 +127,7 @@ } catch (Exception ex) { + // 杩欓噷鍙互鏍规嵁瀹為檯闇�姹傛洿濂藉湴澶勭悊寮傚父锛屾瘮濡傝褰曟棩蹇楃瓑锛岀洰鍓嶅彧鏄敞閲婃帀浜嗙洿鎺ユ姏鍑哄紓甯� //throw new Exception(ex.Message); //璁板綍閿欒淇℃伅 } @@ -238,5 +301,27 @@ } return content; } + + /// <summary> + /// 鏍规嵁璁惧缂栧彿鑾峰彇鍑哄簱璺敱鐐逛綅 + /// </summary> + /// <param name="deviceCode"></param> + /// <returns></returns> + public List<string> QueryOutDeviceCodes(string deviceCode) + { + List<string> positions = new List<string>(); + try + { + List<string> outRouterPositions = BaseDal.QueryData(x => x.ChildPosiDeviceCode == deviceCode && x.InOutType == RouterInOutType.Out).GroupBy(x => x.ChildPosi).Select(x => x.Key).ToList(); + + positions.AddRange(outRouterPositions); + return positions.GroupBy(x => x).Select(x => x.Key).ToList(); + } + catch + { + + } + return positions; + } } } -- Gitblit v1.9.3