diff --git a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs index 871e0d4..23ddf88 100644 --- a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs +++ b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs @@ -131,16 +131,32 @@ namespace SolarPower.Quartz.Jobs #endregion #region 發電金額 - //發電金額 + + history.MONEY = history.KWH * powerStation.PowerRate; + + //即時發電金額 switch (powerStation.SolarType) { case (int)SolarTypeEnum.SelfSold: //自建躉售 - //今日發電金額 計算方式:todaykWh * 授電費率 - calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate; - history.MONEY = history.KWH * powerStation.PowerRate; - //總發電金額 計算方式:totalkWh * 授電費率 - calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate; + if (lastmoneyhistorybyhour != null) + { + history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate; + history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate; + } + else + { + history.TODAYMONEY = history.KWH * powerStation.PowerRate; + history.TOTALMONEY = history.KWH * powerStation.PowerRate; + } + + //今日發電金額 計算方式:todaykWh * 授電費率,如有上筆資料,需累加 上一筆金額 + //calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate; + calcPowerStation.Today_Money = history.TODAYMONEY; + + ////總發電金額 計算方式:totalkWh * 授電費率,如有上筆資料,需累加 上一筆金額 + //calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate; + calcPowerStation.Total_Money = history.TOTALMONEY; break; case (int)SolarTypeEnum.HireSold: //租建躉售 //找出該電站的所有土地房屋資訊 @@ -154,21 +170,43 @@ namespace SolarPower.Quartz.Jobs } //avgLeaseRate = sumLeaseRate / landBuildings.Count(); - //今日發電金額計算方式:todaykWh * 出借費率(各個土地房屋租借比率平均) - calcPowerStation.Today_Money = history.TodayKWh * sumLeaseRate; + if (lastmoneyhistorybyhour != null) + { + history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate; + history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate; - history.MONEY = history.KWH * sumLeaseRate; - //總發電金額 計算方式:totalkWh * 授電費率 - calcPowerStation.Total_Money = history.TotalKWH * sumLeaseRate; + //今日發電金額計算方式:todaykWh * 出借費率(各個土地房屋租借比率平均) + calcPowerStation.Today_Money = lastmoneyhistorybyhour.TODAYMONEY + (history.KWH * powerStation.PowerRate * sumLeaseRate); + //總發電金額 計算方式:totalkWh * 授電費率 + calcPowerStation.Total_Money = lastmoneyhistorybyhour.TOTALMONEY + (history.KWH * powerStation.PowerRate * sumLeaseRate); + } + else + { + history.TODAYMONEY = history.KWH * powerStation.PowerRate; + history.TOTALMONEY = history.KWH * powerStation.PowerRate; + + calcPowerStation.Today_Money = history.KWH * powerStation.PowerRate * sumLeaseRate; + calcPowerStation.Total_Money = history.KWH * powerStation.PowerRate * sumLeaseRate; + } break; case (int)SolarTypeEnum.SelfUse: //自建自用 - //今日發電金額 計算方式:todaykWh * 授電費率 - calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate; - history.MONEY = history.KWH * powerStation.PowerRate; + if (lastmoneyhistorybyhour != null) + { + history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate; + history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate; + } + else + { + history.TODAYMONEY = history.KWH * powerStation.PowerRate; + history.TOTALMONEY = history.KWH * powerStation.PowerRate; + } + + //今日發電金額 計算方式:todaykWh * 授電費率 + calcPowerStation.Today_Money = history.TODAYMONEY; //總發電金額 計算方式:totalkWh * 授電費率 - calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate; + calcPowerStation.Total_Money = history.TOTALMONEY; break; } #endregion @@ -186,26 +224,29 @@ namespace SolarPower.Quartz.Jobs #region 減碳量 carbonRate = Convert.ToDouble(await powerStationRepository.GetOneVariableByName("CarbonRate")); - //今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值] - calcPowerStation.Today_Carbon = history.TodayKWh * carbonRate; - history.CARBON = history.KWH * carbonRate; - //總減碳量(總發電量 * (0.554/1000)[抓資料庫值] - calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate; - if (lastmoneyhistorybyhour != null) { history.TODAYCARBON = lastmoneyhistorybyhour.TODAYCARBON + history.KWH * carbonRate; history.TOTALCARBON = lastmoneyhistorybyhour.TOTALCARBON + history.KWH * carbonRate; - history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate; - history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate; + + //今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值] + calcPowerStation.Today_Carbon = history.TODAYCARBON; + + //總減碳量(總發電量 * (0.554/1000)[抓資料庫值] + calcPowerStation.Total_Carbon = history.TOTALCARBON; } else { history.TODAYCARBON = history.KWH * carbonRate; history.TOTALCARBON = history.KWH * carbonRate; - history.TODAYMONEY = history.KWH * powerStation.PowerRate; - history.TOTALMONEY = history.KWH * powerStation.PowerRate; + + //今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值] + calcPowerStation.Today_Carbon = history.TODAYCARBON; + + history.CARBON = history.KWH * carbonRate; + //總減碳量(總發電量 * (0.554/1000)[抓資料庫值] + calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate; } #endregion diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 5cfe027..cb93614 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -4420,6 +4420,7 @@ namespace SolarPower.Repository.Implement var temp_sql = $@"SELECT FROM_UNIXTIME(inv.TIMESTAMP/1000, '%H:%i') AS TIMESTAMP, inv.INVERTERID, + i.InverterName AS INVERTERName, sen.{entity.Sensor} AS Irradiance, ((inv.DC1W + inv.DC2W + inv.DC3W + inv.DC4W + inv.DC5W) / 1000) AS DCKW, ((inv.AC1W + inv.AC2W + inv.AC3W) / 1000) AS ACKW, @@ -4466,8 +4467,9 @@ namespace SolarPower.Repository.Implement inv.RA5 FROM {table_name} inv LEFT JOIN {sensor_table_name} sen ON FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') = FROM_UNIXTIME(sen.TIMESTAMP/1000, '%Y-%m-%d %H:%i') + LEFT JOIN {entity.SiteDB}.inverter i ON inv.INVERTERID = i.InverterId WHERE FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d') = @NowDay - AND INVERTERID IN ('{inverterIds}')"; + AND inv.INVERTERID IN ('{inverterIds}')"; sql_perSiteDB.Add(temp_sql); } @@ -4503,6 +4505,7 @@ namespace SolarPower.Repository.Implement var temp_sql = $@"SELECT DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP, INVERTERID, + i.InverterName AS INVERTERName, inv.Irradiance, inv.KWH, inv.TODAYKWH, @@ -4513,6 +4516,7 @@ namespace SolarPower.Repository.Implement inv.RA4, inv.RA5 FROM inverter_history_day inv + LEFT JOIN {entity.SiteDBName}.inverter i ON inv.INVERTERID = i.InverterId WHERE inv.PowerStationId = {entity.PowerStationId} AND inv.INVERTERID IN ('{inverterIds}') AND inv.TIMESTAMP BETWEEN @StartDay AND @EndDay"; @@ -4551,6 +4555,7 @@ namespace SolarPower.Repository.Implement var temp_sql = $@"SELECT DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP, INVERTERID, + i.InverterName AS INVERTERName, inv.KWH, inv.TODAYKWH, inv.PR, @@ -4560,6 +4565,7 @@ namespace SolarPower.Repository.Implement inv.RA4, inv.RA5 FROM inverter_history_month inv + LEFT JOIN {entity.SiteDBName}.inverter i ON inv.INVERTERID = i.InverterId WHERE inv.PowerStationId = {entity.PowerStationId} AND inv.INVERTERID IN ('{inverterIds}') AND DATE_FORMAT(inv.TIMESTAMP, '%Y') = @Year"; diff --git a/SolarPower/Views/AnalysisStationCombine/Index.cshtml b/SolarPower/Views/AnalysisStationCombine/Index.cshtml index a118405..5a5907b 100644 --- a/SolarPower/Views/AnalysisStationCombine/Index.cshtml +++ b/SolarPower/Views/AnalysisStationCombine/Index.cshtml @@ -111,22 +111,6 @@ } -
當日有效日照時數
-0.00
-平均有效日照時數(30天)
-0.00
-當日有效日照時數
+0.00
+平均有效日照時數(30天)
+0.00
+| 編號 | 電站名稱 | 裝置容量(kWp) | 逆變器數量 | @@ -353,8 +352,7 @@ } $('#solarTable' + val.cityId).find('tbody').append('|
|---|---|---|---|---|
| ' + val.id + ' | ' + - '' + val.name + ' | ' + + '' + val.name + ' | ' + '' + val.generatingCapacity.toFixed(3) + ' | ' + '' + val.inverterAmount + ' | ' + diff --git a/SolarPower/Views/StationOverview/Index.cshtml b/SolarPower/Views/StationOverview/Index.cshtml index 3c2ed0a..7a05b9a 100644 --- a/SolarPower/Views/StationOverview/Index.cshtml +++ b/SolarPower/Views/StationOverview/Index.cshtml @@ -425,7 +425,8 @@ $('#card_' + val.id).find('#stationtype').html(type); var time = new Date(val.createdAt); $('#card_' + val.id).find('#editSolarUrl').attr('href', localurl + '/Info?stationId=' + val.id); - $('#card_' + val.id).find('#date').html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes()); + @*$('#card_' + val.id).find('#date').html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());*@ + $('#card_' + val.id).find('#date').html(val.electricityMeterAt); $('#card_' + val.id).find('#today_kwh').html(val.today_kWh.toFixed(2)); $('#card_' + val.id).find('#Capacity').html(val.generatingCapacity.toFixed(3)); @if (ViewBag.myUser.Role.Auths.Contains("ShowMoney")) diff --git a/solarApp/Service/procStationSvc.cs b/solarApp/Service/procStationSvc.cs index 3325749..e3e9c0f 100644 --- a/solarApp/Service/procStationSvc.cs +++ b/solarApp/Service/procStationSvc.cs @@ -158,21 +158,21 @@ namespace solarApp.Service 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 , - CASE - WHEN b.SolarType = 1 THEN a.KWH * c.LeaseRate + /* CASE + WHEN b.SolarType = 1 THEN a.KWH * PowerRate * c.LeaseRate ELSE a.KWH * PowerRate END MONEY, CASE - WHEN b.SolarType = 1 THEN a.TODAYKWH * c.LeaseRate + WHEN b.SolarType = 1 THEN a.TODAYKWH * PowerRate * c.LeaseRate ELSE a.TODAYKWH * PowerRate END TODAYMONEY, CASE - WHEN b.SolarType = 1 THEN a.TOTALKWH * c.LeaseRate + WHEN b.SolarType = 1 THEN a.TOTALKWH * PowerRate * c.LeaseRate ELSE a.TOTALKWH * PowerRate - END TOTALMONEY, - -- (a.KWH * PowerRate) MONEY, - -- (a.TODAYKWH * PowerRate) TODAYMONEY, - -- (a.TOTALKWH * PowerRate) TOTALMONEY, + 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 from " + _siteDB + ".s" + _siteID01 + @"_station a join (select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType @@ -196,16 +196,16 @@ namespace solarApp.Service 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, - CASE - WHEN b.SolarType = 1 THEN a.KWH * c.LeaseRate + /*CASE + WHEN b.SolarType = 1 THEN a.KWH * PowerRate * c.LeaseRate ELSE a.KWH * PowerRate END MONEY, CASE - WHEN b.SolarType = 1 THEN a.TOTALKWH * c.LeaseRate + WHEN b.SolarType = 1 THEN a.TOTALKWH * PowerRate * c.LeaseRate ELSE a.TOTALKWH * PowerRate - END TOTALMONEY, - -- (KWH * PowerRate) MONEY, - -- (a.TOTALKWH * PowerRate) TOTALMONEY, + END TOTALMONEY,*/ + (KWH * PowerRate) MONEY, + (a.TOTALKWH * PowerRate) TOTALMONEY, (KWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON from ( @@ -240,16 +240,16 @@ namespace solarApp.Service 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, - CASE + /*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, + END TOTALMONEY,*/ + (TODAYKWH * PowerRate) MONEY, + (a.TOTALKWH * PowerRate) TOTALMONEY, (TODAYKWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON from (