From 9c7c834002f140f0112e632e5df624ff11aae211 Mon Sep 17 00:00:00 2001 From: cesar liu Date: Mon, 27 Jun 2022 11:37:11 +0800 Subject: [PATCH] =?UTF-8?q?debug:=20=E6=AF=8F=E5=A4=A9=E6=AD=B8=E6=AA=94?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E5=85=B1=E4=BA=ABSensor=EF=BC=8C=E6=9A=AB?= =?UTF-8?q?=E6=99=82=E5=81=9A=E6=B3=95=EF=BC=8C=E6=9C=AA=E4=BE=86=E5=B0=9A?= =?UTF-8?q?=E9=9C=80=E5=BE=B9=E5=BA=95=E8=A7=A3=E6=B1=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repository/Implement/CompanyRepository.cs | 3 ++- solarApp/Service/procSensorSvc.cs | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/SolarPower/Repository/Implement/CompanyRepository.cs b/SolarPower/Repository/Implement/CompanyRepository.cs index 5889505..054e337 100644 --- a/SolarPower/Repository/Implement/CompanyRepository.cs +++ b/SolarPower/Repository/Implement/CompanyRepository.cs @@ -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`, (`{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`"; temp_sub_sql.Add(sub_sql); diff --git a/solarApp/Service/procSensorSvc.cs b/solarApp/Service/procSensorSvc.cs index a4dc788..f97611d 100644 --- a/solarApp/Service/procSensorSvc.cs +++ b/solarApp/Service/procSensorSvc.cs @@ -225,20 +225,28 @@ namespace solarApp.Service #endregion 獲取 Sensor 類別 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";