From adf7734a40dec76fc31590906eeadd02c782db90 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期五, 08 十一月 2024 21:29:59 +0800 Subject: [PATCH] 优化导入,优化水流动画 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs | 3561 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 3,200 insertions(+), 361 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs index 5b768cb..813ad8e 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs @@ -1,10 +1,15 @@ 锘縢lobal using Yw.EPAnet; +using DevExpress.Mvvm.Native; using DevExpress.Xpo.Helpers; -using HStation.WinFrmUI.Xhs; -using HStation.WinFrmUI.Xhs.Core; -using NPOI.SS.Formula.Functions; -using Yw.WinFrmUI.HydroL2d; -using Yw.WinFrmUI.HydroL3d; +using DevExpress.XtraRichEdit.Layout; +using DevExpress.XtraSpreadsheet.Commands; +using HStation.WinFrmUI.PhartRelation; +using System.Diagnostics; +using System.Windows.Media.Media3D; +using Yw.Pump; +using Yw.Vmo; +using Yw.WinFrmUI.Bimface; +using Yw.WinFrmUI.Hydro; namespace HStation.WinFrmUI { @@ -15,20 +20,17 @@ 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.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; + RegistBulkSetEvents(); } private HStation.Vmo.XhsProjectVmo _project = null;//椤圭洰 private HStation.Vmo.XhsProjectSiteVmo _projectSite = null;//椤圭洰绔� private Yw.Model.HydroModelInfo _hydroInfo = null;//姘村姏淇℃伅 - private Yw.Model.HydroParterInfo _parter = null; - private Yw.EPAnet.CheckResult _checkResult = null; - private Yw.EPAnet.CalcuResult _calcuResult = null; + + private Yw.WinFrmUI.HydroCheckResult _checkResult = null;//妫�鏌ョ粨鏋� + private Yw.EPAnet.CalcuResult _calcuResult = null;//璁$畻缁撴灉 /// <summary> /// 缁戝畾鏁版嵁 @@ -62,7 +64,7 @@ /// <summary> /// 鍒濆鍖栨暟鎹� /// </summary> - public override async void InitialDataSource() + public override void InitialDataSource() { base.InitialDataSource(); if (_project == null) @@ -70,41 +72,652 @@ return; } this.PageTitle.Caption = $"{_project.Name}\r\n姘村姏妯℃嫙"; - await this.xhsProjectSimulationBimfaceCtrl1.SetBindingData(_project, _projectSite, () => _hydroInfo); - this.xhsProjectSimulationQ3dCtrl1.SetBindingData(_hydroInfo); - this.xhsProjectSimulationL3dCtrl1.SetBindingData(_hydroInfo); - this.xhsProjectSimulationPropertyCtrl1.SetBindingData(() => _hydroInfo); + ShowBimfaceCtrl(); + ShowQ3dCtrl(); + ShowPropertyCtrl(); + } - //姘村姏璁$畻 - private async void barBtnHydroCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + + #region Bimface + + //bimface鎺т欢 + private XhsProjectSimulationBimfaceCtrl _bimfaceCtrl = null; + + //鑾峰彇 bimface 鎺т欢 + private async Task<XhsProjectSimulationBimfaceCtrl> GetBimfaceCtrl() + { + if (_bimfaceCtrl == null) + { + _bimfaceCtrl = new XhsProjectSimulationBimfaceCtrl(); + _bimfaceCtrl.Dock = DockStyle.Fill; + await _bimfaceCtrl.InitialData(_project, _projectSite, () => _hydroInfo); + _bimfaceCtrl.LoadCompletedEvent += () => + {//view鍔犺浇瀹屾垚浜嬩欢 + if (_hydroInfo == null) + { + return; + } + ApplyGrading(); + }; + _bimfaceCtrl.HydroMouseLeftClickEvent += (obj) => + {//榧犳爣宸﹂敭鐐瑰嚮浜嬩欢 + if (_hydroInfo == null) + { + return; + } + _selectedParter = obj; + ShowProperty(); + }; + } + return _bimfaceCtrl; + } + + //鏄剧ず bimface 鎺т欢 + private async void ShowBimfaceCtrl() + { + var bimfaceCtrl = await GetBimfaceCtrl(); + this.tabPageBimface.Controls.Clear(); + this.tabPageBimface.Controls.Add(bimfaceCtrl); + } + + private void SelectBimfaceParter() + { + + } + + #endregion + + #region Q3d + + //Q3d 鎺т欢 + private XhsProjectSimulationQ3dCtrl _q3dCtrl = null; + + //鑾峰彇 Q3d 鎺т欢 + private XhsProjectSimulationQ3dCtrl GetQ3dCtrl() + { + if (_q3dCtrl == null) + { + _q3dCtrl = new XhsProjectSimulationQ3dCtrl(); + _q3dCtrl.Dock = DockStyle.Fill; + _q3dCtrl.InitialData(() => _hydroInfo); + _q3dCtrl.SelectedPartersChangedEvent += (obj) => + { + if (_hydroInfo == null) + { + return; + } + var allParterList = _hydroInfo.GetAllParters(); + _selectedParter = allParterList?.Find(x => x.Code == obj?.FirstOrDefault()); + ShowProperty(); + }; + } + return _q3dCtrl; + } + + //鏄剧ず Q3d 鎺т欢 + private void ShowQ3dCtrl() + { + var q3dCtrl = GetQ3dCtrl(); + this.tabPageQ3d.Controls.Clear(); + this.tabPageQ3d.Controls.Add(q3dCtrl); + } + + #endregion + + #region 鏋勪欢灞炴�� + + //灞炴�ф帶浠� + private XhsProjectSimulationPropertyCtrl _propertyCtrl = null; + + //鑾峰彇灞炴�ф帶浠� + private XhsProjectSimulationPropertyCtrl GetPropertyCtrl() + { + if (_propertyCtrl == null) + { + _propertyCtrl = new XhsProjectSimulationPropertyCtrl(); + _propertyCtrl.Dock = DockStyle.Fill; + _propertyCtrl.InitialData(() => _hydroInfo, () => GetCalcuResultList()); + _propertyCtrl.BlinkLinkParterEvent += async (code, linkCode) => + { //寮鸿皟杩炴帴缁勪欢 + if (string.IsNullOrEmpty(code)) + { + return; + } + if (string.IsNullOrEmpty(linkCode)) + { + return; + } + if (_hydroInfo == null) + { + return; + } + var allVisualList = _hydroInfo.GetAllVisuals(); + if (allVisualList == null || allVisualList.Count < 1) + { + return; + } + var linkParter = allVisualList.Find(x => x.Code == linkCode); + if (linkParter == null) + { + return; + } + var blinkCodes = new List<string>(); + if (linkParter.GetType() == typeof(Yw.Model.HydroJunctionInfo)) + { + var allLinkList = _hydroInfo.GetAllLinks(); + if (allLinkList == null || allLinkList.Count < 1) + { + return; + } + var linkList = allLinkList.Where(x => (x.StartCode == linkParter.Code || x.EndCode == linkParter.Code) && x.Code != code).ToList(); + if (linkList == null || linkList.Count < 1) + { + return; + } + blinkCodes.AddRange(linkList.Select(x => x.Code)); + } + else + { + blinkCodes.Add(linkCode); + } + + await _bimfaceCtrl?.SetBlinkComponents(blinkCodes); + await Task.Delay(5000); + await _bimfaceCtrl?.ClearBlinkComponents(); + }; + + _propertyCtrl.ViewParterEvent += (parter) => + { + if (parter == null) + { + return; + } + _bimfaceCtrl?.ZoomToComponent(parter.Code); + }; + _propertyCtrl.PropertyValueChangedEvent += (parter) => + { + if (parter == null) + { + return; + } + UpdateParterListProperty(parter); + AutoApplyGrading(); + }; + _propertyCtrl.MarkPropertyValueChangedEvent += (parter) => + { + //鏍囨敞灞炴�у彂鐢熸敼鍙� + //鍒ゆ柇褰撳墠鏄惁鏈夋爣娉ㄥ睍绀猴紝鑻ユ湁鍒欐洿鏂版爣娉紝鏈�濂芥槸鏇存柊鍗曚釜鏍囨敞 + }; + _propertyCtrl.GradingPropertyValueChangedEvent += (parter) => + { + //鍒嗙骇灞炴�у彂鐢熸敼鍙� + //鍒ゆ柇褰撳墠鏄惁鏈夊垎绾у睍绀猴紝鑻ユ湁鍒欐洿鏂板垎绾э紝鏈�濂芥槸鏇存柊鍗曚釜鍒嗙骇 + }; + _propertyCtrl.FlowDirectionPropertyValueChangedEvent += async (parter) => + { + //娴佸悜灞炴�у彂鐢熸敼鍙� + //鍒ゆ柇娴佸悜鏄惁鍔犺浇锛屽鏋滃姞杞藉垯鏇存柊娴佸悜锛屾渶濂芥槸鏇存柊鍗曚釜娴佸悜 + UpdateFlowEffect(parter); + //await _bimfaceCtrl?.UnloadFlowEffectById(parter.Code); + }; + + } + return _propertyCtrl; + } + + //鏄剧ず灞炴�ч潰鏉� + private void ShowPropertyCtrl() + { + var propertyCtrl = GetPropertyCtrl(); + this.controlContainerRight.Controls.Clear(); + this.controlContainerRight.Controls.Add(propertyCtrl); + this.docPnlRight.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; + this.docPnlRight.Text = "灞炴��"; + this.docPnlRight.Width = 300; + } + + //鏄剧ず灞炴�� + private void ShowProperty() { 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) + if (this.docPnlRight.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Hidden) { - ShowProperty(); - TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�"); + ShowPropertyCtrl(); + } + if (_selectedParter == null) + { + _propertyCtrl?.CancelSelectParter(); + return; + } + _propertyCtrl?.SelectParter(_selectedParter.Code); + + var allCalcuResultList = GetCalcuResultList(); + if (allCalcuResultList != null && allCalcuResultList.Count > 0) + { + var calcuResult = allCalcuResultList.Find(x => x.Code == _selectedParter.Code); + if (calcuResult != null) + { + _propertyCtrl?.UpdateCalcuProperty(calcuResult); + } + } + } + + #endregion + + #region 閫夋嫨鏋勪欢 + + //閫夋嫨鏋勪欢 + private Yw.Model.HydroParterInfo _selectedParter = null; + + //鏇存柊閫夋嫨缁勪欢灞炴�� + private void UpdateSelectedParterProperty() + { + if (_selectedParter == null) + { + return; + } + _propertyCtrl?.UpdateProperty(); + } + + //鏇存柊閫夋嫨缁勪欢璁$畻灞炴�� + private void UpdateSelectedParterCalcuProperty() + { + if (_selectedParter == null) + { + return; + } + var allCalcuResultList = GetCalcuResultList(); + if (allCalcuResultList == null || allCalcuResultList.Count < 1) + { + return; + } + var calcuResult = allCalcuResultList.Find(x => x.Code == _selectedParter.Code); + if (calcuResult == null) + { + return; + } + _propertyCtrl?.UpdateCalcuProperty(calcuResult); + } + + //鏇存柊鏋勪欢鍒楄〃灞炴�� + private void UpdateParterListProperty() + { + if (this.docPnlBottom.Visibility != DevExpress.XtraBars.Docking.DockVisibility.Visible) + { + return; + } + var parterListCtrl = this.controlContainerBottom.Controls[0] as Yw.WinFrmUI.HydroParterListCtrl; + if (parterListCtrl == null) + { + return; + } + parterListCtrl.UpdateProperty(); + } + + //鏇存柊鏋勪欢鍒楄〃灞炴�� + private void UpdateParterListProperty(Yw.Model.HydroParterInfo parter) + { + if (this.docPnlBottom.Visibility != DevExpress.XtraBars.Docking.DockVisibility.Visible) + { + return; + } + var parterListCtrl = this.controlContainerBottom.Controls[0] as Yw.WinFrmUI.HydroParterListCtrl; + if (parterListCtrl == null) + { + return; + } + parterListCtrl.UpdateProperty(parter); + } + + //鏇存柊鏋勪欢鍒楄〃灞炴�� + private void UpdateParterListProperty(List<Yw.Model.HydroParterInfo> parterList) + { + if (this.docPnlBottom.Visibility != DevExpress.XtraBars.Docking.DockVisibility.Visible) + { + return; + } + var parterListCtrl = this.controlContainerBottom.Controls[0] as Yw.WinFrmUI.HydroParterListCtrl; + if (parterListCtrl == null) + { + return; + } + parterListCtrl.UpdateProperty(parterList); + } + + //鏇存柊鏋勪欢鍒楄〃璁$畻灞炴�� + private void UpdateParterListCalcuProperty() + { + if (this.docPnlBottom.Visibility != DevExpress.XtraBars.Docking.DockVisibility.Visible) + { + return; + } + var parterListCtrl = this.controlContainerBottom.Controls[0] as Yw.WinFrmUI.HydroParterListCtrl; + if (parterListCtrl == null) + { + return; + } + var allCalcuResultList = GetCalcuResultList(); + parterListCtrl.UpdateCalcuProperty(allCalcuResultList); + } + + #endregion + + #region 鑷姩鍖归厤 + + //鑾峰彇鍖归厤鍒楄〃鎺т欢 + private XhsProjectSimulationMatchingListCtrl GetMatchingListCtrl() + { + if (_matchingListCtrl == null) + { + _matchingListCtrl = new XhsProjectSimulationMatchingListCtrl(); + _matchingListCtrl.Dock = DockStyle.Fill; + _matchingListCtrl.HydroClickEvent += async (code) => + { + if (_hydroInfo == null) + { + return; + } + var allParterList = _hydroInfo.GetAllParters(); + _selectedParter = allParterList?.Find(x => x.Code == code); + var elementIds = new List<string>(); + if (_selectedParter != null) + { + elementIds.Add(_selectedParter.Code); + } + await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds); + ShowProperty(); + }; + _matchingListCtrl.ApplyMatchingEvent += (output) => + { + if (_hydroInfo == null) + { + return false; + } + return AssetsMatchingParasHelper.Apply(_hydroInfo, output); + }; + } + return _matchingListCtrl; + } + + //鍖归厤鍒楄〃鎺т欢 + private XhsProjectSimulationMatchingListCtrl _matchingListCtrl = null; + + //鑷姩鍖归厤 + private void barBtnMatchingList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (_hydroInfo == null) + { + return; + } + this.controlContainerBottom.Controls.Clear(); + var matchingListCtrl = GetMatchingListCtrl(); + var input = AssetsMatchingParasHelper.Create(_hydroInfo, GetCalcuResultList()); + matchingListCtrl.SetBindingData(input); + this.controlContainerBottom.Controls.Add(matchingListCtrl); + this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; + this.docPnlBottom.Text = "鍖归厤鍒楄〃"; + this.docPnlBottom.Height = 350; + } + + #endregion + + #region 鏈尮閰嶅垪琛� + + //鑾峰彇鏈尮閰嶅垪琛ㄦ帶浠� + private XhsProjectSimulationUnMatchingListCtrl GetUnMatchingListCtrl() + { + if (_unMatchingListCtrl == null) + { + _unMatchingListCtrl = new XhsProjectSimulationUnMatchingListCtrl(); + _unMatchingListCtrl.Dock = DockStyle.Fill; + _unMatchingListCtrl.HydroClickEvent += async (parter) =>//琛岀偣鍑� + { + if (parter == null) + { + return; + } + if (_hydroInfo == null) + { + return; + } + var allParterList = _hydroInfo.GetAllParters(); + _selectedParter = allParterList?.Find(x => x.Code == parter.Code); + var elementIds = new List<string>() { parter.Code }; + await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds); + ShowProperty(); + }; + _unMatchingListCtrl.ViewModelEvent += async (parters) =>//鏌ョ湅妯″瀷 + { + var codes = parters?.Select(x => x.Code).Distinct().ToList(); + await _bimfaceCtrl?.ZoomAndSelectComponents(codes); + _selectedParter = null; + ShowProperty(); + }; + } + return _unMatchingListCtrl; + } + + private XhsProjectSimulationUnMatchingListCtrl _unMatchingListCtrl = null;//鏈尮閰嶅垪琛� + + //鏈尮閰嶅垪琛� + private void barBtnUnMatchingList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (_hydroInfo == null) + { + return; + } + this.controlContainerBottom.Controls.Clear(); + var unMatchingListCtrl = GetUnMatchingListCtrl(); + unMatchingListCtrl.SetBindingData(_hydroInfo); + this.controlContainerBottom.Controls.Add(unMatchingListCtrl); + this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; + this.docPnlBottom.Text = "鏈尮閰嶅垪琛�"; + this.docPnlBottom.Height = 350; + } + + #endregion + + #region 涓�閿樉闅� + + //鏄鹃殣缂栫爜鍒楄〃 + private List<string> _fastShowHiddenCodeList = null; + + //涓�閿樉闅� + private async void FastShowHidden() + { + if (_hydroInfo == null) + { + return; + } + if (_hydroInfo.Decorators == null || _hydroInfo.Decorators.Count < 1) + { + return; + } + if (_fastShowHiddenCodeList == null) + { + _fastShowHiddenCodeList = _hydroInfo.Decorators.Select(x => x.Code).ToList(); + await _bimfaceCtrl?.HideComponents(_fastShowHiddenCodeList); } else { - this.xhsProjectSimulationHydroCalcuFailedCtrl1.SetBindingData(_calcuResult.FailedList); - this.docPnlHydroCalcu.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; - this.docPnlHydroCalcu.Height = 350; + await _bimfaceCtrl?.ShowComponents(_fastShowHiddenCodeList); + _fastShowHiddenCodeList = null; } - await this.xhsProjectSimulationBimfaceCtrl1.ShowCalcuCustomLabels(_calcuResult); } + //瑙﹀彂涓�閿樉闅� + private void barBtnFastShowHidden_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + FastShowHidden(); + } + #endregion + + #region 姘村姏鏍¢獙 + + //鏍¢獙鎺т欢 + private XhsProjectSimulationHydroCheckResultCtrl _checkCtrl = null; + + //鑾峰彇鏍¢獙鎺т欢 + private XhsProjectSimulationHydroCheckResultCtrl GetCheckCtrl() + { + if (_checkCtrl == null) + { + _checkCtrl = new XhsProjectSimulationHydroCheckResultCtrl(); + _checkCtrl.Dock = DockStyle.Fill; + _checkCtrl.HydroClickEvent += async (code) => + { + if (_hydroInfo == null) + { + return; + } + var elementIds = new List<string>(); + if (string.IsNullOrEmpty(code)) + { + _selectedParter = null; + } + else + { + var allParterList = _hydroInfo.GetAllParters(); + _selectedParter = allParterList?.Find(x => x.Code == code); + if (_selectedParter != null) + { + elementIds.Add(_selectedParter.Code); + } + } + await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds); + ShowProperty(); + }; + } + return _checkCtrl; + } + + //鏄剧ず妫�鏌ユ帶浠� + private void ShowCheckCtrl() + { + if (_checkResult == null) + { + return; + } + var checkCtrl = GetCheckCtrl(); + checkCtrl.SetBindingData(_checkResult); + this.controlContainerBottom.Controls.Clear(); + this.controlContainerBottom.Controls.Add(checkCtrl); + this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; + this.docPnlBottom.Text = "妫�鏌ョ粨鏋�"; + this.docPnlBottom.Height = 350; + + } + + //姘村姏妫�鏌� + private void barBtnHydroCheck_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (_hydroInfo == null) + { + return; + } + _checkResult = _hydroInfo.Check(); + ShowCheckCtrl(); + } + + #endregion + + #region 淇濆瓨淇℃伅 + + //淇濆瓨 + private async void barBtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (_hydroInfo == null) + { + return; + } + Stopwatch sw = new Stopwatch(); + sw.Start(); + + + var id = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.Save(_hydroInfo); + + //鑰楁椂宸ㄥぇ鐨勪唬鐮� + + sw.Stop(); + TimeSpan ts2 = sw.Elapsed; + Console.WriteLine("Stopwatch鎬诲叡鑺辫垂{0}ms.", ts2.TotalMilliseconds); + if (id < 1) + { + TipFormHelper.ShowError("淇濆瓨澶辫触锛�"); + return; + } + _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(id); + TipFormHelper.ShowSucceed("淇濆瓨鎴愬姛锛�"); + } + + #endregion + + #region 鏋勪欢鏄庣粏 + + //鏋勪欢鏄庣粏鎺т欢 + private Yw.WinFrmUI.HydroParterListCtrl _parterListCtrl = null; + + //鑾峰彇鏋勪欢鏄庣粏鎺т欢 + private Yw.WinFrmUI.HydroParterListCtrl GetParterListCtrl() + { + if (_parterListCtrl == null) + { + _parterListCtrl = new HydroParterListCtrl(); + _parterListCtrl.Dock = DockStyle.Fill; + _parterListCtrl.HydroClickEvent += async (parter) => + { + _selectedParter = parter; + await _bimfaceCtrl?.ZoomAndSelectComponent(_selectedParter.Code); + ShowProperty(); + }; + _parterListCtrl.HydroChangedEvent += (parterList) => + { + UpdateSelectedParterProperty(); + AutoApplyGrading(); + }; + } + return _parterListCtrl; + } + + //鏄剧ず鏋勪欢鏄庣粏鎺т欢 + private void ShowParterListCtrl() + { + if (_hydroInfo == null) + { + return; + } + var allCalcuResultList = GetCalcuResultList(); + var parterListCtrl = GetParterListCtrl(); + parterListCtrl.SetBindingData(_hydroInfo, allCalcuResultList); + if (allCalcuResultList == null || allCalcuResultList.Count < 1) + { + parterListCtrl.SetNormalView(); + } + else + { + parterListCtrl.SetCalcuView(); + } + this.controlContainerBottom.Controls.Clear(); + this.controlContainerBottom.Controls.Add(parterListCtrl); + this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; + this.docPnlBottom.Text = "鏋勪欢鏄庣粏"; + this.docPnlBottom.Height = 350; + } + + //鏋勪欢鏄庣粏 + private void barBtnHydroParterList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + ShowParterListCtrl(); + } + + #endregion + + #region INP瀵煎嚭 //瀵煎嚭姘村姏INP鏂囦欢 private void barBtnHydroExportInp_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) @@ -124,331 +737,196 @@ TipFormHelper.ShowSucceed("瀵煎嚭鎴愬姛"); } + #endregion INP瀵煎嚭 + #region 鎵归噺閰嶇疆 - #region Bimface - - //bimface 鍔犺浇瀹屾垚浜嬩欢 - private async void xhsProjectSimulationBimfaceCtrl1_LoadCompletedEvent() + //娉ㄥ唽鎵归噺閰嶇疆浜嬩欢 + private void RegistBulkSetEvents() { - if (_hydroInfo == null) + //姘村簱 + this.barBtnSetReservoirList.ItemClick += delegate { - return; - } - var elementIds = new List<string>(); - var pumps = _hydroInfo.Pumps?.Where(x => x.LinkStatus == Yw.Hydro.PumpStatus.Open).ToList(); - pumps?.ForEach(x => elementIds.Add(x.Code)); - var valves = _hydroInfo.Valves?.Where(x => x.LinkStatus == Yw.Hydro.ValveStatus.Open).ToList(); - valves?.ForEach(x => elementIds.Add(x.Code)); - await this.xhsProjectSimulationBimfaceCtrl1.SetOpenComponentsColor(elementIds); - } - - //bimface 姘村姏鐐瑰嚮浜嬩欢 - private void xhsProjectSimulationBimfaceCtrl1_HydroClickEvent(Yw.Model.HydroParterInfo obj) - { - if (_hydroInfo == null) + //var dlg = new HydroReservoirBulkSetListDlg(); + //dlg.ShowDialog(); + }; + //姘存睜 + this.barBtnSetTankList.ItemClick += delegate { - return; - } - _parter = obj; - ShowProperty(); - SetBimfaceLinkColor(); - } - - //璁剧疆Bimface杩炴帴棰滆壊 - private async void SetBimfaceLinkColor() - { - if (_hydroInfo == null) + //var dlg = new HydroTankBulkSetListDlg(); + //dlg.ShowDialog(); + }; + //姘寸 + this.barBtnSetWaterboxList.ItemClick += delegate { - return; - } - List<string> elementIds = null; - if (_parter != null) - { - if (_parter is Yw.Model.HydroLinkInfo linker) + if (_hydroInfo == null) { - elementIds = new List<string>() { linker.StartCode, linker.EndCode }; + return; } - } - await this.xhsProjectSimulationBimfaceCtrl1.SetLinkComponentsColor(elementIds); - } - - #endregion Bimface - - #region 灞炴�ч潰鏉� - - - - #endregion - - #region 鑷姩鍖归厤 - - //鑷姩鍖归厤 - private void barBtnMatchingList_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.docPnlMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; - this.docPnlUnMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Hidden; - - var input = AssetsMatchingParasHelper.Create(_hydroInfo); - this.xhsProjectSimulationMatchingListCtrl1.SetBindingData(input); - this.docPnlMatchingList.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; - this.docPnlMatchingList.Height = 350; - } - - //姘村姏淇℃伅鐐瑰嚮 - private async void xhsProjectSimulationMatchingListCtrl1_HydroClickEvent(string code) - { - if (_hydroInfo == null) - { - return; - } - var allParterList = _hydroInfo.GetAllParters(); - _parter = allParterList.Find(x => x.Code == code); - var elementIds = new List<string>() { _parter.Code }; - await this.xhsProjectSimulationBimfaceCtrl1.ZoomAndSelectComponents(elementIds); - ShowProperty(); - SetBimfaceLinkColor(); - } - - //搴旂敤鍖归厤浜嬩欢 - private bool xhsProjectSimulationMatchingListCtrl1_ApplyMatchingEvent(AssetsMatchingViewModel output) - { - return AssetsMatchingParasHelper.Apply(_hydroInfo, output); - } - - #endregion - - #region 鏈尮閰嶅垪琛� - - //鏈尮閰嶅垪琛� - 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.docPnlMatchingList.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; - } - - //鏈尮閰嶅垪琛ㄧ偣鍑讳簨浠� - private async void xhsProjectSimulationUnMatchingListCtrl1_HydroClickEvent(Yw.Model.HydroParterInfo parter) - { - var allParterList = _hydroInfo.GetAllParters(); - _parter = allParterList.Find(x => x.ID == parter.ID); - var elementIds = new List<string>() { _parter.Code }; - await this.xhsProjectSimulationBimfaceCtrl1.ZoomAndSelectComponents(elementIds); - ShowProperty(); - SetBimfaceLinkColor(); - } - - //鏈尮閰嶅垪琛ㄦ煡鐪嬫ā鍨� - private async void xhsProjectSimulationUnMatchingListCtrl1_ViewModelEvent(List<Yw.Model.HydroParterInfo> parters) - { - var codes = parters?.Select(x => x.Code).Distinct().ToList(); - await this.xhsProjectSimulationBimfaceCtrl1.ZoomAndSelectComponents(codes); - _parter = null; - ShowProperty(); - } - - #endregion - - #region 涓�閿樉闅� - - //鏄鹃殣缂栫爜鍒楄〃 - private List<string> _fastShowHideCodeList = null; - - //瑙﹀彂涓�閿樉闅� - 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; - } - } - - #endregion - - #region 姘村姏鏍¢獙 - - //姘村姏楠岃瘉 - 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; - this.docPnlMatchingList.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 async void xhsProjectSimulationHydroCheckFailedCtrl1_HydroClickEvent(string code) - { - if (_hydroInfo == null) - { - return; - } - var allParterList = _hydroInfo.GetAllParters(); - _parter = allParterList.Find(x => x.Code == code); - var elementIds = new List<string>() { _parter.Code }; - await this.xhsProjectSimulationBimfaceCtrl1.ZoomAndSelectComponents(elementIds); - ShowProperty(); - SetBimfaceLinkColor(); - } - - #endregion - - #region 淇濆瓨姘村姏淇℃伅 - - //淇濆瓨 - private async void barBtnSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) - { - 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); - TipFormHelper.ShowSucceed("淇濆瓨鎴愬姛锛�"); - } - - #endregion - - #region 鏋勪欢鏄庣粏 - - //姘村姏鏋勪欢鍒楄〃 - 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; - } - - //姘村姏鏋勪欢鏄庣粏闈㈡澘鐐瑰嚮浜嬩欢 - private async void hydroParterListCtrl1_HydroClickEvent(Yw.Model.HydroParterInfo parter) - { - var allParterList = _hydroInfo.GetAllParters(); - _parter = allParterList.Find(x => x.ID == parter.ID); - await this.xhsProjectSimulationBimfaceCtrl1.ZoomAndSelectComponents(new List<string>() { _parter.Code }); - ShowProperty(); - SetBimfaceLinkColor(); - } - - #endregion - - #region 涓氬姟鏂规硶 - - //鏄剧ず灞炴�� - private void ShowProperty() - { - if (_hydroInfo == null) - { - return; - } - if (_parter == null) - { - this.xhsProjectSimulationPropertyCtrl1.SelectParter(null); - return; - } - this.xhsProjectSimulationPropertyCtrl1.SelectParter(_parter.Code); - if (_calcuResult != null) - { - if (_calcuResult.Succeed) + var dlg = new SetHydroWaterboxListDlg(); + dlg.SetBindingData(_hydroInfo); + dlg.HydroClickEvent += async (obj) => { - var allCalcuParterList = _calcuResult.GetParterList(); - var calcuParter = allCalcuParterList.Find(x => x.Id == _parter.Code); - if (calcuParter != null) + if (obj == 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); - } + return; } + _selectedParter = obj; + await _bimfaceCtrl?.ZoomAndSelectComponent(obj.Code); + ShowProperty(); + }; + dlg.HydroChangedEvent += (obj) => + { + + }; + dlg.ShowDialog(); + }; + //杩炴帴鑺傜偣 + this.barBtnSetJunctionList.ItemClick += delegate + { + //var dlg = new HydroJunctionBulkSetListDlg(); + //dlg.ShowDialog(); + }; + //闂峰ご + this.barBtnSetBluntheadList.ItemClick += delegate + { + if (_hydroInfo == null) + { + return; } - } + var dlg = new SetHydroBluntheadListDlg(); + dlg.SetBindingData(_hydroInfo); + dlg.HydroClickEvent += async (obj) => + { + if (obj == null) + { + return; + } + _selectedParter = obj; + await _bimfaceCtrl?.ZoomAndSelectComponent(obj.Code); + ShowProperty(); + }; + dlg.HydroChangedEvent += (obj) => + { + + }; + dlg.ShowDialog(); + }; + //寮ご + this.barBtnSetElbowsList.ItemClick += delegate + { + if (_hydroInfo == null) + { + return; + } + var dlg = new SetHydroElbowListDlg(); + dlg.SetBindingData(_hydroInfo); + dlg.HydroClickEvent += async (obj) => + { + if (obj == null) + { + return; + } + _selectedParter = obj; + await _bimfaceCtrl?.ZoomAndSelectComponent(obj.Code); + ShowProperty(); + }; + dlg.HydroChangedEvent += (obj) => + { + + }; + dlg.ShowDialog(); + }; + //涓夐�� + this.barBtnSetThreelinkList.ItemClick += delegate + { + if (_hydroInfo == null) + { + return; + } + var dlg = new SetHydroThreelinkListDlg(); + dlg.SetBindingData(_hydroInfo); + dlg.ShowDialog(); + }; + //鍥涢�� + this.barBtnSetFourlinkList.ItemClick += delegate + { + if (_hydroInfo == null) + { + return; + } + var dlg = new SetHydroFourlinkListDlg(); + dlg.SetBindingData(_hydroInfo); + dlg.ShowDialog(); + }; + //姘磋〃 + this.barBtnSetMeterList.ItemClick += delegate + { + if (_hydroInfo == null) + { + return; + } + var dlg = new SetHydroMeterListDlg(); + dlg.SetBindingData(_hydroInfo); + dlg.ShowDialog(); + }; + //娴侀噺璁� + this.barBtnSetFlowmeterList.ItemClick += delegate + { + if (_hydroInfo == null) + { + return; + } + var dlg = new SetHydroFlowmeterListDlg(); + dlg.SetBindingData(_hydroInfo); + dlg.ShowDialog(); + }; + //鍘嬪姏琛� + this.barBtnSetPressmeterList.ItemClick += delegate + { + if (_hydroInfo == null) + { + return; + } + var dlg = new SetHydroPressmeterListDlg(); + dlg.SetBindingData(_hydroInfo); + dlg.ShowDialog(); + }; + //绠¢亾 + this.barBtnSetPipeList.ItemClick += delegate + { + if (_hydroInfo == null) + { + return; + } + var dlg = new SetHydroPipeListDlg(); + dlg.SetBindingData(_hydroInfo); + dlg.ShowDialog(); + }; + //姘存车 + this.barBtnSetPumpList.ItemClick += delegate + { + if (_hydroInfo == null) + { + return; + } + var dlg = new SetHydroPumpListDlg(); + dlg.SetBindingData(_hydroInfo); + dlg.ShowDialog(); + }; + //闃�闂� + this.barBtnSetValveList.ItemClick += delegate + { + if (_hydroInfo == null) + { + return; + } + var dlg = new SetHydroValveListDlg(); + dlg.SetBindingData(_hydroInfo); + dlg.ShowDialog(); + }; } - #endregion 涓氬姟鏂规硶 - - #region 閰嶇疆 //鏄剧ずRadialMenu private void barBtnSetList_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) @@ -456,12 +934,444 @@ this.rmSet.ShowPopup(MousePosition, true); } + //寮瑰嚭鍓� + private void rmSet_BeforePopup(object sender, CancelEventArgs e) + { + if (_hydroInfo == null) + { + e.Cancel = true; + return; + } + //姘村簱 + if (_hydroInfo.Reservoirs == null || _hydroInfo.Reservoirs.Count < 1) + { + this.barBtnSetReservoirList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetReservoirList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //姘存睜 + if (_hydroInfo.Tanks == null || _hydroInfo.Tanks.Count < 1) + { + this.barBtnSetTankList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetTankList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //姘寸 + if (_hydroInfo.Waterboxs == null || _hydroInfo.Waterboxs.Count < 1) + { + this.barBtnSetWaterboxList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetWaterboxList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //杩炴帴鑺傜偣 + if (_hydroInfo.Junctions == null || _hydroInfo.Junctions.Count < 1) + { + this.barBtnSetJunctionList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetJunctionList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //鍠峰槾 + if (_hydroInfo.Nozzles == null || _hydroInfo.Nozzles.Count < 1) + { + this.barBtnSetNozzleList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetNozzleList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //娑堢伀鏍� + if (_hydroInfo.Hydrants == null || _hydroInfo.Hydrants.Count < 1) + { + this.barBtnSetHydrantList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetHydrantList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //闂峰ご + if (_hydroInfo.Bluntheads == null || _hydroInfo.Bluntheads.Count < 1) + { + this.barBtnSetBluntheadList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetBluntheadList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //寮ご + if (_hydroInfo.Elbows == null || _hydroInfo.Elbows.Count < 1) + { + this.barBtnSetElbowsList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetElbowsList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //涓夐�� + if (_hydroInfo.Threelinks == null || _hydroInfo.Threelinks.Count < 1) + { + this.barBtnSetThreelinkList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetThreelinkList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //鍥涢�� + if (_hydroInfo.Fourlinks == null || _hydroInfo.Fourlinks.Count < 1) + { + this.barBtnSetFourlinkList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetFourlinkList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //姘磋〃 + if (_hydroInfo.Meters == null || _hydroInfo.Meters.Count < 1) + { + this.barBtnSetMeterList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetMeterList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //娴侀噺璁� + if (_hydroInfo.Flowmeters == null || _hydroInfo.Flowmeters.Count < 1) + { + this.barBtnSetFlowmeterList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetFlowmeterList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //鍘嬪姏琛� + if (_hydroInfo.Pressmeters == null || _hydroInfo.Pressmeters.Count < 1) + { + this.barBtnSetPressmeterList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetPressmeterList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //绠¢亾 + if (_hydroInfo.Pipes == null || _hydroInfo.Pipes.Count < 1) + { + this.barBtnSetPipeList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetPipeList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //杩囨浮浠� + if (_hydroInfo.Translations == null || _hydroInfo.Translations.Count < 1) + { + this.barBtnSetTranslationList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetTranslationList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //鎹㈢儹鍣� + if (_hydroInfo.Exchangers == null || _hydroInfo.Exchangers.Count < 1) + { + this.barBtnSetExchangerList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetExchangerList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //绌哄帇鏈� + if (_hydroInfo.Compressors == null || _hydroInfo.Compressors.Count < 1) + { + this.barBtnSetCompressorList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetCompressorList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //姘存车 + if (_hydroInfo.Pumps == null || _hydroInfo.Pumps.Count < 1) + { + this.barBtnSetPumpList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetPumpList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + //闃�闂� + if (_hydroInfo.Valves == null || _hydroInfo.Valves.Count < 1) + { + this.barBtnSetValveList.Visibility = DevExpress.XtraBars.BarItemVisibility.Never; + } + else + { + this.barBtnSetValveList.Visibility = DevExpress.XtraBars.BarItemVisibility.Always; + } + + } + #endregion - #region 鎬ц兘鏇茬嚎 + #region 骞惰仈鍒嗘瀽 + + //骞惰仈鍒嗘瀽 + private void barBtnAnaly_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (_hydroInfo == null) + { + return; + } + if (_hydroInfo.Pumps == null || _hydroInfo.Pumps.Count < 1) + { + return; + } + var allCalcuResultList = GetCalcuResultList(); + var vmList = new List<XhsSinglePumpViewModel>(); + foreach (var pump in _hydroInfo.Pumps) + { + if (!pump.RatedN.HasValue) + { + continue; + } + var qh = _hydroInfo.Curves?.Find(t => t.Code == pump.CurveQH)?.CurveData; + var qe = _hydroInfo.Curves?.Find(t => t.Code == pump.CurveQE)?.CurveData; + var qp = _hydroInfo.Curves?.Find(t => t.Code == pump.CurveQP)?.CurveData; + if (qh == null) + { + continue; + } + + var qhPtList = qh.Select(x => new XhsSplinePointViewModel(x.X, x.Y)).ToList(); + var qePtList = qe?.Select(x => new XhsSplinePointViewModel(x.X, x.Y)).ToList(); + var qpPtList = qp?.Select(x => new XhsSplinePointViewModel(x.X, x.Y)).ToList(); + + var vm = new XhsSinglePumpViewModel(); + vmList.Add(vm); + vm.ID = pump.ID; + vm.Name = pump.Name; + vm.Code = pump.Code; + vm.IsBp = true; + vm.RunStatus = pump.LinkStatus == Yw.Hydro.LinkStatus.Open; + vm.RatedHz = pump.RatedHz; + vm.CurrentHz = Math.Round(pump.RatedHz * pump.SpeedRatio, 1); + vm.RatedSpeed = pump.RatedN.Value; + vm.CurrentSpeed = Math.Round(pump.RatedN.Value * pump.SpeedRatio); + vm.CurveQH = qhPtList; + vm.CurveQE = qePtList; + vm.CurveQP = qpPtList; + + if (allCalcuResultList != null && allCalcuResultList.Count > 0) + { + var calcuResult = allCalcuResultList.Find(x => x.Code == pump.Code) as HydroCalcuLinkResult; + if (calcuResult != null) + { + if (calcuResult.CalcuFlow.HasValue) + { + vm.CalcuQ = Math.Abs(calcuResult.CalcuFlow.Value); + } + + var calcuResultStart = allCalcuResultList.Find(x => x.Code == pump.StartCode) as HydroCalcuNodeResult; + var calcuResultEnd = allCalcuResultList.Find(x => x.Code == pump.EndCode) as HydroCalcuNodeResult; + if (calcuResultStart != null && calcuResultEnd != null) + { + if (calcuResultStart.CalcuHead.HasValue && calcuResultEnd.CalcuHead.HasValue) + { + vm.CalcuH = Math.Round(Math.Abs(calcuResultStart.CalcuHead.Value - calcuResultEnd.CalcuHead.Value), 4); + } + } + } + } + + } + + var dlg = new PumpParallelAnalyDlg(); + dlg.SetBindingData(vmList); + dlg.ReloadDataEvent += (list) => + { + list?.ForEach(x => + { + var pump = _hydroInfo.Pumps?.Find(t => t.Code == x.Code); + if (pump != null) + { + pump.LinkStatus = x.RunStatus ? Yw.Hydro.PumpStatus.Open : Yw.Hydro.PumpStatus.Closed; + pump.SpeedRatio = Math.Round(x.CurrentHz / pump.RatedHz, 1); + } + }); + ShowProperty(); + return true; + }; + dlg.ShowDialog(); + } + + #endregion + + #region 姘村姏璁$畻 - private void barBtnFeatCurve_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + #region 鍓嶆彁鏉′欢 + + //鏄剧ず璁$畻鍓嶆彁鏉′欢绐椾綋 + private void ShowCalcuPrefixDlg() + { + if (_hydroInfo == null) + { + return; + } + var dlg = new HStation.WinFrmUI.SetHydroCalcuPrefixDlg1(); + dlg.SetBindingData(_hydroInfo); + dlg.HydroViewEvent += async (parter) => + { + _selectedParter = parter; + if (_selectedParter != null) + { + await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _selectedParter.Code }); + } + ShowProperty(); + }; + dlg.HydroCalcuEvent += async () => + { + if (_hydroInfo == null) + { + return; + } + + //鏍¢獙 + _checkResult = _hydroInfo.Check(); + if (!_checkResult.Succeed) + { + ShowCheckCtrl(); + TipFormHelper.ShowWarn("鏍¢獙澶辫触锛岃妫�鏌ュ悗閲嶈瘯"); + return; + } + + WaitFormHelper.ShowWaitForm(this, "姝e湪璁$畻鍒嗘瀽涓紝璇风◢鍊�..."); + + + //await Task.Delay(5000); + + var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); + _calcuResult = netWork.Calcu(); + + WaitFormHelper.HideWaitForm(); + if (_calcuResult.Succeed) + { + GetCalcuResultList(false); + await _bimfaceCtrl?.SetLogicCalcuCustomLabels(_calcuResult); + TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�"); + } + else + { + ShowCalcuFailedCtrl(); + TipFormHelper.ShowError("璁$畻澶辫触锛�"); + } + + }; + dlg.ShowDialog(); + } + + //鏄剧ず宸ュ喌璁$畻绐椾綋 + private void ShowWorkingCalcuDlg() + { + var dlg = new SetHydroWorkingInfoDlg(); + dlg.HydroViewEvent += async (parter) => + { + _selectedParter = parter; + if (_selectedParter != null) + { + await _bimfaceCtrl?.ZoomAndSelectComponents(new List<string>() { _selectedParter.Code }); + } + ShowProperty(); + }; + dlg.HydroCalcuEvent += async (hydroInfo, workingInfo) => + { + if (_hydroInfo == null) + { + return; + } + _hydroInfo.UpdateWorkingInfo(workingInfo); + //鏍¢獙 + _checkResult = _hydroInfo.Check(); + if (!_checkResult.Succeed) + { + ShowCheckCtrl(); + TipFormHelper.ShowWarn("鏍¢獙澶辫触锛岃妫�鏌ュ悗閲嶈瘯"); + return; + } + + WaitFormHelper.ShowWaitForm(this, "姝e湪璁$畻鍒嗘瀽涓紝璇风◢鍊�..."); + + + await Task.Delay(5000); + + var netWork = Yw.Hydro.ParseHelper.ToNetwork(_hydroInfo); + _calcuResult = netWork.Calcu(); + + WaitFormHelper.HideWaitForm(); + if (_calcuResult.Succeed) + { + GetCalcuResultList(false); + await _bimfaceCtrl?.SetLogicCalcuCustomLabels(_calcuResult); + TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�"); + var codes = _hydroInfo.Pumps.Select(x => x.Code).ToList(); + await _bimfaceCtrl?.ZoomAndSelectComponents(codes); + } + else + { + ShowCalcuFailedCtrl(); + TipFormHelper.ShowError("璁$畻澶辫触锛�"); + } + AutoApplyGrading(); + UpdateParterListProperty(); + ShowProperty(); + }; + dlg.SetBindingData(_hydroInfo); + dlg.ShowDialog(); + } + + #endregion + + #region 璁$畻澶辫触 + + //璁$畻澶辫触鎺т欢 + private HydroCalcuFailedCtrl _calcuFailedCtrl = null; + + //鑾峰彇璁$畻澶辫触鎺т欢 + private HydroCalcuFailedCtrl GetCalcuFailedCtrl() + { + if (_calcuFailedCtrl == null) + { + _calcuFailedCtrl = new HydroCalcuFailedCtrl(); + _calcuFailedCtrl.Dock = DockStyle.Fill; + } + return _calcuFailedCtrl; + } + + //鏄剧ず璁$畻澶辫触鎺т欢 + private void ShowCalcuFailedCtrl() { if (_hydroInfo == null) { @@ -471,25 +1381,1954 @@ { return; } - if (!_calcuResult.Succeed) + if (_calcuResult.Succeed) { return; } - var pumps = _hydroInfo.Pumps; - var vmList = pumps.Select(x => new HStation.WinFrmUI.PhartRelation.Perform2dMultiViewModel() - { - Id = x.Code, - Name = x.Code, - SpeedRatio = x.SpeedRatio ?? 1, - PointsQH = _hydroInfo.Curves?.Find(t => t.Code == x.CurveQH)?.CurveData?.Select(z => new PhartRelation.PerformPoint2dViewModel() { X = z.X, Y = z.Y }).ToList(), - PointsQP = _hydroInfo.Curves?.Find(t => t.Code == x.CurveQP)?.CurveData?.Select(z => new PhartRelation.PerformPoint2dViewModel() { X = z.X, Y = z.Y }).ToList(), - PointsQE = _hydroInfo.Curves?.Find(t => t.Code == x.CurveQE)?.CurveData?.Select(z => new PhartRelation.PerformPoint2dViewModel() { X = z.X, Y = z.Y }).ToList(), - }).ToList(); - var dlg = new HStation.WinFrmUI.PhartRelation.XtrPerform2dMultiViewDlg(); - dlg.SetBindingData(vmList, false, true); - dlg.ShowDialog(); + var calcuFailedCtrl = GetCalcuFailedCtrl(); + calcuFailedCtrl.SetBindingData(_calcuResult.FailedList); + this.controlContainerBottom.Controls.Clear(); + this.controlContainerBottom.Controls.Add(calcuFailedCtrl); + this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; + this.docPnlBottom.Text = "璁$畻澶辫触鍘熷洜"; + this.docPnlBottom.Height = 350; } #endregion + + #region 璁$畻缁撴灉 + + //鎵�鏈夎绠楃粨鏋滃垪琛� + private List<HydroCalcuResult> _allCalcuResultList = null; + + //鑾峰彇璁$畻缁撴灉 + //true 浣跨敤缂撳瓨锛宖alse 涓嶄娇鐢ㄧ紦瀛� + private List<HydroCalcuResult> GetCalcuResultList(bool isCache = true) + { + if (_hydroInfo == null) + { + return default; + } + if (_calcuResult == null) + { + return default; + } + if (!_calcuResult.Succeed) + { + return default; + } + if (isCache) + { + return _allCalcuResultList; + } + + _allCalcuResultList = new List<HydroCalcuResult>(); + + //鑺傜偣 + var allNodeList = _hydroInfo.GetAllNodes(); + if (allNodeList != null && allNodeList.Count > 0) + { + foreach (var node in allNodeList) + { + var calcuNode = _calcuResult.NodeList?.Find(x => x.Id == node.Code); + if (calcuNode != null) + { + var calcuResult = new HydroCalcuNodeResult() + { + Code = node.Code, + CalcuPress = calcuNode.Press, + CalcuHead = calcuNode.Head, + CalcuDemand = calcuNode.Demand + }; + _allCalcuResultList.Add(calcuResult); + } + } + } + + //绠℃ + var allLinkList = _hydroInfo.GetAllLinks(); + if (allLinkList != null && allLinkList.Count > 0) + { + foreach (var link in allLinkList) + { + var calcuLink = _calcuResult.LinkList?.Find(x => x.Id == link.Code); + if (calcuLink != null) + { + var calcuResult = new HydroCalcuLinkResult() + { + Code = link.Code, + CalcuFlow = calcuLink.Flow, + CalcuVelocity = calcuLink.Velocity, + CalcuHeadLoss = calcuLink.Headloss + }; + _allCalcuResultList.Add(calcuResult); + } + } + } + + //娴侀噺璁� + var allFlowmeterList = _hydroInfo.Flowmeters; + if (allFlowmeterList != null && allFlowmeterList.Count > 0) + { + foreach (var flowmeter in allFlowmeterList) + { + var calcuFlowmeterResult = _allCalcuResultList.Find(x => x.Code == flowmeter.Code) as HydroCalcuNodeResult; + if (calcuFlowmeterResult != null) + { + var calcuFlowmeterNewResult = new HydroCalcuFlowmeterResult(calcuFlowmeterResult); + var calcuFlowmeterLinkResultList = new List<HydroCalcuLinkResult>(); + var flowmeterLinkList = allLinkList?.Where(x => x.StartCode == flowmeter.Code || x.EndCode == flowmeter.Code).ToList(); + if (flowmeterLinkList != null && flowmeterLinkList.Count > 0) + { + foreach (var flowmeterLink in flowmeterLinkList) + { + var calcuFlowmeterLinkResult = _allCalcuResultList.Find(x => x.Code == flowmeterLink.Code) as HydroCalcuLinkResult; + if (calcuFlowmeterLinkResult != null) + { + calcuFlowmeterLinkResultList.Add(calcuFlowmeterLinkResult); + } + } + } + if (calcuFlowmeterLinkResultList.Exists(x => x.CalcuFlow.HasValue)) + { + calcuFlowmeterNewResult.CalcuQ = calcuFlowmeterLinkResultList.Where(x => x.CalcuFlow.HasValue).Average(x => x.CalcuFlow.Value); + } + _allCalcuResultList.Remove(calcuFlowmeterResult); + _allCalcuResultList.Add(calcuFlowmeterNewResult); + } + } + } + + //鍘嬪姏琛� + var allPressmeterList = _hydroInfo.Pressmeters; + if (allPressmeterList != null && allPressmeterList.Count > 0) + { + foreach (var pressmeter in allPressmeterList) + { + var calcuPressmeterResult = _allCalcuResultList.Find(x => x.Code == pressmeter.Code) as HydroCalcuNodeResult; + if (calcuPressmeterResult != null) + { + var calcuPressmeterNewResult = new HydroCalcuPressmeterResult(calcuPressmeterResult); + calcuPressmeterNewResult.CalcuPr = calcuPressmeterResult.CalcuPress; + _allCalcuResultList.Remove(calcuPressmeterResult); + _allCalcuResultList.Add(calcuPressmeterNewResult); + } + } + } + + //姘存车 + var allPumpList = _hydroInfo.Pumps; + if (allPumpList != null && allPumpList.Count > 0) + { + foreach (var pump in allPumpList) + { + var calcuPumpResult = _allCalcuResultList.Find(x => x.Code == pump.Code) as HydroCalcuLinkResult; + if (calcuPumpResult != null) + { + var calcuPumpNewResult = new HydroCalcuPumpResult(calcuPumpResult); + calcuPumpNewResult.CalcuQ = calcuPumpResult.CalcuFlow; + if (calcuPumpNewResult.CalcuQ.HasValue) + { + var calcuNodeStartResult = _allCalcuResultList.Find(x => x.Code == pump.StartCode) as HydroCalcuNodeResult; + var calcuNodeEndResult = _allCalcuResultList.Find(x => x.Code == pump.EndCode) as HydroCalcuNodeResult; + if (calcuNodeStartResult != null && calcuNodeEndResult != null) + { + if (calcuNodeStartResult.CalcuPress.HasValue && calcuNodeEndResult.CalcuPress.HasValue) + { + calcuPumpNewResult.CalcuH = Math.Abs(calcuNodeStartResult.CalcuPress.Value - calcuNodeEndResult.CalcuPress.Value); + } + if (pump.LinkStatus == Yw.Hydro.PumpStatus.Open && pump.RatedN.HasValue) + { + var curveqp = _hydroInfo.Curves?.Find(x => x.Code == pump.CurveQP); + if (curveqp != null) + { + if (curveqp.CurveData != null && curveqp.CurveData.Count > 3) + { + var point2dList = curveqp.CurveData.Select(x => new Yw.Geometry.Point2d(x.X, x.Y)).ToList(); + var point2dSimularList = point2dList.GetQPPointListByN(pump.RatedN.Value, pump.RatedN.Value * pump.SpeedRatio); + var pumpCurveQp = new Yw.Pump.CurveQP(eFeatType.Cubic, point2dSimularList); + calcuPumpNewResult.CalcuP = pumpCurveQp.FeatCurve.GetPointY(calcuPumpNewResult.CalcuQ.Value); + } + } + } + if (calcuPumpNewResult.CalcuH.HasValue && calcuPumpNewResult.CalcuP.HasValue) + { + calcuPumpNewResult.CalcuE = Yw.Pump.CalculationHelper.CalcuE(calcuPumpNewResult.CalcuQ.Value, calcuPumpNewResult.CalcuH.Value, calcuPumpNewResult.CalcuP.Value); + } + } + } + _allCalcuResultList.Remove(calcuPumpResult); + _allCalcuResultList.Add(calcuPumpNewResult); + } + } + } + + return _allCalcuResultList; + } + + #endregion + + //姘村姏璁$畻 + private void barBtnHydroCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + //ShowCalcuPrefixDlg(); + ShowWorkingCalcuDlg(); + } + + #endregion + + #region 鏋勪欢鏌ヨ + + //鏌ヨ缁勪欢 + private HydroParterSearchListCtrl _searchCtrl = null; + + //鑾峰彇鏌ヨ缁勪欢 + private HydroParterSearchListCtrl GetSearchCtrl() + { + if (_searchCtrl == null) + { + _searchCtrl = new HydroParterSearchListCtrl(); + _searchCtrl.Dock = DockStyle.Fill; + _searchCtrl.InitialData(() => _hydroInfo); + _searchCtrl.HydroClickEvent += async (parter) => + { + if (_hydroInfo == null) + { + return; + } + if (parter == null) + { + return; + } + _selectedParter = parter; + await _bimfaceCtrl?.ZoomAndSelectComponent(parter.Code); + ShowProperty(); + }; + _searchCtrl.HydroSearchEvent += async (list) => + { + if (_hydroInfo == null) + { + return; + } + var elementIds = new List<string>(); + if (list != null && list.Count > 0) + { + _selectedParter = list.First(); + list.ForEach(x => elementIds.Add(x.Code)); + } + else + { + _selectedParter = null; + } + await _bimfaceCtrl?.ZoomAndSelectComponents(elementIds); + ShowProperty(); + }; + } + return _searchCtrl; + } + + //鏄剧ず鏌ヨ鎺т欢 + private void ShowSearchCtrl(string content) + { + if (_hydroInfo == null) + { + return; + } + var searchCtrl = GetSearchCtrl(); + searchCtrl.SetBindingData(content); + this.controlContainerBottom.Controls.Clear(); + this.controlContainerBottom.Controls.Add(searchCtrl); + this.docPnlBottom.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible; + this.docPnlBottom.Text = "鏋勪欢鏌ヨ"; + this.docPnlBottom.Height = 350; + } + + //鏄剧ず鏌ヨ绐椾綋 + private void ShowSearchDlg() + { + if (this.docPnlBottom.Visibility == DevExpress.XtraBars.Docking.DockVisibility.Visible) + { + if (this.controlContainerBottom.Controls.Count > 0) + { + if (this.controlContainerBottom.Controls[0] is HydroParterSearchListCtrl) + { + return; + } + } + } + var dlg = new InputHydroParterSearchListDlg(); + dlg.SearchEvent += (content) => + { + if (string.IsNullOrEmpty(content)) + { + return; + } + ShowSearchCtrl(content); + }; + dlg.SetBindingData(); + dlg.ShowDialog(); + } + + //鏌ヨ + private void barBtnSearch_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + ShowSearchDlg(); + } + + #endregion + + #region 妯″瀷鏍囨敞 + + //鎵�鏈夋爣娉ㄨ缃垪琛� + private List<HydroMarkSetViewModel> _allMarkSetList = null; + + //鑾峰彇鏍囨敞璁剧疆鍒楄〃 + private List<HydroMarkSetViewModel> GetMarkSetList() + { + if (_allMarkSetList == null) + { + _allMarkSetList = new List<HydroMarkSetViewModel>(); + if (_hydroInfo.Waterboxs != null && _hydroInfo.Waterboxs.Count > 0) + { + _allMarkSetList.Add(new HydroMarkSetViewModel() + { + Code = Yw.Hydro.ParterCatalog.Waterbox, + Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Waterbox), + MarkType = (int)eWaterboxMarkType.None + }); + } + if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0) + { + _allMarkSetList.Add(new HydroMarkSetViewModel() + { + Code = Yw.Hydro.ParterCatalog.Pump, + Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pump), + MarkType = (int)eWaterboxMarkType.None + }); + } + if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0) + { + _allMarkSetList.Add(new HydroMarkSetViewModel() + { + Code = Yw.Hydro.ParterCatalog.Valve, + Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Valve), + MarkType = (int)eWaterboxMarkType.None + }); + } + if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0) + { + _allMarkSetList.Add(new HydroMarkSetViewModel() + { + Code = Yw.Hydro.ParterCatalog.Pipe, + Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pipe), + MarkType = (int)eWaterboxMarkType.None + }); + } + if (_hydroInfo.Nozzles != null && _hydroInfo.Nozzles.Count > 0) + { + _allMarkSetList.Add(new HydroMarkSetViewModel() + { + Code = Yw.Hydro.ParterCatalog.Nozzle, + Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Nozzle), + MarkType = (int)eWaterboxMarkType.None + }); + } + } + return _allMarkSetList; + } + + //鎵�鏈夋爣娉ㄧ粨鏋滃垪琛� + private List<HydroMarkResultViewModel> _allMarkResultList = null; + + //鑾峰彇鏍囨敞缁撴灉鍒楄〃 + private List<HydroMarkResultViewModel> GetMarkResultList() + { + if (_hydroInfo == null) + { + return default; + } + _allMarkResultList = new List<HydroMarkResultViewModel>(); + var allMarkSetList = GetMarkSetList(); + foreach (var markSet in allMarkSetList) + { + switch (markSet.Code) + { + case Yw.Hydro.ParterCatalog.Waterbox: + { + if (_hydroInfo.Waterboxs != null && _hydroInfo.Waterboxs.Count > 0) + { + switch ((eWaterboxMarkType)markSet.MarkType) + { + case eWaterboxMarkType.None: + { + + } + break; + case eWaterboxMarkType.PoolElev: + { + _hydroInfo.Waterboxs.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"姹犲簳鏍囬珮:{Math.Round(t.PoolElev, 4)}m" + }); + }); + } + break; + case eWaterboxMarkType.InitLevel: + { + _hydroInfo.Waterboxs.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"鍒濆姘翠綅:{Math.Round(t.InitLevel, 4)}m" + }); + }); + } + break; + case eWaterboxMarkType.MinLevel: + { + _hydroInfo.Waterboxs.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"鏈�灏忔按浣�:{Math.Round(t.MinLevel, 4)}m" + }); + }); + } + break; + case eWaterboxMarkType.MaxLevel: + { + _hydroInfo.Waterboxs.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"鏈�楂樻按浣�:{Math.Round(t.MaxLevel, 4)}m" + }); + }); + } + break; + case eWaterboxMarkType.DN: + { + _hydroInfo.Waterboxs.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"鐩村緞:{Math.Round(t.DN, 4)}m" + }); + }); + } + break; + case eWaterboxMarkType.MinVol: + { + _hydroInfo.Waterboxs.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"鏈�灏忓绉�:{Math.Round(t.MinVol, 1)}m" + }); + }); + } + break; + default: break; + } + } + } + break; + case Yw.Hydro.ParterCatalog.Pump: + { + if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0) + { + switch ((ePumpMarkType)markSet.MarkType) + { + case ePumpMarkType.None: + { + + } + break; + case ePumpMarkType.PumpStatus: + { + _hydroInfo.Pumps.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"寮�鏈虹姸鎬�:{Yw.WinFrmUI.HydroLinkStatusHelper.GetStatusName(t.LinkStatus)}" + }); + }); + } + break; + case ePumpMarkType.RatedP: + { + _hydroInfo.Pumps.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"棰濆畾鍔熺巼:{t.RatedP}kW" + }); + }); + } + break; + case ePumpMarkType.RatedQ: + { + _hydroInfo.Pumps.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"棰濆畾娴侀噺:{t.RatedQ}m鲁/h" + }); + }); + } + break; + case ePumpMarkType.RatedH: + { + _hydroInfo.Pumps.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"棰濆畾鎵▼:{t.RatedH}m" + }); + }); + } + break; + case ePumpMarkType.RatedN: + { + _hydroInfo.Pumps.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"棰濆畾杞��:{t.RatedN}r/min" + }); + }); + } + break; + case ePumpMarkType.RatedHz: + { + _hydroInfo.Pumps.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"棰濆畾棰戠巼:{t.RatedHz}" + }); + }); + } + break; + case ePumpMarkType.CurrentN: + { + _hydroInfo.Pumps.ForEach(t => + { + if (t.RatedN.HasValue) + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"璁惧畾杞��:{Math.Round(t.RatedN.Value * t.SpeedRatio, 1)}r/min" + }); + } + }); + } + break; + case ePumpMarkType.CurrentHz: + { + _hydroInfo.Pumps.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"璁惧畾棰戠巼:{Math.Round(t.RatedHz * t.SpeedRatio, 1)}hz" + }); + }); + } + break; + default: break; + } + } + } + break; + case Yw.Hydro.ParterCatalog.Valve: + { + if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0) + { + switch ((eValveMarkType)markSet.MarkType) + { + case eValveMarkType.None: + { + + } + break; + case eValveMarkType.ValveStatus: + { + _hydroInfo.Valves.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"闃�闂ㄧ姸鎬�:{HydroLinkStatusHelper.GetStatusName(t.LinkStatus)}" + }); + }); + } + break; + case eValveMarkType.ValveType: + { + _hydroInfo.Valves.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"闃�闂ㄧ被鍨�:{HydroValveTypeHelper.GetTypeName(t.ValveType)}" + }); + }); + } + break; + case eValveMarkType.Diameter: + { + _hydroInfo.Valves.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"鐩村緞:{t.Diameter}mm" + }); + }); + } + break; + case eValveMarkType.MinorLoss: + { + _hydroInfo.Valves.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"灞�闃荤郴鏁�:{t.MinorLoss}" + }); + }); + } + break; + default: break; + } + } + } + break; + case Yw.Hydro.ParterCatalog.Pipe: + { + if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0) + { + switch ((ePipeMarkType)markSet.MarkType) + { + case ePipeMarkType.None: + { + + } + break; + case ePipeMarkType.PipeStatus: + { + _hydroInfo.Pipes.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"鐘舵��:{Yw.WinFrmUI.HydroLinkStatusHelper.GetStatusName(t.LinkStatus)}" + }); + }); + } + break; + case ePipeMarkType.Diameter: + { + _hydroInfo.Pipes.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"鐩村緞:{t.Diameter}mm" + }); + }); + } + break; + case ePipeMarkType.Length: + { + _hydroInfo.Pipes.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"闀垮害:{t.Length}m" + }); + }); + } + break; + case ePipeMarkType.Roughness: + { + _hydroInfo.Pipes.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"绮楃硻绯绘暟:{t.Roughness}" + }); + }); + } + break; + case ePipeMarkType.MinorLoss: + { + _hydroInfo.Pipes.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"灞�闃荤郴鏁�:{t.MinorLoss}" + }); + }); + } + break; + default: break; + } + } + } + break; + case Yw.Hydro.ParterCatalog.Nozzle: + { + if (_hydroInfo.Nozzles != null && _hydroInfo.Nozzles.Count > 0) + { + switch ((eNozzleMarkType)markSet.MarkType) + { + case eNozzleMarkType.None: + { + + } + break; + case eNozzleMarkType.Elev: + { + _hydroInfo.Nozzles.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"鏍囬珮:{Math.Round(t.Elev, 4)}m" + }); + }); + } + break; + case eNozzleMarkType.Demand: + { + _hydroInfo.Nozzles.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"闇�姘撮噺:{t.Demand}m鲁/h" + }); + }); + } + break; + case eNozzleMarkType.Coefficient: + { + _hydroInfo.Nozzles.ForEach(t => + { + _allMarkResultList.Add(new HydroMarkResultViewModel() + { + Code = t.Code, + Text = $"鍠峰皠绯绘暟:{t.Coefficient}" + }); + }); + } + break; + default: break; + } + } + } + break; + default: break; + } + } + return _allMarkResultList; + } + + //搴旂敤鏍囨敞缁撴灉鍒楄〃 + private async Task ApplyMarkResultList() + { + var allMarkResultList = GetMarkResultList(); + var leadLabels = allMarkResultList?.Select(x => new LogicMarkLeadLabel(x.Code, x.Text, 100000)).ToList(); + await _bimfaceCtrl?.SetLogicMarkLeadLabels(leadLabels); + TipFormHelper.ShowSucceed("鏍囨敞淇℃伅宸茶缃�"); + } + + //娓呴櫎鏍囨敞缁撴灉鍒楄〃 + private async Task ClearMarkResultList() + { + if (_allMarkResultList == null || _allMarkResultList.Count < 1) + { + TipFormHelper.ShowWarn("灏氭湭璁剧疆鏍囨敞淇℃伅"); + return; + } + _allMarkResultList = null; + await _bimfaceCtrl?.ClearLogicMarkLeadLabels(); + TipFormHelper.ShowSucceed("鏍囨敞淇℃伅宸叉竻闄�"); + } + + //鏄剧ず鏍囨敞璁剧疆绐椾綋 + private void ShowMarkSetDlg() + { + if (_hydroInfo == null) + { + return; + } + var allMarkSetList = GetMarkSetList(); + var dlg = new SetHydroMarkDlg(); + dlg.SetBindingData(allMarkSetList); + dlg.ReloadDataEvent += async (list) => + { + _allMarkSetList = list; + await ApplyMarkResultList(); + }; + dlg.ShowDialog(); + } + + //璁剧疆鏍囨敞 + private void barBtnSetMark_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + ShowMarkSetDlg(); + } + + //娓呴櫎鏍囨敞 + private async void barBtnClearMark_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + await ClearMarkResultList(); + } + + #endregion + + #region 棰滆壊鍒嗙骇 + + #region 棰滆壊閰嶇疆 + + //鎵�鏈夊垎绾у垪琛� + private List<HydroGradingVmo> _allGradingList = null; + + //鑾峰彇鍒嗙骇鍒楄〃 + private async Task<List<HydroGradingVmo>> GetGradingList() + { + if (_hydroInfo == null) + { + return default; + } + if (_allGradingList == null) + { + _allGradingList = await BLLFactory<Yw.BLL.HydroGrading>.Instance.GetByModelID(_hydroInfo.ID); + if (_allGradingList == null || _allGradingList.Count < 1) + { + var config = Yw.Settings.HydroParasHelper.Hydro.Grading; + if (config != null && config.Items != null && config.Items.Count > 0) + { + _allGradingList = new List<HydroGradingVmo>(); + config.Items.ForEach(x => + { + var vmo = new HydroGradingVmo() + { + ModelID = _hydroInfo.ID, + Catalog = x.Catalog, + PropName = x.PropName, + SetValue = x.SetValue, + MinValue = x.MinValue, + MaxValue = x.MaxValue, + Color = x.Color, + SortCode = config.Items.IndexOf(x) + }; + _allGradingList.Add(vmo); + }); + } + } + } + return _allGradingList; + } + + //鏄剧ず閰嶇疆棰滆壊鍒嗙骇绐椾綋 + private async void ShowSetGradingDlg() + { + if (_hydroInfo == null) + { + return; + } + var allGradingList = await GetGradingList(); + var dlg = new SetHydroGradingTreeDlg(); + dlg.SetBindingData(_hydroInfo, allGradingList); + dlg.ReloadDataEvent += (list) => + { + _allGradingList = list; + }; + dlg.ApplyDataEvent += (catalog, propName) => + { + ApplyGrading(catalog, propName); + }; + dlg.ShowDialog(); + } + + //閰嶇疆棰滆壊鍒嗙骇 + private void barBtnGradingSet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + ShowSetGradingDlg(); + } + + #endregion + + #region 搴旂敤鍒嗙骇 + + //棰滆壊鍒嗙骇搴旂敤鍒楄〃 + private List<HydroGradingApplyViewModel> _allGradingApplyList = null; + + //鑾峰彇棰滆壊鍒嗙骇搴旂敤鍒楄〃 + private List<HydroGradingApplyViewModel> GetGradingApplyList() + { + if (_allGradingApplyList == null) + { + _allGradingApplyList = new List<HydroGradingApplyViewModel>(); + + if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0) + { + _allGradingApplyList.Add(new HydroGradingApplyViewModel() + { + Code = Yw.Hydro.ParterCatalog.Pump, + Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pump), + PropName = Yw.Hydro.ParterProp.LinkStatus + }); + } + if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0) + { + _allGradingApplyList.Add(new HydroGradingApplyViewModel() + { + Code = Yw.Hydro.ParterCatalog.Valve, + Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Valve), + PropName = Yw.Hydro.ParterProp.LinkStatus + }); + } + if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0) + { + _allGradingApplyList.Add(new HydroGradingApplyViewModel() + { + Code = Yw.Hydro.ParterCatalog.Pipe, + Name = Yw.WinFrmUI.HydroParterCatalogHelper.GetCatalogName(Yw.Hydro.ParterCatalog.Pipe), + PropName = Yw.Hydro.ParterProp.CalcuFlow + }); + } + } + return _allGradingApplyList; + } + + //鑾峰彇棰滆壊鍒嗙骇搴旂敤缁撴灉鍒楄〃 + private async Task<List<HydroGradingApplyResultViewModel>> GetGradingApplyResultList() + { + if (_hydroInfo == null) + { + return default; + } + + //鎵�鏈夊垎绾у垪琛� + var allGradingList = await GetGradingList(); + if (allGradingList == null || allGradingList.Count < 1) + { + return default; + } + + //鎵�鏈夊垎绾у簲鐢ㄥ垪琛� + var allGradingApplyList = GetGradingApplyList(); + if (allGradingApplyList == null || allGradingApplyList.Count < 1) + { + return default; + } + + //鎵�鏈夎绠楃粨鏋滃垪琛� + var allCalcuResultList = GetCalcuResultList(); + + //鎵�鏈夊簲鐢ㄧ粨鏋滃垪琛� + var allGradingApplyResultList = new List<HydroGradingApplyResultViewModel>(); + allGradingApplyList.ForEach(x => + { + var allCatalogGradingList = allGradingList.Where(t => t.Catalog == x.Code).ToList(); + if (allCatalogGradingList != null || allCatalogGradingList.Count > 0) + { + switch (x.Code) + { + case Yw.Hydro.ParterCatalog.Pump: + { + if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0) + { + foreach (var pump in _hydroInfo.Pumps) + { + switch (x.PropName) + { + case Yw.Hydro.ParterProp.LinkStatus: + { + var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.LinkStatus).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var grading = gradingList.Meet(pump.LinkStatus); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pump.Code, + Color = grading.Color + }; + allGradingApplyResultList.Add(result); + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuFlow: + { + var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuFlow.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pump.Code, + Color = grading.Color + }; + allGradingApplyResultList.Add(result); + } + } + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuVelocity: + { + var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuVelocity.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pump.Code, + Color = grading.Color + }; + allGradingApplyResultList.Add(result); + } + } + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuHeadLoss: + { + var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuHeadLoss.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pump.Code, + Color = grading.Color + }; + allGradingApplyResultList.Add(result); + } + } + } + } + } + break; + default: break; + } + } + } + } + break; + case Yw.Hydro.ParterCatalog.Valve: + { + if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0) + { + foreach (var valve in _hydroInfo.Valves) + { + switch (x.PropName) + { + case Yw.Hydro.ParterProp.LinkStatus: + { + var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.LinkStatus).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var grading = gradingList.Meet(valve.LinkStatus); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = valve.Code, + Color = grading.Color + }; + allGradingApplyResultList.Add(result); + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuFlow: + { + var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuFlow.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = valve.Code, + Color = grading.Color + }; + allGradingApplyResultList.Add(result); + } + } + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuVelocity: + { + var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuVelocity.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = valve.Code, + Color = grading.Color + }; + allGradingApplyResultList.Add(result); + } + } + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuHeadLoss: + { + var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuHeadLoss.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = valve.Code, + Color = grading.Color + }; + allGradingApplyResultList.Add(result); + } + } + } + } + } + break; + default: break; + } + } + } + } + break; + case Yw.Hydro.ParterCatalog.Pipe: + { + if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0) + { + foreach (var pipe in _hydroInfo.Pipes) + { + switch (x.PropName) + { + case Yw.Hydro.ParterProp.CalcuFlow: + { + var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuFlow.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pipe.Code, + Color = grading.Color + }; + allGradingApplyResultList.Add(result); + } + } + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuVelocity: + { + var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuVelocity.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pipe.Code, + Color = grading.Color + }; + allGradingApplyResultList.Add(result); + } + } + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuHeadLoss: + { + var gradingList = allCatalogGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuHeadLoss.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pipe.Code, + Color = grading.Color + }; + allGradingApplyResultList.Add(result); + } + } + } + } + } + break; + default: break; + } + } + } + } + break; + default: break; + } + } + }); + + return allGradingApplyResultList; + } + + //鑾峰彇棰滆壊鍒嗙骇搴旂敤缁撴灉鍒楄〃 + private async Task<List<HydroGradingApplyResultViewModel>> GetGradingApplyResultList(string catalog, string propName) + { + if (_hydroInfo == null) + { + return default; + } + + //鎵�鏈夊垎绾у垪琛� + var allGradingList = await GetGradingList(); + if (allGradingList == null || allGradingList.Count < 1) + { + return default; + } + var currentGradingList = allGradingList.Where(x => x.Catalog == catalog).ToList(); + if (currentGradingList.Count < 1) + { + return default; + } + + //鎵�鏈夊垎绾у簲鐢ㄥ垪琛� + var allGradingApplyList = GetGradingApplyList(); + if (allGradingApplyList == null || allGradingApplyList.Count < 1) + { + return default; + } + + //褰撳墠鍒嗙骇搴旂敤 + var gradingApply = allGradingApplyList.Find(x => x.Code == catalog); + if (gradingApply == null) + { + return default; + } + gradingApply.PropName = propName; + + //鎵�鏈夎绠楃粨鏋� + var allCalcuResultList = GetCalcuResultList(); + + //搴旂敤缁撴灉鍒楄〃 + var gradingApplyResultList = new List<HydroGradingApplyResultViewModel>(); + + switch (catalog) + { + case Yw.Hydro.ParterCatalog.Pump: + { + if (_hydroInfo.Pumps != null && _hydroInfo.Pumps.Count > 0) + { + foreach (var pump in _hydroInfo.Pumps) + { + switch (propName) + { + case Yw.Hydro.ParterProp.LinkStatus: + { + var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.LinkStatus).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var grading = gradingList.Meet(pump.LinkStatus); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pump.Code, + Color = grading.Color + }; + gradingApplyResultList.Add(result); + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuFlow: + { + var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuFlow.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pump.Code, + Color = grading.Color + }; + gradingApplyResultList.Add(result); + } + } + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuVelocity: + { + var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuVelocity.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pump.Code, + Color = grading.Color + }; + gradingApplyResultList.Add(result); + } + } + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuHeadLoss: + { + var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == pump.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuHeadLoss.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pump.Code, + Color = grading.Color + }; + gradingApplyResultList.Add(result); + } + } + } + } + } + break; + default: break; + } + } + } + } + break; + case Yw.Hydro.ParterCatalog.Valve: + { + if (_hydroInfo.Valves != null && _hydroInfo.Valves.Count > 0) + { + foreach (var valve in _hydroInfo.Valves) + { + switch (propName) + { + case Yw.Hydro.ParterProp.LinkStatus: + { + var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.LinkStatus).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var grading = gradingList.Meet(valve.LinkStatus); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = valve.Code, + Color = grading.Color + }; + gradingApplyResultList.Add(result); + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuFlow: + { + var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuFlow.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = valve.Code, + Color = grading.Color + }; + gradingApplyResultList.Add(result); + } + } + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuVelocity: + { + var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuVelocity.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = valve.Code, + Color = grading.Color + }; + gradingApplyResultList.Add(result); + } + } + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuHeadLoss: + { + var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == valve.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuHeadLoss.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = valve.Code, + Color = grading.Color + }; + gradingApplyResultList.Add(result); + } + } + } + } + } + break; + default: break; + } + } + } + } + break; + case Yw.Hydro.ParterCatalog.Pipe: + { + if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0) + { + foreach (var pipe in _hydroInfo.Pipes) + { + switch (propName) + { + case Yw.Hydro.ParterProp.CalcuFlow: + { + var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuFlow).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuFlow.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuFlow.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pipe.Code, + Color = grading.Color + }; + gradingApplyResultList.Add(result); + } + } + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuVelocity: + { + var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuVelocity).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuVelocity.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuVelocity.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pipe.Code, + Color = grading.Color + }; + gradingApplyResultList.Add(result); + } + } + } + } + } + break; + case Yw.Hydro.ParterProp.CalcuHeadLoss: + { + var gradingList = currentGradingList.Where(x => x.PropName == Yw.Hydro.ParterProp.CalcuHeadLoss).OrderBy(t => t.SortCode).ToList(); + if (gradingList != null && gradingList.Count > 0) + { + var calcuResult = allCalcuResultList?.Find(t => t.Code == pipe.Code); + if (calcuResult is HydroCalcuLinkResult calcuLinkResult) + { + if (calcuLinkResult.CalcuHeadLoss.HasValue) + { + var grading = gradingList.Meet(Math.Abs(calcuLinkResult.CalcuHeadLoss.Value)); + if (grading != null) + { + var result = new HydroGradingApplyResultViewModel() + { + Code = pipe.Code, + Color = grading.Color + }; + gradingApplyResultList.Add(result); + } + } + } + } + } + break; + default: break; + } + } + } + } + break; + default: break; + } + + return gradingApplyResultList; + } + + //棰滆壊鍒嗙骇鏄惁搴旂敤浜� + private bool _isGradingApply = false; + //棰滆壊鍒嗙骇搴旂敤缂栫爜鍒楄〃 + private List<string> _allGradingApplyCodeList = null; + + //搴旂敤棰滆壊鍒嗙骇 + private async void ApplyGrading() + { + if (_hydroInfo == null) + { + return; + } + _isGradingApply = true; + var allGradingApplyResultList = await GetGradingApplyResultList(); + if (allGradingApplyResultList == null || allGradingApplyResultList.Count < 1) + { + CancelApplyGrading(); + return; + } + var objGroupList = allGradingApplyResultList.GroupBy(x => x.Color).ToList(); + objGroupList.ForEach(async x => + { + await _bimfaceCtrl?.OverrideComponentsColor(x.Select(t => t.Code).Distinct().ToList(), x.Key, 1); + }); + _allGradingApplyCodeList = allGradingApplyResultList.Select(x => x.Code).Distinct().ToList(); + } + + //搴旂敤棰滆壊鍒嗙骇 + private async void ApplyGrading(string catalog, string propName) + { + if (_hydroInfo == null) + { + return; + } + _isGradingApply = true; + var allGradingApplyResultList = await GetGradingApplyResultList(catalog, propName); + if (allGradingApplyResultList == null || allGradingApplyResultList.Count < 1) + { + return; + } + var objGroupList = allGradingApplyResultList.GroupBy(x => x.Color).ToList(); + objGroupList.ForEach(async x => + { + await _bimfaceCtrl?.OverrideComponentsColor(x.Select(t => t.Code).Distinct().ToList(), x.Key, 1); + }); + var codeList = allGradingApplyResultList.Select(x => x.Code); + if (_allGradingApplyCodeList == null) + { + _allGradingApplyCodeList = new List<string>(); + } + _allGradingApplyCodeList.AddRange(codeList); + _allGradingApplyCodeList = _allGradingApplyCodeList.Distinct().ToList(); + } + + //鑷姩搴旂敤棰滆壊鍒嗙骇 + private void AutoApplyGrading() + { + if (!_isGradingApply) + { + return; + } + ApplyGrading(); + } + + //鍙栨秷搴旂敤棰滆壊鍒嗙骇 + private async void CancelApplyGrading() + { + if (_hydroInfo == null) + { + return; + } + _isGradingApply = false; + if (_allGradingApplyCodeList != null && _allGradingApplyCodeList.Count > 0) + { + await _bimfaceCtrl?.RestoreComponentsColor(_allGradingApplyCodeList); + } + } + + //鏄剧ず搴旂敤棰滆壊鍒嗙骇绐椾綋 + private void ShowApplyGradingDlg() + { + if (_hydroInfo == null) + { + return; + } + var allGradingApplyList = GetGradingApplyList(); + if (allGradingApplyList == null || allGradingApplyList.Count < 1) + { + return; + } + var dlg = new ApplyHydroGradingDlg(); + dlg.SetBindingData(allGradingApplyList); + dlg.ReloadDataEvent += (obj) => + { + _allGradingApplyList = obj; + ApplyGrading(); + }; + dlg.ShowDialog(); + } + + //搴旂敤棰滆壊鍒嗙骇 + private void barBtnGradingApply_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + ShowApplyGradingDlg(); + } + + //鍙栨秷搴旂敤鍒嗙骇 + private void batBtnCancelGradingApply_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + CancelApplyGrading(); + } + + #endregion + + #endregion + + #region 浜哄伐鍒锋柊 + + //鍒锋柊 + private async void barBtnRefresh_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + if (XtraMessageBox.Show("鍒锋柊鍚庡皢涓㈠け褰撳墠姘村姏淇℃伅鏇存敼锛屾槸鍚︾户缁埛鏂帮紵", "璇㈤棶", MessageBoxButtons.YesNo) == DialogResult.Yes) + { + if (_project == null) + { + return; + } + if (_projectSite == null) + { + return; + } + var hydroRelation = await BLLFactory<Yw.BLL.HydroModelRelation>.Instance + .GetDefaultByObjectTypeAndObjectIDOfPurpose(HStation.Xhs.DataType.XhsProjectSite, _projectSite.ID, HStation.Xhs.Purpose.Simulation); + Stopwatch sw = new Stopwatch(); + sw.Start(); + _hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(hydroRelation.ModelID); + sw.Stop(); + TimeSpan ts2 = sw.Elapsed; + Console.WriteLine("Stopwatch鎬诲叡鑺辫垂{0}ms.", ts2.TotalMilliseconds); + _selectedParter = null; + await _bimfaceCtrl?.ZoomAndSelectComponents(null); + ShowProperty(); + TipFormHelper.ShowSucceed("鏁版嵁宸插埛鏂�"); + } + } + + #endregion + + #region 姘存祦鍔ㄧ敾 + + //鎵�鏈夋祦鍚戝垪琛� + private List<Yw.WinFrmUI.Bimface.LogicFlowEffect> _allFlowEffectList = null; + + //鑾峰彇娴佸悜鍒楄〃 + private List<Yw.WinFrmUI.Bimface.LogicFlowEffect> GetFlowEffectList() + { + if (_allFlowEffectList == null) + { + if (_hydroInfo == null) + { + return default; + } + _allFlowEffectList = new List<LogicFlowEffect>(); + var allCalcuResultList = GetCalcuResultList(); + if (_hydroInfo.Pipes != null && _hydroInfo.Pipes.Count > 0) + { + foreach (var parter in _hydroInfo.Pipes) + { + var flowEffect = new LogicFlowEffect(); + _allFlowEffectList.Add(flowEffect); + flowEffect.Id = parter.Code; + flowEffect.Rotation = 90; + flowEffect.SpeedX = 0.1; + if (parter.FlowDirectionX == Yw.Hydro.FlowDirection.None) + { + flowEffect.SpeedX = 0; + } + else if (parter.FlowDirectionX == Yw.Hydro.FlowDirection.Positive) + { + flowEffect.SpeedX = 0.1; + } + else + { + flowEffect.SpeedX = -0.1; + } + + if (parter.FlowDirectionY == Yw.Hydro.FlowDirection.None) + { + flowEffect.SpeedY = 0; + } + else if (parter.FlowDirectionY == Yw.Hydro.FlowDirection.Positive) + { + flowEffect.SpeedY = 0.1; + } + else + { + flowEffect.SpeedY = -0.1; + } + + var calcuResult = allCalcuResultList?.Find(x => x.Code == parter.Code) as HydroCalcuLinkResult; + if (calcuResult != null) + { + if (calcuResult.CalcuVelocity < 0) + { + flowEffect.SpeedX = -flowEffect.SpeedX; + } + } + } + } + } + return _allFlowEffectList; + } + + /// <summary> + /// 鍔犺浇姘存祦鍔ㄧ敾 + /// </summary> + private async void LoadFlowEffect() + { + if (_allFlowEffectList != null) + { + return; + } + var allFlowEffectList = GetFlowEffectList(); + await _bimfaceCtrl?.LoadFlowEffect(allFlowEffectList); + } + + //鍗歌浇娴佸悜 + private async void UnloadFlowEffect() + { + if (_allFlowEffectList == null) + { + return; + } + _allFlowEffectList = null; + await _bimfaceCtrl?.UnloadFlowEffect(); + } + + //鏇存柊姘存祦鍔ㄧ敾 + private async void UpdateFlowEffect(Yw.Model.HydroParterInfo parter) + { + if (_allFlowEffectList == null) + { + return; + } + var visual = parter as Yw.Model.HydroVisualInfo; + if (visual == null) + { + return; + } + var flowEffect = _allFlowEffectList.Find(x => x.Id == parter.Code); + if (flowEffect == null) + { + return; + } + if (visual.FlowDirectionX == Yw.Hydro.FlowDirection.None) + { + flowEffect.SpeedX = 0; + } + else if (visual.FlowDirectionX == Yw.Hydro.FlowDirection.Positive) + { + flowEffect.SpeedX = 0.1; + } + else + { + flowEffect.SpeedX = -0.1; + } + + if (visual.FlowDirectionY == Yw.Hydro.FlowDirection.None) + { + flowEffect.SpeedY = 0; + } + else if (visual.FlowDirectionY == Yw.Hydro.FlowDirection.Positive) + { + flowEffect.SpeedY = 0.1; + } + else + { + flowEffect.SpeedY = -0.1; + } + + var allCalcuResultList = GetCalcuResultList(); + var calcuResult = allCalcuResultList?.Find(x => x.Code == visual.Code) as HydroCalcuLinkResult; + if (calcuResult != null) + { + if (calcuResult.CalcuVelocity < 0) + { + flowEffect.SpeedX = -flowEffect.SpeedX; + } + } + await _bimfaceCtrl?.UpdateFlowEffect(flowEffect); + } + + //鍔犺浇娴佸悜 + private void barBtnLoadFlowDirection_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + LoadFlowEffect(); + } + + //鍗歌浇娴佸悜 + private void barBtnUnloadFlowDirection_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) + { + UnloadFlowEffect(); + } + + #endregion + + + + } } \ No newline at end of file -- Gitblit v1.9.3