using HStation.WinFrmUI.PhartRelation;
|
|
namespace HStation.WinFrmUI.Xhs
|
{
|
public partial class PumpMainCurveChoicePage : DevExpress.XtraEditors.XtraUserControl
|
{
|
public PumpMainCurveChoicePage()
|
{
|
InitializeComponent();
|
this.gridView1.SetNormalView();
|
}
|
|
private List<PumpMainChoieViewModel> _allBindingList = null;
|
|
private BLL.PumpSeries _seriesBll = null;
|
|
private BLL.PumpGroup _groupBll = null;
|
|
private BLL.PumpMain _pumpBll = null;
|
|
private BLL.PumpGroupAndMainMap _groupMapBll = null;
|
|
private readonly Lazy<BLL.XhsPumpMainPhartMappingExtensions> _bll_ex = new();
|
|
private long _DbID; //泵型号ID
|
private long _Curveid;//曲线ID
|
private Vmo.XhsPumpMainPhartMappingExtensions _Curveinfo; //曲线详细信息
|
|
private string _SearchText;
|
|
public class CurvieText
|
{
|
public long Dbid { get; set; }
|
public long Curveid { get; set; }
|
public Vmo.XhsPumpMainPhartMappingExtensions Curveinfo { get; set; }
|
}
|
|
/// <summary>
|
/// 初始化
|
/// </summary>
|
public async void SetBindingData(string dbiD, string ModelType)
|
{
|
_seriesBll = new BLL.PumpSeries();
|
_groupBll = new BLL.PumpGroup();
|
_pumpBll = new BLL.PumpMain();
|
_groupMapBll = new BLL.PumpGroupAndMainMap();
|
this.pumpMainCurveForm1.SelectEventReload += PumpMainCurveForm1_SelectEventReload;
|
if (dbiD != null)
|
{
|
if (long.TryParse(dbiD, out long DbID))
|
{
|
var model = await _pumpBll.GetByID(DbID);
|
if (model == null)
|
return;
|
_DbID = DbID;
|
pumpMainCurveForm1.SetBindingData(model);
|
}
|
}
|
if (ModelType != null)
|
{
|
_SearchText = ModelType;
|
var alllist = await TreelistShow();
|
if (alllist.Count <= 0)
|
return;
|
var model = await _pumpBll.GetByID(alllist.First().ID);
|
if (model == null)
|
return;
|
_DbID = model.ID;
|
pumpMainCurveForm1.SetBindingData(model);
|
TextPopupPumpChoice.ShowPopup();
|
}
|
}
|
|
//
|
private async void PumpMainCurveForm1_SelectEventReload(long ID)
|
{
|
var vmo = await _bll_ex.Value.GetByID(ID);
|
_Curveid = ID;
|
_Curveinfo = vmo;
|
InitChart(vmo);
|
}
|
|
public CurvieText GetCurrentCurveinfo()
|
{
|
var ss = new CurvieText
|
{
|
Dbid = _DbID,
|
Curveid = _Curveid,
|
Curveinfo = _Curveinfo
|
};
|
return ss;
|
}
|
|
//初始化图表数据
|
private void InitChart(Vmo.XhsPumpMainPhartMappingExtensions dto)
|
{
|
if (dto == null)
|
{
|
return;
|
}
|
var diagram = dto.Diagram;
|
if (diagram == null)
|
{
|
return;
|
}
|
var graph_list = diagram.GraphList;
|
if (graph_list == null || !graph_list.Any())
|
{
|
return;
|
}
|
|
var graph_qh = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQH);
|
var graph_qe = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQH);
|
var graph_qp = graph_list.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQH);
|
|
if (graph_qp == null)
|
{
|
return;
|
}
|
|
List<Yw.Geometry.Point2d> points_qh = null, points_qe = null, points_qp = null;
|
points_qh = PhartPerformCurveHelper.GetFeatPointList(graph_qh.GraphType, graph_qh.GeometryInfo, 12, null);
|
if (graph_qe != null)
|
points_qe = PhartPerformCurveHelper.GetFeatPointList(graph_qe.GraphType, graph_qe.GeometryInfo, 12, null);
|
if (graph_qp != null)
|
points_qp = PhartPerformCurveHelper.GetFeatPointList(graph_qp.GraphType, graph_qp.GeometryInfo, 12, null);
|
|
var cubic_spline_qh = new Yw.Geometry.CubicSpline2d(points_qh);
|
var cubic_spline_qe = new Yw.Geometry.CubicSpline2d(points_qe);
|
var cubic_spline_qp = new Yw.Geometry.CubicSpline2d(points_qp);
|
|
var disp_paras = diagram.DispParas;
|
var is_calc_disp_paras = string.IsNullOrWhiteSpace(disp_paras);
|
this.xtrPerform2dChart1.SetBindingData(cubic_spline_qh, cubic_spline_qe, cubic_spline_qp, disp_paras, is_calc_disp_paras);
|
}
|
|
//根据泵型号模糊查询(树显示)
|
private async void simpleLabelSearch_Click(object sender, EventArgs e)
|
{
|
if (TextPopupPumpChoice.EditValue == null)
|
return;
|
_SearchText = Convert.ToString(TextPopupPumpChoice.EditValue);
|
TextPopupPumpChoice.Properties.PopupControl = popupContainerControl1;
|
if (_SearchText == null)
|
{
|
return;
|
}
|
await TreelistShow();
|
this.treeList1.DataSource = _allBindingList;
|
TextPopupPumpChoice.ShowPopup();
|
}
|
|
private async Task<List<PumpMainChoieViewModel>> TreelistShow()
|
{
|
_allBindingList = new List<PumpMainChoieViewModel>();
|
var allSeries = await _seriesBll.GetAll();
|
var allGroup = await _groupBll.GetAll();
|
var allPumpMain = await _pumpBll.GetAll();
|
var allGroupMap = await _groupMapBll.GetAll();
|
//泵型号
|
foreach (var item in allPumpMain)
|
{
|
if (item.Name.Contains(_SearchText.Trim()))
|
{
|
var groupMap = allGroupMap.Find(x => x.PumpMainID == item.ID);
|
if (groupMap != null)
|
{
|
var group = allGroup.Find(x => x.ID == groupMap.PumpGroupID);
|
if (group != null)
|
{
|
var series = allSeries.Find(x => x.ID == group.PumpSeriesID);
|
if (series != null)
|
{
|
if (_allBindingList.Find(x => x.ID == series.ID) == null)
|
{
|
_allBindingList.Add(new PumpMainChoieViewModel(series));
|
}
|
if (_allBindingList.Find(x => x.ID == group.ID) == null)
|
{
|
_allBindingList.Add(new PumpMainChoieViewModel(item, group.ID));
|
}
|
_allBindingList.Add(new PumpMainChoieViewModel(group));
|
}
|
}
|
}
|
else
|
{
|
var series = allSeries.Find(x => x.ID == item.PumpSeriesID);
|
if (series != null)
|
{
|
if (_allBindingList.Find(x => x.ID == series.ID) == null)
|
{
|
_allBindingList.Add(new PumpMainChoieViewModel(series));
|
}
|
_allBindingList.Add(new PumpMainChoieViewModel(item));
|
}
|
}
|
}
|
}
|
return _allBindingList.Where(x => x.IsPump == true).ToList();
|
}
|
|
//模糊查询(表格显示)
|
private async void simpleLabelItemVagueSearch_Click(object sender, EventArgs e)
|
{
|
if (TextPopupPumpChoice.EditValue == null)
|
{
|
return;
|
}
|
_allBindingList = new List<PumpMainChoieViewModel>();
|
TextPopupPumpChoice.Properties.PopupControl = popupContainerControl2;
|
var allPumpMain = await _pumpBll.GetAll();
|
foreach (var Main in allPumpMain)
|
{
|
if (Main.Name.Contains(TextPopupPumpChoice.Text))
|
{
|
_allBindingList.Add(new PumpMainChoieViewModel(Main));
|
}
|
}
|
this.gridControl1.DataSource = _allBindingList;
|
TextPopupPumpChoice.Size = new Size(500, 300);
|
TextPopupPumpChoice.ShowPopup();
|
}
|
|
//选择项变换
|
private async void treeList1_SelectionChanged(object sender, EventArgs e)
|
{
|
var vm = this.treeList1.GetCurrentViewModel(_allBindingList);
|
if (vm != null)
|
{
|
if (!vm.IsPump)
|
{
|
return;
|
}
|
var model = await _pumpBll.GetByID(vm.ID);
|
if (model == null)
|
return;
|
_DbID = vm.ID;
|
pumpMainCurveForm1.SetBindingData(model);
|
}
|
//treeList1.CloseEditForm();
|
}
|
|
private void BtnAddPumpMain_Click(object sender, EventArgs e)
|
{
|
var dlg = new AddPumpMainDlg();
|
dlg.ShowDialog();
|
}
|
|
private async void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
|
{
|
var vm = this.gridView1.GetCurrentViewModel(_allBindingList);
|
if (vm != null)
|
{
|
var model = await _pumpBll.GetByID(vm.ID);
|
if (model == null)
|
return;
|
_DbID = vm.ID;
|
pumpMainCurveForm1.SetBindingData(model);
|
}
|
}
|
}
|
}
|