Merge branch 'master' of https://github.com/shanghohui-Company/SolarPower
This commit is contained in:
commit
0551a094a8
@ -185,64 +185,74 @@ namespace solarApp.Service
|
||||
_logger.LogInformation("【ProcInvSvc】開始執行[{0}]在{1}逆變器15min補償", _siteID, _date1);
|
||||
}
|
||||
|
||||
sql = @$"DROP TABLE IF EXISTS del_Inv_day_" + _powerStationID + @"_s1;
|
||||
CREATE TABLE del_Inv_day_" + _powerStationID + @"_s1
|
||||
select * from " + _siteDB + ".s" + _siteID01 + @"_inv a
|
||||
WHERE left(crdTime, 10) = @date1;
|
||||
# 2. add index
|
||||
ALTER TABLE del_Inv_day_" + _powerStationID + @"_s1 ADD INDEX `temp_index` (crdTime, inverterid);";
|
||||
int ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
|
||||
sql = @"
|
||||
INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
|
||||
select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
|
||||
(
|
||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
|
||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
from del_Inv_day_" + _powerStationID + @"_s1
|
||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '00' and '10'
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
union
|
||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':15:00')reportdate, inverterid,
|
||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
from del_Inv_day_" + _powerStationID + @"_s1
|
||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
union
|
||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':30:00')reportdate, inverterid,
|
||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
from del_Inv_day_" + _powerStationID + @"_s1
|
||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
union
|
||||
select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':45:00')reportdate, inverterid,
|
||||
(sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
from del_Inv_day_" + _powerStationID + @"_s1
|
||||
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '45' and '55'
|
||||
group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
|
||||
|
||||
// sql = @"
|
||||
//sql = @"
|
||||
// INSERT INTO solar_master.inverter_history_15min( PowerStationId, TIMESTAMP, INVERTERID, KWH, TODAYKWH, KWHKWP)
|
||||
// select PowerStationId, reportdate, a.inverterid, KWH, TODAYKWH, (kwh/(capacity/4)) kwpkwp from
|
||||
// (
|
||||
//select @PowerStationId PowerStationId,CONCAT(left(CrdTime, 13), '%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
|
||||
// select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00:00')reportdate, inverterid,
|
||||
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
// from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
// where left(CrdTime, 10) = @date1 and CONCAT(left(CrdTime, 13), '%Y-%m-%d %H:%i') , 2) between '00' and '10'
|
||||
// where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '00' and '10'
|
||||
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
// union
|
||||
// select @PowerStationId PowerStationId, CONCAT(left(CrdTime, 13), ':15:00')reportdate, inverterid,
|
||||
// select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':15:00')reportdate, inverterid,
|
||||
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
// from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
// where left(CrdTime, 10) = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
|
||||
// where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '15' and '25'
|
||||
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
// union
|
||||
// select @PowerStationId PowerStationId, CONCAT(left(CrdTime, 13), ':30:00')reportdate, inverterid,
|
||||
// select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':30:00')reportdate, inverterid,
|
||||
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
// from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
// where left(CrdTime, 10) = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
|
||||
// where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '30' and '40'
|
||||
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
// union
|
||||
// select @PowerStationId PowerStationId, CONCAT(left(CrdTime, 13), ':45:00')reportdate, inverterid,
|
||||
// select @PowerStationId PowerStationId, CONCAT(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':45:00')reportdate, inverterid,
|
||||
// (sum(WH)/1000) KWH, max(TODAYKWH) TODAYKWH
|
||||
// from " + _siteDB + ".s" + _siteID01 + @"_inv
|
||||
// where left(CrdTime, 10) = @date1 and MINUTE(CrdTime) between '45' and '55'
|
||||
// where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and right(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H:%i') , 2) between '45' and '55'
|
||||
// group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') , inverterid
|
||||
// ) a join " + _siteDB + @".inverter b on a.inverterid = b.inverterid";
|
||||
|
||||
|
||||
|
||||
var ds = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
|
||||
if (_logger != null)
|
||||
@ -310,14 +320,6 @@ namespace solarApp.Service
|
||||
// order by a.INVERTERID, a.reportDate;";
|
||||
//int ct = conn.Execute(sql, new { date1 = _date1, PowerStationID = _powerStationID });
|
||||
|
||||
sql = @$"DROP TEMPORARY TABLE IF EXISTS Inv_day_"+ _powerStationID + @"_s1;
|
||||
CREATE TEMPORARY TABLE Inv_day_" + _powerStationID + @"_s1
|
||||
select * from " + _siteDB + ".s" + _siteID01 + @"_inv a
|
||||
WHERE left(crdTime, 10) = @date1;
|
||||
# 2. add index
|
||||
ALTER TABLE Inv_day_" + _powerStationID + @"_s1 ADD INDEX `temp_index` (crdTime, inverterid);";
|
||||
int ct = conn.Execute(sql, new { date1 = _date1});
|
||||
|
||||
sql = @$"DROP TEMPORARY TABLE IF EXISTS Inv_day_" + _powerStationID + @"_s2;
|
||||
CREATE TEMPORARY TABLE Inv_day_" + _powerStationID + @"_s2
|
||||
SELECT " + _powerStationID + @" powerStationID, a.INVERTERID, a.reportDate,a.AC1V, a.AC1A, a.AC1W, a.AC1F, a.AC1WH, a.AC2V, a.AC2A, a.AC2W, a.AC2F, a.AC2WH,
|
||||
@ -336,7 +338,7 @@ namespace solarApp.Service
|
||||
SUM(DC4WH) AS DC4WH, AVG(DC5V) AS DC5V, AVG(DC5A) AS DC5A, SUM(DC5W) AS DC5W, SUM(DC5WH) AS DC5WH,
|
||||
AVG(RA1) AS RA1, AVG(RA2) AS RA2, AVG(RA3) AS RA3,
|
||||
AVG(RA4) AS RA4, AVG(RA5) AS RA5, MAX(TODAYKWH) AS TODAYKWH, MAX(TOTALKWH) AS TOTALKWH, (SUM(WH) / 1000) AS KWH
|
||||
FROM Inv_day_" + _powerStationID + @"_s1
|
||||
FROM del_Inv_day_" + _powerStationID + @"_s1
|
||||
GROUP BY left(crdTime, 13), INVERTERID
|
||||
) a
|
||||
-- 取得逆變器容量
|
||||
@ -347,14 +349,17 @@ namespace solarApp.Service
|
||||
from sensor_history_hour
|
||||
where powerstationID = " + _powerStationID + @" and DATE_FORMAT(`TIMESTAMP`, '%Y-%m-%d') = @date1
|
||||
)irr on a.reportDate = irr.reportDate; ";
|
||||
ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
int ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
|
||||
|
||||
|
||||
//# 3. insert ans
|
||||
sql = @$"
|
||||
INSERT INTO solar_master.inverter_history_hour(`powerStationID`, `INVERTERID`, `TIMESTAMP`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `KWH`, `TODAYKWH`, `TOTALKWH`, `Irradiance`, `PR`, `DCKW`, `ACKW`, `KWHKWP`)
|
||||
select `powerStationID`, a.`INVERTERID`, a.`reportDate`, `AC1V`, `AC1A`, `AC1W`, `AC1F`, `AC1WH`, `AC2V`, `AC2A`, `AC2W`, `AC2F`, `AC2WH`, `AC3V`, `AC3A`, `AC3W`, `AC3F`, `AC3WH`, `DC1V`, `DC1A`, `DC1W`, `DC1WH`, `DC2V`, `DC2A`, `DC2W`, `DC2WH`, `DC3V`, `DC3A`, `DC3W`, `DC3WH`, `DC4V`, `DC4A`, `DC4W`, `DC4WH`, `DC5V`, `DC5A`, `DC5W`, `DC5WH`, `RA1`, `RA2`, `RA3`, `RA4`, `RA5`, `KWH`, `TODAYKWH`, `TOTALKWH`, `irr`, inv_pr.`PR`, `DCKW`, `ACKW`, `KWHKWP`
|
||||
from Inv_day_" + _powerStationID + @"_s2 a left JOIN( -- 取得整點值PR
|
||||
SELECT concat(left(crdTime, 13), ':00:00') AS reportDate, inv.INVERTERID, inv.PR
|
||||
FROM Inv_day_" + _powerStationID + @"_s1 inv
|
||||
FROM del_Inv_day_" + _powerStationID + @"_s1 inv
|
||||
WHERE minute(crdtime) = '55'
|
||||
GROUP BY left(crdTime, 13), inv.INVERTERID
|
||||
) inv_pr
|
||||
@ -362,7 +367,11 @@ namespace solarApp.Service
|
||||
ct = conn.Execute(sql, new { date1 = _date1 });
|
||||
if (_logger != null)
|
||||
_logger.LogInformation("【ProcInvSvc】執行完成[{0}]在{1}逆變器hour補償", _siteID, _date1);
|
||||
|
||||
ss = @$"DROP TABLE IF EXISTS del_Inv_day_" + _powerStationID + @"_s1; ";
|
||||
conn.Execute(ss);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (_logger != null)
|
||||
|
||||
@ -242,7 +242,7 @@ namespace solarApp.Service
|
||||
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 powerStationID , concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(Temperature), 6) Temperature,
|
||||
envTemperature, humidity, Vane, Dust, WingDirection, irrDay
|
||||
envTemperature, humidity, Vane, Dust, avg(WingDirection) WingDirection, max(irrDay) irrDay
|
||||
from solar_master.sensor_history_hour
|
||||
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1
|
||||
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
|
||||
@ -266,7 +266,7 @@ namespace solarApp.Service
|
||||
select a.powerstationID, a.reportdate, ifnull(b.Irradiance, 0) irrAvg, a.Temperature, a.envTemperature, a.humidity, a.Vane, a.Dust, WingDirection, irrDay from
|
||||
(
|
||||
select powerStationID , concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(Temperature), 6) Temperature,
|
||||
envTemperature, humidity, Vane, Dust, WingDirection, irrDay
|
||||
avg(envTemperature) envTemperature, avg(humidity) humidity, avg(Vane) Vane, avg(Dust) Dust, avg(WingDirection) WingDirection, max(irrDay) irrDay
|
||||
from solar_master.sensor_history_day
|
||||
where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = @date1
|
||||
group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m')
|
||||
|
||||
@ -195,7 +195,7 @@ namespace solarApp.Service
|
||||
sql = @" INSERT INTO solar_master.power_station_history_day( PowerStationId, `TIMESTAMP`, SITEID, SITETYPE, TODAYKWH, TOTALKWH, KWHKWP,
|
||||
PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON)
|
||||
|
||||
select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, a.TODAYKWH, a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR,
|
||||
select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, a.TODAYKWH, a.TOTALKWH, a.KWHKWP, a1.PR, a.MP, a.SOLARHOUR,
|
||||
/*CASE
|
||||
WHEN b.SolarType = 1 THEN a.KWH * PowerRate * c.LeaseRate
|
||||
ELSE a.KWH * PowerRate
|
||||
@ -211,11 +211,18 @@ namespace solarApp.Service
|
||||
(
|
||||
select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00:00') reportdate, siteid, siteType, round((sum(KWH)), 6) KWH,
|
||||
round((max(TODAYKWH)), 6) TODAYKWH, round((max(TOTALKWH)), 6) TOTALKWH, round((max(KWHKWP)), 6) KWHKWP,
|
||||
round((max(PR)), 6) PR, round((max(MP)), 6) as MP, round((max(SOLARHOUR)), 6) SOLARHOUR
|
||||
#round((max(PR)), 6) PR,
|
||||
round((max(MP)), 6) as MP, round((max(SOLARHOUR)), 6) SOLARHOUR
|
||||
from solar_master.power_station_history_hour a
|
||||
where SITEID = @siteID and DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m-%d') = @date1
|
||||
group by a.siteid, DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d')
|
||||
)a join
|
||||
(
|
||||
select id, SITEID, round(PR, 4) PR
|
||||
from solar_master.power_station_history_hour a
|
||||
where SITEID = @siteID and DATE_FORMAT(a.`TIMESTAMP`,'%Y-%m-%d') = @date1
|
||||
order by 1 desc limit 1
|
||||
)a1 on a.siteID = a1.siteID join
|
||||
(
|
||||
select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType
|
||||
from solar_master.power_station
|
||||
|
||||
Loading…
Reference in New Issue
Block a user