電站報表: 修改日月年區間報表匯出和綜合比較匯出的格式和取值

This commit is contained in:
wanling040@gmail.com 2022-08-10 17:52:52 +08:00
parent 6cd312eed8
commit 0c42f22241
2 changed files with 137 additions and 78 deletions

View File

@ -267,10 +267,14 @@ namespace SolarPower.Controllers
#region body //RowPosition = 1
RowPosition++;
var thour = ""; var tpr = ""; var tkwh = ""; var kWhkwp = ""; var ntd = ""; var ntdone = "";var GeneratingCapacity = "";var AverageDailyProfit = "";
int vForDataCount = 0;
foreach (dynamic body in Formbody.Result.Data)
{
index = 0;
var dbody = body as IDictionary<string, object>;
if (vForDataCount < (Formbody.Result.Data.Count - 1))//最後一筆(總計),不須取值
{
vForDataCount++;
thour = Checknull(Math.Round(Convert.ToDouble(dbody["tothour"]), 2).ToString());
tpr = Checknull(Math.Round(Convert.ToDouble(dbody["pr"]), 2).ToString());
tkwh = Checknull(Math.Round(Convert.ToDouble(dbody["totKWH"]), 2).ToString());
@ -278,13 +282,17 @@ namespace SolarPower.Controllers
ntd = Checknull(Math.Round(Convert.ToDouble(dbody["totmoney"]), 2).ToString());
GeneratingCapacity = Checknull(Math.Round(Convert.ToDouble(dbody["GeneratingCapacity"]), 2).ToString());
double kwp = Convert.ToDouble(tkwh) / Convert.ToDouble(GeneratingCapacity);
kWhkwp = Checknull(Math.Round(kwp, 2).ToString());
double onemoney = Convert.ToDouble(ntd) / Convert.ToDouble(tkwh);
if (double.IsNaN(onemoney))
{
onemoney = 0;
}
ntdone = Checknull(Math.Round(onemoney, 4).ToString());
ntdone = Checknull(Math.Round(onemoney, 2).ToString());
AverageDailyProfit = Checknull(Math.Round((Convert.ToDouble(ntd) / Convert.ToDouble(GeneratingCapacity)), 2).ToString());
}
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
@ -302,7 +310,7 @@ namespace SolarPower.Controllers
List<string> bodynames = new List<string>(){
"hourKWH",
"hourKWHp",
"irradiance",
"irrDayHour",
"temperature"
};
if (Formhead.Result.Data.ShowMoney == 1)
@ -467,18 +475,26 @@ namespace SolarPower.Controllers
var monthGeneratingCapacity = "";
var check_hire = false;
var sitedb = "";
vForDataCount = 0;
foreach (dynamic body in Formbody.Result.Data)
{
index2 = 0;
var dbody = body as IDictionary<string, object>;
if (vForDataCount < (Formbody.Result.Data.Count - 1))//最後一筆(總計),不須取值
{
vForDataCount++;
avghour = (Convert.ToDouble(dbody["tothour"].ToString()) + Convert.ToDouble(avghour)).ToString();
avgKWHKWP = (Convert.ToDouble(dbody["KWHKWP"].ToString()) + Convert.ToDouble(avgKWHKWP)).ToString();
avgdayKWH = (Convert.ToDouble(dbody["dayKWH"].ToString()) + Convert.ToDouble(avgdayKWH)).ToString();
monthKWH = dbody["monthKWH"] == null ? "0": dbody["monthKWH"].ToString();
monthKWH = dbody["monthKWH"] == null ? "0" : dbody["monthKWH"].ToString();
monthmoney = dbody["monthmoney"] == null ? "0" : dbody["monthmoney"].ToString();
monthmoneyone = (Convert.ToDouble(dbody["monthmoneyone"].ToString()) + Convert.ToDouble(monthmoneyone)).ToString();
monthGeneratingCapacity = Checknull(Math.Round(Convert.ToDouble(dbody["GeneratingCapacity"]), 2).ToString());
}
double kwp = Convert.ToDouble(monthKWH) / Convert.ToDouble(monthGeneratingCapacity);
avgKWHKWP = Checknull(Math.Round(kwp, 2).ToString());
if (dbody["SolarType"].ToString() == "1" && Formhead.Result.Data.ShowMoney == 1)//檢驗是否為租用
{
check_hire = true;
@ -533,7 +549,7 @@ namespace SolarPower.Controllers
#region //RowPosition = body + 2
RowPosition += 2;//空兩行
index = 0;
var Useday = Formbody.Result.Data.Count;
var Useday = (Formbody.Result.Data.Count - 1);//最後一筆為總計故減1
row = sheet.CreateRow(RowPosition);
//cell = row.CreateCell(index);
@ -610,7 +626,7 @@ namespace SolarPower.Controllers
if (Formhead.Result.Data.ShowMoney == 1)
{
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoney) / Convert.ToDouble(monthGeneratingCapacity), 3));
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoney) / Convert.ToDouble(monthGeneratingCapacity), 2));
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
@ -618,7 +634,7 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoneyone) / Useday, 4));
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoneyone) / Useday, 2));
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
@ -741,11 +757,15 @@ namespace SolarPower.Controllers
check_hire = false;
sitedb = "";
monthGeneratingCapacity = "";
string days = "0";
vForDataCount = 0;
foreach (dynamic body in Formbody.Result.Data)
{
index3 = 0;
var dbody = body as IDictionary<string, object>;
if (vForDataCount < (Formbody.Result.Data.Count - 1))//最後一筆(總計),不須取值
{
vForDataCount++;
avghour = (Convert.ToDouble(dbody["tothour"].ToString()) + Convert.ToDouble(avghour)).ToString();
avgKWHKWP = (Convert.ToDouble(dbody["KWHKWP"].ToString()) + Convert.ToDouble(avgKWHKWP)).ToString();
avgdayKWH = (Convert.ToDouble(dbody["dayKWH"].ToString()) + Convert.ToDouble(avgdayKWH)).ToString();
@ -753,6 +773,8 @@ namespace SolarPower.Controllers
monthmoney = dbody["monthmoney"] == null ? "0" : dbody["monthmoney"].ToString();
monthmoneyone = (Convert.ToDouble(dbody["monthmoneyone"].ToString()) + Convert.ToDouble(monthmoneyone)).ToString();
monthGeneratingCapacity = Checknull(Math.Round(Convert.ToDouble(dbody["GeneratingCapacity"]), 2).ToString());
days = Checknull(Math.Round(Convert.ToDouble(dbody["Days"])).ToString());
}
if (dbody["SolarType"].ToString() == "1" && Formhead.Result.Data.ShowMoney == 1)//檢驗是否為租用
{
check_hire = true;
@ -807,7 +829,7 @@ namespace SolarPower.Controllers
#region //RowPosition = body + 2
RowPosition += 2;//空兩行
index = 0;
Useday = Formbody.Result.Data.Count;
Useday = (Formbody.Result.Data.Count - 1);//最後一筆為總計故減1
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
@ -819,6 +841,10 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("裝置容量");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("發電量平均(kWh)(月)");
cell.CellStyle = styleLine12;
index++;
@ -856,7 +882,11 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(avgKWHKWP) / Useday, 2));
cell.SetCellValue(Math.Round(Convert.ToDouble(monthKWH) / Convert.ToDouble(monthGeneratingCapacity), 2));
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthGeneratingCapacity), 2));///
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
@ -878,7 +908,7 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoney) / Convert.ToDouble(monthGeneratingCapacity) / Useday / 30, 2));//一個月為30天
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoney) / Convert.ToDouble(monthGeneratingCapacity) / Convert.ToDouble(days), 2));//一個月為30天 Useday / 30
cell.CellStyle = styleLine12;
index++;
}
@ -1142,11 +1172,14 @@ namespace SolarPower.Controllers
#region body //RowPosition = 1
RowPosition++;
var thour = ""; var tpr = ""; var tkwh = ""; var kWhkwp = ""; var ntd = ""; var ntdone = ""; var GeneratingCapacity = ""; var AverageDailyProfit = "";
int vForDataCount = 0;
foreach (dynamic body in Formbody.Result.Data)
{
index = 0;
var dbody = body as IDictionary<string, object>;
if (vForDataCount < (Formbody.Result.Data.Count - 1))//最後一筆為總計,不須取值
{
vForDataCount++;
thour = Checknull(Math.Round(Convert.ToDouble(dbody["tothour"]), 2).ToString());
tpr = Checknull(Math.Round(Convert.ToDouble(dbody["pr"]), 2).ToString());
tkwh = Checknull(Math.Round(Convert.ToDouble(dbody["totKWH"]), 2).ToString());
@ -1154,13 +1187,17 @@ namespace SolarPower.Controllers
ntd = Checknull(Math.Round(Convert.ToDouble(dbody["totmoney"]), 2).ToString());
GeneratingCapacity = Checknull(Math.Round(Convert.ToDouble(dbody["GeneratingCapacity"]), 2).ToString());
double kwp = Convert.ToDouble(tkwh) / Convert.ToDouble(GeneratingCapacity);
kWhkwp = Checknull(Math.Round(kwp, 2).ToString());
double onemoney = Convert.ToDouble(ntd) / Convert.ToDouble(tkwh);
if (double.IsNaN(onemoney))
{
onemoney = 0;
}
ntdone = Checknull(Math.Round(onemoney, 4).ToString());
ntdone = Checknull(Math.Round(onemoney, 2).ToString());
AverageDailyProfit = Checknull(Math.Round((Convert.ToDouble(ntd) / Convert.ToDouble(GeneratingCapacity)), 2).ToString());
}
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
@ -1178,7 +1215,7 @@ namespace SolarPower.Controllers
List<string> bodynames = new List<string>(){
"hourKWH",
"hourKWHp",
"irradiance",
"irrDayHour",
"temperature"
};
if (Formhead.Result.Data.ShowMoney == 1)
@ -1344,11 +1381,14 @@ namespace SolarPower.Controllers
var monthGeneratingCapacity = "";
var check_hire = false;
var sitedb = "";
vForDataCount = 0;
foreach (dynamic body in Formbody.Result.Data)
{
index2 = 0;
var dbody = body as IDictionary<string, object>;
if (vForDataCount < (Formbody.Result.Data.Count - 1))//最後一筆為總計,不須取值
{
vForDataCount++;
avghour = (Convert.ToDouble(dbody["tothour"].ToString()) + Convert.ToDouble(avghour)).ToString();
avgKWHKWP = (Convert.ToDouble(dbody["KWHKWP"].ToString()) + Convert.ToDouble(avgKWHKWP)).ToString();
avgdayKWH = (Convert.ToDouble(dbody["dayKWH"].ToString()) + Convert.ToDouble(avgdayKWH)).ToString();
@ -1356,6 +1396,11 @@ namespace SolarPower.Controllers
monthmoney = dbody["monthmoney"] == null ? "0" : dbody["monthmoney"].ToString();
monthmoneyone = (Convert.ToDouble(dbody["monthmoneyone"].ToString()) + Convert.ToDouble(monthmoneyone)).ToString();
monthGeneratingCapacity = Checknull(Math.Round(Convert.ToDouble(dbody["GeneratingCapacity"]), 2).ToString());
double kwp = Convert.ToDouble(monthKWH) / Convert.ToDouble(monthGeneratingCapacity);
avgKWHKWP = Checknull(Math.Round(kwp, 2).ToString());
}
if (dbody["SolarType"].ToString() == "1" && Formhead.Result.Data.ShowMoney == 1)//檢驗是否為租用
{
check_hire = true;
@ -1410,7 +1455,7 @@ namespace SolarPower.Controllers
#region //RowPosition = body + 2
RowPosition += 2;//空兩行
index = 0;
var Useday = Formbody.Result.Data.Count;
var Useday = (Formbody.Result.Data.Count - 1);//最後一筆為總計故減1
row = sheet.CreateRow(RowPosition);
//cell = row.CreateCell(index);
@ -1487,7 +1532,7 @@ namespace SolarPower.Controllers
if (Formhead.Result.Data.ShowMoney == 1)
{
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoney) / Convert.ToDouble(monthGeneratingCapacity), 3));
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoney) / Convert.ToDouble(monthGeneratingCapacity), 2));
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
@ -1495,7 +1540,7 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoneyone) / Useday, 4));
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoneyone) / Useday, 2));
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
@ -1737,7 +1782,7 @@ namespace SolarPower.Controllers
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(form.AvgKWHKWP, 2));//日均發電度數
cell.SetCellValue(Math.Round((form.Kwh/form.GeneratingCapacity), 2));//日均發電度數
cell.CellStyle = styleLine12;
index++;
@ -1802,7 +1847,7 @@ namespace SolarPower.Controllers
{
City = form.CityName,
Count = 1,
Kwh = form.TotalKWH,
Kwh = form.Kwh,
SolarHour = form.SolarHour,
Kwhkwp = form.AvgKWHKWP,
GeneratingCapacity = form.GeneratingCapacity
@ -1834,7 +1879,7 @@ namespace SolarPower.Controllers
"電站類型",
"掛錶日期",
"躉售費率",
"每kw日均獲利",
"日均獲利",
"日均發電度數",
"發電量",
//"平均日照",
@ -1884,7 +1929,7 @@ namespace SolarPower.Controllers
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(cityArray.Kwh, 3));
cell.SetCellValue(Math.Round(cityArray.Kwh, 2));
cell.CellStyle = styleLine12;
region = new CellRangeAddress(cityRowPosition, cityRowPosition, index, index + 1);
sheet.AddMergedRegion(region);
@ -2243,7 +2288,7 @@ namespace SolarPower.Controllers
"電站類型",
"掛錶日期",
"躉售費率",
"每kw日均獲利",
"日均獲利",
"日均發電度數",
"發電量",
//"平均日照",

