綜合報表修改

This commit is contained in:
cesar liu 2022-04-25 01:06:21 +08:00
parent edeb83b59a
commit 56cee0ae8a
5 changed files with 140 additions and 88 deletions

View File

@ -801,6 +801,7 @@ namespace SolarPower.Quartz.Jobs
for (; start_date <= end_date; start_date = start_date.AddDays(1))
{
var day_str = start_date.ToString("yyyy-MM-dd");
#region Sensor
try
{
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Sensor補償機制】", powerStation.Code, day_str);
@ -816,7 +817,9 @@ namespace SolarPower.Quartz.Jobs
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
}
}
#endregion
#region
try
{
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Meter補償機制】", powerStation.Code, day_str);
@ -832,7 +835,9 @@ namespace SolarPower.Quartz.Jobs
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
}
}
#endregion
#region Inv
try
{
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Inverter補償機制】", powerStation.Code, day_str);
@ -848,7 +853,9 @@ namespace SolarPower.Quartz.Jobs
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
}
}
#endregion
#region Station hour
try
{
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的Site補償機制】", powerStation.Code, day_str);
@ -864,6 +871,25 @@ namespace SolarPower.Quartz.Jobs
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
}
}
#endregion
#region
try
{
logger.LogInformation("【CalcAvgPowerStationJob】【開始執行電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str);
invSvc.report_invDay(powerStation.Code, day_str);
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str);
}
catch (Exception exception)
{
logger.LogInformation("【CalcAvgPowerStationJob】【執行失敗電站[{0}]在{1}的 日報表製作】", powerStation.Code, day_str);
logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message);
if (exception.InnerException != null)
{
logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message);
}
}
#endregion
}
}
logger.LogInformation("【CalcAvgPowerStationJob】【執行完成補償機制】");

View File

