This commit is contained in:
Kai 2022-01-17 16:35:45 +08:00
commit c7cd824346
9 changed files with 449 additions and 353 deletions

View File

@ -3256,7 +3256,7 @@ namespace SolarPower.Controllers
var sitecheck = await powerStationRepository.Check4table(powerStation.Code, powerStation.SiteDB);
if(powerStation.Code != sitecheck.Avg && sitecheck.Avg != null)
{
status.Add($"s{powerStation.Code}01_avg SITEID錯誤");
status.Add($"s{powerStation.Code}01_sensoravg SITEID錯誤");
}
if (powerStation.Code != sitecheck.Inv_site && sitecheck.Inv_site != null)
{

View File

@ -266,7 +266,7 @@ namespace SolarPower.Controllers
#region body //RowPosition = 1
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)
{
index = 0;
@ -276,13 +276,14 @@ namespace SolarPower.Controllers
tkwh = Checknull(Math.Round(Convert.ToDouble(dbody["totKWH"]), 2).ToString());
kWhkwp = Checknull(Math.Round(Convert.ToDouble(dbody["totKWHKWP"]), 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);
if (double.IsNaN(onemoney))
{
onemoney = 0;
}
ntdone = Checknull(Math.Round(onemoney, 2).ToString());
ntdone = Checknull(Math.Round(onemoney, 4).ToString());
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
@ -328,20 +329,20 @@ namespace SolarPower.Controllers
#region //RowPosition = body + 2
RowPosition += 2;//空兩行
index = 0;
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
cell.SetCellValue("日照小時:");
cell.CellStyle = styleLine12;
cell = row.CreateCell(1);
cell.SetCellValue(Convert.ToDouble(thour));
cell.CellStyle = styleLine12;
RowPosition++;
//index = 0;
//row = sheet.CreateRow(RowPosition);
//cell = row.CreateCell(index);
//cell.SetCellValue("日照小時:");
//cell.CellStyle = styleLine12;
//cell = row.CreateCell(1);
//cell.SetCellValue(Convert.ToDouble(thour));
//cell.CellStyle = styleLine12;
//RowPosition++;
index = 0;
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
cell.SetCellValue("kWH/kWP:");
cell.SetCellValue("有效發電小時:");
cell.CellStyle = styleLine12;
cell = row.CreateCell(1);
cell.SetCellValue(Convert.ToDouble(kWhkwp));
@ -369,6 +370,15 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12;
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)
{
@ -422,7 +432,7 @@ namespace SolarPower.Controllers
"日照小時(hr)",
"有效發電小時",
"PR%",
"日平均日照度(W/㎡)",
"累積日照量(W/㎡)",
"日平均模組溫度(°C)"
};
@ -443,6 +453,7 @@ namespace SolarPower.Controllers
#region body //RowPosition = 1
RowPosition++;
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 sitedb = "";
foreach (dynamic body in Formbody.Result.Data)
@ -456,6 +467,7 @@ namespace SolarPower.Controllers
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());
if (dbody["SolarType"].ToString() == "1" && Formhead.Result.Data.ShowMoney == 1)//檢驗是否為租用
{
check_hire = true;
@ -481,7 +493,7 @@ namespace SolarPower.Controllers
"tothour",
"KWHKWP",
"PR",
"irradiance",
"IrrDay",
"temperature"
};
if (Formhead.Result.Data.ShowMoney == 1)
@ -513,12 +525,12 @@ namespace SolarPower.Controllers
var Useday = Formbody.Result.Data.Count;
row = sheet.CreateRow(RowPosition);
//cell = row.CreateCell(index);
//cell.SetCellValue("日照平均(日)");
//cell.CellStyle = styleLine12;
//index++;
cell = row.CreateCell(index);
cell.SetCellValue("日照平均(日)");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("平均有效發電小時(日)");
cell.SetCellValue("有效發電小時(日)");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
@ -529,8 +541,17 @@ namespace SolarPower.Controllers
cell.SetCellValue("發電量(kWh)(月)");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("裝置容量");
cell.CellStyle = styleLine12;
index++;
if (Formhead.Result.Data.ShowMoney == 1)
{
cell = row.CreateCell(index);
cell.SetCellValue("每度獲利");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("售電金額(NTD)(月)");
cell.CellStyle = styleLine12;
@ -550,10 +571,10 @@ namespace SolarPower.Controllers
RowPosition++;
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(avghour)/Useday,2));
cell.CellStyle = styleLine12;
index++;
//cell = row.CreateCell(index);
//cell.SetCellValue(Math.Round(Convert.ToDouble(avghour)/Useday,2));
//cell.CellStyle = styleLine12;
//index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(avgKWHKWP) / Useday,2));
cell.CellStyle = styleLine12;
@ -566,14 +587,23 @@ namespace SolarPower.Controllers
cell.SetCellValue(Convert.ToDouble(monthKWH));
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Convert.ToDouble(monthGeneratingCapacity));
cell.CellStyle = styleLine12;
index++;
if (Formhead.Result.Data.ShowMoney == 1)
{
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoney) / Convert.ToDouble(monthGeneratingCapacity), 3));
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Convert.ToDouble(monthmoney));
cell.CellStyle = styleLine12;
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;
index++;
}
@ -1066,7 +1096,7 @@ namespace SolarPower.Controllers
#region body //RowPosition = 1
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)
{
index = 0;
@ -1076,13 +1106,14 @@ namespace SolarPower.Controllers
tkwh = Checknull(Math.Round(Convert.ToDouble(dbody["totKWH"]), 2).ToString());
kWhkwp = Checknull(Math.Round(Convert.ToDouble(dbody["totKWHKWP"]), 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);
if (double.IsNaN(onemoney))
{
onemoney = 0;
}
ntdone = Checknull(Math.Round(onemoney, 2).ToString());
ntdone = Checknull(Math.Round(onemoney, 4).ToString());
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
@ -1128,15 +1159,15 @@ namespace SolarPower.Controllers
#region //RowPosition = body + 2
RowPosition += 2;//空兩行
index = 0;
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
cell.SetCellValue("日照小時:");
cell.CellStyle = styleLine12;
cell = row.CreateCell(1);
cell.SetCellValue(!string.IsNullOrEmpty(thour)? Convert.ToDouble(thour) : 0);
cell.CellStyle = styleLine12;
RowPosition++;
//index = 0;
//row = sheet.CreateRow(RowPosition);
//cell = row.CreateCell(index);
//cell.SetCellValue("日照小時:");
//cell.CellStyle = styleLine12;
//cell = row.CreateCell(1);
//cell.SetCellValue(!string.IsNullOrEmpty(thour)? Convert.ToDouble(thour) : 0);
//cell.CellStyle = styleLine12;
//RowPosition++;
index = 0;
row = sheet.CreateRow(RowPosition);
@ -1169,6 +1200,16 @@ namespace SolarPower.Controllers
cell.CellStyle = styleLine12;
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)
{
@ -1222,7 +1263,7 @@ namespace SolarPower.Controllers
"日照小時(hr)",
"有效發電小時",
"PR%",
"日平均日照度(W/㎡)",
"累積日照量(W/㎡)",
"日平均模組溫度(°C)"
};
@ -1243,6 +1284,7 @@ namespace SolarPower.Controllers
#region body //RowPosition = 1
RowPosition++;
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 sitedb = "";
foreach (dynamic body in Formbody.Result.Data)
@ -1256,6 +1298,7 @@ namespace SolarPower.Controllers
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());
if (dbody["SolarType"].ToString() == "1" && Formhead.Result.Data.ShowMoney == 1)//檢驗是否為租用
{
check_hire = true;
@ -1281,7 +1324,7 @@ namespace SolarPower.Controllers
"tothour",
"KWHKWP",
"PR",
"irradiance",
"IrrDay",
"temperature"
};
if (Formhead.Result.Data.ShowMoney == 1)
@ -1313,24 +1356,33 @@ namespace SolarPower.Controllers
var Useday = Formbody.Result.Data.Count;
row = sheet.CreateRow(RowPosition);
//cell = row.CreateCell(index);
//cell.SetCellValue("日日照小時平均");
//cell.CellStyle = styleLine12;
//index++;
cell = row.CreateCell(index);
cell.SetCellValue("日日照小時平均");
cell.SetCellValue("有效發電小時(日)");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("日kWH/kWP平均");
cell.SetCellValue("發電量平均(kWh)(日)");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("發電量平均(kWh)");
cell.SetCellValue("發電量(kWh)(月)");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("月發電量(kWh)");
cell.SetCellValue("裝置容量");
cell.CellStyle = styleLine12;
index++;
if (Formhead.Result.Data.ShowMoney == 1)
{
cell = row.CreateCell(index);
cell.SetCellValue("每度獲利");
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue("月售電金額(NTD)");
cell.CellStyle = styleLine12;
@ -1350,10 +1402,10 @@ namespace SolarPower.Controllers
RowPosition++;
row = sheet.CreateRow(RowPosition);
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(avghour) / Useday, 2));
cell.CellStyle = styleLine12;
index++;
//cell = row.CreateCell(index);
//cell.SetCellValue(Math.Round(Convert.ToDouble(avghour) / Useday, 2));
//cell.CellStyle = styleLine12;
//index++;
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(avgKWHKWP) / Useday, 2));
cell.CellStyle = styleLine12;
@ -1366,14 +1418,23 @@ namespace SolarPower.Controllers
cell.SetCellValue(Convert.ToDouble(monthKWH));
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Convert.ToDouble(monthGeneratingCapacity));
cell.CellStyle = styleLine12;
index++;
if (Formhead.Result.Data.ShowMoney == 1)
{
cell = row.CreateCell(index);
cell.SetCellValue(Math.Round(Convert.ToDouble(monthmoney) / Convert.ToDouble(monthGeneratingCapacity), 3));
cell.CellStyle = styleLine12;
index++;
cell = row.CreateCell(index);
cell.SetCellValue(Convert.ToDouble(monthmoney));
cell.CellStyle = styleLine12;
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;
index++;
}

