From 4b59d59b7c0f72d509c9faf54ec683544474d1bf Mon Sep 17 00:00:00 2001 From: Kai Date: Fri, 10 Sep 2021 14:15:55 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=9C=96?= =?UTF-8?q?=E7=B8=BD=E8=A6=BD=20-=20=E8=A3=9D=E7=BD=AE=E5=AE=B9=E9=87=8F?= =?UTF-8?q?=E5=B0=8F=E6=95=B8=E9=BB=9E=E7=AC=AC=E4=B8=89=E4=BD=8D=202.=20?= =?UTF-8?q?=E7=95=AB=E9=9D=A2=E8=AA=BF=E6=95=B4=203.=20=E9=81=8B=E7=B6=AD?= =?UTF-8?q?=E5=BB=A0=E5=95=86=E5=8A=A0=E5=85=A5=E7=B5=B1=E7=B7=A8=E3=80=81?= =?UTF-8?q?=E5=82=99=E8=A8=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ElectricitySoldRecordController.cs | 46 +++++++++++++++++++ .../Controllers/PowerStationController.cs | 16 +++++-- SolarPower/DBSchema/solar_power_schema.sql | 5 ++ SolarPower/Models/PowerStation.cs | 2 + .../Repository/Implement/CompanyRepository.cs | 2 + .../Implement/PowerStationRepository.cs | 11 ++++- .../Views/AnalysisInverter/Index.cshtml | 2 +- .../Views/AnalysisStationCombine/Index.cshtml | 10 ++-- .../Views/AnalysisStationInfo/Index.cshtml | 2 +- .../Views/ElectricitySoldRecord/Index.cshtml | 8 ++-- SolarPower/Views/MapOverview/Index.cshtml | 21 +++++++-- SolarPower/Views/NoticeSchedule/Index.cshtml | 6 +-- SolarPower/Views/PowerGeneration/Index.cshtml | 4 +- SolarPower/Views/PowerStation/Index.cshtml | 2 +- .../PowerStation/PowerStationEdit.cshtml | 21 ++++++++- .../Views/PowerStation/_Operation.cshtml | 12 +++++ SolarPower/Views/Shared/_Layout.cshtml | 25 ++++++---- SolarPower/Views/StationOverview/Index.cshtml | 10 ++-- .../StationOverviewInfo.cshtml | 11 +++-- .../Views/StationOverview/_Inverter.cshtml | 2 +- .../StationOverview/_InverterInfo.cshtml | 2 +- SolarPower/Views/StationReport/Index.cshtml | 6 +-- SolarPower/wwwroot/css/site.css | 24 ++++++---- 23 files changed, 189 insertions(+), 61 deletions(-) diff --git a/SolarPower/Controllers/ElectricitySoldRecordController.cs b/SolarPower/Controllers/ElectricitySoldRecordController.cs index b54e935..787fce7 100644 --- a/SolarPower/Controllers/ElectricitySoldRecordController.cs +++ b/SolarPower/Controllers/ElectricitySoldRecordController.cs @@ -29,6 +29,52 @@ namespace SolarPower.Controllers { return View(); } + + [HttpPost] + public ApiResult>> GetPowerStationCollapse(string filter) + { + ApiResult>> apiResult = new ApiResult>>(); + try + { + List where = new List(); + Dictionary where_entities = new Dictionary(); + if (!string.IsNullOrEmpty(filter)) + { + var temp_psname_where = $@" ps.Name LIKE CONCAT('%', @Filter, '%')"; + where.Add(temp_psname_where); + + where_entities.Add("Filter", filter); + } + + //抓出 除了自建自用 + var temp_solarType_where = $@" ps.SolarType != 2"; + where.Add(temp_solarType_where); + + var powerStations = myPowerStationService.GetMyPowerStations(myUser, 1, null, where, where_entities); + + var siteDBNamePowerStationId = new Dictionary>(); + + var powerStation_Group = powerStations.GroupBy(x => x.CityName).ToList(); + foreach (var stations in powerStation_Group) + { + siteDBNamePowerStationId.Add(stations.Key, stations.ToList()); + } + + apiResult.Code = "0000"; + + apiResult.Data = siteDBNamePowerStationId; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + Logger.LogError("【" + controllerName + "/" + actionName + "】"); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + + apiResult.Msg = errorCode.GetString(apiResult.Code); + return apiResult; + } + public async Task> SaveSoldMoney(ElectricitySoldRecord post) { ApiResult apiResult = new ApiResult(); diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs index 0534149..b4563b5 100644 --- a/SolarPower/Controllers/PowerStationController.cs +++ b/SolarPower/Controllers/PowerStationController.cs @@ -912,7 +912,9 @@ namespace SolarPower.Controllers CreatedBy = myUser.Id, ContactPerson = post.ContactPerson, PowerStationId = post.PowerStationId, - Type = post.Type + Type = post.Type, + TaxIDNumber = post.TaxIDNumber, + Remark = post.Remark }; List properties = new List() { @@ -923,7 +925,9 @@ namespace SolarPower.Controllers "CreatedBy", "ContactPerson", "PowerStationId", - "Type" + "Type", + "TaxIDNumber", + "Remark", }; await powerStationRepository.AddOperation(operation, properties, powerStation.SiteDB); @@ -941,7 +945,9 @@ namespace SolarPower.Controllers CreatedBy = myUser.Id, ContactPerson = post.ContactPerson, PowerStationId = post.PowerStationId, - Type = post.Type + Type = post.Type, + TaxIDNumber = post.TaxIDNumber, + Remark = post.Remark }; List properties = new List() { @@ -952,7 +958,9 @@ namespace SolarPower.Controllers "CreatedBy", "ContactPerson", "PowerStationId", - "Type" + "Type", + "TaxIDNumber", + "Remark", }; await powerStationRepository.UpdateOperation(operation, properties, powerStation.SiteDB); apiResult.Code = "0000"; diff --git a/SolarPower/DBSchema/solar_power_schema.sql b/SolarPower/DBSchema/solar_power_schema.sql index 7bb5ae4..8f74a13 100644 --- a/SolarPower/DBSchema/solar_power_schema.sql +++ b/SolarPower/DBSchema/solar_power_schema.sql @@ -2194,6 +2194,11 @@ ALTER TABLE `power_station` ALTER TABLE `power_station` ADD COLUMN `Status` TINYINT(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否啟用, 0:否 1:是' AFTER `AreaId`; +-- 運維廠商 加入 統一編號、備註欄位 20210910 +ALTER TABLE `operation_firm` + ADD COLUMN `TaxIDNumber` VARCHAR(8) NULL DEFAULT NULL COMMENT '統一編號' AFTER `Email`, + ADD COLUMN `Remark` VARCHAR(255) NULL DEFAULT NULL COMMENT '備註' AFTER `TaxIDNumber`; + /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; /*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/SolarPower/Models/PowerStation.cs b/SolarPower/Models/PowerStation.cs index 205fc60..eb8b3b2 100644 --- a/SolarPower/Models/PowerStation.cs +++ b/SolarPower/Models/PowerStation.cs @@ -375,6 +375,8 @@ namespace SolarPower.Models.PowerStation public string ContactPerson { get; set; }//聯絡人 public string Phone { get; set; }//電話 public string Email { get; set; }//Email + public string TaxIDNumber { get; set; }//統一編號 + public string Remark { get; set; }//備註 } /// diff --git a/SolarPower/Repository/Implement/CompanyRepository.cs b/SolarPower/Repository/Implement/CompanyRepository.cs index d5705b9..ca457c9 100644 --- a/SolarPower/Repository/Implement/CompanyRepository.cs +++ b/SolarPower/Repository/Implement/CompanyRepository.cs @@ -531,6 +531,8 @@ namespace SolarPower.Repository.Implement `ContactPerson` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '聯絡人', `Phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電話', `Email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Email', + `TaxIDNumber` VARCHAR(8) NULL DEFAULT NULL COMMENT '統一編號' COLLATE 'utf8mb4_unicode_ci', + `Remark` VARCHAR(255) NULL DEFAULT NULL COMMENT '備註' COLLATE 'utf8mb4_unicode_ci', `CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者', `CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '建立時間', `UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者', diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index af4b7aa..e500016 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -84,10 +84,17 @@ namespace SolarPower.Repository.Implement { show_enable_str = ""; } + var now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - var sql = @"SELECT ps.*, c.Name AS CityName + var sql = $@"SELECT ps.*, c.Name AS CityName, wf.Wx FROM power_station ps - LEFT JOIN city c ON ps.CityId = c.Id"; + LEFT JOIN city c ON ps.CityId = c.Id + LEFT JOIN (SELECT * FROM ( + SELECT MAX(w.Id) AS aa FROM weather_forecast w + WHERE '{now}' BETWEEN w.StartTime AND w.EndTime + GROUP BY w.LocationName + ) A + LEFT JOIN weather_forecast B ON A.aa = B.Id) wf ON c.Name = wf.LocationName"; if (myUser.Role.Layer == (int)RoleLayerEnum.CompanyAdmin) { //公司管理員 diff --git a/SolarPower/Views/AnalysisInverter/Index.cshtml b/SolarPower/Views/AnalysisInverter/Index.cshtml index de50d1d..76d8087 100644 --- a/SolarPower/Views/AnalysisInverter/Index.cshtml +++ b/SolarPower/Views/AnalysisInverter/Index.cshtml @@ -48,9 +48,9 @@
- +
diff --git a/SolarPower/Views/AnalysisStationCombine/Index.cshtml b/SolarPower/Views/AnalysisStationCombine/Index.cshtml index 1bf3e69..a118405 100644 --- a/SolarPower/Views/AnalysisStationCombine/Index.cshtml +++ b/SolarPower/Views/AnalysisStationCombine/Index.cshtml @@ -52,9 +52,9 @@
- +
@@ -102,11 +102,11 @@

當日發電金額

-

0.00

+

0

總發金額

-

0.00

+

0

@@ -408,7 +408,7 @@ return; } $('#total_kwh').html(rel.data.all_kwh.toFixed(2)); - $('#total_money').html(rel.data.all_money.toFixed(2)); + $('#total_money').html(rel.data.all_money.toFixed()); $('#total_kwhkwp').html(rel.data.all_KWH_KWP.toFixed(2)); $('#total_PR').html(rel.data.all_PR.toFixed(2)); $('#total_carbon').html(rel.data.all_Carbon.toFixed(2)); @@ -416,7 +416,7 @@ $('#today_kwh').html(rel.data.now_kwh.toFixed(2)); - $('#today_money').html(rel.data.now_money.toFixed(2)); + $('#today_money').html(rel.data.now_money.toFixed()); $('#today_kwhkwp').html(rel.data.now_KWH_KWP.toFixed(2)); $('#today_PR').html(rel.data.now_PR.toFixed(2)); $('#today_carbon').html(rel.data.now_Carbon.toFixed(2)); diff --git a/SolarPower/Views/AnalysisStationInfo/Index.cshtml b/SolarPower/Views/AnalysisStationInfo/Index.cshtml index 19821f1..e00674a 100644 --- a/SolarPower/Views/AnalysisStationInfo/Index.cshtml +++ b/SolarPower/Views/AnalysisStationInfo/Index.cshtml @@ -48,9 +48,9 @@
- +
diff --git a/SolarPower/Views/ElectricitySoldRecord/Index.cshtml b/SolarPower/Views/ElectricitySoldRecord/Index.cshtml index 91bb98b..91f1886 100644 --- a/SolarPower/Views/ElectricitySoldRecord/Index.cshtml +++ b/SolarPower/Views/ElectricitySoldRecord/Index.cshtml @@ -138,9 +138,9 @@
- +
@@ -341,7 +341,7 @@ function GetPowerStationCollapse(filter) { - var url = "/StationReport/GetPowerStationCollapse" + var url = "/ElectricitySoldRecord/GetPowerStationCollapse" var send_data = { Filter: filter @@ -398,7 +398,7 @@ '
' + '' + '
' + - '
' + inverter.name + '
' + + '
' + inverter.name + '
' + '
' + ''; } @@ -408,7 +408,7 @@ '
' + '' + '
' + - '
' + inverter.name + '
' + + '
' + inverter.name + '
' + '
' + ''; } diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index 2aad55c..eb128a3 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -196,6 +196,16 @@ "data": "subPowerStationCount" }, { "data": "subTotalCapacity" + }], + "columnDefs": [{ + 'targets': 2, + 'searchable': false, + 'orderable': false, + 'createdCell': function (td, cellData, rowData, row, col) { + @*$(td).append('
');*@ + cellData = cellData.toFixed(3); + $(td).html(cellData); + } }], "language": { "emptyTable": "查無資料", @@ -243,7 +253,7 @@ $("#today_carbon").html(mapOverview.today_carbon.toFixed(2)); $("#total_carbon").html(mapOverview.total_carbon.toFixed(2)); $("#total_power_station_count").html(mapOverview.totalPowerStationCount); - $("#total_capacity").html(mapOverview.totalCapacity.toFixed(2)); + $("#total_capacity").html(mapOverview.totalCapacity.toFixed(3)); $("#update_at").html(mapOverview.updatedAt); capacityTable.clear().rows.add(mapOverview.capacityDataTables).draw(); @@ -255,13 +265,13 @@ }); function initMap() { - + mapOverview.powerStations.forEach(function (item, index) { var contentString = '
' + '
' + - '

' + - '' + + '

' + + '' + item.name + '' + '

' + @@ -271,7 +281,8 @@ '
即時總發電量:' + item.today_kWh + '
'+ '
即時平均日照度:' + item.today_irradiance + '
'+ '
發電小時:' + item.solarHour + '
' + - '
裝置容量:' + item.generatingCapacity + '
' + + '
裝置容量:' + item.generatingCapacity.toFixed(3) + '
' + + '
掛錶日期:' + item.electricityMeterAt + '
' + '
天氣:' + item.wx + '
'+ '

' + '
' + diff --git a/SolarPower/Views/NoticeSchedule/Index.cshtml b/SolarPower/Views/NoticeSchedule/Index.cshtml index 817165e..793a2f0 100644 --- a/SolarPower/Views/NoticeSchedule/Index.cshtml +++ b/SolarPower/Views/NoticeSchedule/Index.cshtml @@ -187,9 +187,9 @@
- +
@@ -502,7 +502,7 @@ '
' + '' + '
' + - '
' + inverter.name + '
' + + '
' + inverter.name + '
' + '
' + ''; } @@ -512,7 +512,7 @@ '
' + '' + '
' + - '
' + inverter.name + '
' + + '
' + inverter.name + '
' + '' + ''; } diff --git a/SolarPower/Views/PowerGeneration/Index.cshtml b/SolarPower/Views/PowerGeneration/Index.cshtml index f3a9f78..7bc5cb8 100644 --- a/SolarPower/Views/PowerGeneration/Index.cshtml +++ b/SolarPower/Views/PowerGeneration/Index.cshtml @@ -420,7 +420,7 @@ '
' + '' + '
' + - '
' + inverter.name + '
' + + '
' + inverter.name + '
' + '' + ''; } @@ -430,7 +430,7 @@ '
' + '' + '
' + - '
' + inverter.name + '
' + + '
' + inverter.name + '
' + '' + ''; } diff --git a/SolarPower/Views/PowerStation/Index.cshtml b/SolarPower/Views/PowerStation/Index.cshtml index 3799128..3143acf 100644 --- a/SolarPower/Views/PowerStation/Index.cshtml +++ b/SolarPower/Views/PowerStation/Index.cshtml @@ -355,7 +355,7 @@ $('#solarTable' + val.cityId).find('tbody').append('' + '' + val.id + '' + '' + val.name + '' + - '' + val.generatingCapacity.toFixed(2) + '' + + '' + val.generatingCapacity.toFixed(3) + '' + '' + val.inverterAmount + '' + '' + val.electricityMeterAt + '' + diff --git a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml index f4e52d0..a7f3b3d 100644 --- a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml +++ b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml @@ -522,6 +522,10 @@ }, { "data": "function" }], + "columnDefs": [{ + 'targets': 0, + 'visible': false + }], "language": { "emptyTable": "查無資料", "processing": "處理中...", @@ -622,6 +626,10 @@ }, { "data": "function" }], + "columnDefs": [{ + 'targets': 0, + 'visible': false + }], "language": { "emptyTable": "查無資料", "processing": "處理中...", @@ -1661,7 +1669,7 @@ $("#estimated_recovery_time_text").html(powerStationData.estimatedRecoveryTime); $("#created_by_text").html(powerStationData.creatorName); - $("#generating_capacity_text").html(powerStationData.generatingCapacity); + $("#generating_capacity_text").html(powerStationData.generatingCapacity.toFixed(3)); $("#escrow_name_text").html(powerStationData.escrowName); $("#coordinate_text").html(powerStationData.coordinate); $("#created_at_text").html(powerStationData.createdAt); @@ -2095,6 +2103,8 @@ ContactPerson: $("#Operation_name_modal").val(), Phone: $("#Operation_phone_modal").val(), Email: $("#Operation_email_modal").val(), + TaxIDNumber: $("#Operation_taxIDNumber_modal").val(), + Remark: $("#Operation_remark_modal").val(), } $.post(url, send_data, function (rel) { @@ -2167,6 +2177,8 @@ $("#Operation_name_modal").val(rel.data.contactPerson); $("#Operation_phone_modal").val(rel.data.phone); $("#Operation_email_modal").val(rel.data.email); + $("#Operation_taxIDNumber_modal").val(rel.data.taxIDNumber); + $("#Operation_remark_modal").val(rel.data.remark); $("#Operation-modal").modal(); }, 'json'); @@ -3066,6 +3078,13 @@ }, Operation_role_modal: { required: true + }, + Operation_taxIDNumber_modal: { + required: true, + maxlength: 8 + }, + Operation_remark_modal: { + maxlength: 255 } } }); diff --git a/SolarPower/Views/PowerStation/_Operation.cshtml b/SolarPower/Views/PowerStation/_Operation.cshtml index 129e62e..846ba54 100644 --- a/SolarPower/Views/PowerStation/_Operation.cshtml +++ b/SolarPower/Views/PowerStation/_Operation.cshtml @@ -66,6 +66,18 @@ +
+
+ + +
+
+
+
+ + +
+
diff --git a/SolarPower/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index d606907..2e6e05c 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -109,7 +109,14 @@