Inv 超時問題,優化SQL 語法
This commit is contained in:
parent
0551a094a8
commit
d4c5d3f9b0
@ -85,7 +85,7 @@
|
||||
<th>時間</th>
|
||||
<th>發電量(kWh)</th>
|
||||
<th>有效日照時數</th>
|
||||
<th>日照度(kWh/m2)</th>
|
||||
<th>日照度(W/m2)</th>
|
||||
<th>PR(%)</th>
|
||||
<th>溫度(℃)</th>
|
||||
</tr>
|
||||
|
||||
@ -547,6 +547,7 @@ ALTER TABLE `temp_invDay{_powerStationID}_s1` ADD INDEX `temp_indexs1` (report_d
|
||||
#endregion
|
||||
|
||||
#region 先新增 inv_no01
|
||||
string inv01 = _siteID01 + "0001";
|
||||
sql = @$"
|
||||
insert report_invday(`report_date`, `PowerStationID`, inv_01, `hourKWH`, `hourKWHp`, `irradiance`, `temperature`, `hourmoney`, `pr`, createTime)
|
||||
select a.report_date, a.powerstationId , ifnull(round(a.kwh, 6), 0) inv_01, ifnull(b.KWH, 0) hourKWH,
|
||||
@ -554,7 +555,7 @@ select a.report_date, a.powerstationId , ifnull(round(a.kwh, 6), 0) inv_01, ifn
|
||||
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',
|
||||
ifnull(b.money, 0) 'hourmoney', ifnull(round(b.PR, 2), 0) as pr, now() createTime
|
||||
from temp_invDay{_powerStationID}_s1 a left join
|
||||
from temp_invDay{_powerStationID}_s1 a join
|
||||
( # 每小時加總 inv
|
||||
select powerStationid, `TIMESTAMP` report_date, siteid, sitetype, round(KWH, 2) KWH,
|
||||
round(TODAYKWH, 2) TODAYKWH,round(KWHKWP, 2) KWHKWP, round(PR, 2) PR, round(money, 2) money
|
||||
@ -568,7 +569,7 @@ from temp_invDay{_powerStationID}_s1 a left join
|
||||
from sensor_history_hour
|
||||
where powerstationid = {_powerStationID} and left(`TIMESTAMP`,10) = '{_date1}'
|
||||
) d on a.powerStationid = d.powerStationid and a.`report_date` = d.report_date
|
||||
where right(a.inverterid, 4) = '0001'
|
||||
where a.inverterid = '{inv01}' # right(a.inverterid, 4) = '0001'
|
||||
GROUP BY left(a.report_date, 13)
|
||||
order by a.report_date ;";
|
||||
conn.Execute(sql);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user