From 9886c494da5adcc9a670e2b7ff2c657a98f27b96 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期四, 28 十一月 2024 14:23:30 +0800 Subject: [PATCH] 导入优化 --- WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs | 76 +++++++++++++++----------------------- 1 files changed, 30 insertions(+), 46 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs index 584d927..83aa7f4 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/14-matching/00-core/HydroMatchingHelper.cs @@ -13,142 +13,126 @@ /// <summary> /// 鍒涘缓鑷姩鍖归厤ViewModel /// </summary> - public static HydroMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuVisualResult> allCalcuVisualResultList = null) + public static HydroMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, List<HydroCalcuVisualResult> allCalcuResultVisualList = null) { - #region 鍒濆鍖栧瓧鍏� - - Dictionary<string, HydroCalcuVisualResult> dict = null; - if (allCalcuVisualResultList != null && allCalcuVisualResultList.Count > 0) + if (hydroInfo == null) { - dict = new Dictionary<string, HydroCalcuVisualResult>(); - allCalcuVisualResultList.ForEach(x => dict.Add(x.Code, x)); - } - - #endregion - - #region 鑾峰彇璁$畻缁撴灉鏂规硶 - - HydroCalcuVisualResult getCalcuVisualResult(string code) - { - if (dict == null) - { - return default; - } - if (dict.ContainsKey(code)) - { - return dict[code]; - } return default; } + var allCalcuResultVisualDict = allCalcuResultVisualList?.ToDictionary(x => x.Code); + return Create(hydroInfo, allCalcuResultVisualDict); + } - #endregion + /// <summary> + /// 鍒涘缓 + /// </summary> + public static HydroMatchingViewModel Create(Yw.Model.HydroModelInfo hydroInfo, Dictionary<string, HydroCalcuVisualResult> allCalcuResultVisualDict = null) + { + if (hydroInfo == null) + { + return default; + } var vm = new HydroMatchingViewModel(); #region 姘存睜 var tanks = hydroInfo.GetAllTanks(); - vm.Tanks = tanks?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Tanks = tanks?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); #endregion #region 闂峰ご - vm.Bluntheads = hydroInfo.Bluntheads?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Bluntheads = hydroInfo.Bluntheads?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); #endregion #region 寮ご - vm.Elbows = hydroInfo.Elbows?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Elbows = hydroInfo.Elbows?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); #endregion #region 涓夐�� - vm.Threelinks = hydroInfo.Threelinks?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Threelinks = hydroInfo.Threelinks?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); #endregion #region 鍥涢�� - vm.Fourlinks = hydroInfo.Fourlinks?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Fourlinks = hydroInfo.Fourlinks?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); #endregion #region 鍠峰槾 - vm.Nozzles = hydroInfo.Nozzles?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Nozzles = hydroInfo.Nozzles?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); #endregion #region 娑堢伀鏍� - vm.Hydrants = hydroInfo.Hydrants?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Hydrants = hydroInfo.Hydrants?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); #endregion #region 姘磋〃 - vm.Meters = hydroInfo.Meters?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuNodeResult)).ToList(); + vm.Meters = hydroInfo.Meters?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuNodeResult)).ToList(); #endregion #region 娴侀噺璁� - vm.Flowmeters = hydroInfo.Flowmeters?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuFlowmeterResult)).ToList(); + vm.Flowmeters = hydroInfo.Flowmeters?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuFlowmeterResult)).ToList(); #endregion #region 鍘嬪姏琛� - vm.Pressmeters = hydroInfo.Pressmeters?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuPressmeterResult)).ToList(); + vm.Pressmeters = hydroInfo.Pressmeters?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuPressmeterResult)).ToList(); #endregion #region 绠¢亾 - vm.Pipes = hydroInfo.Pipes?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuLinkResult)).ToList(); + vm.Pipes = hydroInfo.Pipes?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuLinkResult)).ToList(); #endregion #region 杩囨浮浠� - vm.Translations = hydroInfo.Translations?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuLinkResult)).ToList(); + vm.Translations = hydroInfo.Translations?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuLinkResult)).ToList(); #endregion #region 姘存车 - vm.Pumps = hydroInfo.Pumps?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuPumpResult)).ToList(); + vm.Pumps = hydroInfo.Pumps?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuPumpResult)).ToList(); #endregion #region 闃�闂� - vm.Valves = hydroInfo.Valves?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuLinkResult)).ToList(); + vm.Valves = hydroInfo.Valves?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuLinkResult)).ToList(); #endregion #region 鎹㈢儹鍣� - vm.Exchangers = hydroInfo.Exchangers?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuLinkResult)).ToList(); + vm.Exchangers = hydroInfo.Exchangers?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuLinkResult)).ToList(); #endregion #region 鍘嬬缉鏈� - vm.Compressors = hydroInfo.Compressors?.Select(x => Create(x, hydroInfo, getCalcuVisualResult(x.Code) as HydroCalcuLinkResult)).ToList(); + vm.Compressors = hydroInfo.Compressors?.Select(x => Create(x, hydroInfo, allCalcuResultVisualDict?.GetValue(x.Code) as HydroCalcuLinkResult)).ToList(); #endregion return vm; - - } - - public static HydroMatchingViewModel Create(List<HydroVisualViewModel> allVisualList) - { - return default; } #region 姘存睜 -- Gitblit v1.9.3