View File

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

View File

@ -2426,6 +2426,7 @@
function getTable()
{
$('#all').hide();
if (historyRange == "")
{
var today = new Date();
@ -2793,6 +2794,7 @@
'<td>' + tempALL.toFixed(2) + '</td>' +
'</tr>');
}
$('#all').show();
})
}

View File

@ -50,48 +50,49 @@
</div>
<div id="all">
<div class="row mb-5">
<div class="card p-3 w-100">
<h5 class="font-weight-bold mb-3 pl-5 pb-3">總結</h5>
<table class="table m-0">
<thead>
<tr>
<th>時間</th>
<th>發電量(kWh)</th>
<th>有效日照時數</th>
<th>日照度(kWh/m2)</th>
<th>PR(%)</th>
<th>溫度(℃)</th>
</tr>
</thead>
<tbody id="HistoryTotalTable">
</tbody>
</table>
</div>
</div>
<div id="history-kWh-convas-div">
<canvas id="history-kWh"></canvas>
</div>
<div class="row mb-5">
<div class="card p-3 w-100">
<h5 class="font-weight-bold mb-3 pl-5 pb-3">總結</h5>
<table class="table m-0">
<thead>
<tr>
<th>時間</th>
<th>發電量(kWh)</th>
<th>有效日照時數</th>
<th>日照度(kWh/m2)</th>
<th>PR(%)</th>
<th>溫度(℃)</th>
</tr>
</thead>
<tbody id="HistoryTotalTable">
</tbody>
</table>
<div class="row mb-5">
<div class="card p-3 w-100">
<h5 class="font-weight-bold mb-3 pl-5 pb-3">詳細資訊</h5>
<table class="table m-0">
<thead>
<tr>
<th>時間</th>
<th>發電量(kWh)</th>
<th>有效發電小時</th>
<th>日照度(W/m2)</th>
<th>PR(%)</th>
<th>溫度(℃)</th>
</tr>
</thead>
<tbody id="HistoryDetailTable">
</tbody>
</table>
</div>
</div>
</div>
<div id="history-kWh-convas-div">
<canvas id="history-kWh"></canvas>
</div>
<div class="row mb-5">
<div class="card p-3 w-100">
<h5 class="font-weight-bold mb-3 pl-5 pb-3">詳細資訊</h5>
<table class="table m-0">
<thead>
<tr>
<th>時間</th>
<th>發電量(kWh)</th>
<th>有效日照時數</th>
<th>日照度(kWh/m2)</th>
<th>PR(%)</th>
<th>溫度(℃)</th>
</tr>
</thead>
<tbody id="HistoryDetailTable">
</tbody>
</table>
</div>
</div>

