This commit is contained in:
JiaHao Liu 2021-12-28 13:10:43 +08:00
commit 7007e907aa
6 changed files with 354 additions and 218 deletions

View File

@ -266,7 +266,7 @@ namespace SolarPower.Controllers
#region body //RowPosition = 1 #region body //RowPosition = 1
RowPosition++; RowPosition++;
var thour = ""; var tpr = ""; var tkwh = ""; var kWhkwp = ""; var ntd = ""; var ntdone = ""; var thour = ""; var tpr = ""; var tkwh = ""; var kWhkwp = ""; var ntd = ""; var ntdone = "";var GeneratingCapacity = "";
foreach (dynamic body in Formbody.Result.Data) foreach (dynamic body in Formbody.Result.Data)
{ {
index = 0; index = 0;
@ -276,13 +276,14 @@ namespace SolarPower.Controllers
tkwh = Checknull(Math.Round(Convert.ToDouble(dbody["totKWH"]), 2).ToString()); tkwh = Checknull(Math.Round(Convert.ToDouble(dbody["totKWH"]), 2).ToString());
kWhkwp = Checknull(Math.Round(Convert.ToDouble(dbody["totKWHKWP"]), 2).ToString()); kWhkwp = Checknull(Math.Round(Convert.ToDouble(dbody["totKWHKWP"]), 2).ToString());
ntd = Checknull(Math.Round(Convert.ToDouble(dbody["totmoney"]), 2).ToString()); ntd = Checknull(Math.Round(Convert.ToDouble(dbody["totmoney"]), 2).ToString());
GeneratingCapacity = Checknull(Math.Round(Convert.ToDouble(dbody["GeneratingCapacity"]), 2).ToString());
double onemoney = Convert.ToDouble(ntd) / Convert.ToDouble(tkwh); double onemoney = Convert.ToDouble(ntd) / Convert.ToDouble(tkwh);
if (double.IsNaN(onemoney)) if (double.IsNaN(onemoney))
{ {
onemoney = 0; onemoney = 0;
} }
ntdone = Checknull(Math.Round(onemoney, 2).ToString()); ntdone = Checknull(Math.Round(onemoney, 4).ToString());
row = sheet.CreateRow(RowPosition); row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index); cell = row.CreateCell(index);
@ -328,20 +329,20 @@ namespace SolarPower.Controllers
#region //RowPosition = body + 2 #region //RowPosition = body + 2
RowPosition += 2;//空兩行 RowPosition += 2;//空兩行
index = 0; //index = 0;
row = sheet.CreateRow(RowPosition); //row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index); //cell = row.CreateCell(index);
cell.SetCellValue("日照小時:"); //cell.SetCellValue("日照小時:");
cell.CellStyle = styleLine12; //cell.CellStyle = styleLine12;
cell = row.CreateCell(1); //cell = row.CreateCell(1);
cell.SetCellValue(Convert.ToDouble(thour)); //cell.SetCellValue(Convert.ToDouble(thour));
cell.CellStyle = styleLine12; //cell.CellStyle = styleLine12;
RowPosition++; //RowPosition++;
index = 0; index = 0;
row = sheet.CreateRow(RowPosition); row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue("kWH/kWP:"); cell.SetCellValue("有效發電小時:");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
cell = row.CreateCell(1); cell = row.CreateCell(1);
cell.SetCellValue(Convert.ToDouble(kWhkwp)); cell.SetCellValue(Convert.ToDouble(kWhkwp));
@ -369,6 +370,15 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
RowPosition++; RowPosition++;
index = 0;
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
cell.SetCellValue("裝置容量:");
cell.CellStyle = styleLine12;
cell = row.CreateCell(1);
cell.SetCellValue(Convert.ToDouble(GeneratingCapacity));
cell.CellStyle = styleLine12;
RowPosition++;
if (Formhead.Result.Data.ShowMoney == 1) if (Formhead.Result.Data.ShowMoney == 1)
{ {
@ -422,7 +432,7 @@ namespace SolarPower.Controllers
"日照小時(hr)", "日照小時(hr)",
"有效發電小時", "有效發電小時",
"PR%", "PR%",
"日平均日照度(W/㎡)", "累積日照量(kWh)",
"日平均模組溫度(°C)" "日平均模組溫度(°C)"
}; };
@ -443,6 +453,7 @@ namespace SolarPower.Controllers
#region body //RowPosition = 1 #region body //RowPosition = 1
RowPosition++; RowPosition++;
var avghour = "0"; var avgKWHKWP = "0"; var avgdayKWH = "0"; var monthKWH = "0"; var monthmoney = "0"; var monthmoneyone = "0"; var avghour = "0"; var avgKWHKWP = "0"; var avgdayKWH = "0"; var monthKWH = "0"; var monthmoney = "0"; var monthmoneyone = "0";
var monthGeneratingCapacity = "";
var check_hire = false; var check_hire = false;
var sitedb = ""; var sitedb = "";
foreach (dynamic body in Formbody.Result.Data) foreach (dynamic body in Formbody.Result.Data)
@ -456,6 +467,7 @@ namespace SolarPower.Controllers
monthKWH = dbody["monthKWH"] == null ? "0": dbody["monthKWH"].ToString(); monthKWH = dbody["monthKWH"] == null ? "0": dbody["monthKWH"].ToString();
monthmoney = dbody["monthmoney"] == null ? "0" : dbody["monthmoney"].ToString(); monthmoney = dbody["monthmoney"] == null ? "0" : dbody["monthmoney"].ToString();
monthmoneyone = (Convert.ToDouble(dbody["monthmoneyone"].ToString()) + Convert.ToDouble(monthmoneyone)).ToString(); monthmoneyone = (Convert.ToDouble(dbody["monthmoneyone"].ToString()) + Convert.ToDouble(monthmoneyone)).ToString();
monthGeneratingCapacity = Checknull(Math.Round(Convert.ToDouble(dbody["GeneratingCapacity"]), 2).ToString());
if (dbody["SolarType"].ToString() == "1" && Formhead.Result.Data.ShowMoney == 1)//檢驗是否為租用 if (dbody["SolarType"].ToString() == "1" && Formhead.Result.Data.ShowMoney == 1)//檢驗是否為租用
{ {
check_hire = true; check_hire = true;
@ -481,7 +493,7 @@ namespace SolarPower.Controllers
"tothour", "tothour",
"KWHKWP", "KWHKWP",
"PR", "PR",
"irradiance", "IrrDay",
"temperature" "temperature"
}; };
if (Formhead.Result.Data.ShowMoney == 1) if (Formhead.Result.Data.ShowMoney == 1)
@ -513,12 +525,12 @@ namespace SolarPower.Controllers
var Useday = Formbody.Result.Data.Count; var Useday = Formbody.Result.Data.Count;
row = sheet.CreateRow(RowPosition); row = sheet.CreateRow(RowPosition);
//cell = row.CreateCell(index);
//cell.SetCellValue("日照平均(日)");
//cell.CellStyle = styleLine12;
//index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue("日照平均(日)"); cell.SetCellValue("有效發電小時(日)");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("平均有效發電小時(日)");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
@ -529,6 +541,14 @@ namespace SolarPower.Controllers
cell.SetCellValue("發電量(kWh)(月)"); cell.SetCellValue("發電量(kWh)(月)");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index);
cell.SetCellValue("裝置容量");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("每度獲利");
cell.CellStyle = styleLine12;
index++;
if (Formhead.Result.Data.ShowMoney == 1) if (Formhead.Result.Data.ShowMoney == 1)
{ {
cell = row.CreateCell(index); cell = row.CreateCell(index);
@ -550,10 +570,10 @@ namespace SolarPower.Controllers
RowPosition++; RowPosition++;
row = sheet.CreateRow(RowPosition); row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index); //cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(avghour)/Useday,2)); //cell.SetCellValue(Math.Round(Convert.ToDouble(avghour)/Useday,2));
cell.CellStyle = styleLine12; //cell.CellStyle = styleLine12;
index++; //index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(avgKWHKWP) / Useday,2)); cell.SetCellValue(Math.Round(Convert.ToDouble(avgKWHKWP) / Useday,2));
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
@ -566,6 +586,14 @@ namespace SolarPower.Controllers
cell.SetCellValue(Convert.ToDouble(monthKWH)); cell.SetCellValue(Convert.ToDouble(monthKWH));
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index);
cell.SetCellValue(Convert.ToDouble(monthGeneratingCapacity));
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthKWH)/Convert.ToDouble(monthGeneratingCapacity),3) );
cell.CellStyle = styleLine12;
index++;
if (Formhead.Result.Data.ShowMoney == 1) if (Formhead.Result.Data.ShowMoney == 1)
{ {
cell = row.CreateCell(index); cell = row.CreateCell(index);
@ -573,7 +601,7 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoneyone) / Useday, 2)); cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoneyone) / Useday, 4));
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
} }
@ -1066,7 +1094,7 @@ namespace SolarPower.Controllers
#region body //RowPosition = 1 #region body //RowPosition = 1
RowPosition++; RowPosition++;
var thour = ""; var tpr = ""; var tkwh = ""; var kWhkwp = ""; var ntd = ""; var ntdone = ""; var thour = ""; var tpr = ""; var tkwh = ""; var kWhkwp = ""; var ntd = ""; var ntdone = ""; var GeneratingCapacity = "";
foreach (dynamic body in Formbody.Result.Data) foreach (dynamic body in Formbody.Result.Data)
{ {
index = 0; index = 0;
@ -1076,13 +1104,14 @@ namespace SolarPower.Controllers
tkwh = Checknull(Math.Round(Convert.ToDouble(dbody["totKWH"]), 2).ToString()); tkwh = Checknull(Math.Round(Convert.ToDouble(dbody["totKWH"]), 2).ToString());
kWhkwp = Checknull(Math.Round(Convert.ToDouble(dbody["totKWHKWP"]), 2).ToString()); kWhkwp = Checknull(Math.Round(Convert.ToDouble(dbody["totKWHKWP"]), 2).ToString());
ntd = Checknull(Math.Round(Convert.ToDouble(dbody["totmoney"]), 2).ToString()); ntd = Checknull(Math.Round(Convert.ToDouble(dbody["totmoney"]), 2).ToString());
GeneratingCapacity = Checknull(Math.Round(Convert.ToDouble(dbody["GeneratingCapacity"]), 2).ToString());
double onemoney = Convert.ToDouble(ntd) / Convert.ToDouble(tkwh); double onemoney = Convert.ToDouble(ntd) / Convert.ToDouble(tkwh);
if (double.IsNaN(onemoney)) if (double.IsNaN(onemoney))
{ {
onemoney = 0; onemoney = 0;
} }
ntdone = Checknull(Math.Round(onemoney, 2).ToString()); ntdone = Checknull(Math.Round(onemoney, 4).ToString());
row = sheet.CreateRow(RowPosition); row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index); cell = row.CreateCell(index);
@ -1128,15 +1157,15 @@ namespace SolarPower.Controllers
#region //RowPosition = body + 2 #region //RowPosition = body + 2
RowPosition += 2;//空兩行 RowPosition += 2;//空兩行
index = 0; //index = 0;
row = sheet.CreateRow(RowPosition); //row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index); //cell = row.CreateCell(index);
cell.SetCellValue("日照小時:"); //cell.SetCellValue("日照小時:");
cell.CellStyle = styleLine12; //cell.CellStyle = styleLine12;
cell = row.CreateCell(1); //cell = row.CreateCell(1);
cell.SetCellValue(!string.IsNullOrEmpty(thour)? Convert.ToDouble(thour) : 0); //cell.SetCellValue(!string.IsNullOrEmpty(thour)? Convert.ToDouble(thour) : 0);
cell.CellStyle = styleLine12; //cell.CellStyle = styleLine12;
RowPosition++; //RowPosition++;
index = 0; index = 0;
row = sheet.CreateRow(RowPosition); row = sheet.CreateRow(RowPosition);
@ -1169,6 +1198,16 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
RowPosition++; RowPosition++;
index = 0;
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
cell.SetCellValue("裝置容量:");
cell.CellStyle = styleLine12;
cell = row.CreateCell(1);
cell.SetCellValue(Convert.ToDouble(GeneratingCapacity));
cell.CellStyle = styleLine12;
RowPosition++;
if (Formhead.Result.Data.ShowMoney == 1) if (Formhead.Result.Data.ShowMoney == 1)
{ {
@ -1222,7 +1261,7 @@ namespace SolarPower.Controllers
"日照小時(hr)", "日照小時(hr)",
"有效發電小時", "有效發電小時",
"PR%", "PR%",
"日平均日照度(W/㎡)", "累積日照量(kWh)",
"日平均模組溫度(°C)" "日平均模組溫度(°C)"
}; };
@ -1243,6 +1282,7 @@ namespace SolarPower.Controllers
#region body //RowPosition = 1 #region body //RowPosition = 1
RowPosition++; RowPosition++;
var avghour = "0"; var avgKWHKWP = "0"; var avgdayKWH = "0"; var monthKWH = "0"; var monthmoney = "0"; var monthmoneyone = "0"; var avghour = "0"; var avgKWHKWP = "0"; var avgdayKWH = "0"; var monthKWH = "0"; var monthmoney = "0"; var monthmoneyone = "0";
var monthGeneratingCapacity = "";
var check_hire = false; var check_hire = false;
var sitedb = ""; var sitedb = "";
foreach (dynamic body in Formbody.Result.Data) foreach (dynamic body in Formbody.Result.Data)
@ -1256,6 +1296,7 @@ namespace SolarPower.Controllers
monthKWH = dbody["monthKWH"] == null ? "0" : dbody["monthKWH"].ToString(); monthKWH = dbody["monthKWH"] == null ? "0" : dbody["monthKWH"].ToString();
monthmoney = dbody["monthmoney"] == null ? "0" : dbody["monthmoney"].ToString(); monthmoney = dbody["monthmoney"] == null ? "0" : dbody["monthmoney"].ToString();
monthmoneyone = (Convert.ToDouble(dbody["monthmoneyone"].ToString()) + Convert.ToDouble(monthmoneyone)).ToString(); monthmoneyone = (Convert.ToDouble(dbody["monthmoneyone"].ToString()) + Convert.ToDouble(monthmoneyone)).ToString();
monthGeneratingCapacity = Checknull(Math.Round(Convert.ToDouble(dbody["GeneratingCapacity"]), 2).ToString());
if (dbody["SolarType"].ToString() == "1" && Formhead.Result.Data.ShowMoney == 1)//檢驗是否為租用 if (dbody["SolarType"].ToString() == "1" && Formhead.Result.Data.ShowMoney == 1)//檢驗是否為租用
{ {
check_hire = true; check_hire = true;
@ -1281,7 +1322,7 @@ namespace SolarPower.Controllers
"tothour", "tothour",
"KWHKWP", "KWHKWP",
"PR", "PR",
"irradiance", "IrrDay",
"temperature" "temperature"
}; };
if (Formhead.Result.Data.ShowMoney == 1) if (Formhead.Result.Data.ShowMoney == 1)
@ -1313,20 +1354,28 @@ namespace SolarPower.Controllers
var Useday = Formbody.Result.Data.Count; var Useday = Formbody.Result.Data.Count;
row = sheet.CreateRow(RowPosition); row = sheet.CreateRow(RowPosition);
//cell = row.CreateCell(index);
//cell.SetCellValue("日日照小時平均");
//cell.CellStyle = styleLine12;
//index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue("日日照小時平均"); cell.SetCellValue("有效發電小時(日)");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue("日kWH/kWP平均"); cell.SetCellValue("發電量平均(kWh)(日)");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue("發電量平均(kWh)"); cell.SetCellValue("發電量(kWh)(月)");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue("月發電量(kWh)"); cell.SetCellValue("裝置容量");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("每度獲利");
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
if (Formhead.Result.Data.ShowMoney == 1) if (Formhead.Result.Data.ShowMoney == 1)
@ -1350,10 +1399,10 @@ namespace SolarPower.Controllers
RowPosition++; RowPosition++;
row = sheet.CreateRow(RowPosition); row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index); //cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(avghour) / Useday, 2)); //cell.SetCellValue(Math.Round(Convert.ToDouble(avghour) / Useday, 2));
cell.CellStyle = styleLine12; //cell.CellStyle = styleLine12;
index++; //index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(avgKWHKWP) / Useday, 2)); cell.SetCellValue(Math.Round(Convert.ToDouble(avgKWHKWP) / Useday, 2));
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
@ -1366,6 +1415,14 @@ namespace SolarPower.Controllers
cell.SetCellValue(Convert.ToDouble(monthKWH)); cell.SetCellValue(Convert.ToDouble(monthKWH));
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index);
cell.SetCellValue(Convert.ToDouble(monthGeneratingCapacity));
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthKWH) / Convert.ToDouble(monthGeneratingCapacity), 3));
cell.CellStyle = styleLine12;
index++;
if (Formhead.Result.Data.ShowMoney == 1) if (Formhead.Result.Data.ShowMoney == 1)
{ {
cell = row.CreateCell(index); cell = row.CreateCell(index);
@ -1373,7 +1430,7 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
cell = row.CreateCell(index); cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoneyone) / Useday, 2)); cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoneyone) / Useday, 4));
cell.CellStyle = styleLine12; cell.CellStyle = styleLine12;
index++; index++;
} }

