debug: 每天歸檔中的共享Sensor,暫時做法,未來尚需徹底解決
This commit is contained in:
parent
008c98feec
commit
9c7c834002
@ -732,6 +732,7 @@ namespace SolarPower.Repository.Implement
|
||||
{
|
||||
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`.`Deleted` AS `Deleted`,
|
||||
`{db_name}`.`inverter`.`Status` AS status, (`{db_name}`.`inverter`.`Model` collate utf8mb4_unicode_ci) AS `Model`
|
||||
from `{db_name}`.`inverter`";
|
||||
|
||||
|
||||
@ -227,18 +227,26 @@ namespace solarApp.Service
|
||||
try
|
||||
{
|
||||
#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)
|
||||
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,
|
||||
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
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H')
|
||||
) a left join
|
||||
(
|
||||
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 的數值
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H')
|
||||
)b on a.reportdate = b.reportdate";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user