@ -315,6 +315,11 @@ namespace SolarPower.Repository.Implement
}
}
/// <summary>
/// 綜合報表
/// </summary>
/// <param name="post"></param>
/// <returns></returns>
public async Task<List<MaxFormbody>> GetMaxtablebody(Select_table2 post)
{
List<MaxFormbody> result = new List<MaxFormbody>();
@ -342,56 +347,81 @@ namespace SolarPower.Repository.Implement
3 => $"AND DATE_FORMAT(ps.TIMESTAMP,'%Y') = '{post.Time}' AND DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') != '{DateTime.Now.ToString("yyyy-MM-dd")}'",
_ => ""
};
string sql = @$"SELECT
c.Name AS 'CityName',
a.Name AS 'AreaName',
ps.Name AS 'PowerstationName',
ps.SiteDB AS 'PowerstationDB',
ps.SolarType AS 'PowerstationType',
//string sql = @$"SELECT
// c.Name AS 'CityName',
// a.Name AS 'AreaName',
// ps.Name AS 'PowerstationName',
// ps.SiteDB AS 'PowerstationDB',
// ps.SolarType AS 'PowerstationType',
// ps.Id as 'PowerStationId',
// n.*
// FROM power_station ps
// LEFT JOIN city c ON c.Id = ps.CityId
// LEFT JOIN area a ON a.Id = ps.AreaId
// left JOIN
// (
// SELECT a.SolarHour ,a.Kwh ,b.PR AvgPR,b.KWHKWP AvgKWHKWP,c.Irradiance AvgIrradiance,b.TodayMoney as 'TodayMoney',a.Id,a.time,a.maxtime,a.mintime FROM
// (
// SELECT ps.Id,SUM(k.SolarHour) SolarHour,SUM(k.Kwh) Kwh , k.time , max(k.maxtime) maxtime ,min(k.mintime) mintime FROM power_station ps
// LEFT JOIN
// (
// SELECT Max(ps.SOLARHOUR) AS 'SolarHour',MAX(ps.TODAYKWH) 'Kwh' ,DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d %H:%i') AS 'time',MAX(DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d %H:%i')) AS 'maxtime',MIN(DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d %H:%i')) AS 'mintime', ps.PowerStationId
// FROM power_station_history_hour ps
// WHERE ps.PowerStationId IN @ids {wheretime}
// GROUP BY DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d'),ps.PowerStationId
// ) k ON k.PowerStationId = ps.Id WHERE ps.Id IN @ids GROUP BY k.PowerStationId
// ) a
// LEFT JOIN
// (
// SELECT ps.Id,AVG(n.PR) PR,AVG(n.KWHKWP) KWHKWP,SUM(n.TodayMoney) TodayMoney FROM power_station ps
// LEFT JOIN
// (
// SELECT B.PR ,B.KWHKWP,B.TODAYMONEY AS 'TodayMoney', DATE_FORMAT(A.bb,'%Y-%m-%d') 'time' ,B.PowerStationId FROM
// (
// SELECT Max(ps.TIMESTAMP) AS bb FROM power_station_history_hour ps
// WHERE ps.PowerStationId IN @ids {wheretime}
// GROUP BY DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d'),ps.PowerStationId
// ) A
// LEFT JOIN power_station_history_hour B ON A.bb = B.TIMESTAMP
// GROUP BY B.PowerStationId ,DATE_FORMAT(A.bb,'%Y-%m-%d')
// )n ON ps.Id = n.PowerStationId WHERE ps.Id IN @ids GROUP BY n.PowerStationId
// ) b
// ON a.Id = b.Id
// LEFT JOIN
// (
// SELECT SUM(ps.Irradiance) AS Irradiance , DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') AS TIME ,ps.PowerStationId
// from sensor_history_hour ps
// WHERE ps.PowerStationId IN @ids {wheretime}
// GROUP BY DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d'),ps.PowerStationId
// ) c
// ON a.Id = c.PowerStationId
// GROUP BY a.Id,a.time
// ) n ON n.Id = ps.Id
// WHERE ps.Id IN @ids ORDER BY ps.CityId";
string sql = $@"SELECT ct.`Name` AS 'CityName', ar.Name AS 'AreaName', ps.Name AS 'PowerstationName', ps.SiteDB AS 'PowerstationDB', ps.SolarType AS 'PowerstationType',
ps.Id as 'PowerStationId',
n.*
a.SolarHour ,a.Kwh ,a.PR AvgPR, a.KWHKWP AvgKWHKWP,c.Irradiance AvgIrradiance,
(a.TODAYKWH * PowerRate) 'TodayMoney', a.Id,a.time,a.maxtime,a.mintime
FROM power_station ps
LEFT JOIN city c ON c.Id = ps.CityId
LEFT JOIN area a ON a.Id = ps.AreaId
LEFT JOIN city ct ON ct.Id = ps.CityId
LEFT JOIN area ar ON ar.Id = ps.AreaId
left JOIN
(
SELECT a.SolarHour ,a.Kwh ,b.PR AvgPR,b.KWHKWP AvgKWHKWP,c.Irradiance AvgIrradiance,b.TodayMoney as 'TodayMoney',a.Id,a.time,a.maxtime,a.mintime FROM
(
SELECT ps.Id,SUM(k.SolarHour) SolarHour,SUM(k.Kwh) Kwh , k.time , max(k.maxtime) maxtime ,min(k.mintime) mintime FROM power_station ps
LEFT JOIN
(
SELECT Max(ps.SOLARHOUR) AS 'SolarHour',MAX(ps.TODAYKWH) 'Kwh' ,DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d %H:%i') AS 'time',MAX(DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d %H:%i')) AS 'maxtime',MIN(DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d %H:%i')) AS 'mintime', ps.PowerStationId
FROM power_station_history_hour ps
SELECT powerStationid id, ps.SOLARHOUR AS 'SolarHour',ps.TODAYKWH 'Kwh' , PR, KWHKWP, TODAYKWH,
DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') AS 'time',
MAX(DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d %H:%i')) AS 'maxtime',
MIN(DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d %H:%i')) AS 'mintime', ps.PowerStationId
FROM power_station_history_day ps
WHERE ps.PowerStationId IN @ids {wheretime}
GROUP BY DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d'),ps.PowerStationId
) k ON k.PowerStationId = ps.Id WHERE ps.Id IN @ids GROUP BY k.PowerStationId
) a
LEFT JOIN
(
SELECT ps.Id,AVG(n.PR) PR,AVG(n.KWHKWP) KWHKWP,SUM(n.TodayMoney) TodayMoney FROM power_station ps
LEFT JOIN
(
SELECT B.PR ,B.KWHKWP,B.TODAYMONEY AS 'TodayMoney', DATE_FORMAT(A.bb,'%Y-%m-%d') 'time' ,B.PowerStationId FROM
(
SELECT Max(ps.TIMESTAMP) AS bb FROM power_station_history_hour ps
WHERE ps.PowerStationId IN @ids {wheretime}
GROUP BY DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d'),ps.PowerStationId
) A
LEFT JOIN power_station_history_hour B ON A.bb = B.TIMESTAMP
GROUP BY B.PowerStationId ,DATE_FORMAT(A.bb,'%Y-%m-%d')
)n ON ps.Id = n.PowerStationId WHERE ps.Id IN @ids GROUP BY n.PowerStationId
) b
ON a.Id = b.Id
) a ON ps.Id = a.Id
LEFT JOIN
(
SELECT SUM(ps.Irradiance) AS Irradiance , DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') AS TIME ,ps.PowerStationId
from sensor_history_hour ps
WHERE ps.PowerStationId IN @ids {wheretime}
GROUP BY DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d'),ps.PowerStationId
) c
ON a.Id = c.PowerStationId
GROUP BY a.Id,a.time
) n ON n.Id = ps.Id
) c ON a.Id = c.PowerStationId and a.time = c.time
WHERE ps.Id IN @ids ORDER BY ps.CityId";
result = (await conn.QueryAsync<MaxFormbody>(sql,new { ids = ids}, commandTimeout: 300)).ToList();
}

