From 866f64cc106f6d951dfee414f94f9d62168f061d Mon Sep 17 00:00:00 2001 From: Kai Date: Wed, 22 Sep 2021 09:08:37 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=20=E4=BF=AE=E6=94=B9=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=9F=B7=E8=A1=8C=20=E9=87=91=E9=A1=8D=E8=A8=88=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Quartz/Jobs/CalcPowerStationJob.cs | 91 ++++++++++++++----- .../Implement/PowerStationRepository.cs | 8 +- .../Views/AnalysisStationCombine/Index.cshtml | 33 ++++--- SolarPower/Views/MapOverview/Index.cshtml | 8 +- .../Views/Operation/OperationRecord.cshtml | 2 + SolarPower/Views/PowerStation/Index.cshtml | 4 +- SolarPower/Views/StationOverview/Index.cshtml | 3 +- solarApp/Service/procStationSvc.cs | 36 ++++---- 8 files changed, 116 insertions(+), 69 deletions(-) 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 @@ } -
-
-

有效日照時數

-
hr
-
-
-
-

當日有效日照時數

-

0.00

-
-
-

平均有效日照時數(30天)

-

0.00

-
-
-

PR值

@@ -143,7 +127,22 @@
- +
+
+

有效日照時數

+
hr
+
+
+
+

當日有效日照時數

+

0.00

+
+
+

平均有效日照時數(30天)

+

0.00

+
+
+

減碳量

diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index eb128a3..95e0bcb 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -278,10 +278,10 @@ '
' + '
' + '
' + - '
即時總發電量:' + item.today_kWh + '
'+ - '
即時平均日照度:' + item.today_irradiance + '
'+ - '
發電小時:' + item.solarHour + '
' + - '
裝置容量:' + item.generatingCapacity.toFixed(3) + '
' + + '
今日發電量(kW h):' + item.today_kWh + '
'+ + '
今日日照度(k W/m2):' + item.today_irradiance + '
'+ + '
今日發電小時(hr):' + item.solarHour + '
' + + '
裝置容量(kWp):' + item.generatingCapacity.toFixed(3) + '
' + '
掛錶日期:' + item.electricityMeterAt + '
' + '
天氣:' + item.wx + '
'+ '
' + diff --git a/SolarPower/Views/Operation/OperationRecord.cshtml b/SolarPower/Views/Operation/OperationRecord.cshtml index 9d053aa..14c4f70 100644 --- a/SolarPower/Views/Operation/OperationRecord.cshtml +++ b/SolarPower/Views/Operation/OperationRecord.cshtml @@ -675,9 +675,11 @@ //#region 新增維修單 function AddRecord() { selected_id = 0; + record = undefined; $("#record-form-modal .modal-title .main-title").html("維修單"); $("#record-form-modal .modal-title .sub-title").html(""); $("#power_station_select_modal").attr("disabled", false); + $("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change'); $(".fix-div").show(); $("#record-form").trigger("reset"); $("input[name=status_modal][value='" + 0 + "']").prop('checked', true); //狀態 diff --git a/SolarPower/Views/PowerStation/Index.cshtml b/SolarPower/Views/PowerStation/Index.cshtml index ade8cdc..d1cb700 100644 --- a/SolarPower/Views/PowerStation/Index.cshtml +++ b/SolarPower/Views/PowerStation/Index.cshtml @@ -135,7 +135,6 @@ - @@ -353,8 +352,7 @@ } $('#solarTable' + val.cityId).find('tbody').append('' + - '' + - '' + + '' + '' + '' + 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 (
編號 電站名稱 裝置容量(kWp) 逆變器數量
' + val.id + '' + val.name + '' + val.name + '' + val.generatingCapacity.toFixed(3) + '' + val.inverterAmount + '