diff --git a/solarApp/Service/procInvSvc.cs b/solarApp/Service/procInvSvc.cs index 62079db..3971c15 100644 --- a/solarApp/Service/procInvSvc.cs +++ b/solarApp/Service/procInvSvc.cs @@ -238,9 +238,9 @@ namespace solarApp.Service SUM(a.AC3W) AS AC3W, AVG(a.AC3F) AS AC3F, SUM(a.AC3WH) AS AC3WH, AVG(a.DC1V) AS DC1V, AVG(a.DC1A) AS DC1A, SUM(a.DC1W) AS DC1W, SUM(a.DC1WH) AS DC1WH, AVG(a.DC2V) AS DC2V, AVG(a.DC2A) AS DC2A, SUM(a.DC2W) AS DC2W, SUM(a.DC2WH) AS DC2WH, AVG(a.DC3V) AS DC3V, AVG(a.DC3A) AS DC3A, AVG(a.DC3W) AS DC3W, AVG(a.DC3WH) AS DC3WH, AVG(a.DC4V) AS DC4V, AVG(a.DC4A) AS DC4A, SUM(a.DC4W) AS DC4W, - SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH, max(PR) AS PR, + SUM(a.DC4WH) AS DC4WH,AVG(a.DC5V) AS DC5V, AVG(a.DC5A) AS DC5A, SUM(a.DC5W) AS DC5W, SUM(a.DC5WH) AS DC5WH, avg(PR) AS PR, AVG(a.RA1) AS RA1, AVG(a.RA2) AS RA2, AVG(a.RA3) AS RA3, AVG(a.RA4) AS RA4, AVG(a.RA5) AS RA5, avg(DCKW) as DCKW, avg(ACKW) as ACKW, - MAX(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, SUM(a.KWH) AS KWH + avg(a.TODAYKWH) AS TODAYKWH, MAX(a.TOTALKWH) AS TOTALKWH, SUM(a.KWH) AS KWH FROM solar_master.inverter_history_day a WHERE powerstationID = @powerstationID and DATE_FORMAT(a.TIMESTAMP, '%Y-%m') = @date1 GROUP BY DATE_FORMAT(a.TIMESTAMP, '%Y-%m'), a.INVERTERID @@ -264,7 +264,6 @@ namespace solarApp.Service throw ex; } return result; - } - + } } } diff --git a/solarApp/Service/procSensorSvc.cs b/solarApp/Service/procSensorSvc.cs index af61447..6ceab0e 100644 --- a/solarApp/Service/procSensorSvc.cs +++ b/solarApp/Service/procSensorSvc.cs @@ -207,7 +207,7 @@ namespace solarApp.Service 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 + @"), 2) irrAvg + select concat(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00') reportdate, round(avg(" + irrCol + @"), 6) irrAvg from " + _siteDB + ".s" + _siteID01 + @"_sensorAvg where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 " + irrNot0 + @" #需要過濾 0 的數值 group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') @@ -229,7 +229,7 @@ namespace solarApp.Service group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') ) a left join ( - select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(Irradiance), 2) Irradiance + select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(Irradiance), 6) Irradiance from solar_master.sensor_history_hour where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1 and Irradiance <> 0 #需要過濾 0 的數值 @@ -253,7 +253,7 @@ namespace solarApp.Service group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m') ) a left join ( - select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(Irradiance), 2) Irradiance + select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(Irradiance), 6) Irradiance from solar_master.sensor_history_day where powerstationID = @powerstationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = @date1 and Irradiance <> 0 #需要過濾 0 的數值 @@ -284,7 +284,7 @@ namespace solarApp.Service { sql += @" update sensoravg_history_hour a join ( - select @powerstationID powerstationID, concat(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00') reportdate, round(avg(" + item.colname + @"), 2) irrAvg + select @powerstationID powerstationID, concat(FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H'), ':00') reportdate, round(avg(" + item.colname + @"), 6) irrAvg from " + _siteDB + ".s" + _siteID01 + @"_sensorAvg where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and " + item.colname + @" <> 0 #需要過濾 0 的數值 group by FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d %H') @@ -317,7 +317,7 @@ namespace solarApp.Service { sql += @" update solar_master.sensoravg_history_day a join ( - select @powerstationID powerstationID, concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(" + item.colname + @"), 2) irrAvg + select @powerstationID powerstationID, concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00') reportdate, round(avg(" + item.colname + @"), 6) irrAvg from solar_master.sensoravg_history_hour where powerStationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = @date1 and " + item.colname + @" <> 0 #需要過濾 0 的數值 group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') @@ -352,7 +352,7 @@ namespace solarApp.Service { sql += @" update solar_master.sensoravg_history_month a join ( - select @powerstationID powerstationID, concat( DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(" + item.colname + @"), 2) irrAvg + select @powerstationID powerstationID, concat( DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00') reportdate, round(avg(" + item.colname + @"), 6) irrAvg from solar_master.sensoravg_history_day where powerStationID = @powerStationID and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = @date1 and " + item.colname + @" <> 0 #需要過濾 0 的數值 group by DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') diff --git a/solarApp/Service/procStationSvc.cs b/solarApp/Service/procStationSvc.cs index 9e551ad..3a84694 100644 --- a/solarApp/Service/procStationSvc.cs +++ b/solarApp/Service/procStationSvc.cs @@ -166,9 +166,9 @@ namespace solarApp.Service (KWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON from ( - select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d'), ' 00:00:00') reportdate, siteid, siteType, round((sum(KWH)), 4) KWH, - round((max(TODAYKWH)), 4) TODAYKWH, round((max(TOTALKWH)), 4) TOTALKWH, round((max(KWHKWP)), 4) KWHKWP, - round((max(PR)), 4) PR, round((max(MP)), 4) as MP, round((max(SOLARHOUR)), 4) SOLARHOUR + 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 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') @@ -183,20 +183,20 @@ namespace solarApp.Service #region month sql = @" - delete from power_station_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = left(@date1, 7) ; + delete from power_station_history_month where powerstationID = @powerStationID and left(`TIMESTAMP`, 7) = @date1 ; - INSERT INTO solar_master.power_station_history_month(PowerStationId, `TIMESTAMP`, SITEID, SITETYPE, TOTALKWH, KWHKWP, + INSERT INTO solar_master.power_station_history_month(PowerStationId, `TIMESTAMP`, SITEID, SITETYPE, monthKwh , TOTALKWH, KWHKWP, PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON) - select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR, - (KWH * PowerRate) MONEY, (a.TOTALKWH * PowerRate) TOTALMONEY, - (KWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON + 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, + (TODAYKWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON from ( - select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00:00') reportdate, siteid, siteType, round((sum(KWH)), 4) KWH, - round((max(TODAYKWH)), 4) TODAYKWH, round((max(TOTALKWH)), 4) TOTALKWH, round((max(KWHKWP)), 4) KWHKWP, - round((max(PR)), 4) PR, round((max(MP)), 4) as MP, round((max(SOLARHOUR)), 4) SOLARHOUR - from solar_master.power_station_history_hour a + select concat(DATE_FORMAT(`TIMESTAMP`,'%Y-%m'), '-01 00:00:00') reportdate, siteid, siteType, + round((sum(TODAYKWH)), 6) TODAYKWH, round((max(TOTALKWH)), 6) TOTALKWH, round((avg(KWHKWP)), 6) KWHKWP, + round((avg(PR)), 6) PR, round((avg(MP)), 6) as MP, round((avg(SOLARHOUR)), 6) SOLARHOUR + from solar_master.power_station_history_day a where SITEID = @siteID and DATE_FORMAT(a.`TIMESTAMP`, '%Y-%m') = @date1 group by a.siteid, DATE_FORMAT(`TIMESTAMP`, '%Y-%m') )a join