View File

@ -21,7 +21,9 @@ namespace SolarPower.Models.PowerStation
EMM = 4, //環境濕度計 EMM = 4, //環境濕度計
VAN = 5, //風速計 VAN = 5, //風速計
FOM = 6, //落塵計 FOM = 6, //落塵計
PWR = 7 //電錶 PWR = 7, //電錶
WIN = 8, //風向計
TPY = 9 //累計日照量
} }
public class PowerStation : Created public class PowerStation : Created
@ -729,6 +731,8 @@ namespace SolarPower.Models.PowerStation
public double Humidity { get; set; } //濕度 public double Humidity { get; set; } //濕度
public double Vane { get; set; } //風速 public double Vane { get; set; } //風速
public double Dust { get; set; } //落塵計 public double Dust { get; set; } //落塵計
public double WingDirection { get; set; } //風向計
public double IrrDay { get; set; } //累計日照量
} }
public class AvgPyrheliometerHistory public class AvgPyrheliometerHistory

View File

@ -428,7 +428,7 @@ namespace SolarPower.Quartz.Jobs
logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message); logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message);
} }
//5. 計算該電站 - 落塵計(FOM) //6. 計算該電站 - 落塵計(FOM)
try try
{ {
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的落塵計設備資訊】", powerStation.Code, dateTime); logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的落塵計設備資訊】", powerStation.Code, dateTime);
@ -452,6 +452,54 @@ namespace SolarPower.Quartz.Jobs
logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message); logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message);
} }
//7. 計算該電站 - 風向計(WIN)
try
{
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的風向計設備資訊】", powerStation.Code, dateTime);
var WINdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, SensorTypeEnum.WIN.ToString(), powerStation.SiteDB);
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的風向計設備資訊】", powerStation.Code, dateTime);
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的風向計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(WINdeviceInfos));
if (WINdeviceInfos != null && WINdeviceInfos.Count() > 0)
{
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的風向計的平均%】", powerStation.Code, dateTime);
var WINHistory = await powerStationRepository.CalcSensorHistoryPerHour(dateTime, WINdeviceInfos, Convert.ToInt32(SensorTypeEnum.WIN));
if (WINHistory != null)
{
sensorHistory.WingDirection = WINHistory.WingDirection;
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的風向計的平均值】", powerStation.Code, dateTime);
}
}
}
catch (Exception ex)
{
logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的風向計的平均值】", powerStation.Code, dateTime);
logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message);
}
//8. 計算該電站 - 累計日照量(TPY)
try
{
logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的累計日照量設備資訊】", powerStation.Code, dateTime);
var TPYdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, SensorTypeEnum.TPY.ToString(), powerStation.SiteDB);
logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的累計日照量備資訊】", powerStation.Code, dateTime);
logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的累計日照量設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(TPYdeviceInfos));
if (TPYdeviceInfos != null && TPYdeviceInfos.Count() > 0)
{
logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的累計日照量的平均%】", powerStation.Code, dateTime);
var TPYHistory = await powerStationRepository.CalcSensorHistoryPerHour(dateTime, TPYdeviceInfos, Convert.ToInt32(SensorTypeEnum.TPY));
if (TPYHistory != null)
{
sensorHistory.IrrDay = TPYHistory.IrrDay;
logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的累計日照量的平均值】", powerStation.Code, dateTime);
}
}
}
catch (Exception ex)
{
logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的累計日照量的平均值】", powerStation.Code, dateTime);
logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message);
}
sensorHistoriesHour.Add(sensorHistory); sensorHistoriesHour.Add(sensorHistory);
} }

