From c62abea9769bd09d8339628b364105fb3bf934f1 Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期二, 10 十二月 2024 17:34:13 +0800 Subject: [PATCH] 修改报表方法 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/12-report/SimulationWordReport.cs | 366 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 336 insertions(+), 30 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/12-report/SimulationWordReport.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/12-report/SimulationWordReport.cs index eb55041..b76fe97 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/12-report/SimulationWordReport.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/12-report/SimulationWordReport.cs @@ -10,12 +10,6 @@ { } - //鎶ュ憡鏍囬椤圭洰鍚嶇О - private string _title = "*********"; - - //椤圭洰鎯呭喌浠嬬粛 涓�)绯荤粺姒傛嫭涓� - private string _Instructions = "*******************************************************************"; - //鏂囧瓧鎻忚堪杩愯妯″紡浠嬬粛 浜岋級杩愯鎯呭喌涓庤兘鑰楀垎鏋愪腑 "鍏ㄥ勾:"鍚� private string _run_mode = "*******************************************************************"; @@ -93,25 +87,25 @@ return strem; } - protected void SetWordHander(Aspose.Words.Document doc) + protected void SetWordHander(Aspose.Words.Document doc, string title) { DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc); builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary); SimulationWordReportHelper Text_center_10_Gray = new SimulationWordReportHelper(builder) { fontalignment = ParagraphAlignment.Right, fontsize = 10, fontcolor = Color.Gray }; - Text_center_10_Gray.structureText(string.Format("{0}{1}", _title, "椤圭洰鑺傝兘鏂规鎶ュ憡")); + Text_center_10_Gray.structureText(string.Format("{0}{1}", title, "椤圭洰鑺傝兘鏂规鎶ュ憡")); builder.InsertHorizontalRule(); // 绉诲姩鍒颁笅涓�琛岋紝浠ヤ究缁х画娣诲姞鍏朵粬鍐呭 builder.MoveToDocumentStart(); } - protected void SetWordFooter(Aspose.Words.Document doc) + protected void SetWordFooter(Aspose.Words.Document doc, string title) { DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc); builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary); SimulationWordReportHelper Text_center_10_Gray = new SimulationWordReportHelper(builder) { fontalignment = ParagraphAlignment.Left, fontsize = 10, fontcolor = Color.Gray }; builder.InsertHorizontalRule(); - Text_center_10_Gray.structureText(string.Format("{0}{1}", _title, "椤圭洰鑺傝兘鏂规鎶ュ憡")); + Text_center_10_Gray.structureText(string.Format("{0}{1}", title, "椤圭洰鑺傝兘鏂规鎶ュ憡")); // 绉诲姩鍒颁笅涓�琛岋紝浠ヤ究缁х画娣诲姞鍏朵粬鍐呭 builder.MoveToDocumentStart(); } @@ -126,8 +120,8 @@ SimulationWordReportHelper Text_left_15_black = new SimulationWordReportHelper(builder) { fontsize = 15, isblod = true };//涓�绾ф爣棰� SimulationWordReportHelper Text_left_12_black = new SimulationWordReportHelper(builder) { fontsize = 12 }; SimulationWordReportHelper Text_reight_10_black = new SimulationWordReportHelper(builder) { fontalignment = ParagraphAlignment.Right, fontsize = 12 }; - SetWordHander(src); - SetWordFooter(src); + SetWordHander(src, reportViewModel.ProjectName); + SetWordFooter(src, reportViewModel.ProjectName); builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Multiple; builder.ParagraphFormat.LineSpacing = 18; // 璁剧疆琛岃窛涓�1.5鍊嶉粯璁よ璺� @@ -139,11 +133,11 @@ SimulationWordReportHelper Cell_h_merging_start = new SimulationWordReportHelper(builder) { horizontalMerge = Aspose.Words.Tables.CellMerge.First }; SimulationWordReportHelper Cell_h_merging_end = new SimulationWordReportHelper(builder) { horizontalMerge = Aspose.Words.Tables.CellMerge.Previous }; - Text_center_25_black.structureText(string.Format("{0}{1}", _title, "椤圭洰鑺傝兘鏂规鎶ュ憡")); + Text_center_25_black.structureText(string.Format("{0}{1}", reportViewModel.ProjectName, "椤圭洰鑺傝兘鏂规鎶ュ憡")); Text_left_15_black.structureText("涓�銆佺郴缁熸杩�"); Text_left_15_black.AddBlankLine(); Text_left_15_black.AddBlankLine(); - Text_left_12_black.structureText(string.Format("{0}", _Instructions)); + Text_left_12_black.structureText(string.Format("{0}", reportViewModel.Description)); Text_left_12_black.structureText("1.1銆佽澶囧熀鏈厤缃�"); #region 璁惧埆鍩烘湰閰嶇疆琛� @@ -192,6 +186,47 @@ Cell.structureCell(item.Speed); builder.EndRow(); } + } + else + { + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); + + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); + + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); } builder.EndTable(); basic_config_table.AllowAutoFit = false; @@ -253,6 +288,40 @@ Cell.structureCell(item.ReturnPressure); builder.EndRow(); } + } + else + { + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); + + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); + + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); } builder.EndTable(); @@ -456,23 +525,58 @@ Cell.structureCell("骞磋繍琛屾椂闂�(h)"); Cell.structureCell("骞磋�楃數閲忥紙涓噆W.h)"); builder.EndRow(); - + double totalPower = 0; + int totalHour = 0; + double AnnualPower = 0; if (reportViewModel.PowerConsumptionInfos != null) { foreach (var item in reportViewModel.PowerConsumptionInfos) { Cell.structureCell(item.RunMode); Cell.structureCell(item.PreTechPowerConsumption); + if (double.TryParse(item.PreTechPowerConsumption, out double power)) + { + totalPower += power; + } Cell.structureCell(item.AnnualRunningHours); + if (int.TryParse(item.AnnualRunningHours, out int hour)) + { + totalHour += hour; + } Cell.structureCell(item.AnnualPowerConsumption); + if (double.TryParse(item.AnnualPowerConsumption, out double annualPower)) + { + AnnualPower += annualPower; + } builder.EndRow(); } } Cell.structureCell("鍚堣"); - Cell.structureCell(""); - Cell.structureCell(""); - Cell.structureCell(""); + if (totalPower != 0) + { + Cell.structureCell(totalPower.ToString()); + } + else + { + Cell.structureCell(""); + } + if (totalHour != 0) + { + Cell.structureCell(totalHour.ToString()); + } + else + { + Cell.structureCell(""); + } + if (AnnualPower != 0) + { + Cell.structureCell(AnnualPower.ToString()); + } + else + { + Cell.structureCell(""); + } builder.EndTable(); actual_energy_consumption_table.AllowAutoFit = false; Processing_pagination(src, builder, actual_energy_consumption_table); @@ -615,6 +719,7 @@ Cell.structureCell(item.EquipmentName); Cell.structureCell(item.EquipmentNumber); Cell.structureCell(item.EquipmentMainName); + Cell.structureCell(item.Count); Cell.structureCell(item.RatedFlow); Cell.structureCell(item.RatedHead); Cell.structureCell(item.TypeOfDrive); @@ -625,6 +730,47 @@ Cell.structureCell(item.Speed); builder.EndRow(); } + } + else + { + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); + + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); + + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); } builder.EndTable(); Device_configuration_table.AllowAutoFit = false; @@ -685,6 +831,40 @@ Cell.structureCell(item.ReturnPressure); builder.EndRow(); } + } + else + { + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); + + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); + + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); } builder.EndTable(); //estimated_running_table.AllowAutoFit = false; @@ -818,23 +998,58 @@ Cell.structureCell("骞磋繍琛屾椂闂�(h)"); Cell.structureCell("鏀瑰悗骞磋�楃數閲忥紙涓噆W.h)"); builder.EndRow(); - + totalPower = 0; + totalHour = 0; + AnnualPower = 0; if (reportViewModel.AfterPowerConsumptionInfos != null) { foreach (var item in reportViewModel.AfterPowerConsumptionInfos) { Cell.structureCell(item.RunMode); Cell.structureCell(item.PreTechPowerConsumption); + if (double.TryParse(item.PreTechPowerConsumption, out double power)) + { + totalPower += power; + } Cell.structureCell(item.AnnualRunningHours); + if (int.TryParse(item.AnnualRunningHours, out int hour)) + { + totalHour += hour; + } Cell.structureCell(item.AnnualPowerConsumption); + if (double.TryParse(item.AnnualPowerConsumption, out double annualPower)) + { + AnnualPower += annualPower; + } builder.EndRow(); } } Cell.structureCell("鍚堣"); - Cell.structureCell(""); - Cell.structureCell(""); - Cell.structureCell(""); + if (totalPower != 0) + { + Cell.structureCell(totalPower.ToString()); + } + else + { + Cell.structureCell(""); + } + if (totalHour != 0) + { + Cell.structureCell(totalHour.ToString()); + } + else + { + Cell.structureCell(""); + } + if (AnnualPower != 0) + { + Cell.structureCell(AnnualPower.ToString()); + } + else + { + Cell.structureCell(""); + } builder.EndTable(); expected_power_savings.AllowAutoFit = false; Processing_pagination(src, builder, expected_power_savings); @@ -873,7 +1088,8 @@ Cell.structureCell("(%)"); Cell.structureCell("(h)"); builder.EndRow(); - + double savingRate = 0; + double runningTime = 0; if (reportViewModel.PowerRelatedInfos != null) { foreach (var item in reportViewModel.PowerRelatedInfos) @@ -883,17 +1099,48 @@ Cell.structureCell(item.PostTechDesignedPower); Cell.structureCell(item.HourlyPowerSaving); Cell.structureCell(item.PowerSavingRate); + if (double.TryParse(item.PowerSavingRate, out double power)) + { + savingRate += power; + } Cell.structureCell(item.RunningTime); + if (double.TryParse(item.RunningTime, out double time)) + { + runningTime += time; + } builder.EndRow(); } } - + else + { + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); + } Cell_h_merging_start.structureCell("鍚堣骞磋妭鐢甸噺(涓囧害)"); Cell_h_merging_end.structureCell(""); Cell_h_merging_end.structureCell(""); Cell_h_merging_end.structureCell(""); - Cell_h_merging_start.structureCell(""); - Cell_h_merging_start.structureCell(""); + if (savingRate != 0) + { + Cell_h_merging_start.structureCell(savingRate.ToString()); + } + else + { + Cell_h_merging_start.structureCell(""); + } + if (runningTime != 0) + { + Cell_h_merging_start.structureCell(runningTime.ToString()); + } + else + { + Cell_h_merging_start.structureCell(""); + } builder.EndTable(); summary_table.AllowAutoFit = false; Processing_pagination(src, builder, summary_table); @@ -915,25 +1162,84 @@ Cell.structureCell("鏀瑰悗骞磋妭鐢甸噺\r\n(涓囧害/骞�)"); builder.EndRow(); + double totalBeforePower = 0; + double totalSavingRate = 0; + double totalAfterAnnualPower = 0; if (reportViewModel.AfterEquipmentPowers != null) { int i = 0; foreach (var item in reportViewModel.AfterEquipmentPowers) { - Cell.structureCell((i++).ToString()); + Cell.structureCell((++i).ToString()); Cell.structureCell(item.EquipmentName); Cell.structureCell(item.PowerConsumptionBeforeTech); + if (double.TryParse(item.PowerConsumptionBeforeTech, out double BeforePower)) + { + totalBeforePower += BeforePower; + } Cell.structureCell(item.PowerSavingRate); + if (double.TryParse(item.PowerSavingRate, out double SavingRate)) + { + totalSavingRate += SavingRate; + } Cell.structureCell(item.AnnualPowerSavingAfterTech); + if (double.TryParse(item.AnnualPowerSavingAfterTech, out double AfterAnnualPower)) + { + totalAfterAnnualPower += AfterAnnualPower; + } builder.EndRow(); } + } + else + { + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); + + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); + + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + Cell.structureCell(""); + builder.EndRow(); } Cell.structureCell(""); Cell.structureCell("鍚堣"); - Cell.structureCell(""); - Cell.structureCell(""); - Cell.structureCell(""); + if (totalBeforePower != 0) + { + Cell.structureCell(totalBeforePower.ToString()); + } + else + { + Cell.structureCell(""); + } + if (totalSavingRate != 0) + { + Cell.structureCell(totalSavingRate.ToString()); + } + else + { + Cell.structureCell(""); + } + if (totalAfterAnnualPower != 0) + { + Cell.structureCell(totalAfterAnnualPower.ToString()); + } + else + { + Cell.structureCell(""); + } builder.EndRow(); builder.EndTable(); power_saving_effect_table.AllowAutoFit = false; -- Gitblit v1.9.3