View File

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

View File

@ -185,64 +185,74 @@ namespace solarApp.Service
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器15min補償", _siteID, _date1);
}
sql = @"
sql = @$"DROP TABLE IF EXISTS del_Inv_day_" + _powerStationID + @"_s1;
CREATE TABLE del_Inv_day_" + _powerStationID + @"_s1
select * from " + _siteDB + ".s" + _siteID01 + @"_inv a
WHERE left(crdTime, 10) = @date1;
# 2. add index
ALTER TABLE del_Inv_day_" + _powerStationID + @"_s1 ADD INDEX `temp_index` (crdTime, inverterid);";
int ct = conn.Execute(sql, new { date1 = _date1 });
sql = @"
INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
(
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
from " + _siteDB + ".s" + _siteID01 + @"_inv
from del_Inv_day_" + _powerStationID + @"_s1
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '00' and '10'
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
union
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':15:00')reportdate, inverterid,
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
from " + _siteDB + ".s" + _siteID01 + @"_inv
from del_Inv_day_" + _powerStationID + @"_s1
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
union
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':30:00')reportdate, inverterid,
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
from " + _siteDB + ".s" + _siteID01 + @"_inv
from del_Inv_day_" + _powerStationID + @"_s1
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
union
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':45:00')reportdate, inverterid,
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
from " + _siteDB + ".s" + _siteID01 + @"_inv
from del_Inv_day_" + _powerStationID + @"_s1
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '45' and '55'
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
// sql = @"
// INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
// select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
// (
//select @PowerStationId PowerStationId,CONCAT(left(CrdTime, 13), '%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
// from " + _siteDB + ".s" + _siteID01 + @"_inv
// where left(CrdTime, 10) = @date1 and CONCAT(left(CrdTime, 13), '%Y-%m-%d %H:%i') , 2) between '00' and '10'
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
// union
// select @PowerStationId PowerStationId, CONCAT(left(CrdTime, 13), ':15:00')reportdate, inverterid,
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
// from " + _siteDB + ".s" + _siteID01 + @"_inv
// where left(CrdTime, 10) = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
// union
// select @PowerStationId PowerStationId, CONCAT(left(CrdTime, 13), ':30:00')reportdate, inverterid,
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
// from " + _siteDB + ".s" + _siteID01 + @"_inv
// where left(CrdTime, 10) = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
// union
// select @PowerStationId PowerStationId, CONCAT(left(CrdTime, 13), ':45:00')reportdate, inverterid,
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
// from " + _siteDB + ".s" + _siteID01 + @"_inv
// where left(CrdTime, 10) = @date1 and MINUTE(CrdTime) between '45' and '55'
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
// ) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
//sql = @"
// INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
// select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
// (
// select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
// from " + _siteDB + ".s" + _siteID01 + @"_inv
// where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '00' and '10'
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
// union
// select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':15:00')reportdate, inverterid,
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
// from " + _siteDB + ".s" + _siteID01 + @"_inv
// where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
// union
// select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':30:00')reportdate, inverterid,
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
// from " + _siteDB + ".s" + _siteID01 + @"_inv
// where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
// union
// select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':45:00')reportdate, inverterid,
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
// from " + _siteDB + ".s" + _siteID01 + @"_inv
// where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '45' and '55'
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
// ) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
if (_logger != null)
@ -308,61 +318,60 @@ namespace solarApp.Service
// where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1
// )irr on a.reportDate = irr.reportDate
// order by a.INVERTERID, a.reportDate;";
//int ct = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
//int ct = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
sql = @$"DROP TEMPORARY TABLE IF EXISTS Inv_day_"+ _powerStationID + @"_s1;
CREATE TEMPORARY TABLE Inv_day_" + _powerStationID + @"_s1
select * from " + _siteDB + ".s" + _siteID01 + @"_inv a
WHERE left(crdTime, 10) = @date1;
# 2. add index
ALTER TABLE Inv_day_" + _powerStationID + @"_s1 ADD INDEX `temp_index` (crdTime, inverterid);";
int ct = conn.Execute(sql, new { date1 = _date1});
sql = @$"DROP TEMPORARY TABLE IF EXISTS Inv_day_" + _powerStationID + @"_s2;
CREATE TEMPORARY TABLE Inv_day_" + _powerStationID + @"_s2
SELECT " + _powerStationID + @" powerStationID, a.INVERTERID, a.reportDate,a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH, a.DC1V, a.DC1A, a.DC1W, a.DC1WH, a.DC2V, a.DC2A, a.DC2W, a.DC2WH, a.DC3V, a.DC3A, a.DC3W,
a.DC3WH, a.DC4V, a.DC4A, a.DC4W, a.DC4WH, a.DC5V, a.DC5A, a.DC5W, a.DC5WH,
a.RA1, a.RA2, a.RA3, a.RA4, a.RA5, a.KWH, a.TODAYKWH, a.TOTALKWH,
IFNULL(Irradiance, 0) irr, 0 as PR, ((DC1W + DC2W + DC3W + DC4W + DC5W) / 1000) DCKW, ((AC1W + AC2W + AC3W) / 1000) ACKW, (a.KWH / i.Capacity) AS KWHKWP
from
(-- KWH
SELECT concat(left(crdTime, 13), ':00:00') reportDate, INVERTERID,
AVG(AC1V) AS AC1V, AVG(AC1A) AS AC1A, round(SUM(AC1W), 5) AS AC1W, AVG(AC1F) AS AC1F, SUM(AC1WH) AS AC1WH, AVG(AC2V) AS AC2V,
AVG(AC2A) AS AC2A, round(SUM(AC2W), 5) AS AC2W, AVG(AC2F) AS AC2F, SUM(AC2WH) AS AC2WH, AVG(AC3V) AS AC3V, AVG(AC3A) AS AC3A,
round(SUM(AC3W), 5) AS AC3W, AVG(AC3F) AS AC3F, SUM(AC3WH) AS AC3WH, AVG(DC1V) AS DC1V, AVG(DC1A) AS DC1A, SUM(DC1W) AS DC1W,
SUM(DC1WH) AS DC1WH, AVG(DC2V) AS DC2V, AVG(DC2A) AS DC2A, SUM(DC2W) AS DC2W, SUM(DC2WH) AS DC2WH, AVG(DC3V) AS DC3V,
AVG(DC3A) AS DC3A, AVG(DC3W) AS DC3W, AVG(DC3WH) AS DC3WH, AVG(DC4V) AS DC4V, AVG(DC4A) AS DC4A, SUM(DC4W) AS DC4W,
SUM(DC4WH) AS DC4WH, AVG(DC5V) AS DC5V, AVG(DC5A) AS DC5A, SUM(DC5W) AS DC5W, SUM(DC5WH) AS DC5WH,
AVG(RA1) AS RA1, AVG(RA2) AS RA2, AVG(RA3) AS RA3,
AVG(RA4) AS RA4, AVG(RA5) AS RA5, MAX(TODAYKWH) AS TODAYKWH, MAX(TOTALKWH) AS TOTALKWH, (SUM(WH) / 1000) AS KWH
FROM del_Inv_day_" + _powerStationID + @"_s1
GROUP BY left(crdTime, 13), INVERTERID
) a
--
LEFT JOIN " + _siteDB + @".inverter i ON a.INVERTERID = i.InverterId
-- -------------------- -
left join(
select concat(DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d %H'), ':00:00') AS reportDate, Irradiance
from sensor_history_hour
where powerstationID = " + _powerStationID + @" and DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d') = @date1
)irr on a.reportDate = irr.reportDate; ";
int ct = conn.Execute(sql, new { date1 = _date1 });
//# 3. insert ans
sql = @$"
INSERT INTO solar_master.inverter_history_hour(`powerStationID`, `INVERTERID`, `TIMESTAMP`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `KWH`, `TODAYKWH`, `TOTALKWH`, `Irradiance`, `PR`, `DCKW`, `ACKW`, `KWHKWP`)
select `powerStationID`, a.`INVERTERID`, a.`reportDate`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `KWH`, `TODAYKWH`, `TOTALKWH`, `irr`, inv_pr.`PR`, `DCKW`, `ACKW`, `KWHKWP`
from Inv_day_" + _powerStationID + @"_s2 a left JOIN( -- PR
SELECT concat(left(crdTime, 13), ':00:00') AS reportDate, inv.INVERTERID, inv.PR
FROM del_Inv_day_" + _powerStationID + @"_s1 inv
WHERE minute(crdtime) = '55'
GROUP BY left(crdTime, 13), inv.INVERTERID
) inv_pr
ON a.reportDate = inv_pr.reportDate AND a.INVERTERID = inv_pr.INVERTERID;";
ct = conn.Execute(sql, new { date1 = _date1 });
if (_logger != null)
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器hour補償", _siteID, _date1);
ss = @$"DROP TABLE IF EXISTS del_Inv_day_" + _powerStationID + @"_s1; ";
conn.Execute(ss);
}
sql = @$"DROP TEMPORARY TABLE IF EXISTS Inv_day_" + _powerStationID + @"_s2;
CREATE TEMPORARY TABLE Inv_day_" + _powerStationID + @"_s2
SELECT " + _powerStationID + @" powerStationID, a.INVERTERID, a.reportDate,a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
a.AC3V, a.AC3A, a.AC3W, a.AC3F, a.AC3WH, a.DC1V, a.DC1A, a.DC1W, a.DC1WH, a.DC2V, a.DC2A, a.DC2W, a.DC2WH, a.DC3V, a.DC3A, a.DC3W,
a.DC3WH, a.DC4V, a.DC4A, a.DC4W, a.DC4WH, a.DC5V, a.DC5A, a.DC5W, a.DC5WH,
a.RA1, a.RA2, a.RA3, a.RA4, a.RA5, a.KWH, a.TODAYKWH, a.TOTALKWH,
IFNULL(Irradiance, 0) irr, 0 as PR, ((DC1W + DC2W + DC3W + DC4W + DC5W) / 1000) DCKW, ((AC1W + AC2W + AC3W) / 1000) ACKW, (a.KWH / i.Capacity) AS KWHKWP
from
(-- KWH
SELECT concat(left(crdTime, 13), ':00:00') reportDate, INVERTERID,
AVG(AC1V) AS AC1V, AVG(AC1A) AS AC1A, round(SUM(AC1W), 5) AS AC1W, AVG(AC1F) AS AC1F, SUM(AC1WH) AS AC1WH, AVG(AC2V) AS AC2V,
AVG(AC2A) AS AC2A, round(SUM(AC2W), 5) AS AC2W, AVG(AC2F) AS AC2F, SUM(AC2WH) AS AC2WH, AVG(AC3V) AS AC3V, AVG(AC3A) AS AC3A,
round(SUM(AC3W), 5) AS AC3W, AVG(AC3F) AS AC3F, SUM(AC3WH) AS AC3WH, AVG(DC1V) AS DC1V, AVG(DC1A) AS DC1A, SUM(DC1W) AS DC1W,
SUM(DC1WH) AS DC1WH, AVG(DC2V) AS DC2V, AVG(DC2A) AS DC2A, SUM(DC2W) AS DC2W, SUM(DC2WH) AS DC2WH, AVG(DC3V) AS DC3V,
AVG(DC3A) AS DC3A, AVG(DC3W) AS DC3W, AVG(DC3WH) AS DC3WH, AVG(DC4V) AS DC4V, AVG(DC4A) AS DC4A, SUM(DC4W) AS DC4W,
SUM(DC4WH) AS DC4WH, AVG(DC5V) AS DC5V, AVG(DC5A) AS DC5A, SUM(DC5W) AS DC5W, SUM(DC5WH) AS DC5WH,
AVG(RA1) AS RA1, AVG(RA2) AS RA2, AVG(RA3) AS RA3,
AVG(RA4) AS RA4, AVG(RA5) AS RA5, MAX(TODAYKWH) AS TODAYKWH, MAX(TOTALKWH) AS TOTALKWH, (SUM(WH) / 1000) AS KWH
FROM Inv_day_" + _powerStationID + @"_s1
GROUP BY left(crdTime, 13), INVERTERID
) a
--
LEFT JOIN " + _siteDB + @".inverter i ON a.INVERTERID = i.InverterId
-- -------------------- -
left join(
select concat(DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d %H'), ':00:00') AS reportDate, Irradiance
from sensor_history_hour
where powerstationID = " + _powerStationID + @" and DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d') = @date1
)irr on a.reportDate = irr.reportDate; ";
ct = conn.Execute(sql, new { date1 = _date1 });
//# 3. insert ans
sql = @$"
INSERT INTO solar_master.inverter_history_hour(`powerStationID`, `INVERTERID`, `TIMESTAMP`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `KWH`, `TODAYKWH`, `TOTALKWH`, `Irradiance`, `PR`, `DCKW`, `ACKW`, `KWHKWP`)
select `powerStationID`, a.`INVERTERID`, a.`reportDate`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `KWH`, `TODAYKWH`, `TOTALKWH`, `irr`, inv_pr.`PR`, `DCKW`, `ACKW`, `KWHKWP`
from Inv_day_" + _powerStationID + @"_s2 a left JOIN( -- PR
SELECT concat(left(crdTime, 13), ':00:00') AS reportDate, inv.INVERTERID, inv.PR
FROM Inv_day_" + _powerStationID + @"_s1 inv
WHERE minute(crdtime) = '55'
GROUP BY left(crdTime, 13), inv.INVERTERID
) inv_pr
ON a.reportDate = inv_pr.reportDate AND a.INVERTERID = inv_pr.INVERTERID;";
ct = conn.Execute(sql, new { date1 = _date1 });
if (_logger != null)
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器hour補償", _siteID, _date1);
}
catch (Exception ex)
{
if (_logger != null)
@ -538,6 +547,7 @@ ALTER TABLE `temp_invDay{_powerStationID}_s1` ADD INDEX `temp_indexs1` (report_d
#endregion
#region inv_no01
string inv01 = _siteID01 + "0001";
sql = @$"
insert report_invday(`report_date`, `PowerStationID`, inv_01, `hourKWH`, `hourKWHp`, `irradiance`, `temperature`, `hourmoney`, `pr`, createTime)
select a.report_date, a.powerstationId , ifnull(round(a.kwh, 6), 0) inv_01, ifnull(b.KWH, 0) hourKWH,
@ -545,7 +555,7 @@ select a.report_date, a.powerstationId , ifnull(round(a.kwh, 6), 0) inv_01, ifn
WHERE DATE_FORMAT(TIMESTAMP,'%Y-%m-%d') = '{_date1}' and powerstationid = {_powerStationID} ))*100,2)
, 0) 'hourKWHp', ifnull(d.irradiance, 0) 'irradiance', ifnull(d.Temperature, 0) 'temperature',
ifnull(b.money, 0) 'hourmoney', ifnull(round(b.PR, 2), 0) as pr, now() createTime
from temp_invDay{_powerStationID}_s1 a left join
from temp_invDay{_powerStationID}_s1 a join
( # inv
select powerStationid, `TIMESTAMP` report_date, siteid, sitetype, round(KWH, 2) KWH,
round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, round(money, 2) money
@ -559,7 +569,7 @@ from temp_invDay{_powerStationID}_s1 a left join
from sensor_history_hour
where powerstationid = {_powerStationID} and left(`TIMESTAMP`,10) = '{_date1}'
) d on a.powerStationid = d.powerStationid and a.`report_date` = d.report_date
where right(a.inverterid, 4) = '0001'
where a.inverterid = '{inv01}' # right(a.inverterid, 4) = '0001'
GROUP BY left(a.report_date, 13)
order by a.report_date ;";
conn.Execute(sql);