View File

@ -752,19 +752,15 @@
$(".btn-station").attr("disabled", false);
break;
}
return;
}
$('#TableHead').empty();
var str = "<tr>";
switch (form)
{
case 0:
case 0: // 日報
str += "<th>Date</th>";
$.each(rel.data.inv, function (index, inverter) {
haveinvertName.push(inverter);
@ -778,7 +774,7 @@
str += "<th>小時<br />售電<br />金額<br />(NTD)</th>";
}
break;
case 1:
case 1: // 月報
str += "<th>Date</th>";
$.each(rel.data.inv, function (index, inverter) {
haveinvertName.push(inverter);
@ -795,7 +791,7 @@
str += "<th>日<br />售電金額<br />(NTD)</th>";
}
break;
case 2:
case 2: //綜合報表
str += "<th>區域</th>";
str += "<th>電站名稱</th>";
str += "<th>發電量</th>";
@ -828,9 +824,12 @@
}
str += "</tr>";
$('#TableHead').append(str);
if (form != 2) {
// 日月年 報
tablebody(form, rel.data.showMoney);
} else {
//綜合報表
maxtableinfobody(rel.data.showMoney);
}
}, 'json');
@ -932,8 +931,8 @@
});
sta += "<td>" + Number(inverter.hourKWH) + "</td>";
sta += "<td>" + Number(inverter.hourKWHp) + "</td>";
sta += "<td>" + Number(inverter.irradiance) + "</td>";
sta += "<td>" + Number(inverter.temperature) + "</td>";
sta += "<td>" + Number(inverter.irradiance) + "</td>"; // body 小時平均日照度
sta += "<td>" + Number(inverter.temperature) + "</td>"; //body 小時平均模組溫度
if (showmoney == 1) {
sta += "<td>" + toThousands(Math.round(Number(inverter.hourmoney))) + "</td>";
}
@ -941,7 +940,7 @@
thour = inverter.tothour ? inverter.tothour.toFixed(2) : 0;
tpr = inverter.pr ? inverter.pr.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;
ntdone = inverter.totmoney / inverter.totKWH ? Math.round(inverter.totmoney / inverter.totKWH * 10000) / 10000 : 0;
GeneratingCapacity = inverter.GeneratingCapacity;
@ -961,8 +960,8 @@
var stb = "<tr>";
/* stb += "<td>" + thour + "</td>";*/
stb += "<td>" + kWhkwp + "</td>";
stb += "<td>" + tpr + "</td>";
stb += "<td>" + kWhkwp + "</td>"; //header - 有效發電小時
stb += "<td>" + tpr + "</td>"; //
stb += "<td>" + tkwh + "</td>";
stb += "<td>" + GeneratingCapacity + "</td>";
if (showmoney == 1) {
@ -1274,7 +1273,7 @@
}
}
}
// 綜合報表
function maxtableinfobody(showmoney)
{
var send_data =
@ -1320,9 +1319,6 @@
mintime = data.mintime;
}
var hirerate = 0;
if (data.powerstationType == 1)
{
@ -1360,9 +1356,9 @@
StrInfoBody += "<tr>";
StrInfoBody += "<td>" + data.cityName + data.areaName + "</td>";
StrInfoBody += "<td>" + data.powerstationName + "</td>";
StrInfoBody += "<td>" + data.kwh.toFixed(2) + "</td>";
StrInfoBody += "<td>" + data.avgKWHKWP.toFixed(2) + "</td>";
StrInfoBody += "<td>" + data.avgIrradiance.toFixed(2) + "</td>";
StrInfoBody += "<td>" + data.kwh.toFixed(2) + "</td>"; // 發電量
StrInfoBody += "<td>" + data.avgKWHKWP.toFixed(2) + "</td>"; // 有效發電小時
StrInfoBody += "<td>" + data.avgIrradiance.toFixed(2) + "</td>"; // 平均日照
StrInfoBody += "<td>" + data.avgPR.toFixed(2) + "</td>";
if (showmoney == 1) {

View File

@ -8,21 +8,21 @@
},
"LoginExpireMinute": 60, //()
"GoBackDay": 1, //(())
"DBConfig": {
"Server": "MVgHWzR3rGDgD57TUoFunA==",
"port": "r4AoXMUDodcQjIzofGNCcg==",
"Database": "z8TVtiXZ6MwgWbUEAOXA/fiHzd7c0iUhFqn1mHzxhKo=",
"Root": "mWlR2HshQNhRRE34jg4kdg==",
"Password": "y4uPqlH9ncTgR/I07qpwaA=="
},
"mySql": "server=210.61.91.43;user=idafenweb;Database=solar_master;Port=10068;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;",
//"DBConfig": {
// "Server": "AVXfxd+IRlLtJ0MCi9HU1g==",
// "port": "CrEmevYrUsSo7Mkb7Gxn8A==",
// "Database": "CEyYZnO8B5+yTXQcFSsiBA==",
// "Root": "Aph7AzoiwAmmBHCfS1rqeQ==",
// "Password": "8WMHBEWuT0XoAB4kzduQHA=="
// "Server": "MVgHWzR3rGDgD57TUoFunA==",
// "port": "r4AoXMUDodcQjIzofGNCcg==",
// "Database": "z8TVtiXZ6MwgWbUEAOXA/fiHzd7c0iUhFqn1mHzxhKo=",
// "Root": "mWlR2HshQNhRRE34jg4kdg==",
// "Password": "y4uPqlH9ncTgR/I07qpwaA=="
//},
"mySql": "server=210.61.91.43;user=idafenweb;Database=solar_master;Port=10068;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;",
"DBConfig": {
"Server": "AVXfxd+IRlLtJ0MCi9HU1g==",
"port": "CrEmevYrUsSo7Mkb7Gxn8A==",
"Database": "CEyYZnO8B5+yTXQcFSsiBA==",
"Root": "Aph7AzoiwAmmBHCfS1rqeQ==",
"Password": "8WMHBEWuT0XoAB4kzduQHA=="
},
"BackgroundServiceCron": {
"CalcPowerStationJob": "0 5 * * * ?",
"CalcAvgPowerStationJob": "0 0 2 * * ?",

View File

@ -107,7 +107,7 @@ namespace solarApp.Service
clearData();
insert_inv();
//日報表
insert_report_invDay(); //get_ck_invDay_list
//insert_report_invDay(); //get_ck_invDay_list
return result;
}