電站月報表改用post

This commit is contained in:
cesar liu 2022-06-27 11:37:11 +08:00 committed by ken
parent 008c98feec
commit e965795e33
3 changed files with 22 additions and 6 deletions

View File

@ -732,7 +732,8 @@ namespace SolarPower.Repository.Implement
{ {
var sub_sql = $@"select '{db_name}' AS `dbName`,(`{db_name}`.`inverter`.`InverterId` collate utf8mb4_unicode_ci) AS `InverterId`, var sub_sql = $@"select '{db_name}' AS `dbName`,(`{db_name}`.`inverter`.`InverterId` collate utf8mb4_unicode_ci) AS `InverterId`,
(`{db_name}`.`inverter`.`Brand` collate utf8mb4_unicode_ci) AS `Brand`,`{db_name}`.`inverter`.`Enabled` AS `enabled`, (`{db_name}`.`inverter`.`Brand` collate utf8mb4_unicode_ci) AS `Brand`,`{db_name}`.`inverter`.`Enabled` AS `enabled`,
`{db_name}`.`inverter`.`Status` AS status, (`{db_name}`.`inverter`.`Model` collate utf8mb4_unicode_ci) AS `Model` `{db_name}`.`inverter`.`Deleted` AS `Deleted`,
`{db_name}`.`inverter`.`Status` AS status, (`{db_name}`.`inverter`.`Model` collate utf8mb4_unicode_ci) AS `Model`
from `{db_name}`.`inverter`"; from `{db_name}`.`inverter`";
temp_sub_sql.Add(sub_sql); temp_sub_sql.Add(sub_sql);

View File

@ -292,7 +292,11 @@
<div>
<form id="report" name="report" method="post">
<input type="hidden" id="post" name="post"/>
</form>
</div>
</main> </main>
</div> </div>
</div> </div>
@ -1244,7 +1248,10 @@
if (send_data.FormType != null && send_data.PowerStation.length != 0 && send_data.FormType != 2) { if (send_data.FormType != null && send_data.PowerStation.length != 0 && send_data.FormType != 2) {
$.post("/StationReport/CheckExcel", send_data, function (rel) { $.post("/StationReport/CheckExcel", send_data, function (rel) {
if (rel.code == "0000") { if (rel.code == "0000") {
window.location = "/StationReport/ExportExcel?post=" + JSON.stringify(send_data); //window.location = "/StationReport/ExportExcel?post=" + JSON.stringify(send_data);
$("#post").val(JSON.stringify(send_data));
document.report.action = "StationReport/ExportExcel";
document.report.submit();
return; return;
} }
else else

View File

@ -225,20 +225,28 @@ namespace solarApp.Service
#endregion Sensor #endregion Sensor
try try
{ {
#region hour #region hour
// 暫時解法 儘針對整個 Device 都是共享的情況 ---------------
string tableName = "s" + _siteID01 + "_sensorAvg";
foreach (var item in ds_sensor)
{
tableName = item.TableName;
break;
}
sql = @"insert into sensor_history_hour( `PowerStationId`, `TIMESTAMP`, Irradiance, Temperature, EnvTemperature, Humidity, Vane, Dust, WingDirection, irrDay) sql = @"insert into sensor_history_hour( `PowerStationId`, `TIMESTAMP`, Irradiance, Temperature, EnvTemperature, Humidity, Vane, Dust, WingDirection, irrDay)
select a.powerstationID, a.reportdate, ifnull(b.irrAvg, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust, WingDirection, irrDay from select a.powerstationID, a.reportdate, ifnull(b.irrAvg, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust, WingDirection, irrDay from
( (
select @powerStationID powerstationID, FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') reportdate, round(avg(" + modelTempCol + @"), 4) Temperature, select @powerStationID powerstationID, FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') reportdate, round(avg(" + modelTempCol + @"), 4) Temperature,
avg(" + evnTempCol + @") envTemperature, avg(" + humCol + @") humidity, avg(" + vanCol + @") Vane, avg(" + dustCol + @") Dust, avg(" + winCol + @") WingDirection, max(" + irrDayCol + @") irrDay avg(" + evnTempCol + @") envTemperature, avg(" + humCol + @") humidity, avg(" + vanCol + @") Vane, avg(" + dustCol + @") Dust, avg(" + winCol + @") WingDirection, max(" + irrDayCol + @") irrDay
from " + _siteDB + ".s" + _siteID01 + @"_sensorAvg from " + _siteDB + "." + tableName + @"
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H')
) a left join ) a left join
( (
select concat(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00') reportdate, round(avg(" + irrCol + @"), 6) irrAvg select concat(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00') reportdate, round(avg(" + irrCol + @"), 6) irrAvg
from " + _siteDB + ".s" + _siteID01 + @"_sensorAvg from " + _siteDB + "." + tableName + @"
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 " + irrNot0 + @" # 0 where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 " + irrNot0 + @" # 0
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H')
)b on a.reportdate = b.reportdate"; )b on a.reportdate = b.reportdate";