View File

@ -2523,26 +2523,41 @@ namespace SolarPower.Repository.Implement
{ {
SensorTypeEnum SensorTypeEnum = (SensorTypeEnum)type; SensorTypeEnum SensorTypeEnum = (SensorTypeEnum)type;
var typename = ""; var typename = "";
var calc = "";
switch (SensorTypeEnum) switch (SensorTypeEnum)
{ {
case SensorTypeEnum.PYR: //日照計 case SensorTypeEnum.PYR: //日照計
calc = "AVG";
typename = "Irradiance"; typename = "Irradiance";
break; break;
case SensorTypeEnum.MTR: //模組溫度計 case SensorTypeEnum.MTR: //模組溫度計
calc = "AVG";
typename = "Temperature"; typename = "Temperature";
break; break;
case SensorTypeEnum.ETR: //環境溫度計 case SensorTypeEnum.ETR: //環境溫度計
calc = "AVG";
typename = "EnvTemperature"; typename = "EnvTemperature";
break; break;
case SensorTypeEnum.EMM: //環境濕度計 case SensorTypeEnum.EMM: //環境濕度計
calc = "AVG";
typename = "Humidity"; typename = "Humidity";
break; break;
case SensorTypeEnum.VAN: //風速計 case SensorTypeEnum.VAN: //風速計
calc = "AVG";
typename = "Vane"; typename = "Vane";
break; break;
case SensorTypeEnum.FOM: //落塵計 case SensorTypeEnum.FOM: //落塵計
calc = "AVG";
typename = "Dust"; typename = "Dust";
break; break;
case SensorTypeEnum.WIN: //風向計
calc = "AVG";
typename = "WingDirection";
break;
case SensorTypeEnum.TPY: //累計日照量
calc = "MAX";
typename = "IrrDay";
break;
} }
PyrheliometerHistory result; PyrheliometerHistory result;
@ -2563,7 +2578,7 @@ namespace SolarPower.Repository.Implement
sql_per_device.Add(str); sql_per_device.Add(str);
} }
var sql = @$"SELECT a.TIMESTAMP, AVG(a.SENSOR) AS {typename} FROM(" + string.Join(" UNION ", sql_per_device) + @") a GROUP BY `TIMESTAMP`"; var sql = @$"SELECT a.TIMESTAMP, {calc}(a.SENSOR) AS {typename} FROM(" + string.Join(" UNION ", sql_per_device) + @") a GROUP BY `TIMESTAMP`";
result = await conn.QueryFirstOrDefaultAsync<PyrheliometerHistory>(sql, new { DateTime = dateTime }); result = await conn.QueryFirstOrDefaultAsync<PyrheliometerHistory>(sql, new { DateTime = dateTime });
} }

