Merge branch 'kai補償機制'

This commit is contained in:
Kai 2021-09-15 11:11:58 +08:00
commit fa6e3f1979
2 changed files with 67 additions and 10 deletions

View File

@ -134,8 +134,8 @@ namespace solarApp.Service
#region hour -- solar_type 0 1 2 ------------ 1 #region hour -- solar_type 0 1 2 ------------ 1
//select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, a.KWH, a.TODAYKWH, a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR, //select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, a.KWH, a.TODAYKWH, a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR,
// (KWH * PowerRate) MONEY, (a.TODAYKWH * PowerRate) TODAYMONEY, (a.TOTALKWH * PowerRate) TOTALMONEY, // (KWH * PowerRate) MONEY, (a.TODAYKWH * PowerRate) TODAYMONEY, (a.TOTALKWH * PowerRate) TOTALMONEY,
// (KWH * CarbonRate) CARBON, (a.TODAYKWH * CarbonRate) TODAYCARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON // (KWH * CarbonRate) CARBON, (a.TODAYKWH * CarbonRate) TODAYCARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON
// from // from
// ( // (
// select siteid, siteType, concat(FROM_UNIXTIME(`TIMESTAMP`/ 1000, '%Y-%m-%d %H'), ':00:00') reportdate, // select siteid, siteType, concat(FROM_UNIXTIME(`TIMESTAMP`/ 1000, '%Y-%m-%d %H'), ':00:00') reportdate,
@ -158,14 +158,36 @@ namespace solarApp.Service
select b.id PowerStationId, concat(FROM_UNIXTIME(`TIMESTAMP`/1000, '%Y-%m-%d %H'), ':00:00') reportdate, a.siteid, a.siteType, select b.id PowerStationId, concat(FROM_UNIXTIME(`TIMESTAMP`/1000, '%Y-%m-%d %H'), ':00:00') reportdate, a.siteid, a.siteType,
a.KWH, TODAYKWH, TOTALKWH, KWHKWP , PR, MP, a.SOLARHOUR , a.KWH, TODAYKWH, TOTALKWH, KWHKWP , PR, MP, a.SOLARHOUR ,
(a.KWH * PowerRate) MONEY, (a.TODAYKWH * PowerRate) TODAYMONEY, (a.TOTALKWH * PowerRate) TOTALMONEY, CASE
WHEN b.SolarType = 1 THEN a.KWH * c.LeaseRate
ELSE a.KWH * PowerRate
END MONEY,
CASE
WHEN b.SolarType = 1 THEN a.TODAYKWH * c.LeaseRate
ELSE a.TODAYKWH * PowerRate
END TODAYMONEY,
CASE
WHEN b.SolarType = 1 THEN a.TOTALKWH * c.LeaseRate
ELSE a.TOTALKWH * PowerRate
END TOTALMONEY,
-- (a.KWH * PowerRate) MONEY,
-- (a.TODAYKWH * PowerRate) TODAYMONEY,
-- (a.TOTALKWH * PowerRate) TOTALMONEY,
(a.KWH * CarbonRate) CARBON, (a.TODAYKWH * CarbonRate) TODAYCARBON, round((a.TOTALKWH * CarbonRate), 3) TOTALCARBON (a.KWH * CarbonRate) CARBON, (a.TODAYKWH * CarbonRate) TODAYCARBON, round((a.TOTALKWH * CarbonRate), 3) TOTALCARBON
from " + _siteDB + ".s" + _siteID01 + @"_station a join from " + _siteDB + ".s" + _siteID01 + @"_station a join
(select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType (select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType
from solar_master.power_station where `code` = @siteID from solar_master.power_station where `code` = @siteID
) b on a.siteID = b.siteID ) b on a.siteID = b.siteID
LEFT JOIN (
SELECT
SUM(lb.LeaseRate) LeaseRate,
ps.Code siteID FROM " + _siteDB + @".land_building lb
LEFT JOIN solar_master.power_station ps ON lb.PowerStationId = ps.Id
WHERE ps.Code = @siteID
GROUP BY lb.PowerStationId
) c ON a.siteID = c.siteID
where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and a.SITEID = @siteID "; where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and a.SITEID = @siteID ";
int ct = conn.Execute(sql, new { date1 = _date1, siteID = _siteID }); int ct = conn.Execute(sql, new { date1 = _date1, siteID = _siteID });
#endregion hour #endregion hour
@ -174,7 +196,16 @@ namespace solarApp.Service
PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON) 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, a.PR, a.MP, a.SOLARHOUR,
(KWH * PowerRate) MONEY, (a.TOTALKWH * PowerRate) TOTALMONEY, CASE
WHEN b.SolarType = 1 THEN a.KWH * c.LeaseRate
ELSE a.KWH * PowerRate
END MONEY,
CASE
WHEN b.SolarType = 1 THEN a.TOTALKWH * c.LeaseRate
ELSE a.TOTALKWH * PowerRate
END TOTALMONEY,
-- (KWH * PowerRate) MONEY,
-- (a.TOTALKWH * PowerRate) TOTALMONEY,
(KWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON (KWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON
from from
( (
@ -188,8 +219,16 @@ namespace solarApp.Service
( (
select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType
from solar_master.power_station from solar_master.power_station
where `code` = @siteID where `code` = @siteID
) b on a.siteID = b.siteID "; ) b on a.siteID = b.siteID
LEFT JOIN (
SELECT
SUM(lb.LeaseRate) LeaseRate,
ps.Code siteID FROM " + _siteDB + @".land_building lb
LEFT JOIN solar_master.power_station ps ON lb.PowerStationId = ps.Id
WHERE ps.Code = @siteID
GROUP BY lb.PowerStationId
) c ON a.siteID = c.siteID";
conn.Execute(sql, new { date1 = _date1, siteID = _siteID }); conn.Execute(sql, new { date1 = _date1, siteID = _siteID });
#endregion day #endregion day
@ -201,7 +240,16 @@ namespace solarApp.Service
PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON) PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON)
select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, TODAYKWH as monthKwh , a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR, select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, TODAYKWH as monthKwh , a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR,
(TODAYKWH * PowerRate) MONEY, (a.TOTALKWH * PowerRate) TOTALMONEY, CASE
WHEN b.SolarType = 1 THEN a.TODAYKWH * c.LeaseRate
ELSE a.TODAYKWH * PowerRate
END MONEY,
CASE
WHEN b.SolarType = 1 THEN a.TOTALKWH * c.LeaseRate
ELSE a.TOTALKWH * PowerRate
END TOTALMONEY,
-- (TODAYKWH * PowerRate) MONEY,
-- (a.TOTALKWH * PowerRate) TOTALMONEY,
(TODAYKWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON (TODAYKWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON
from from
( (
@ -216,8 +264,16 @@ namespace solarApp.Service
select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType
from solar_master.power_station from solar_master.power_station
where `code` = @siteID where `code` = @siteID
) b on a.siteID = b.siteID "; ) b on a.siteID = b.siteID
conn.Execute(sql, new { date1 = _date1.Substring(0, 7), siteID = _siteID, powerStationID = _powerStationID }); LEFT JOIN (
SELECT
SUM(lb.LeaseRate) LeaseRate,
ps.Code siteID FROM " + _siteDB + @".land_building lb
LEFT JOIN solar_master.power_station ps ON lb.PowerStationId = ps.Id
WHERE ps.Code = @siteID
GROUP BY lb.PowerStationId
) c ON a.siteID = c.siteID";
conn.Execute(sql, new { date1 = _date1.Substring(0, 7), siteID = _siteID, powerStationID = _powerStationID });
#endregion month #endregion month

View File

@ -186,6 +186,7 @@ namespace solarApp
procSensorSvc sensorSvc = new procSensorSvc(); procSensorSvc sensorSvc = new procSensorSvc();
sensorSvc.archiveMeterData(lbSiteID_sensor.Text.Substring(0, 9), date1); sensorSvc.archiveMeterData(lbSiteID_sensor.Text.Substring(0, 9), date1);
MessageBox.Show("OK");
} }
} }
} }