View File

@ -219,7 +219,7 @@
</div>
<div class="mb-3 d-flex justify-content-start">
<div class="pr-3">
<button type="button" class="btn btn-primary waves-effect waves-themed" onclick="ExportExcel()"><span class="fal fa-file-excel mr-1"></span> 匯出</button>
<button type="button" class="btn btn-primary waves-effect waves-themed ml-1 btn-report" onclick="ExportExcel()" id="exportBtn"><span class="fal fa-file-excel mr-1"></span> 匯出</button>
</div>
<div class="row">
<div class="pr-3" id="selectOneStation">
@ -874,7 +874,7 @@
str += "<th>掛錶日期</th>";
/*str += "<th>裝置容量</th>";*/
str += "<th>躉售費率</th>";
str += "<th>每kw日均獲利</th>";
str += "<th>日均獲利</th>";
str += "<th>日均發電度數</th>";
str += "<th>發電量</th>";
str += "<th>PR</th>";
@ -1111,11 +1111,13 @@
sta += "<td>" + toThousands(inverter.soldmoney.toFixed(2)) + "</td>";
}
sta += "</tr>";
if (index < rel.data.length - 1) {
avghour += inverter.tothour ? inverter.tothour : 0;
avgKWHKWP += inverter.KWHKWP ? inverter.KWHKWP : 0;
avgdayKWH += inverter.dayKWH ? inverter.dayKWH : 0;
monthKWH = inverter.monthKWH ? inverter.monthKWH : 0;
monthmoney = inverter.monthmoney ? inverter.monthmoney : 0;
}
if (inverter.SolarType == 1) {
check_hire = true;
@ -1161,8 +1163,8 @@
}
else {
/*stb += "<td>" + (avghour / monthday).toFixed(2) + "</td>";*/
stb += "<td>" + toThousands((avgKWHKWP / monthday).toFixed(2)) + "</td>";
stb += "<td>" + toThousands((avgdayKWH / monthday).toFixed(2)) + "</td>";
stb += "<td>" + toThousands((monthKWH / GeneratingCapacity).toFixed(2)) + "</td>";
stb += "<td>" + toThousands((monthKWH / monthday).toFixed(2)) + "</td>";
stb += "<td>" + toThousands(monthKWH.toFixed(2)) + "</td>";
stb += "<td>" + toThousands(GeneratingCapacity.toFixed(2)) + "</td>";
@ -1172,7 +1174,7 @@
stb += "<td>" + toThousands(monthmoneyone.toFixed(2)) + "</td>";
stb += "<td>" + toThousands((averageDailyProfit / monthday).toFixed(2)) + "</td>";
}
stb += "<td>" + monthday.toFixed(2) + "</td>";
stb += "<td>" + monthday + "</td>";
stb += "</tr>";
}
var std = "";
@ -1219,6 +1221,7 @@
var monthmoneyone = 0;
var monthday = 0;
var averageDailyProfit = 0;
var generatingCapacity = 0;
var days = 0;
var sta = "";
var check_hire = false;
@ -1249,6 +1252,7 @@
avgdayKWH += inverter.dayKWH ? inverter.dayKWH : 0;
monthKWH = inverter.monthKWH ? inverter.monthKWH : 0;
monthmoney = inverter.monthmoney ? inverter.monthmoney : 0;
generatingCapacity = inverter.GeneratingCapacity ? inverter.GeneratingCapacity : 0;
averageDailyProfit = monthmoney / inverter.GeneratingCapacity ? (monthmoney / inverter.GeneratingCapacity) : 0;
@ -1260,12 +1264,14 @@
})
monthday = (rel.data.length - 1);
monthmoneyone = rel.data[0].monthmoneyone ? rel.data[0].monthmoneyone : 0;
//ntdone = inverter.totmoney / inverter.totKWH ? (inverter.totmoney / inverter.totKWH).toFixed(2) : 0;
days = rel.data[0].Days;
var stc = "<tr>";
stc += "<th>" + '日照平均(月)' + "</th>";
stc += "<th>" + '日均發電度數(月)' + "</th>";
stc += "<th>" + '裝置容量' + "</th>";
stc += "<th>" + '發電量平均(kWh)(月)' + "</th>";
stc += "<th>" + '發電量(kWh)(年)' + "</th>";
if (showmoney == 1) {
@ -1292,15 +1298,17 @@
}
else {
stb += "<td>" + toThousands((avghour / monthday).toFixed(2)) + "</td>";
stb += "<td>" + toThousands((avgKWHKWP / monthday).toFixed(2)) + "</td>";
stb += "<td>" + toThousands((avgdayKWH / monthday).toFixed(2)) + "</td>";
stb += "<td>" + toThousands((monthKWH / generatingCapacity).toFixed(2)) + "</td>";
stb += "<td>" + toThousands(generatingCapacity.toFixed(2)) + "</td>";
stb += "<td>" + toThousands((monthKWH / monthday).toFixed(2)) + "</td>";
stb += "<td>" + toThousands(monthKWH.toFixed(2)) + "</td>";
if (showmoney == 1) {
stb += "<td>" + toThousands(monthmoney.toFixed(2)) + "</td>";
stb += "<td>" + toThousands(monthmoneyone.toFixed(2)) + "</td>";
stb += "<td>" + toThousands((averageDailyProfit / days).toFixed(2)) + "</td>";
}
stb += "<td>" + toThousands(monthday.toFixed(2)) + "</td>";
stb += "<td>" + toThousands(monthday) + "</td>";
stb += "</tr>";
}
var std = "";
@ -1423,7 +1431,8 @@
}
else {
/*stb += "<td>" + (avghour / monthday).toFixed(2) + "</td>";*/
stb += "<td>" + toThousands((avgKWHKWP / monthday).toFixed(2)) + "</td>";
//stb += "<td>" + toThousands((avgKWHKWP / monthday).toFixed(2)) + "</td>";
stb += "<td>" + toThousands((monthKWH / GeneratingCapacity).toFixed(2)) + "</td>";
stb += "<td>" + toThousands((avgdayKWH / monthday).toFixed(2)) + "</td>";
stb += "<td>" + toThousands(monthKWH.toFixed(2)) + "</td>";
stb += "<td>" + toThousands(GeneratingCapacity.toFixed(2)) + "</td>";
@ -1434,7 +1443,7 @@
stb += "<td>" + toThousands(monthmoneyone / monthday.toFixed(2)) + "</td>";
stb += "<td>" + toThousands((averageDailyProfit / monthday).toFixed(2)) + "</td>";
}
stb += "<td>" + toThousands(monthday.toFixed(2)) + "</td>";
stb += "<td>" + toThousands(monthday) + "</td>";
stb += "</tr>";
}
var std = "";
@ -1481,6 +1490,8 @@
}
function ExportExcel() {
$("#exportBtn").html('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>').attr("disabled", true);
var send_data =
{
SearchType: searchType,
@ -1495,10 +1506,12 @@
$("#post").val(JSON.stringify(send_data));
document.report.action = "StationReport/ExportExcel";
document.report.submit();
$("#exportBtn").html('<span class="fal fa-file-excel mr-1"></span> 匯出').attr("disabled", false);
return;
}
else
{
$("#exportBtn").html('<span class="fal fa-file-excel mr-1"></span> 匯出').attr("disabled", false);
var text = "原因如下:<br\>";
$.each(rel.data, function (index, val) {
text += index + 1 + "." + val + "<br\>";
@ -1521,6 +1534,7 @@
{
window.location = "/StationReport/ExportExcelmaxtable?post=" + JSON.stringify(send_data);
}
$("#exportBtn").html('<span class="fal fa-file-excel mr-1"></span> 匯出').attr("disabled", false);
}
}
// 綜合比較