View File

@ -56,46 +56,35 @@ namespace SolarPower.Repository.Implement
case 0: case 0:
sql += @$" sql += @$"
SET @sql = NULL; SET @sql = NULL;
SELECT SELECT
GROUP_CONCAT(DISTINCT GROUP_CONCAT( 'a.inv_',RIGHT(v.InverterId, 2)) INTO @sql
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then a.KWH end) ''inv_', right(INVERTERID, 2), '''') from v_company_inv v
) INTO @sql LEFT JOIN power_station p ON p.Code = left(inverterid, 9)
FROM inverter_history_hour where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = '{post.Time}'; WHERE p.Id = {post.PowerStation} AND v.enabled = 1 ;
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m-%d %H'') report_date, ', @sql,
', b.KWH hourKWH, round((b.KWH / (SELECT MAX(TODAYKWH) FROM power_station_history_hour WHERE DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}'' and powerstationid = {post.PowerStation}))*100,2) ''hourKWHp'', d.irradiance ''irradiance'', d.Temperature ''temperature'', SET @sql = CONCAT('SELECT DATE_FORMAT(a.report_date,''%m-%d %H'') report_date, ', @SQL,
b.money ''hourmoney'', c.TODAYKWH ''totKWH'', c.KWHKWP ''totKWHKWP'', c.money ''totmoney'', stationName, powerRate daymoney, c.SOLARHOUR tothour,round(b.PR, 2) as pr ', a.hourKWH hourKWH, a.hourKWHp ''hourKWHp'', a.irradiance ''irradiance'', a.Temperature ''temperature'',
FROM inverter_history_hour a left join a.hourmoney ''hourmoney'', c.TODAYKWH ''totKWH'', c.KWHKWP ''totKWHKWP'', c.money ''totmoney'', stationName, powerRate daymoney, c.SOLARHOUR tothour,round(a.PR, 2) as pr,GeneratingCapacity
( # inv FROM report_invday a
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'') report_date, siteid, sitetype, round(KWH, 2) KWH, left join
round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, round(money, 2) money ( # day
from power_station_history_hour select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, sitetype, round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP
where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d'') = ''{post.Time}'' , round(PR, 2) PR, round(money, 2) money , round(SOLARHOUR, 2) SOLARHOUR
) b on a.powerStationid = b.powerStationid and DATE_FORMAT(a.`TIMESTAMP`,''%Y-%m-%d %H:%i'') = b.report_date from power_station_history_day
left join where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d'') = ''{post.Time}''
( # day ) c on a.PowerStationID = c.powerStationid and DATE_FORMAT(a.`report_date`,''%Y-%m-%d'') = c.report_date
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, sitetype, round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP join
, round(PR, 2) PR, round(money, 2) money , round(SOLARHOUR, 2) SOLARHOUR (
from power_station_history_day select id, name stationName, powerRate,GeneratingCapacity from power_station where id = {post.PowerStation}
where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d'') = ''{post.Time}'' )z on a.PowerStationID = z.id
) c on a.powerStationid = c.powerStationid and DATE_FORMAT(a.`TIMESTAMP`,''%Y-%m-%d'') = c.report_date where DATE_FORMAT(a.report_date,''%Y-%m-%d'') = ''{post.Time}'' and a.PowerStationID = {post.PowerStation}
left join GROUP BY DATE_FORMAT(a.report_date,''%Y-%m-%d %H:%i'')
( order by DATE_FORMAT(a.report_date,''%Y-%m-%d %H:%i'') ');
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:00'')report_date, irradiance, Temperature
from sensor_history_hour
where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d'') = ''{post.Time}''
) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d %H:00'') = d.report_date
join
(
select id, name stationName, powerRate from power_station where id = {post.PowerStation}
)z on a.powerstationid = z.id
where DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}''
GROUP BY DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d %H:%i'')
order by DATE_FORMAT(a.`TIMESTAMP`,''%Y-%m-%d %H:%i'') ');
#select @sql as 'mySelect'; # #select @sql as 'mySelect'; #
PREPARE stmt FROM @sql; PREPARE stmt FROM @sql;
EXECUTE stmt; EXECUTE stmt;
DEALLOCATE PREPARE stmt;"; DEALLOCATE PREPARE stmt;";
break; break;
case 1: case 1:
if(post.SearchType == 2) if(post.SearchType == 2)
@ -108,9 +97,9 @@ namespace SolarPower.Repository.Implement
) INTO @sql ) INTO @sql
FROM inverter_history_day where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = '{post.Time}'; FROM inverter_history_day where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = '{post.Time}';
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql, SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql,
',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR, ',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR,z.GeneratingCapacity,
d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'', d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'',
c.monthKWH ''monthKWH'', c.money ''monthmoney'', stationName, powerRate ''monthmoneyone'',SolarType,SiteDB c.monthKWH ''monthKWH'', c.money ''monthmoney'', stationName, powerRate ''monthmoneyone'',SolarType,SiteDB,d.IrrDay
FROM inverter_history_day a left join FROM inverter_history_day a left join
( # inv ( # inv
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, siteid, sitetype, #, round(KWH, 2) KWH, select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, siteid, sitetype, #, round(KWH, 2) KWH,
@ -127,13 +116,13 @@ namespace SolarPower.Repository.Implement
) c on a.powerStationid = c.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m'') = c.report_date ) c on a.powerStationid = c.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m'') = c.report_date
left join left join
( (
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'')report_date, irradiance, Temperature select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'')report_date, irradiance, Temperature ,IrrDay
from sensor_history_day from sensor_history_day
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m'') = ''{post.Time}'' where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m'') = ''{post.Time}''
) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = d.report_date ) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = d.report_date
join join
( (
select id, name stationName, powerRate,SolarType,SiteDB from power_station where id = {post.PowerStation} select id, name stationName, powerRate,SolarType,SiteDB,GeneratingCapacity from power_station where id = {post.PowerStation}
)z on a.powerstationid = z.id )z on a.powerstationid = z.id
where DATE_FORMAT(a.TIMESTAMP,''%Y-%m'') = ''{post.Time}'' where DATE_FORMAT(a.TIMESTAMP,''%Y-%m'') = ''{post.Time}''
GROUP BY DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') GROUP BY DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'')
@ -155,9 +144,9 @@ namespace SolarPower.Repository.Implement
) INTO @sql ) INTO @sql
FROM inverter_history_day where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{times[0]}' AND '{times[1]}'; FROM inverter_history_day where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{times[0]}' AND '{times[1]}';
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql, SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m/%d'') report_date, ', @sql,
',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR, ',b.TODAYKWH ''dayKWH'', round((b.TODAYKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR,GeneratingCapacity,
d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'', d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'',
c.monthKWH ''monthKWH'', c.money ''monthmoney'', stationName, powerRate ''monthmoneyone'',SolarType,SiteDB c.monthKWH ''monthKWH'', c.money ''monthmoney'', stationName, powerRate ''monthmoneyone'',SolarType,SiteDB ,d.IrrDay
FROM inverter_history_day a left join FROM inverter_history_day a left join
( # inv ( # inv
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, siteid, sitetype, #, round(KWH, 2) KWH, select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, siteid, sitetype, #, round(KWH, 2) KWH,
@ -176,13 +165,13 @@ namespace SolarPower.Repository.Implement
) c on a.powerStationid = c.powerStationid ) c on a.powerStationid = c.powerStationid
left join left join
( (
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'')report_date, irradiance, Temperature select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'')report_date, irradiance, Temperature ,IrrDay
from sensor_history_day from sensor_history_day
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') BETWEEN ''{times[0]}'' AND ''{times[1]}'' where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') BETWEEN ''{times[0]}'' AND ''{times[1]}''
) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = d.report_date ) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = d.report_date
join join
( (
select id, name stationName, powerRate, SolarType, SiteDB from power_station where id = {post.PowerStation} select id, name stationName, powerRate, SolarType, SiteDB,GeneratingCapacity from power_station where id = {post.PowerStation}
)z on a.powerstationid = z.id )z on a.powerstationid = z.id
where DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') BETWEEN ''{times[0]}'' AND ''{times[1]}'' where DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') BETWEEN ''{times[0]}'' AND ''{times[1]}''
GROUP BY DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') GROUP BY DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'')
@ -204,7 +193,7 @@ namespace SolarPower.Repository.Implement
) INTO @sql ) INTO @sql
FROM inverter_history_month where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y') = '{post.Time}'; FROM inverter_history_month where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y') = '{post.Time}';
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%Y/%m'') report_date, ', @sql, SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%Y/%m'') report_date, ', @sql,
',b.todayKWH ''dayKWH'', round((b.todayKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', c.PR, ',b.todayKWH ''dayKWH'', round((b.todayKWH / c.monthKWH)*100,2) ''dayKWHp'', b.SOLARHOUR ''tothour'', b.KWHKWP ''KWHKWP'', b.PR,
d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'', d.irradiance ''irradiance'', d.Temperature ''temperature'', b.money ''soldmoney'',
c.monthKWH ''monthKWH'', c.money ''monthmoney'', stationName, powerRate ''monthmoneyone'',SolarType,SiteDB c.monthKWH ''monthKWH'', c.money ''monthmoney'', stationName, powerRate ''monthmoneyone'',SolarType,SiteDB
FROM inverter_history_month a left join FROM inverter_history_month a left join
@ -431,47 +420,36 @@ namespace SolarPower.Repository.Implement
{ {
case 0: case 0:
sql = @$" sql = @$"
SET @sql = NULL; SET @sql = NULL;
SELECT SELECT
GROUP_CONCAT(DISTINCT GROUP_CONCAT( 'a.inv_',RIGHT(v.InverterId, 2)) INTO @sql
CONCAT('max(case when INVERTERID = ''', INVERTERID, ''' then a.KWH end) ''inv_', right(INVERTERID, 2), '''') from v_company_inv v
) INTO @sql LEFT JOIN power_station p ON p.Code = left(inverterid, 9)
FROM inverter_history_hour where powerstationId = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = '{post.Time}'; WHERE p.Id = {post.PowerStation} AND v.enabled = 1 ;
SET @sql = CONCAT('SELECT DATE_FORMAT(a.TIMESTAMP,''%m-%d %H'') report_date, ', @sql,
', b.KWH hourKWH, round((b.KWH / (SELECT MAX(TODAYKWH) FROM power_station_history_hour WHERE DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}'' and powerstationid = {post.PowerStation}))*100,2) ''hourKWHp'', d.irradiance ''irradiance'', d.Temperature ''temperature'', SET @sql = CONCAT('SELECT DATE_FORMAT(a.report_date,''%m-%d %H'') report_date, ', @SQL,
b.money ''hourmoney'', c.TODAYKWH ''totKWH'', c.KWHKWP ''totKWHKWP'', c.money ''totmoney'', stationName, powerRate daymoney, c.SOLARHOUR tothour,round(b.PR, 2) as pr ', a.hourKWH hourKWH, a.hourKWHp ''hourKWHp'', a.irradiance ''irradiance'', a.Temperature ''temperature'',
FROM inverter_history_hour a left join a.hourmoney ''hourmoney'', c.TODAYKWH ''totKWH'', c.KWHKWP ''totKWHKWP'', c.money ''totmoney'', stationName, powerRate daymoney, c.SOLARHOUR tothour,round(a.PR, 2) as pr,GeneratingCapacity
( # inv FROM report_invday a
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'') report_date, siteid, sitetype, round(KWH, 2) KWH, left join
round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, round(money, 2) money ( # day
from power_station_history_hour select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, sitetype, round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP
where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d'') = ''{post.Time}'' , round(PR, 2) PR, round(money, 2) money , round(SOLARHOUR, 2) SOLARHOUR
) b on a.powerStationid = b.powerStationid and DATE_FORMAT(a.`TIMESTAMP`,''%Y-%m-%d %H:%i'') = b.report_date from power_station_history_day
left join where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,''%Y-%m-%d'') = ''{post.Time}''
( # day ) c on a.PowerStationID = c.powerStationid and DATE_FORMAT(a.`report_date`,''%Y-%m-%d'') = c.report_date
select powerStationid, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') report_date, sitetype, round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP join
, round(PR, 2) PR, round(money, 2) money , round(SOLARHOUR, 2) SOLARHOUR (
from power_station_history_day select id, name stationName, powerRate,GeneratingCapacity from power_station where id = {post.PowerStation}
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}'' )z on a.PowerStationID = z.id
) c on a.powerStationid = c.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d'') = c.report_date where DATE_FORMAT(a.report_date,''%Y-%m-%d'') = ''{post.Time}'' and
left join GROUP BY DATE_FORMAT(a.report_date,''%Y-%m-%d %H:%i'')
( order by DATE_FORMAT(a.report_date,''%Y-%m-%d %H:%i'') ');
select powerStationID, DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'')report_date, irradiance, Temperature
from sensor_history_hour
where powerstationid = {post.PowerStation} and DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}''
) d on a.powerStationid = d.powerStationid and DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d %H:%i'') = d.report_date
join
(
select id, name stationName, powerRate from power_station where id = {post.PowerStation}
)z on a.powerstationid = z.id
where DATE_FORMAT(TIMESTAMP,''%Y-%m-%d'') = ''{post.Time}''
GROUP BY DATE_FORMAT(TIMESTAMP,''%Y-%m-%d %H:%i'')
order by DATE_FORMAT(a.TIMESTAMP,''%Y-%m-%d %H:%i'') ');
select @sql as 'mySelect'; # select @sql as 'mySelect'; #
#PREPARE stmt FROM @sql; #PREPARE stmt FROM @sql;
#EXECUTE stmt; #EXECUTE stmt;
#DEALLOCATE PREPARE stmt;"; #DEALLOCATE PREPARE stmt;";
break; break;
case 1: case 1:
if (post.SearchType == 2) if (post.SearchType == 2)

