This commit is contained in:
Celeste 2023-08-24 15:13:39 +08:00
commit a93b405ba6

View File

@ -475,7 +475,7 @@ namespace FrontendWebApi.ApiControllers
if (r.Count > 0) if (r.Count > 0)
{ {
string buildingName = r.Select(x => x.building_name).FirstOrDefault(); string buildingName = r.Select(x => x.building_name).FirstOrDefault();
var sheet = workbook.CreateSheet($"{buildingName}電表報表"); var sheet = workbook.CreateSheet($"{buildingName} 電表報表");
int RowPosition = 0; int RowPosition = 0;
#region set cell #region set cell
IRow row = sheet.CreateRow(RowPosition); IRow row = sheet.CreateRow(RowPosition);
@ -493,7 +493,10 @@ namespace FrontendWebApi.ApiControllers
cell = row.CreateCell(i++); cell = row.CreateCell(i++);
cell.SetCellValue("設備"); cell.SetCellValue("設備");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
cell = row.CreateCell(i++);
cell.SetCellValue("單位");
cell.CellStyle = styleLine12;
foreach (var rr in r.FirstOrDefault().rawData) foreach (var rr in r.FirstOrDefault().rawData)
{ {
cell = row.CreateCell(i++); cell = row.CreateCell(i++);
@ -515,7 +518,7 @@ namespace FrontendWebApi.ApiControllers
foreach (var rr in r) foreach (var rr in r)
{ {
RowPosition += 1; RowPosition += 1;
int k = 3; int k = 4;
row = sheet.CreateRow(RowPosition); row = sheet.CreateRow(RowPosition);
for (int j = 0; j <= i; j++) for (int j = 0; j <= i; j++)
{ {
@ -524,16 +527,20 @@ namespace FrontendWebApi.ApiControllers
{ {
cell.SetCellValue(rr.building_name); cell.SetCellValue(rr.building_name);
} }
if (j == 1) else if (j == 1)
{ {
cell.SetCellValue(rr.floor_tag); cell.SetCellValue(rr.floor_tag);
} }
if (j == 2) else if (j == 2)
{ {
cell.SetCellValue(rr.device_full_name); 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) foreach (var rrr in rr.rawData)
{ {
@ -543,16 +550,16 @@ namespace FrontendWebApi.ApiControllers
cell = row.CreateCell(j); cell = row.CreateCell(j);
} }
} }
if (j == k) if (j == k)
{ {
cell.SetCellValue(rr.total); cell.SetCellValue(rr.total);
} }
if (j == k+1) else if (j == k+1)
{ {
cell.SetCellValue(rr.price); cell.SetCellValue(rr.price);
} }
if (j == k+2) else if (j == k+2)
{ {
cell.SetCellValue(rr.total_price); cell.SetCellValue(rr.total_price);
} }
@ -697,6 +704,9 @@ namespace FrontendWebApi.ApiControllers
cell = row.CreateCell(i++); cell = row.CreateCell(i++);
cell.SetCellValue("設備"); cell.SetCellValue("設備");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
cell = row.CreateCell(i++);
cell.SetCellValue("單位");
cell.CellStyle = styleLine12;
foreach (var rr in rawDataTitle) 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; string compareDictKey = r.building_tag + r.floor_tag + r.device_serial_tag + r.device_number;
RowPosition += 1; RowPosition += 1;
int k = 3; int k = 4;
row = sheet.CreateRow(RowPosition); row = sheet.CreateRow(RowPosition);
for (int j = 0; j <= i; j++) for (int j = 0; j <= i; j++)
{ {
@ -745,16 +755,20 @@ namespace FrontendWebApi.ApiControllers
{ {
cell.SetCellValue(r.building_name); cell.SetCellValue(r.building_name);
} }
if (j == 1) else if (j == 1)
{ {
cell.SetCellValue(r.floor_tag); cell.SetCellValue(r.floor_tag);
} }
if (j == 2) else if (j == 2)
{ {
cell.SetCellValue(r.device_full_name); 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) foreach (var rr in rawDataTitle)
{ {
@ -770,23 +784,23 @@ namespace FrontendWebApi.ApiControllers
{ {
cell.SetCellValue(r.total); cell.SetCellValue(r.total);
} }
if (j == k + 1) else if (j == k + 1)
{ {
cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][0] : ""); cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][0] : "");
} }
if (j == k + 2) else if (j == k + 2)
{ {
cell.SetCellValue(r.price); cell.SetCellValue(r.price);
} }
if (j == k + 3) else if (j == k + 3)
{ {
cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][1] : ""); cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][1] : "");
} }
if (j == k + 4) else if (j == k + 4)
{ {
cell.SetCellValue(r.total_price); cell.SetCellValue(r.total_price);
} }
if (j == k + 5) else if (j == k + 5)
{ {
cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][2] : ""); cell.SetCellValue(compareDict.ContainsKey(compareDictKey) ? compareDict[compareDictKey][2] : "");
} }