From 3259da82f657375379ba39dea0a9aea5a4020072 Mon Sep 17 00:00:00 2001 From: keke Date: Thu, 24 Aug 2023 15:04:45 +0800 Subject: [PATCH] =?UTF-8?q?[FE=20API]=20=E6=96=B0=E5=A2=9E=E5=8C=AF?= =?UTF-8?q?=E5=87=BA=E5=A0=B1=E8=A1=A8=E6=AC=84=E4=BD=8D=20=E5=96=AE?= =?UTF-8?q?=E4=BD=8D=20(kWh)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/HydroMeterController.cs | 50 ++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/FrontendWebApi/ApiControllers/HydroMeterController.cs b/FrontendWebApi/ApiControllers/HydroMeterController.cs index fb5dd13..8bc1b49 100644 --- a/FrontendWebApi/ApiControllers/HydroMeterController.cs +++ b/FrontendWebApi/ApiControllers/HydroMeterController.cs @@ -475,7 +475,7 @@ namespace FrontendWebApi.ApiControllers if (r.Count > 0) { string buildingName = r.Select(x => x.building_name).FirstOrDefault(); - var sheet = workbook.CreateSheet($"{buildingName}電表報表"); + var sheet = workbook.CreateSheet($"{buildingName} 電表報表"); int RowPosition = 0; #region set cell IRow row = sheet.CreateRow(RowPosition); @@ -493,7 +493,10 @@ namespace FrontendWebApi.ApiControllers cell = row.CreateCell(i++); cell.SetCellValue("設備"); cell.CellStyle = styleLine12; - + cell = row.CreateCell(i++); + cell.SetCellValue("單位"); + cell.CellStyle = styleLine12; + foreach (var rr in r.FirstOrDefault().rawData) { cell = row.CreateCell(i++); @@ -515,7 +518,7 @@ namespace FrontendWebApi.ApiControllers foreach (var rr in r) { RowPosition += 1; - int k = 3; + int k = 4; row = sheet.CreateRow(RowPosition); for (int j = 0; j <= i; j++) { @@ -524,16 +527,20 @@ namespace FrontendWebApi.ApiControllers { cell.SetCellValue(rr.building_name); } - if (j == 1) + else if (j == 1) { cell.SetCellValue(rr.floor_tag); } - if (j == 2) + else if (j == 2) { cell.SetCellValue(rr.device_full_name); } + else if (j == 3) + { + cell.SetCellValue("kWh"); + } - if (j == 3) + else if (j == 4) { foreach (var rrr in rr.rawData) { @@ -543,16 +550,16 @@ namespace FrontendWebApi.ApiControllers cell = row.CreateCell(j); } } - + if (j == k) { cell.SetCellValue(rr.total); } - if (j == k+1) + else if (j == k+1) { cell.SetCellValue(rr.price); } - if (j == k+2) + else if (j == k+2) { cell.SetCellValue(rr.total_price); } @@ -697,6 +704,9 @@ namespace FrontendWebApi.ApiControllers cell = row.CreateCell(i++); cell.SetCellValue("設備"); cell.CellStyle = styleLine12; + cell = row.CreateCell(i++); + cell.SetCellValue("單位"); + cell.CellStyle = styleLine12; foreach (var rr in rawDataTitle) { @@ -736,7 +746,7 @@ namespace FrontendWebApi.ApiControllers { string compareDictKey = r.building_tag + r.floor_tag + r.device_serial_tag + r.device_number; RowPosition += 1; - int k = 3; + int k = 4; row = sheet.CreateRow(RowPosition); for (int j = 0; j <= i; j++) { @@ -745,16 +755,20 @@ namespace FrontendWebApi.ApiControllers { cell.SetCellValue(r.building_name); } - if (j == 1) + else if (j == 1) { cell.SetCellValue(r.floor_tag); } - if (j == 2) + else if (j == 2) { cell.SetCellValue(r.device_full_name); } + else if (j == 3) + { + cell.SetCellValue("kWh"); + } - if (j == 3) + else if (j == 4) { foreach (var rr in rawDataTitle) { @@ -770,23 +784,23 @@ namespace FrontendWebApi.ApiControllers { cell.SetCellValue(r.total); } - if (j == k + 1) + else if (j == k + 1) { cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][0] : ""); } - if (j == k + 2) + else if (j == k + 2) { cell.SetCellValue(r.price); } - if (j == k + 3) + else if (j == k + 3) { cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][1] : ""); } - if (j == k + 4) + else if (j == k + 4) { cell.SetCellValue(r.total_price); } - if (j == k + 5) + else if (j == k + 5) { cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][2] : ""); }