View File

@ -228,67 +228,71 @@
</div> </div>
</div> </div>
<div class="row mb-5"> <div id="all">
<div class="col-xl-12"> <div class="row mb-5">
<div class="card p-3 w-100" id="overviewtable"> <div class="col-xl-12">
<table class="table m-0"> <div class="card p-3 w-100" id="overviewtable">
<thead id="tothead"> <table class="table m-0">
</thead> <thead id="tothead">
<tbody id="totbody"> </thead>
</tbody> <tbody id="totbody">
</table> </tbody>
</div> </table>
</div> </div>
</div> </div>
<div class="row mb-5"> </div>
<div class="col-xl-12"> <div class="row mb-5">
<div class="card p-3 w-100" id="hiretable" style="overflow-x:auto"> <div class="col-xl-12">
<table class="table m-0"> <div class="card p-3 w-100" id="hiretable" style="overflow-x:auto">
<thead id="HireTableHead"> <table class="table m-0">
<tr> <thead id="HireTableHead">
<th>出租人</th> <tr>
<th>租金比例</th> <th>出租人</th>
<th>租金金額(未稅)</th> <th>租金比例</th>
<th>租金金額(含稅)</th> <th>租金金額(未稅)</th>
</tr> <th>租金金額(含稅)</th>
</thead> </tr>
<tbody id="HireTableBody"> </thead>
</tbody> <tbody id="HireTableBody">
</table> </tbody>
</div> </table>
</div> </div>
</div> </div>
<div class="row mb-5"> </div>
<div class="col-xl-12"> <div class="row mb-5">
<div class="card p-3 w-100 " id="maxtable" style="overflow-x:auto"> <div class="col-xl-12">
<table class="table m-0"> <div class="card p-3 w-100 " id="maxtable" style="overflow-x:auto">
<thead> <table class="table m-0">
<tr> <thead>
<th>縣市</th> <tr>
<th>平均發電量(kWp)</th> <th>縣市</th>
<th>有效發電小時</th> <th>平均發電量(kWp)</th>
</tr> <th>有效發電小時</th>
</thead> </tr>
<tbody id="maxtableBody"> </thead>
</tbody> <tbody id="maxtableBody">
</table> </tbody>
</div> </table>
</div> </div>
</div> </div>
<div class="row mb-5"> </div>
<div class="col-xl-12"> <div class="row mb-5">
<div class="card p-3 w-100" id="detailtable" style="overflow-x:auto"> <div class="col-xl-12">
<table class="table m-0"> <div class="card p-3 w-100" id="detailtable" style="overflow-x:auto">
<thead id="TableHead"> <table class="table m-0">
</thead> <thead id="TableHead">
<tbody id="TableBody"> </thead>
</tbody> <tbody id="TableBody">
</table> </tbody>
</table>
</div>
</div> </div>
</div> </div>
</div> </div>
</main> </main>
</div> </div>
</div> </div>
@ -785,7 +789,7 @@
str += "<th>日照小時(hr)</th>"; str += "<th>日照小時(hr)</th>";
str += "<th>有效發電小時</th>"; str += "<th>有效發電小時</th>";
str += "<th>PR%</th>"; str += "<th>PR%</th>";
str += "<th>日<br />平均<br />日照度<br />(W/㎡)</th>"; str += "<th>累積日照量(kWh)</th>";
str += "<th>日<br />平均<br />模組溫度<br />(°C)</th>"; str += "<th>日<br />平均<br />模組溫度<br />(°C)</th>";
if (rel.data.showMoney == 1) { if (rel.data.showMoney == 1) {
str += "<th>日<br />售電金額<br />(NTD)</th>"; str += "<th>日<br />售電金額<br />(NTD)</th>";
@ -840,9 +844,11 @@
$(e).removeClass("btn-primary").addClass("btn-success"); $(e).removeClass("btn-primary").addClass("btn-success");
button = e; button = e;
$('#all').hide();
$('#hiretable').hide(); $('#hiretable').hide();
$('#maxtable').hide(); $('#maxtable').hide();
tablehand(form); tablehand(form);
} }
@ -913,6 +919,7 @@
var ntd = 0; var ntd = 0;
var ntdone = 0; var ntdone = 0;
var sta = ""; var sta = "";
var GeneratingCapacity = 0;
$.each(rel.data, function (index, inverter) { $.each(rel.data, function (index, inverter) {
sta += "<tr>"; sta += "<tr>";
sta += "<td>" + inverter.report_date + "</td>"; sta += "<td>" + inverter.report_date + "</td>";
@ -928,7 +935,7 @@
sta += "<td>" + Number(inverter.irradiance) + "</td>"; sta += "<td>" + Number(inverter.irradiance) + "</td>";
sta += "<td>" + Number(inverter.temperature) + "</td>"; sta += "<td>" + Number(inverter.temperature) + "</td>";
if (showmoney == 1) { if (showmoney == 1) {
sta += "<td>" + Math.round(Number(inverter.hourmoney)) + "</td>"; sta += "<td>" + toThousands(Math.round(Number(inverter.hourmoney))) + "</td>";
} }
sta += "</tr>"; sta += "</tr>";
thour = inverter.tothour ? inverter.tothour.toFixed(2) : 0; thour = inverter.tothour ? inverter.tothour.toFixed(2) : 0;
@ -936,13 +943,15 @@
tkwh = inverter.totKWH ? inverter.totKWH.toFixed(2) : 0; tkwh = inverter.totKWH ? inverter.totKWH.toFixed(2) : 0;
kWhkwp = inverter.totKWHKWP ? inverter.totKWHKWP.toFixed(2) : 0; kWhkwp = inverter.totKWHKWP ? inverter.totKWHKWP.toFixed(2) : 0;
ntd = inverter.totmoney ? Math.round(inverter.totmoney) : 0; ntd = inverter.totmoney ? Math.round(inverter.totmoney) : 0;
ntdone = inverter.totmoney / inverter.totKWH ? Math.round(inverter.totmoney / inverter.totKWH) : 0; ntdone = inverter.totmoney / inverter.totKWH ? Math.round(inverter.totmoney / inverter.totKWH * 10000) / 10000 : 0;
GeneratingCapacity = inverter.GeneratingCapacity;
}) })
var stc = "<tr>"; var stc = "<tr>";
stc += "<th>" + '日照小時' + "</th>"; /* stc += "<th>" + '日照小時' + "</th>";*/
stc += "<th>" + '有效發電小時' + "</th>"; stc += "<th>" + '有效發電小時' + "</th>";
stc += "<th>" + 'PR%' + "</th>"; stc += "<th>" + 'PR%' + "</th>";
stc += "<th>" + '日發電量(kWh)' + "</th>"; stc += "<th>" + '日發電量(kWh)' + "</th>";
stc += "<th>" + '裝置容量' + "</th>";
if (showmoney == 1) { if (showmoney == 1) {
stc += "<th>" + '日售電金額(NTD)' + "</th>"; stc += "<th>" + '日售電金額(NTD)' + "</th>";
stc += "<th>" + '日售電單價(NTD)' + "</th>"; stc += "<th>" + '日售電單價(NTD)' + "</th>";
@ -951,13 +960,14 @@
var stb = "<tr>"; var stb = "<tr>";
stb += "<td>" + thour + "</td>"; /* stb += "<td>" + thour + "</td>";*/
stb += "<td>" + kWhkwp + "</td>"; stb += "<td>" + kWhkwp + "</td>";
stb += "<td>" + tpr + "</td>"; stb += "<td>" + tpr + "</td>";
stb += "<td>" + tkwh + "</td>"; stb += "<td>" + tkwh + "</td>";
stb += "<td>" + GeneratingCapacity + "</td>";
if (showmoney == 1) { if (showmoney == 1) {
stb += "<td>" + Math.round(ntd) + "</td>"; stb += "<td>" + toThousands(Math.round(ntd)) + "</td>";
stb += "<td>" + Math.round(ntdone) + "</td>"; stb += "<td>" + Math.round(ntdone * 10000) / 10000 + "</td>";
} }
stb += "</tr>"; stb += "</tr>";
@ -979,6 +989,7 @@
var sta = ""; var sta = "";
var check_hire = false; var check_hire = false;
var sitedb = ""; var sitedb = "";
var GeneratingCapacity = 0;
$.each(rel.data, function (index, inverter) { $.each(rel.data, function (index, inverter) {
sta += "<tr>"; sta += "<tr>";
sta += "<td>" + inverter.report_date + "</td>"; sta += "<td>" + inverter.report_date + "</td>";
@ -994,10 +1005,10 @@
sta += "<td>" + inverter.tothour + "</td>"; sta += "<td>" + inverter.tothour + "</td>";
sta += "<td>" + inverter.KWHKWP + "</td>"; sta += "<td>" + inverter.KWHKWP + "</td>";
sta += "<td>" + ((inverter.PR == null) ? 0 : inverter.PR.toFixed(2)) + "</td>"; sta += "<td>" + ((inverter.PR == null) ? 0 : inverter.PR.toFixed(2)) + "</td>";
sta += "<td>" + inverter.irradiance + "</td>"; sta += "<td>" + ((inverter.IrrDay == null) ? 0 : inverter.IrrDay) + "</td>";
sta += "<td>" + inverter.temperature + "</td>"; sta += "<td>" + inverter.temperature + "</td>";
if (showmoney == 1) { if (showmoney == 1) {
sta += "<td>" + Math.round(inverter.soldmoney) + "</td>"; sta += "<td>" + toThousands(Math.round(inverter.soldmoney)) + "</td>";
} }
sta += "</tr>"; sta += "</tr>";
avghour += inverter.tothour ? inverter.tothour : 0; avghour += inverter.tothour ? inverter.tothour : 0;
@ -1011,16 +1022,18 @@
check_hire = true; check_hire = true;
sitedb = inverter.SiteDB sitedb = inverter.SiteDB
} }
GeneratingCapacity = inverter.GeneratingCapacity;
}) })
monthday = rel.data.length; monthday = rel.data.length;
var stc = "<tr>"; var stc = "<tr>";
stc += "<th>" + '日照平均(日)' + "</th>"; /*stc += "<th>" + '日照平均(日)' + "</th>";*/
stc += "<th>" + '有效發電小時(日)' + "</th>"; stc += "<th>" + '有效發電小時(日)' + "</th>";
stc += "<th>" + '發電量平均(kWh)(日)' + "</th>"; stc += "<th>" + '發電量平均(kWh)(日)' + "</th>";
stc += "<th>" + '發電量(kWh)(月)' + "</th>"; stc += "<th>" + '發電量(kWh)(月)' + "</th>";
stc += "<th>" + '裝置容量' + "</th>";
stc += "<th>" + '每度獲利' + "</th>";
if (showmoney == 1) { if (showmoney == 1) {
stc += "<th>" + '售電金額(NTD)(月)' + "</th>"; stc += "<th>" + '售電金額(NTD)(月)' + "</th>";
stc += "<th>" + '售電單價(NTD)(月)' + "</th>"; stc += "<th>" + '售電單價(NTD)(月)' + "</th>";
@ -1042,13 +1055,16 @@
stb += "</tr>"; stb += "</tr>";
} }
else { else {
stb += "<td>" + (avghour / monthday).toFixed(2) + "</td>"; /*stb += "<td>" + (avghour / monthday).toFixed(2) + "</td>";*/
stb += "<td>" + (avgKWHKWP / monthday).toFixed(2) + "</td>"; stb += "<td>" + (avgKWHKWP / monthday).toFixed(2) + "</td>";
stb += "<td>" + (avgdayKWH / monthday).toFixed(2) + "</td>"; stb += "<td>" + (avgdayKWH / monthday).toFixed(2) + "</td>";
stb += "<td>" + monthKWH + "</td>"; stb += "<td>" + monthKWH + "</td>";
stb += "<td>" + GeneratingCapacity + "</td>";
stb += "<td>" + (monthKWH / GeneratingCapacity).toFixed(3) + "</td>";
if (showmoney == 1) { if (showmoney == 1) {
stb += "<td>" + Math.round(monthmoney) + "</td>";
stb += "<td>" + Math.round(monthmoneyone / monthday) + "</td>"; stb += "<td>" + toThousands(Math.round(monthmoney)) + "</td>";
stb += "<td>" + Math.round(monthmoneyone / monthday*10000)/10000 + "</td>";
} }
stb += "<td>" + monthday + "</td>"; stb += "<td>" + monthday + "</td>";
stb += "</tr>"; stb += "</tr>";
@ -1071,8 +1087,8 @@
std += "<tr>"; std += "<tr>";
std += "<td>" + value.landowner + "</td>"; std += "<td>" + value.landowner + "</td>";
std += "<td>" + value.leaseRate + "%" + "</td>"; std += "<td>" + value.leaseRate + "%" + "</td>";
std += "<td>" + Math.round(monthmoney * value.leaseRate / 100) + "</td>"; std += "<td>" + toThousands(Math.round(monthmoney * value.leaseRate / 100)) + "</td>";
std += "<td>" + Math.round(monthmoney * value.leaseRate / 100 * 1.05) + "</td>"; std += "<td>" + toThousands(Math.round(monthmoney * value.leaseRate / 100 * 1.05)) + "</td>";
std += "</tr>"; std += "</tr>";
}) })
$('#HireTableBody').append(std); $('#HireTableBody').append(std);
@ -1117,7 +1133,7 @@
sta += "<td>" + inverter.irradiance + "</td>"; sta += "<td>" + inverter.irradiance + "</td>";
sta += "<td>" + inverter.temperature + "</td>"; sta += "<td>" + inverter.temperature + "</td>";
if (showmoney == 1) { if (showmoney == 1) {
sta += "<td>" + Math.round(inverter.soldmoney) + "</td>"; sta += "<td>" + toThousands(Math.round(inverter.soldmoney)) + "</td>";
} }
sta += "</tr>"; sta += "</tr>";
avghour += inverter.tothour ? inverter.tothour : 0; avghour += inverter.tothour ? inverter.tothour : 0;
@ -1167,8 +1183,8 @@
stb += "<td>" + (avgdayKWH / monthday).toFixed(2) + "</td>"; stb += "<td>" + (avgdayKWH / monthday).toFixed(2) + "</td>";
stb += "<td>" + monthKWH + "</td>"; stb += "<td>" + monthKWH + "</td>";
if (showmoney == 1) { if (showmoney == 1) {
stb += "<td>" + Math.round(monthmoney) + "</td>"; stb += "<td>" + toThousands(Math.round(monthmoney)) + "</td>";
stb += "<td>" + Math.round(monthmoneyone / monthday) + "</td>"; stb += "<td>" + Math.round(monthmoneyone / monthday*10000)/10000 + "</td>";
} }
stb += "<td>" + monthday + "</td>"; stb += "<td>" + monthday + "</td>";
stb += "</tr>"; stb += "</tr>";
@ -1191,8 +1207,8 @@
std += "<tr>"; std += "<tr>";
std += "<td>" + value.landowner + "</td>"; std += "<td>" + value.landowner + "</td>";
std += "<td>" + value.leaseRate + "%" + "</td>"; std += "<td>" + value.leaseRate + "%" + "</td>";
std += "<td>" + Math.round(monthmoney * value.leaseRate / 100) + "</td>"; std += "<td>" + toThousands(Math.round(monthmoney * value.leaseRate / 100)) + "</td>";
std += "<td>" + Math.round(monthmoney * value.leaseRate / 100 * 1.05) + "</td>"; std += "<td>" + toThousands(Math.round(monthmoney * value.leaseRate / 100 * 1.05)) + "</td>";
std += "</tr>"; std += "</tr>";
}) })
$('#HireTableBody').append(std); $('#HireTableBody').append(std);
@ -1211,7 +1227,8 @@
} }
$('#overviewtable').show(); $('#overviewtable').show();
$('#detailtable').show(); $('#detailtable').show();
$('#all').show();
nowform = form; nowform = form;
}, 'json'); }, 'json');
} }
@ -1347,11 +1364,11 @@
StrInfoBody += "<td>" + data.avgIrradiance.toFixed(2) + "</td>"; StrInfoBody += "<td>" + data.avgIrradiance.toFixed(2) + "</td>";
StrInfoBody += "<td>" + data.avgPR.toFixed(2) + "</td>"; StrInfoBody += "<td>" + data.avgPR.toFixed(2) + "</td>";
if (showmoney == 1) { if (showmoney == 1) {
StrInfoBody += "<td>" + Math.round(data.todayMoney) + "</td>"; StrInfoBody += "<td>" + toThousands(main_system_guid) + "</td>";
StrInfoBody += "<td>" + Math.round(data.todayMoney * hirerate * 0.01)+ "</td>"; StrInfoBody += "<td>" + toThousands(Math.round(data.todayMoney * hirerate * 0.01))+ "</td>";
StrInfoBody += "<td>" + Math.round(data.todayMoney) + "</td>"; StrInfoBody += "<td>" + toThousands(Math.round(data.todayMoney)) + "</td>";
} }
@ -1436,5 +1453,22 @@
return hirerate; return hirerate;
} }
function toThousands(num) {
var num = (num || 0).toString(), result = '';
var last = "";
if (num.indexOf('.') != -1) {
var nn = num.split('.');
num = nn[0];
last = "." + nn[1];
}
while (num.length > 3) {
result = ',' + num.slice(-3) + result;
num = num.slice(0, num.length - 3);
}
if (num) { result = num + result + last; }
return result;
}
</script> </script>
} }