solar_App: 加入irrDayHour計算
This commit is contained in:
parent
439b46ff96
commit
41fac9bc24
@ -623,12 +623,12 @@ ALTER TABLE `temp_invDay{_powerStationID}_s1` ADD INDEX `temp_indexs1` (report_d
|
|||||||
#region 先新增 inv_no01
|
#region 先新增 inv_no01
|
||||||
string inv01 = _siteID01 + "0001";
|
string inv01 = _siteID01 + "0001";
|
||||||
sql = @$"
|
sql = @$"
|
||||||
insert report_invday(`report_date`, `PowerStationID`, inv_01, `hourKWH`, `hourKWHp`, `irradiance`, `temperature`, `hourmoney`, `pr`, createTime)
|
insert report_invday(`report_date`, `PowerStationID`, inv_01, `hourKWH`, `hourKWHp`, `irradiance`, `temperature`, `hourmoney`, `pr`, createTime, IrrDay, IrrDayHour )
|
||||||
select a.report_date, a.powerstationId , ifnull(round(a.kwh, 6), 0) inv_01, ifnull(b.KWH, 0) hourKWH,
|
select a.report_date, a.powerstationId , ifnull(round(a.kwh, 6), 0) inv_01, ifnull(b.KWH, 0) hourKWH,
|
||||||
ifnull(round((b.KWH / (SELECT MAX(TODAYKWH) FROM power_station_history_hour
|
ifnull(round((b.KWH / (SELECT MAX(TODAYKWH) FROM power_station_history_hour
|
||||||
WHERE DATE_FORMAT(TIMESTAMP,'%Y-%m-%d') = '{_date1}' and powerstationid = {_powerStationID} ))*100,2)
|
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',
|
, 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
|
ifnull(b.money, 0) 'hourmoney', ifnull(round(b.PR, 2), 0) as pr, now() createTime, ifnull(d.IrrDay, 0)IrrDay, ifnull(d.IrrDayHour, 0)IrrDayHour
|
||||||
from temp_invDay{_powerStationID}_s1 a join
|
from temp_invDay{_powerStationID}_s1 a join
|
||||||
( # 每小時加總 inv
|
( # 每小時加總 inv
|
||||||
select powerStationid, `TIMESTAMP` report_date, siteid, sitetype, round(KWH, 2) KWH,
|
select powerStationid, `TIMESTAMP` report_date, siteid, sitetype, round(KWH, 2) KWH,
|
||||||
@ -639,7 +639,7 @@ from temp_invDay{_powerStationID}_s1 a join
|
|||||||
|
|
||||||
left join
|
left join
|
||||||
(
|
(
|
||||||
select powerStationID, `TIMESTAMP` report_date, irradiance, Temperature
|
select powerStationID, `TIMESTAMP` report_date, irradiance, Temperature, IrrDay, IrrDayHour
|
||||||
from sensor_history_hour
|
from sensor_history_hour
|
||||||
where powerstationid = {_powerStationID} and left(`TIMESTAMP`,10) = '{_date1}'
|
where powerstationid = {_powerStationID} and left(`TIMESTAMP`,10) = '{_date1}'
|
||||||
) d on a.powerStationid = d.powerStationid and a.`report_date` = d.report_date
|
) d on a.powerStationid = d.powerStationid and a.`report_date` = d.report_date
|
||||||
|
|||||||
@ -236,8 +236,8 @@ namespace solarApp.Service
|
|||||||
break;
|
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, irrDayHour)
|
||||||
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, 0 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
|
||||||
@ -267,14 +267,30 @@ namespace solarApp.Service
|
|||||||
TimeSpan duration = DateTime.Now - dt_start2;
|
TimeSpan duration = DateTime.Now - dt_start2;
|
||||||
arclog.insert_log(_powerStationID, "sensor step1", duration.TotalSeconds, "sensor_history_hour", "insert sensor hour", "0", "", rowCT.ToString(), conn, cmd);
|
arclog.insert_log(_powerStationID, "sensor step1", duration.TotalSeconds, "sensor_history_hour", "insert sensor hour", "0", "", rowCT.ToString(), conn, cmd);
|
||||||
|
|
||||||
|
//irrDayHour計算
|
||||||
|
sql = $@"update sensor_history_hour a join (
|
||||||
|
select LEFT(DATE_ADD(`TIMESTAMP`, INTERVAL +1 hour), 13) hour_1, irrday
|
||||||
|
from sensor_history_hour a
|
||||||
|
where powerstationID = {_powerStationID} and LEFT(a.TIMESTAMP, 10 ) = '{_date1}'
|
||||||
|
|
||||||
|
)b on LEFT(a.`TIMESTAMP`, 13) = hour_1
|
||||||
|
Set irrDayhour = case when a.`irrday` - b.`irrday` < 0 then 0 else a.`irrday` - b.`irrday` end
|
||||||
|
where a.powerstationID = {_powerStationID}";
|
||||||
|
|
||||||
|
dt_start2 = DateTime.Now;
|
||||||
|
cmd.CommandText = sql;
|
||||||
|
int rowCT2 = cmd.ExecuteNonQuery();
|
||||||
|
cmd.Parameters.Clear();
|
||||||
|
duration = DateTime.Now - dt_start2;
|
||||||
|
arclog.insert_log(_powerStationID, "sensor step1 for irrDayHour", duration.TotalSeconds, "sensor_history_hour", "update sensor hour", "0", "", rowCT2.ToString(), conn, cmd);
|
||||||
#endregion hour
|
#endregion hour
|
||||||
|
|
||||||
#region day
|
#region day
|
||||||
sql = @"insert into sensor_history_day( `PowerStationId`, `TIMESTAMP`, Irradiance, Temperature, EnvTemperature, Humidity, Vane, Dust, WingDirection, irrDay)
|
sql = @"insert into sensor_history_day( `PowerStationId`, `TIMESTAMP`, Irradiance, Temperature, EnvTemperature, Humidity, Vane, Dust, WingDirection, irrDay, irrDayHour)
|
||||||
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 a.powerstationID, a.reportdate, ifnull(b.Irradiance, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust, a.WingDirection, a.irrDay, a.irrDayHour from
|
||||||
(
|
(
|
||||||
select powerStationID , concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(Temperature), 6) Temperature,
|
select powerStationID , concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(Temperature), 6) Temperature,
|
||||||
envTemperature, humidity, Vane, Dust, avg(WingDirection) WingDirection, max(irrDay) irrDay
|
envTemperature, humidity, Vane, Dust, avg(WingDirection) WingDirection, max(irrDay) irrDay, sum(irrDayHour) irrDayHour
|
||||||
from solar_master.sensor_history_hour
|
from solar_master.sensor_history_hour
|
||||||
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1
|
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1
|
||||||
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
|
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
|
||||||
@ -299,11 +315,11 @@ namespace solarApp.Service
|
|||||||
sql = @"
|
sql = @"
|
||||||
delete from sensor_history_month where left(`TIMESTAMP`, 7) = @date1 and PowerStationID = @powerStationID;
|
delete from sensor_history_month where left(`TIMESTAMP`, 7) = @date1 and PowerStationID = @powerStationID;
|
||||||
|
|
||||||
insert into sensor_history_month( `PowerStationId`, `TIMESTAMP`, `Irradiance`, Temperature, EnvTemperature, Humidity, Vane, Dust, WingDirection, irrDay)
|
insert into sensor_history_month( `PowerStationId`, `TIMESTAMP`, `Irradiance`, Temperature, EnvTemperature, Humidity, Vane, Dust, WingDirection, irrDay, irrDayHour)
|
||||||
select a.powerstationID, a.reportdate, ifnull(b.Irradiance, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust, WingDirection, irrDay from
|
select a.powerstationID, a.reportdate, ifnull(b.Irradiance, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust, WingDirection, irrDay, irrDayHour from
|
||||||
(
|
(
|
||||||
select powerStationID , concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(Temperature), 6) Temperature,
|
select powerStationID , concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(Temperature), 6) Temperature,
|
||||||
avg(envTemperature) envTemperature, avg(humidity) humidity, avg(Vane) Vane, avg(Dust) Dust, avg(WingDirection) WingDirection, max(irrDay) irrDay
|
avg(envTemperature) envTemperature, avg(humidity) humidity, avg(Vane) Vane, avg(Dust) Dust, avg(WingDirection) WingDirection, max(irrDay) irrDay, sum(irrDayHour) irrDayHour
|
||||||
from solar_master.sensor_history_day
|
from solar_master.sensor_history_day
|
||||||
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = @date1
|
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = @date1
|
||||||
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m')
|
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user