diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs index a513baf..de08b78 100644 --- a/SolarPower/Controllers/PowerStationController.cs +++ b/SolarPower/Controllers/PowerStationController.cs @@ -3086,6 +3086,8 @@ namespace SolarPower.Controllers await powerStationRepository.DropShareDevice(stationId, powerstation.SiteDB); + await powerStationRepository.DeleteALLPowerStationOperationPersonnel(stationId); + await powerStationRepository.DeleteOne(stationId); apiResult.Msg = "刪除成功"; diff --git a/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs b/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs index 800b4d2..3ebd463 100644 --- a/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs +++ b/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs @@ -32,13 +32,14 @@ namespace SolarPower.Repository.Implement { case 0: string timerange = Convert.ToDateTime(post.Timerange).ToString("yyyy-MM-dd"); - sql = $@"SELECT m.*,n.* FROM + sql = $@"SELECT m.*,n.*,o.* FROM ( - SELECT AVG(KWHKWP) AS All_KWH_KWP ,SUM(TOTALMONEY) AS All_money, - SUM(TOTALKWH) AS All_kwh,SUM(TOTALCARBON) AS All_Carbon, - AVG(PR) AS All_PR - from power_station_history_month - WHERE PowerStationId IN @ids + SELECT + SUM(TOTALMONEY) AS All_money, + SUM(TOTALKWH) AS All_kwh, + SUM(TOTALCARBON) AS All_Carbon + from power_station_history_month + WHERE PowerStationId IN @ids ) AS m, ( @@ -55,17 +56,26 @@ namespace SolarPower.Repository.Implement ON c.maxTIMESTAMP = b.`TIMESTAMP` WHERE PowerStationId IN @ids ) - AS n"; + AS n, + ( + SELECT + AVG(avg_kwhkwp) AS All_KWH_KWP, + AVG(avg_PR) AS All_PR + from power_station + WHERE Id IN @ids + ) + AS o"; break; case 1: var time = post.Timerange.Split('-'); - sql = $@"SELECT m.*,n.* FROM + sql = $@"SELECT m.*,n.*,o.* FROM ( - SELECT AVG(KWHKWP) AS All_KWH_KWP, SUM(TOTALMONEY) AS All_money, - SUM(TOTALKWH) AS All_kwh, SUM(TOTALCARBON) AS All_Carbon, - AVG(PR) AS All_PR - from power_station_history_month - WHERE PowerStationId IN @ids + SELECT + SUM(TOTALMONEY) AS All_money, + SUM(TOTALKWH) AS All_kwh, + SUM(TOTALCARBON) AS All_Carbon + from power_station_history_month + WHERE PowerStationId IN @ids ) AS m, ( @@ -78,19 +88,25 @@ namespace SolarPower.Repository.Implement FROM power_station_history_day b WHERE PowerStationId IN @ids AND TIMESTAMP BETWEEN '{time[0]}' AND '{time[1]}' ) - AS n"; + AS n, + ( + SELECT + AVG(avg_kwhkwp) AS All_KWH_KWP, + AVG(avg_PR) AS All_PR + from power_station + WHERE Id IN @ids + ) + AS o"; break; case 2: - sql = $@"SELECT m.*,n.* FROM + sql = $@"SELECT m.*,n.*,o.* FROM ( SELECT - AVG(KWHKWP) AS All_KWH_KWP, - SUM(TOTALMONEY) AS All_money, - SUM(TOTALKWH) AS All_kwh, - SUM(TOTALCARBON) AS All_Carbon, - AVG(PR) AS All_PR - from power_station_history_month - WHERE PowerStationId IN @ids + SUM(TOTALMONEY) AS All_money, + SUM(TOTALKWH) AS All_kwh, + SUM(TOTALCARBON) AS All_Carbon + from power_station_history_month + WHERE PowerStationId IN @ids ) AS m, ( @@ -103,14 +119,23 @@ namespace SolarPower.Repository.Implement FROM power_station_history_day b WHERE PowerStationId IN @ids AND DATE_FORMAT(TIMESTAMP, '%Y-%m') = '{post.Timerange}' ) - AS n"; + AS n, + ( + SELECT + AVG(avg_kwhkwp) AS All_KWH_KWP, + AVG(avg_PR) AS All_PR + from power_station + WHERE Id IN @ids + ) + AS o"; break; case 3: - sql = $@"SELECT m.*,n.* FROM + sql = $@"SELECT m.*,n.*,o.* FROM ( - SELECT AVG(KWHKWP) AS All_KWH_KWP, SUM(TOTALMONEY) AS All_money, - SUM(TOTALKWH) AS All_kwh, SUM(TOTALCARBON) AS All_Carbon, - AVG(PR) AS All_PR + SELECT + SUM(TOTALMONEY) AS All_money, + SUM(TOTALKWH) AS All_kwh, + SUM(TOTALCARBON) AS All_Carbon from power_station_history_month WHERE PowerStationId IN @ids ) @@ -126,7 +151,15 @@ namespace SolarPower.Repository.Implement FROM power_station_history_month b WHERE PowerStationId IN @ids AND DATE_FORMAT(TIMESTAMP, '%Y') = '{post.Timerange}' ) - AS n"; + AS n, + ( + SELECT + AVG(avg_kwhkwp) AS All_KWH_KWP, + AVG(avg_PR) AS All_PR + from power_station + WHERE Id IN @ids + ) + AS o"; break; } diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index d12b3b7..069627f 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -5396,5 +5396,35 @@ namespace SolarPower.Repository.Implement } } } + + public async Task DeleteALLPowerStationOperationPersonnel(int stationId) + { + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + conn.Open(); + using (var trans = conn.BeginTransaction()) + { + try + { + var sql = @$"UPDATE power_station_operation_personnel + SET Deleted = 1 + WHERE PowerStationId = {stationId} "; + + await conn.ExecuteAsync(sql, trans); + + trans.Commit(); + } + catch (Exception exception) + { + trans.Rollback(); + throw exception; + } + finally + { + conn.Close(); + } + } + } + } } } diff --git a/SolarPower/Repository/Interface/IPowerStationRepository.cs b/SolarPower/Repository/Interface/IPowerStationRepository.cs index eb26cdd..a27d8f6 100644 --- a/SolarPower/Repository/Interface/IPowerStationRepository.cs +++ b/SolarPower/Repository/Interface/IPowerStationRepository.cs @@ -602,5 +602,6 @@ namespace SolarPower.Repository.Interface Task> GetApicallList(int PowerStationId, string Type); Task> GetShareDevicePowerstationName(int Id, string DBname); Task DropShareDevice(int powerstationId, string DBname); + Task DeleteALLPowerStationOperationPersonnel(int stationId); } } diff --git a/SolarPower/Views/AnalysisStationCombine/Index.cshtml b/SolarPower/Views/AnalysisStationCombine/Index.cshtml index 60ad5a9..1bf3e69 100644 --- a/SolarPower/Views/AnalysisStationCombine/Index.cshtml +++ b/SolarPower/Views/AnalysisStationCombine/Index.cshtml @@ -83,7 +83,7 @@
-