View File

@ -242,7 +242,7 @@ namespace solarApp.Service
select a.powerstationID, a.reportdate, ifnull(b.Irradiance, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust, a.WingDirection, a.irrDay from
(
select powerStationID , concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(Temperature), 6) Temperature,
envTemperature, humidity, Vane, Dust, WingDirection, irrDay
envTemperature, humidity, Vane, Dust, avg(WingDirection) WingDirection, max(irrDay) irrDay
from solar_master.sensor_history_hour
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
@ -266,7 +266,7 @@ namespace solarApp.Service
select a.powerstationID, a.reportdate, ifnull(b.Irradiance, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust, WingDirection, irrDay from
(
select powerStationID , concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(Temperature), 6) Temperature,
envTemperature, humidity, Vane, Dust, WingDirection, irrDay
avg(envTemperature) envTemperature, avg(humidity) humidity, avg(Vane) Vane, avg(Dust) Dust, avg(WingDirection) WingDirection, max(irrDay) irrDay
from solar_master.sensor_history_day
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = @date1
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m')

View File

@ -195,7 +195,7 @@ namespace solarApp.Service
sql = @" INSERT INTO solar_master.power_station_history_day( PowerStationId, `TIMESTAMP`, SITEID, SITETYPE, TODAYKWH, TOTALKWH, KWHKWP,
PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON)
select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, a.TODAYKWH, a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR,
select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, a.TODAYKWH, a.TOTALKWH, a.KWHKWP, a1.PR, a.MP, a.SOLARHOUR,
/*CASE
WHEN b.SolarType = 1 THEN a.KWH * PowerRate * c.LeaseRate
ELSE a.KWH * PowerRate
@ -211,11 +211,18 @@ namespace solarApp.Service
(
select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00:00') reportdate, siteid, siteType, round((sum(KWH)), 6) KWH,
round((max(TODAYKWH)), 6) TODAYKWH, round((max(TOTALKWH)), 6) TOTALKWH, round((max(KWHKWP)), 6) KWHKWP,
round((max(PR)), 6) PR, round((max(MP)), 6) as MP, round((max(SOLARHOUR)), 6) SOLARHOUR
#round((max(PR)), 6) PR,
round((max(MP)), 6) as MP, round((max(SOLARHOUR)), 6) SOLARHOUR
from solar_master.power_station_history_hour a
where SITEID = @siteID and DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m-%d') = @date1
group by a.siteid, DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
)a join
(
select id, SITEID, round(PR, 4) PR
from solar_master.power_station_history_hour a
where SITEID = @siteID and DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m-%d') = @date1
order by 1 desc limit 1
)a1 on a.siteID = a1.siteID join
(
select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType
from solar_master.power_station