From 81819f13e1e3a49bf8456051ec0f0b51e3f10821 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期一, 23 九月 2024 12:20:33 +0800 Subject: [PATCH] 解析优化 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/XhsProjectSimulationCorePage.cs | 490 +++++++++++++++++++++++++++++++++++++++--------------- 1 files changed, 355 insertions(+), 135 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/XhsProjectSimulationCorePage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/XhsProjectSimulationCorePage.cs index 1b685e4..24d5df3 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/XhsProjectSimulationCorePage.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/XhsProjectSimulationCorePage.cs @@ -1,6 +1,9 @@ -锘縰sing Yw.EPAnet; -using HStation.Vmo; -using Yw.DAL.Basic; +锘縢lobal using Yw.EPAnet; +using DevExpress.Xpo.Helpers; +using HStation.WinFrmUI.Xhs; +using HStation.WinFrmUI.Xhs.Core; +using NPOI.SS.Formula.Functions; +using Yw.WinFrmUI.HydroL2d; namespace HStation.WinFrmUI { @@ -11,14 +14,22 @@ InitializeComponent(); this.PageTitle.Caption = "姘村姏妯℃嫙"; this.PageTitle.HeaderSvgImage = this.svgImg32[0]; + this.docPnlHydroCheck.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlHydroCalcu.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlHydroParterList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlUnMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.assetsMainChoicePage1.FormRowClickEvent += xhsProjectSimulationHydroCheckFailedCtrl1_HydroClickEvent; } private HStation.Vmo.XhsProjectVmo _project = null;//椤圭洰 private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//椤圭洰绔� private Yw.Model.HydroModelInfo _hydroInfo = null;//姘村姏淇℃伅 + private List<string> _fastShowHideCodeList = null;//鏄鹃殣缂栫爜鍒楄〃 private Yw.Model.HydroParterInfo _parter = null; - private List<CalcuParter> _allCalcuParterList = null; + private Yw.EPAnet.CheckResult _checkResult = null; + private Yw.EPAnet.CalcuResult _calcuResult = null; /// <summary> /// 缁戝畾鏁版嵁 @@ -47,6 +58,8 @@ .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation); _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID); } + this.xhsProjectSimulationQ3dCtrl1.SetBindingData(_hydroInfo); + this.xhsProjectSimulationL3dCtrl1.SetBindingData(_hydroInfo); } /// <summary> @@ -63,147 +76,354 @@ await this.xhsProjectSimulationBimfaceCtrl1.SetBindingData(_project, _projectSite); } + //灞炴�ч潰鏉胯幏鍙栨按鍔涗俊鎭簨浠� + private Yw.Model.HydroModelInfo xhsProjectSimulationPropertyCtrl1_GetHydroInfoEvent() + { + return _hydroInfo; + } + + //涓�閿樉闅� + private async void barBtnShowHide_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (_hydroInfo == null) + { + return; + } + if (_hydroInfo.Decorators == null || _hydroInfo.Decorators.Count < 1) + { + return; + } + if (_fastShowHideCodeList == null) + { + _fastShowHideCodeList = _hydroInfo.Decorators.Select(x => x.Code).ToList(); + await this.xhsProjectSimulationBimfaceCtrl1.HideComponents(_fastShowHideCodeList); + } + else + { + await this.xhsProjectSimulationBimfaceCtrl1.ShowComponents(_fastShowHideCodeList); + _fastShowHideCodeList = null; + } + } + + //姘村姏楠岃瘉 + private void barBtnHydroCheck_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (_hydroInfo == null) + { + return; + } + this.docPnlHydroCheck.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlHydroCalcu.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlHydroParterList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlUnMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + + var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); + _checkResult = netWork.Check(); + if (_checkResult.Succeed) + { + TipFormHelper.ShowSucceed("鏍¢獙閫氳繃锛�"); + return; + } + this.xhsProjectSimulationHydroCheckFailedCtrl1.SetBindingData(_checkResult.FailedList); + this.docPnlHydroCheck.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; + this.docPnlHydroCheck.Height = 350; + } + + //姘村姏璁$畻 + private void barBtnHydroCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (_hydroInfo == null) + { + return; + } + this.docPnlHydroCheck.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlHydroCalcu.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlHydroParterList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlUnMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + + var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); + _calcuResult = netWork.Calcu(); + if (_calcuResult.Succeed) + { + ShowProperty(); + TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�"); + return; + } + this.xhsProjectSimulationHydroCalcuFailedCtrl1.SetBindingData(_calcuResult.FailedList); + this.docPnlHydroCalcu.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; + this.docPnlHydroCalcu.Height = 350; + } + + //姘村姏鏋勪欢鍒楄〃 + private void barBtnHydroParterList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (_hydroInfo == null) + { + return; + } + this.docPnlHydroCheck.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlHydroCalcu.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlHydroParterList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlUnMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + // this.docPnlMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + + this.hydroParterListCtrl1.SetBindingData(_hydroInfo); + this.docPnlHydroParterList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; + this.docPnlHydroParterList.Height = 350; + } + + //瀵煎嚭姘村姏INP鏂囦欢 + private void barBtnHydroExportInp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (_hydroInfo == null) + { + return; + } + var fileName = Yw.WinFrmUI.FileDialogHelper.SaveInp("瀵煎嚭Inp鏂囦欢"); + if (string.IsNullOrEmpty(fileName)) + { + return; + } + var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); + var result = netWork.ToInpString(); + File.WriteAllText(fileName, result); + TipFormHelper.ShowSucceed("瀵煎嚭鎴愬姛"); + } + + //鏈尮閰嶅垪琛� + private void barBtnUnMatchingList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (_hydroInfo == null) + { + return; + } + this.docPnlHydroCheck.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlHydroCalcu.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlHydroParterList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlUnMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + + this.xhsProjectSimulationUnMatchingListCtrl1.SetBindingData(_hydroInfo); + this.docPnlUnMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; + this.docPnlUnMatchingList.Height = 350; + } + //bimface 鏋勪欢鐐瑰嚮 - private void XhsProjectHydroQ3dCtrl1_ClickParterEvent(string objectId) + private void xhsProjectSimulationBimfaceCtrl1_ClickParterEvent(string objectId) { - //if (_hydro == null) - //{ - // _parter = null; - // return; - //} - //var allParterList = _hydro.GetAllParters(); - //_parter = allParterList.Find(x => x.Code == objectId); - //this.xhsProjectSimulationPropertyCtrl1.SelectParter(_parter, allParterList); - //if (_parter != null) - //{ - // if (_allCalcuParterList != null && _allCalcuParterList.Count > 0) - // { - // var calcuParter = _allCalcuParterList.Find(x => x.Id == _parter.Code); - // if (calcuParter != null) - // { - // IHydroCalcuProperty calcuProperty = null; - // if (calcuParter is CalcuNode calcuNode) - // { - // var calcuNodeProperty = new Yw.WinFrmUI.HydroCalcuNodeProperty(); - // calcuNodeProperty.ID = _parter.ID; - // calcuNodeProperty.CalcuPress = calcuNode.Press; - // calcuNodeProperty.CalcuDemand = calcuNode.Demand; - // calcuNodeProperty.CalcuHead = calcuNode.Head; - // calcuProperty = calcuNodeProperty; - // } - // else if (calcuParter is CalcuLink calcuLink) - // { - // var calcuLinkProperty = new Yw.WinFrmUI.HydroCalcuLinkProperty(); - // calcuLinkProperty.ID = _parter.ID; - // calcuLinkProperty.CalcuHeadLoss = calcuLink.Headloss; - // calcuLinkProperty.CalcuFlow = calcuLink.Flow; - // calcuLinkProperty.CalcuVelocity = calcuLink.Velocity; - // calcuProperty = calcuLinkProperty; - // } - - // if (calcuProperty != null) - // { - // this.xhsProjectSimulationPropertyCtrl1.UpdateCalcuProperty(calcuProperty); - // } - // } - // } - //} - + if (_hydroInfo == null) + { + return; + } + var allParterList = _hydroInfo.GetAllParters(); + _parter = allParterList.Find(x => x.Code == objectId); + ShowProperty(); } - private void barBtnCheck_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + //鏄剧ず灞炴�� + private void ShowProperty() { - //if (_hydro == null) - //{ - // return; - //} - //var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydro); - //var result = netWork.Check(); - //XtraMessageBox.Show(JsonHelper.Object2FormatJson(result)); + if (_hydroInfo == null) + { + return; + } + if (_parter == null) + { + return; + } + var allParterList = _hydroInfo.GetAllParters(); + this.xhsProjectSimulationPropertyCtrl1.SelectParter(_parter, allParterList); + if (_calcuResult != null) + { + if (_calcuResult.Succeed) + { + var allCalcuParterList = _calcuResult.GetParterList(); + var calcuParter = allCalcuParterList.Find(x => x.Id == _parter.Code); + if (calcuParter != null) + { + IHydroCalcuProperty calcuProperty = null; + if (calcuParter is Yw.EPAnet.CalcuNode calcuNode) + { + var calcuNodeProperty = new Yw.WinFrmUI.HydroCalcuNodeProperty(); + calcuNodeProperty.ID = _parter.ID; + calcuNodeProperty.CalcuPress = calcuNode.Press; + calcuNodeProperty.CalcuDemand = calcuNode.Demand; + calcuNodeProperty.CalcuHead = calcuNode.Head; + calcuProperty = calcuNodeProperty; + } + else if (calcuParter is Yw.EPAnet.CalcuLink calcuLink) + { + var calcuLinkProperty = new Yw.WinFrmUI.HydroCalcuLinkProperty(); + calcuLinkProperty.ID = _parter.ID; + calcuLinkProperty.CalcuHeadLoss = calcuLink.Headloss; + calcuLinkProperty.CalcuFlow = calcuLink.Flow; + calcuLinkProperty.CalcuVelocity = calcuLink.Velocity; + calcuProperty = calcuLinkProperty; + } + + if (calcuProperty != null) + { + this.xhsProjectSimulationPropertyCtrl1.UpdateCalcuProperty(calcuProperty); + } + } + } + } } - private void barBtnCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) - { - //if (_hydro == null) - //{ - // return; - //} - //var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydro); - //var result = netWork.Calcu(); - //if (!result.Succeed) - //{ - // XtraMessageBox.Show(JsonHelper.Object2FormatJson(result)); - // return; - //} - //_allCalcuParterList = result.GetParterList(); - //TipFormHelper.ShowSucceed("璁$畻鎴愬姛"); - //if (_parter != null) - //{ - // var calcuParter = _allCalcuParterList.Find(x => x.Id == _parter.Code); - // if (calcuParter != null) - // { - // IHydroCalcuProperty calcuProperty = null; - // if (calcuParter is CalcuNode calcuNode) - // { - // var calcuNodeProperty = new Yw.WinFrmUI.HydroCalcuNodeProperty(); - // calcuNodeProperty.ID = _parter.ID; - // calcuNodeProperty.CalcuPress = calcuNode.Press; - // calcuNodeProperty.CalcuDemand = calcuNode.Demand; - // calcuNodeProperty.CalcuHead = calcuNode.Head; - // calcuProperty = calcuNodeProperty; - // } - // else if (calcuParter is CalcuLink calcuLink) - // { - // var calcuLinkProperty = new Yw.WinFrmUI.HydroCalcuLinkProperty(); - // calcuLinkProperty.ID = _parter.ID; - // calcuLinkProperty.CalcuHeadLoss = calcuLink.Headloss; - // calcuLinkProperty.CalcuFlow = calcuLink.Flow; - // calcuLinkProperty.CalcuVelocity = calcuLink.Velocity; - // calcuProperty = calcuLinkProperty; - // } - - // if (calcuProperty != null) - // { - // this.xhsProjectSimulationPropertyCtrl1.UpdateCalcuProperty(calcuProperty); - // } - // } - //} - } - - private void barBtnParter_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) - { - //var dlg = new HydroParterListDlg(); - //dlg.SetBindingData(_hydro); - //dlg.Show(); - } - - private void barBtnInp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) - { - //var fileName = Yw.WinFrmUI.FileDialogHelper.SaveInp("瀵煎嚭Inp鏂囦欢"); - //if (string.IsNullOrEmpty(fileName)) - //{ - // return; - //} - //var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydro); - //var result = netWork.ToInpString(); - //File.WriteAllText(fileName, result); - //TipFormHelper.ShowSucceed("瀵煎嚭鎴愬姛"); - } - + //淇濆瓨 private async void barBtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { - //if (_hydro == null) - //{ - // return; - //} - //var bll = new Yw.BLL.HydroModelInfo(); - //var result = await bll.Save(_hydro); - //if (result > 0) - //{ - // Yw.WinFrmUI.TipFormHelper.ShowSucceed("淇濆瓨鎴愬姛"); - //} + if (_hydroInfo == null) + { + return; + } + var id = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(_hydroInfo); + if (id < 1) + { + TipFormHelper.ShowError("淇濆瓨澶辫触锛�"); + return; + } + _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(id); + //this.xhsProjectSimulationPropertyCtrl1.SetMatching(_hydroInfo); + TipFormHelper.ShowSucceed("淇濆瓨鎴愬姛锛�"); } + //鑷姩鍖归厤 + private void barBtnAllAutoMatching_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (_hydroInfo == null) + { + return; + } + var input = new AssetsAutoMatchingViewModel(); + input.PumpMatchingModels = _hydroInfo.Pumps?.Select(x => new PumpMatchingViewModel() + { + ID = x.ID, + Code = x.Code, + Name = x.Name, + DbID = x.DbId, + DbLocked = x.DbLocked, + ChartDbID = _hydroInfo.Curves?.Find(t => t.Code == x.CurveQH)?.DbId, + ModelType = x.ModelType, + RatedP = x.RatedP, + RatedH = x.RatedH, + RatedN = x.RatedN, + RatedQ = x.RatedQ, + }).ToList(); + input.ElbowsMatchingModels = _hydroInfo.Elbows?.Select(x => new ElbowsMatchingViewModel() + { + ID = x.ID, + Name = x.Name, + Code = x.Code, + Dbid = x.DbId, + DbLocked = x.DbLocked, + ModelType = x.ModelType, + Caliber = x.Caliber, + Material = x.Material + }).ToList(); + input.ThreeLinkMatchingModels = _hydroInfo.Threelinks?.Select(x => new ThreeLinkMatchingViewModel() + { + ID = x.ID, + Name = x.Name, + Code = x.Code, + DbId = x.DbId, + DbLocked = x.DbLocked, + ModelType = x.ModelType, + Caliber = x.Caliber, + Material = x.Material + }).ToList(); + input.FourLinkMatchingModels = _hydroInfo.Fourlinks?.Select(x => new FourLinkMatchingViewModel() + { + ID = x.ID, + Name = x.Name, + Code = x.Code, + Dbid = x.DbId, + DbLocked = x.DbLocked, + ModelType = x.ModelType, + Caliber = x.Caliber, + Material = x.Material + }).ToList(); + input.PipeLineMatchingModels = _hydroInfo.Pipes?.Select(x => new PipeLineMatchingViewModel() + { + ID = x.ID, + Name = x.Name, + Code = x.Code, + DbId = x.DbId, + DbLocked = x.DbLocked, + ModelType = x.ModelType, + Caliber = x.Diameter,//杩欓噷鏄暟鍊� + Material = x.Material + }).ToList(); + input.ValveMatchingModels = _hydroInfo.Pipes?.Select(x => new ValveMatchingViewModel() + { + ID = x.ID, + Name = x.Name, + Code = x.Code, + DbId = x.DbId, + DbLocked = x.DbLocked, + ModelType = x.ModelType, + Caliber = x.Diameter,//杩欓噷鏄暟鍊� + Material = x.Material//鎬庝箞娌℃湁闃�闂ㄧ被鍨� + }).ToList(); + this.docPnlHydroCheck.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlHydroCalcu.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlHydroParterList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlUnMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.hydroParterListCtrl1.SetBindingData(_hydroInfo); + this.docPnlHydroParterList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + this.docPnlMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; + this.docPnlMatchingList.Height = 350; + this.assetsMainChoicePage1.SetBindingData(input); + this.assetsMainChoicePage1.RelaodEvent += (rhs) => + { + return false; + }; + } + + private void BtnPerformChart_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + var dlg = new PerformChart(); + dlg.ShowDialog(); + } + + //姘村姏鏍¢獙鐐瑰嚮 + private async void xhsProjectSimulationHydroCheckFailedCtrl1_HydroClickEvent(string obj) + { + if (_hydroInfo == null) + { + return; + } + await this.xhsProjectSimulationBimfaceCtrl1.SetSelectedComponents(new List<string>() { obj }); + var allParterList = _hydroInfo.GetAllParters(); + _parter = allParterList.Find(x => x.Code == obj); + ShowProperty(); + } + + //姘村姏鏋勪欢鏄庣粏闈㈡澘鐐瑰嚮浜嬩欢 + private async void hydroParterListCtrl1_HydroClickEvent(Yw.Model.HydroParterInfo parter) + { + var allParterList = _hydroInfo.GetAllParters(); + _parter = allParterList.Find(x => x.ID == parter.ID); + await this.xhsProjectSimulationBimfaceCtrl1.SetSelectedComponents(new List<string>() { _parter.Code }); + ShowProperty(); + } + + //鏈尮閰嶅垪琛ㄧ偣鍑讳簨浠� + private async void xhsProjectSimulationUnMatchingListCtrl1_HydroClickEvent(Yw.Model.HydroParterInfo parter) + { + var allParterList = _hydroInfo.GetAllParters(); + _parter = allParterList.Find(x => x.ID == parter.ID); + await this.xhsProjectSimulationBimfaceCtrl1.SetSelectedComponents(new List<string>() { _parter.Code }); + ShowProperty(); + } + + //鏈尮閰嶅垪琛ㄦ煡鐪嬫ā鍨� + private async void xhsProjectSimulationUnMatchingListCtrl1_ViewModelEvent(List<Yw.Model.HydroParterInfo> parters) + { + var codes = parters?.Select(x => x.Code).Distinct().ToList(); + await this.xhsProjectSimulationBimfaceCtrl1.AddSelectedComponents(codes); + _parter = null; + ShowProperty(); + } } -} +} \ No newline at end of file -- Gitblit v1.9.3