今日發電量

+

當日發電量

0.00

@@ -101,7 +101,7 @@
-

今日發電金額

+

當日發電金額

0.00

@@ -118,11 +118,11 @@
-

今日有效日照時數

+

當日有效日照時數

0.00

-

平均有效日照時數

+

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

0.00

@@ -134,11 +134,11 @@
-

今日PR值

+

當日PR值

0.00

-

平均 PR 值

+

平均 PR 值(30天)

0.00

@@ -151,7 +151,7 @@
-

今日減碳量

+

當日減碳量

0.00

@@ -242,12 +242,16 @@ document.getElementById("DateGettextdiv").style.display = "none";//隱藏 document.getElementById("DateGet").style.display = "";//隱藏 $(e).removeClass("btn-secondary").addClass("btn-success"); + var timename = ""; + + switch (type) { case 0: $('#DateGet').prop({ 'type': 'date' }); $(".btn-change-quickSearch1").html("今天"); $(".btn-change-quickSearch2").html("昨天"); var today = new Date().toISOString().substring(0, 10); $('#DateGet').val(today); + timename = "當日"; break; case 1: @@ -282,13 +286,14 @@ document.getElementById("DateGet").style.display = "none";//隱藏 //#endregion $('#DateGettext').val(dateLimit_format + ' - ' + today_format); - + timename = "期間"; break; case 2: $('#DateGet').prop({ 'type': 'month' }); $(".btn-change-quickSearch1").html("本月"); $(".btn-change-quickSearch2").html("上個月"); var now_month = new Date().toISOString().substring(0, 7); $('#DateGet').val(now_month); + timename = "當月"; break; case 3: $(".btn-change-quickSearch1").html("今年"); @@ -296,8 +301,17 @@ var now_year = new Date().toISOString().substring(0, 4); $('#DateGet').prop({ 'type': 'number', 'min': 1900, 'max': now_year, 'step': 1 }); $('#DateGet').val(now_year); + timename = "當年"; break; } + + $("#today_kwh_label").html(timename + "發電量"); + $("#today_money_label").html(timename + "發電金額"); + $("#today_kwhkwp_label").html(timename + "有效日照時數"); + $("#today_PR_label").html(timename + "PR值"); + $("#today_carbon_label").html(timename + "減碳量"); + + if (type == 1) { timerange = $('#DateGettext').val(); }