qin
2025-03-18 fd206ba4e3e792eb01898fea540d50c2fd92f364
WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/13-print/report/SimulationCommonReport.cs
@@ -21,6 +21,8 @@
        public void SetBingdingData(SimulationPrintViewModel vm)
        {
            if (vm == null)
                return;
            // A4设置 827 1169
            this.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.A4;
            this.Margins = new DevExpress.Drawing.DXMargins(50, 50, 50, 50);
@@ -234,89 +236,100 @@
                    this.Detail.Controls.Add(labForAccuracy);
                    currentY += firstCaptionHeight;
                    var accuracyScaleChart = ReportHelper.CreateAccuracyScale(working.Accuracy.Scale, 300F, 230F, currentY);
                    Detail.Controls.Add(accuracyScaleChart);
                    var accuracyFlowChart = ReportHelper.CreateAccuracyItem(working.Accuracy.Flow?.AvgError ?? 0, 213F, 230F, 300F, currentY);
                    Detail.Controls.Add(accuracyFlowChart);
                    var accuracyPressChart = ReportHelper.CreateAccuracyItem(working.Accuracy.Press?.AvgError ?? 0, 213F, 230F, 513F, currentY);
                    Detail.Controls.Add(accuracyPressChart);
                    currentY += accuracyScaleChart.HeightF;
                    currentY += 20F;
                    var labForAccuracyList = ReportHelper.CreateFirstCaption("(1.1)、评估列表", contentWidth - 25F, 15F, 20F, currentY);
                    this.Detail.Controls.Add(labForAccuracyList);
                    currentY += firstCaptionHeight;
                    #region 评估列表
                    if (working.Accuracy.Items != null && working.Accuracy.Items.Count > 0)
                    {                // 创建 XRTable
                        var tableForAccuracyList = new XRTable();
                        tableForAccuracyList.LocationF = new DevExpress.Utils.PointFloat(0F, currentY);
                        tableForAccuracyList.SizeF = new SizeF(727F, 30F + working.Accuracy.Items.Count * 25F); // 设置大小
                        // 创建表头行
                        XRTableRow headerRowAccuracyList = new XRTableRow();
                        headerRowAccuracyList.BackColor = Color.LightGray; // 设置背景颜色
                        // 添加表头列
                        headerRowAccuracyList.Cells.Add(ReportHelper.CreateTableCell("评估构件", 100));
                        headerRowAccuracyList.Cells.Add(ReportHelper.CreateTableCell("评估项", 100));
                        headerRowAccuracyList.Cells.Add(ReportHelper.CreateTableCell("监测值", 100));
                        headerRowAccuracyList.Cells.Add(ReportHelper.CreateTableCell("计算值", 100));
                        headerRowAccuracyList.Cells.Add(ReportHelper.CreateTableCell("评估误差", 100));
                        // 将表头行添加到表格
                        tableForAccuracyList.Rows.Add(headerRowAccuracyList);
                        foreach (var item in working.Accuracy.Items)
                    if (working.Accuracy != null)
                    {
                        XRChart accuracyScaleChart = null;
                        if (working.Accuracy.Scale != null)
                        {
                            // 创建数据行
                            var dataRow = new XRTableRow();
                            dataRow.Cells.Add(new XRTableCell()
                            {
                                Text = item.EvaluateName,
                                WidthF = 100F,
                                TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
                                Borders = DevExpress.XtraPrinting.BorderSide.All
                            });
                            dataRow.Cells.Add(new XRTableCell()
                            {
                                Text = item.EvaluateItem,
                                WidthF = 100F,
                                TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
                                Borders = DevExpress.XtraPrinting.BorderSide.All
                            });
                            dataRow.Cells.Add(new XRTableCell()
                            {
                                Text = item.MonitorValue.ToString(),
                                WidthF = 100F,
                                TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
                                Borders = DevExpress.XtraPrinting.BorderSide.All
                            });
                            dataRow.Cells.Add(new XRTableCell()
                            {
                                Text = item.CalcuValue.ToString(),
                                WidthF = 100F,
                                TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
                                Borders = DevExpress.XtraPrinting.BorderSide.All
                            });
                            dataRow.Cells.Add(new XRTableCell()
                            {
                                Text = item.EvaluateError?.ToString(),
                                WidthF = 100F,
                                TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
                                ForeColor = Color.Red,
                                Borders = DevExpress.XtraPrinting.BorderSide.All
                            });
                            tableForAccuracyList.Rows.Add(dataRow);
                            accuracyScaleChart = ReportHelper.CreateAccuracyScale(working.Accuracy.Scale, 300F, 230F, currentY);
                            Detail.Controls.Add(accuracyScaleChart);
                        }
                        // 将表格添加到Detail
                        this.Detail.Controls.Add(tableForAccuracyList);
                        currentY += tableForAccuracyList.HeightF;
                        var accuracyFlowChart = ReportHelper.CreateAccuracyItem(working.Accuracy.Flow?.AvgError ?? 0, 213F, 230F, 300F, currentY);
                        Detail.Controls.Add(accuracyFlowChart);
                        var accuracyPressChart = ReportHelper.CreateAccuracyItem(working.Accuracy.Press?.AvgError ?? 0, 213F, 230F, 513F, currentY);
                        Detail.Controls.Add(accuracyPressChart);
                        currentY += 20F;
                        var labForAccuracyList = ReportHelper.CreateFirstCaption("(1.1)、评估列表", contentWidth - 25F, 15F, 20F, currentY);
                        this.Detail.Controls.Add(labForAccuracyList);
                        currentY += firstCaptionHeight;
                        if (accuracyScaleChart != null)
                        {
                            currentY += accuracyScaleChart.HeightF;
                        }
                        #region 评估列表
                        if (working.Accuracy.Items != null && working.Accuracy.Items.Count > 0)
                        {                // 创建 XRTable
                            var tableForAccuracyList = new XRTable();
                            tableForAccuracyList.LocationF = new DevExpress.Utils.PointFloat(0F, currentY);
                            tableForAccuracyList.SizeF = new SizeF(727F, 30F + working.Accuracy.Items.Count * 25F); // 设置大小
                            // 创建表头行
                            XRTableRow headerRowAccuracyList = new XRTableRow();
                            headerRowAccuracyList.BackColor = Color.LightGray; // 设置背景颜色
                            // 添加表头列
                            headerRowAccuracyList.Cells.Add(ReportHelper.CreateTableCell("评估构件", 100));
                            headerRowAccuracyList.Cells.Add(ReportHelper.CreateTableCell("评估项", 100));
                            headerRowAccuracyList.Cells.Add(ReportHelper.CreateTableCell("监测值", 100));
                            headerRowAccuracyList.Cells.Add(ReportHelper.CreateTableCell("计算值", 100));
                            headerRowAccuracyList.Cells.Add(ReportHelper.CreateTableCell("评估误差", 100));
                            // 将表头行添加到表格
                            tableForAccuracyList.Rows.Add(headerRowAccuracyList);
                            foreach (var item in working.Accuracy.Items)
                            {
                                // 创建数据行
                                var dataRow = new XRTableRow();
                                dataRow.Cells.Add(new XRTableCell()
                                {
                                    Text = item.EvaluateName,
                                    WidthF = 100F,
                                    TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
                                    Borders = DevExpress.XtraPrinting.BorderSide.All
                                });
                                dataRow.Cells.Add(new XRTableCell()
                                {
                                    Text = item.EvaluateItem,
                                    WidthF = 100F,
                                    TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
                                    Borders = DevExpress.XtraPrinting.BorderSide.All
                                });
                                dataRow.Cells.Add(new XRTableCell()
                                {
                                    Text = item.MonitorValue.ToString(),
                                    WidthF = 100F,
                                    TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
                                    Borders = DevExpress.XtraPrinting.BorderSide.All
                                });
                                dataRow.Cells.Add(new XRTableCell()
                                {
                                    Text = item.CalcuValue.ToString(),
                                    WidthF = 100F,
                                    TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
                                    Borders = DevExpress.XtraPrinting.BorderSide.All
                                });
                                dataRow.Cells.Add(new XRTableCell()
                                {
                                    Text = item.EvaluateError?.ToString(),
                                    WidthF = 100F,
                                    TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleCenter,
                                    ForeColor = Color.Red,
                                    Borders = DevExpress.XtraPrinting.BorderSide.All
                                });
                                tableForAccuracyList.Rows.Add(dataRow);
                            }
                            // 将表格添加到Detail
                            this.Detail.Controls.Add(tableForAccuracyList);
                            currentY += tableForAccuracyList.HeightF;
                            currentY += 20F;
                        }
                    }
                    #endregion 评估列表
@@ -569,14 +582,17 @@
                            foreach (var valve in item)
                            {
                                if (valve.Items.Count > 0)
                                if (valve.Items != null && valve.Items.Count > 0)
                                {
                                    foreach (var curve in valve.Items)
                                    {
                                        Series seriesQh = new Series("Series Qh", ViewType.Spline);
                                        foreach (var qh in curve.CurrentCurveQH)
                                        if (curve.CurrentCurveQH != null)
                                        {
                                            seriesQh.Points.Add(new SeriesPoint(qh.X, qh.Y));
                                            foreach (var qh in curve.CurrentCurveQH)
                                            {
                                                seriesQh.Points.Add(new SeriesPoint(qh.X, qh.Y));
                                            }
                                        }
                                   ((SplineSeriesView)seriesQh.View).MarkerVisibility = DefaultBoolean.False;
                                        seriesQh.LabelsVisibility = DefaultBoolean.False;
@@ -590,9 +606,12 @@
                                        }
                                        Series seriesQe = new Series("Series Qe", ViewType.Spline);
                                        foreach (var qe in curve.CurrentCurveQE)
                                        if (curve.CurrentCurveQE != null)
                                        {
                                            seriesQe.Points.Add(new SeriesPoint(qe.X, qe.Y));
                                            foreach (var qe in curve.CurrentCurveQE)
                                            {
                                                seriesQe.Points.Add(new SeriesPoint(qe.X, qe.Y));
                                            }
                                        }
                                        ((XYDiagramSeriesViewBase)seriesQe.View).Pane = pane2;
@@ -602,9 +621,12 @@
                                        chart.Series.Add(seriesQe);
                                        Series seriesQp = new Series("Series Qp", ViewType.Spline);
                                        foreach (var qp in curve.CurrentCurveQP)
                                        if (curve.CurrentCurveQP != null)
                                        {
                                            seriesQp.Points.Add(new SeriesPoint(qp.X, qp.Y));
                                            foreach (var qp in curve.CurrentCurveQP)
                                            {
                                                seriesQp.Points.Add(new SeriesPoint(qp.X, qp.Y));
                                            }
                                        }
                                        ((XYDiagramSeriesViewBase)seriesQp.View).Pane = pane1;
@@ -668,8 +690,16 @@
                                        {
                                            if (valve.CurveQH != null)
                                            {
                                                itemInList.Items[0].CurrentCurveQH.AddRange(valve.CurveQH);
                                                break;
                                                foreach (var items in itemInList.Items)
                                                {
                                                    if (items != null && items.CurrentCurveQH != null)
                                                    {
                                                        items.CurrentCurveQH.AddRange(valve.CurveQH);
                                                        break;
                                                    }
                                                }
                                                //itemInList.Items[0].CurrentCurveQH.AddRange(valve.CurveQH);
                                                //break;
                                            }
                                        }
                                    }
@@ -679,8 +709,16 @@
                                        {
                                            if (valve.CurveQE != null)
                                            {
                                                itemInList.Items[0].CurrentCurveQE.AddRange(valve.CurveQE);
                                                break;
                                                foreach (var items in itemInList.Items)
                                                {
                                                    if (items != null && items.CurrentCurveQE != null)
                                                    {
                                                        items.CurrentCurveQE.AddRange(valve.CurveQE);
                                                        break;
                                                    }
                                                }
                                                //itemInList.Items[0].CurrentCurveQE.AddRange(valve.CurveQE);
                                                //break;
                                            }
                                        }
                                    }
@@ -688,11 +726,19 @@
                                    {
                                        if (itemInList.Items != null && itemInList.Items.Count > 0)
                                        {
                                            if (valve.CurveQP != null)
                                            foreach (var items in itemInList.Items)
                                            {
                                                if (items != null && items.CurrentCurveQP != null)
                                                {
                                                    items.CurrentCurveQP.AddRange(valve.CurveQP);
                                                    break;
                                                }
                                            }
                                            /*if (valve.CurveQP != null)
                                            {
                                                itemInList.Items[0].CurrentCurveQP.AddRange(valve.CurveQP);
                                                break;
                                            }
                                            }*/
                                        }
                                    }
@@ -760,7 +806,7 @@
                    this.Detail.Controls.Add(labForMonitor);
                    currentY += 20F;
                    if (working.MonitorAnaly.Items != null && working.MonitorAnaly.Items.Count > 0)
                    if (working.MonitorAnaly != null && working.MonitorAnaly.Items != null && working.MonitorAnaly.Items.Count > 0)
                    {                // 创建 XRTable
                        var tableForMonitorList = new XRTable();
                        tableForMonitorList.LocationF = new DevExpress.Utils.PointFloat(0F, currentY);
@@ -907,10 +953,10 @@
                                    _pointTuple.Add(new Tuple<XYDiagram, AxisX, AxisY, SecondaryAxisY, SecondaryAxisY, HydroEnergyAnalyPipeItemViewModel>(
                                      xyDiagram,
                                      xyDiagram.AxisX,
                                        xyDiagram.AxisY,
                                      xyDiagram.AxisY,
                                      secondaryAxisY2,
                                      secondaryAxisY1,
                                     pipe
                                      pipe
           ));
                                }
@@ -953,34 +999,34 @@
                                                if (pt_f_list != null)
                                                {
                                                    itemInList.CurrentCurveQH.AddRange(pt_f_list);
                                                    // 处理 X 轴设置
                                                    var allQHForX = item
                                                       .Where(singleItem => singleItem.CurrentCurveQH != null)
                                                       .SelectMany(singleItem => singleItem.CurrentCurveQH);
                                                    if (allQHForX.Any())
                                                    {
                                                        var globalXMax = allQHForX.Max(qh => qh.X);
                                                        var globalXMin = allQHForX.Min(qh => qh.X);
                                                        ReportHelper.SetAxisX(xyDiagram, ReportHelper.RoundDownMin(globalXMin), ReportHelper.RoundUpMax(globalXMax));
                                                    }
                                                    // 处理 Y 轴设置
                                                    var allQHForY = item
                                                       .Where(singleItem => singleItem.CurrentCurveQH != null)
                                                       .SelectMany(singleItem => singleItem.CurrentCurveQH);
                                                    if (allQHForY.Any())
                                                    {
                                                        var globalYMax = allQHForY.Max(qh => qh.Y);
                                                        var globalYMin = allQHForY.Min(qh => qh.Y);
                                                        ReportHelper.SetAxisY(xyDiagram, ReportHelper.RoundDownMin(globalYMin), ReportHelper.RoundUpMax(globalYMax));
                                                    }
                                                    itemInList.CurrentCurveQH.RemoveAll(item => pt_f_list.Contains(item));
                                                    break;
                                                }
                                            }
                                        }
                                        // 处理 X 轴设置
                                        var allQHForX = item
                                           .Where(singleItem => singleItem.CurrentCurveQH != null)
                                           .SelectMany(singleItem => singleItem.CurrentCurveQH);
                                        if (allQHForX.Any())
                                        {
                                            var globalXMax = allQHForX.Max(qh => qh.X);
                                            var globalXMin = allQHForX.Min(qh => qh.X);
                                            ReportHelper.SetAxisX(xyDiagram, globalXMin, ReportHelper.RoundUpMax(globalXMax));
                                        }
                                        // 处理 Y 轴设置
                                        var allQHForY = item
                                           .Where(singleItem => singleItem.CurrentCurveQH != null)
                                           .SelectMany(singleItem => singleItem.CurrentCurveQH);
                                        if (allQHForY.Any())
                                        {
                                            var globalYMax = allQHForY.Max(qh => qh.Y);
                                            var globalYMin = allQHForY.Min(qh => qh.Y);
                                            ReportHelper.SetAxisY(xyDiagram, ReportHelper.RoundDownMin(globalYMin), ReportHelper.RoundUpMax(globalYMax));
                                        }
                                        // 处理 Y 轴设置