using DevExpress.XtraEditors;
|
|
namespace HStation.WinFrmUI.Phart
|
{
|
public partial class XhsPumpCurveMainPanel : DocumentPage
|
{
|
public XhsPumpCurveMainPanel()
|
{
|
InitializeComponent();
|
this.PageTitle.Caption = "泵曲线管理";
|
}
|
|
|
private HStation.Dto.Assets.PumpMainDto _pump_main = null;
|
private Dto.XhsPumpPhartMappingExtensionsStdDto _xhs_phart_diagram_ex_dto = null;
|
private BLL.XhsPumpPhartMappingExtensions _bll_ex = new();
|
private BLL.XhsPumpPhartMappingExtensionsStd _bll_ex_std = new();
|
|
|
public async void InitialDataSource(HStation.Dto.Assets.PumpMainDto pump_main)
|
{
|
_pump_main = pump_main;
|
if (_pump_main == null)
|
{
|
return;
|
}
|
_xhs_phart_diagram_ex_dto = await _bll_ex_std.GetDefaultByPumpID(_pump_main.ID);
|
if (_xhs_phart_diagram_ex_dto == null)
|
{
|
return;
|
}
|
InitChart(_xhs_phart_diagram_ex_dto);
|
}
|
|
//初始化图表数据
|
private void InitChart(Dto.XhsPumpPhartMappingExtensionsStdDto 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 == eGraphType.QH);
|
var graph_qe = graph_list.Find(x => x.GraphType == eGraphType.QH);
|
var graph_qp = graph_list.Find(x => x.GraphType == eGraphType.QH);
|
|
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.cubicSpline2dChart1.SetBindingData(cubic_spline_qh, cubic_spline_qe, cubic_spline_qp, disp_paras, is_calc_disp_paras);
|
}
|
|
//清空图表数据
|
private void ClearChart()
|
{
|
this.cubicSpline2dChart1.InitialChartData();
|
}
|
|
//Excel 导入
|
private void barBtnImportByExcel_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
var dlg = new Yw.WinFrmUI.Phart.Cubic.ImportCurveByExcelDlg();
|
dlg.ReloadDataEvent += async (other_name, qh, qe, qp) =>
|
{
|
var bol = await Import(other_name,qh,qe,qp);
|
return bol;
|
};
|
dlg.ShowDialog();
|
}
|
|
//Image 导入
|
private void barBtnImportByImage_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
|
}
|
|
private async Task<bool> Import(string other_name, Yw.Pump.CurveQH qh, Yw.Pump.CurveQE qe, Yw.Pump.CurveQP qp)
|
{
|
if (_pump_main == null)
|
{
|
XtraMessageBox.Show("PumpMain is null!");
|
return false;
|
}
|
if (_xhs_phart_diagram_ex_dto != null)
|
{
|
var bol = await Delete();
|
if (!bol)
|
{
|
return false;
|
}
|
}
|
|
var input = new Dto.AddXhsPumpPhartMappingExtensionsInput();
|
input.PumpID = _pump_main.ID;
|
input.Importance = 0;
|
input.OtherName = other_name;
|
input.Diagram = new Dto.AddXhsPhartDiagramExGraphListInput()
|
{
|
DiagramType = eDiagramType.Feat,
|
Name = other_name,
|
GraphList = new List<Dto.AddXhsPhartGraphInput>()
|
{
|
new Dto.AddXhsPhartGraphInput()
|
{
|
Name = other_name,
|
GeometryStyle= eGeometryStyle.FeatCurve,
|
GraphType= eGraphType.QH,
|
GeometryInfo=qh.ToDbString()
|
},
|
new Dto.AddXhsPhartGraphInput()
|
{
|
Name = other_name,
|
GeometryStyle= eGeometryStyle.FeatCurve,
|
GraphType= eGraphType.QE,
|
GeometryInfo=qe.ToDbString()
|
},
|
new Dto.AddXhsPhartGraphInput()
|
{
|
Name = other_name,
|
GeometryStyle= eGeometryStyle.FeatCurve,
|
GraphType= eGraphType.QP,
|
GeometryInfo=qp.ToDbString()
|
},
|
}
|
};
|
|
|
var mapping_id = await _bll_ex.Insert(input);
|
if (mapping_id < 1)
|
{
|
return false;
|
}
|
_xhs_phart_diagram_ex_dto = await _bll_ex_std.GetDefaultByPumpID(_pump_main.ID);
|
InitChart(_xhs_phart_diagram_ex_dto);
|
|
return true;
|
}
|
|
//删除
|
private async void barBtnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
{
|
await Delete();
|
}
|
|
|
private async Task<bool> Delete()
|
{
|
if (_xhs_phart_diagram_ex_dto == null)
|
{
|
return false;
|
}
|
var diagramId = _xhs_phart_diagram_ex_dto.Diagram.ID;
|
var bol = await _bll_ex.DeleteByDiagramID(diagramId);
|
if (!bol)
|
{
|
XtraMessageBox.Show("删除失败!");
|
return false;
|
}
|
XtraMessageBox.Show("删除成功!");
|
_xhs_phart_diagram_ex_dto = null;
|
ClearChart();
|
return true;
|
}
|
|
|
}
|
}
|