From 821599ce3195c4b540e5b50fde09904206352d6c Mon Sep 17 00:00:00 2001 From: Kai Date: Mon, 30 Aug 2021 15:50:43 +0800 Subject: [PATCH 1/4] =?UTF-8?q?1.=20bug=20fix=202.=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=AC=8A=E9=99=90=203.=20=E9=9B=BB=E7=AB=99=E4=BA=A4=E5=8F=89?= =?UTF-8?q?=E5=88=86=E6=9E=90=20=E4=B8=8D=E9=A0=90=E8=A8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AnalysisInverterController.cs | 83 ++++++++++--------- SolarPower/Controllers/MyBaseController.cs | 12 ++- SolarPower/Controllers/UserController.cs | 1 - SolarPower/Models/AnalysisInverter.cs | 1 + .../Repository/Implement/CompanyRepository.cs | 1 + .../Repository/Implement/RepositoryBase.cs | 4 +- .../Repository/Implement/RoleRepository.cs | 3 +- .../Implement/MyPowerStationService.cs | 26 ++++++ .../Views/AnalysisInverter/Index.cshtml | 16 ++-- .../Views/AnalysisStationInfo/Index.cshtml | 6 +- SolarPower/Views/Shared/_Layout.cshtml | 33 ++++++-- SolarPower/Views/StationOverview/Index.cshtml | 2 +- .../StationOverviewInfo.cshtml | 13 +-- SolarPower/Views/User/Index.cshtml | 4 +- 14 files changed, 135 insertions(+), 70 deletions(-) create mode 100644 SolarPower/Services/Implement/MyPowerStationService.cs diff --git a/SolarPower/Controllers/AnalysisInverterController.cs b/SolarPower/Controllers/AnalysisInverterController.cs index 4905b0d..6590fe8 100644 --- a/SolarPower/Controllers/AnalysisInverterController.cs +++ b/SolarPower/Controllers/AnalysisInverterController.cs @@ -165,7 +165,7 @@ namespace SolarPower.Controllers var temp_item = item.OrderBy(x => x.TIMESTAMP).ToList(); InverterHistoryInfo Irradiance = new InverterHistoryInfo(); - Irradiance.Name = string.Format("{0}:{1}", item.Key, "日照度"); + Irradiance.Name = string.Format("{0}:{1}", item.First().INVERTERName, "日照度"); Irradiance.YaxesKey = "Irradiance"; Irradiance.Values = new List(); foreach (var history in temp_item) @@ -183,7 +183,7 @@ namespace SolarPower.Controllers InverterHistoryInfo DCKW = new InverterHistoryInfo(); - DCKW.Name = string.Format("{0}:{1}", item.Key, "直流功率 (KW)"); + DCKW.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流功率 (KW)"); DCKW.YaxesKey = "DCKW"; DCKW.Values = new List(); foreach (var history in temp_item) @@ -200,7 +200,7 @@ namespace SolarPower.Controllers series.Add(DCKW); InverterHistoryInfo ACKW = new InverterHistoryInfo(); - ACKW.Name = string.Format("{0}:{1}", item.Key, "輸出功率 (KW)"); + ACKW.Name = string.Format("{0}:{1}", item.First().INVERTERName, "輸出功率 (KW)"); ACKW.YaxesKey = "ACKW"; ACKW.Values = new List(); foreach (var history in temp_item) @@ -217,7 +217,7 @@ namespace SolarPower.Controllers series.Add(ACKW); InverterHistoryInfo DC1V = new InverterHistoryInfo(); - DC1V.Name = string.Format("{0}:{1}", item.Key, "直流電壓1 (V)"); + DC1V.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流電壓1 (V)"); DC1V.YaxesKey = "DC1V"; DC1V.Values = new List(); foreach (var history in temp_item) @@ -234,7 +234,7 @@ namespace SolarPower.Controllers series.Add(DC1V); InverterHistoryInfo DC1A = new InverterHistoryInfo(); - DC1A.Name = string.Format("{0}:{1}", item.Key, "直流電流1 (A)"); + DC1A.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流電流1 (A)"); DC1A.YaxesKey = "DC1A"; DC1A.Values = new List(); foreach (var history in temp_item) @@ -251,7 +251,7 @@ namespace SolarPower.Controllers series.Add(DC1A); InverterHistoryInfo DC1KW = new InverterHistoryInfo(); - DC1KW.Name = string.Format("{0}:{1}", item.Key, "直流功率1 (KW)"); + DC1KW.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流功率1 (KW)"); DC1KW.YaxesKey = "DC1KW"; DC1KW.Values = new List(); foreach (var history in temp_item) @@ -268,7 +268,7 @@ namespace SolarPower.Controllers series.Add(DC1KW); InverterHistoryInfo DC2V = new InverterHistoryInfo(); - DC2V.Name = string.Format("{0}:{1}", item.Key, "直流電壓2 (V)"); + DC2V.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流電壓2 (V)"); DC2V.YaxesKey = "DC2V"; DC2V.Values = new List(); foreach (var history in temp_item) @@ -285,7 +285,7 @@ namespace SolarPower.Controllers series.Add(DC2V); InverterHistoryInfo DC2A = new InverterHistoryInfo(); - DC2A.Name = string.Format("{0}:{1}", item.Key, "直流電流2 (A)"); + DC2A.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流電流2 (A)"); DC2A.YaxesKey = "DC2A"; DC2A.Values = new List(); foreach (var history in temp_item) @@ -302,7 +302,7 @@ namespace SolarPower.Controllers series.Add(DC2A); InverterHistoryInfo DC2KW = new InverterHistoryInfo(); - DC2KW.Name = string.Format("{0}:{1}", item.Key, "直流功率2 (KW)"); + DC2KW.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流功率2 (KW)"); DC2KW.YaxesKey = "DC2KW"; DC2KW.Values = new List(); foreach (var history in temp_item) @@ -319,7 +319,7 @@ namespace SolarPower.Controllers series.Add(DC2KW); InverterHistoryInfo DC3V = new InverterHistoryInfo(); - DC3V.Name = string.Format("{0}:{1}", item.Key, "直流電壓3 (V)"); + DC3V.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流電壓3 (V)"); DC3V.YaxesKey = "DC3V"; DC3V.Values = new List(); foreach (var history in temp_item) @@ -336,7 +336,7 @@ namespace SolarPower.Controllers series.Add(DC3V); InverterHistoryInfo DC3A = new InverterHistoryInfo(); - DC3A.Name = string.Format("{0}:{1}", item.Key, "直流電流3 (A)"); + DC3A.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流電流3 (A)"); DC3A.YaxesKey = "DC3A"; DC3A.Values = new List(); foreach (var history in temp_item) @@ -353,7 +353,7 @@ namespace SolarPower.Controllers series.Add(DC3A); InverterHistoryInfo DC3KW = new InverterHistoryInfo(); - DC3KW.Name = string.Format("{0}:{1}", item.Key, "直流功率3 (KW)"); + DC3KW.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流功率3 (KW)"); DC3KW.YaxesKey = "DC3KW"; DC3KW.Values = new List(); foreach (var history in temp_item) @@ -370,7 +370,7 @@ namespace SolarPower.Controllers series.Add(DC3KW); InverterHistoryInfo DC4V = new InverterHistoryInfo(); - DC4V.Name = string.Format("{0}:{1}", item.Key, "直流電壓4 (V)"); + DC4V.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流電壓4 (V)"); DC4V.YaxesKey = "DC4V"; DC4V.Values = new List(); foreach (var history in temp_item) @@ -387,7 +387,7 @@ namespace SolarPower.Controllers series.Add(DC4V); InverterHistoryInfo DC4A = new InverterHistoryInfo(); - DC4A.Name = string.Format("{0}:{1}", item.Key, "直流電流4 (A)"); + DC4A.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流電流4 (A)"); DC4A.YaxesKey = "DC4A"; DC4A.Values = new List(); foreach (var history in temp_item) @@ -404,7 +404,7 @@ namespace SolarPower.Controllers series.Add(DC4A); InverterHistoryInfo DC4KW = new InverterHistoryInfo(); - DC4KW.Name = string.Format("{0}:{1}", item.Key, "直流功率4 (KW)"); + DC4KW.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流功率4 (KW)"); DC4KW.YaxesKey = "DC4KW"; DC4KW.Values = new List(); foreach (var history in temp_item) @@ -421,7 +421,7 @@ namespace SolarPower.Controllers series.Add(DC4KW); InverterHistoryInfo DC5V = new InverterHistoryInfo(); - DC5V.Name = string.Format("{0}:{1}", item.Key, "直流電壓5 (V)"); + DC5V.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流電壓5 (V)"); DC5V.YaxesKey = "DC5V"; DC5V.Values = new List(); foreach (var history in temp_item) @@ -438,7 +438,7 @@ namespace SolarPower.Controllers series.Add(DC5V); InverterHistoryInfo DC5A = new InverterHistoryInfo(); - DC5A.Name = string.Format("{0}:{1}", item.Key, "直流電流5 (A)"); + DC5A.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流電流5 (A)"); DC5A.YaxesKey = "DC5A"; DC5A.Values = new List(); foreach (var history in temp_item) @@ -455,7 +455,7 @@ namespace SolarPower.Controllers series.Add(DC5A); InverterHistoryInfo DC5KW = new InverterHistoryInfo(); - DC5KW.Name = string.Format("{0}:{1}", item.Key, "直流功率5 (KW)"); + DC5KW.Name = string.Format("{0}:{1}", item.First().INVERTERName, "直流功率5 (KW)"); DC5KW.YaxesKey = "DC5KW"; DC5KW.Values = new List(); foreach (var history in temp_item) @@ -472,7 +472,7 @@ namespace SolarPower.Controllers series.Add(DC5KW); InverterHistoryInfo AC1V = new InverterHistoryInfo(); - AC1V.Name = string.Format("{0}:{1}", item.Key, "交流電壓A (V)"); + AC1V.Name = string.Format("{0}:{1}", item.First().INVERTERName, "交流電壓A (V)"); AC1V.YaxesKey = "AC1V"; AC1V.Values = new List(); foreach (var history in temp_item) @@ -489,7 +489,7 @@ namespace SolarPower.Controllers series.Add(AC1V); InverterHistoryInfo AC2V = new InverterHistoryInfo(); - AC2V.Name = string.Format("{0}:{1}", item.Key, "交流電壓B (V)"); + AC2V.Name = string.Format("{0}:{1}", item.First().INVERTERName, "交流電壓B (V)"); AC2V.YaxesKey = "AC2V"; AC2V.Values = new List(); foreach (var history in temp_item) @@ -506,7 +506,7 @@ namespace SolarPower.Controllers series.Add(AC2V); InverterHistoryInfo AC3V = new InverterHistoryInfo(); - AC3V.Name = string.Format("{0}:{1}", item.Key, "交流電壓C (V)"); + AC3V.Name = string.Format("{0}:{1}", item.First().INVERTERName, "交流電壓C (V)"); AC3V.YaxesKey = "AC3V"; AC3V.Values = new List(); foreach (var history in temp_item) @@ -523,7 +523,7 @@ namespace SolarPower.Controllers series.Add(AC3V); InverterHistoryInfo AC1A = new InverterHistoryInfo(); - AC1A.Name = string.Format("{0}:{1}", item.Key, "交流電流A (A)"); + AC1A.Name = string.Format("{0}:{1}", item.First().INVERTERName, "交流電流A (A)"); AC1A.YaxesKey = "AC1A"; AC1A.Values = new List(); foreach (var history in temp_item) @@ -540,7 +540,7 @@ namespace SolarPower.Controllers series.Add(AC1A); InverterHistoryInfo AC2A = new InverterHistoryInfo(); - AC2A.Name = string.Format("{0}:{1}", item.Key, "交流電流B (A)"); + AC2A.Name = string.Format("{0}:{1}", item.First().INVERTERName, "交流電流B (A)"); AC2A.YaxesKey = "AC2A"; AC2A.Values = new List(); foreach (var history in temp_item) @@ -557,7 +557,7 @@ namespace SolarPower.Controllers series.Add(AC2A); InverterHistoryInfo AC3A = new InverterHistoryInfo(); - AC3A.Name = string.Format("{0}:{1}", item.Key, "交流電流C (A)"); + AC3A.Name = string.Format("{0}:{1}", item.First().INVERTERName, "交流電流C (A)"); AC3A.YaxesKey = "AC3A"; AC3A.Values = new List(); foreach (var history in temp_item) @@ -574,7 +574,7 @@ namespace SolarPower.Controllers series.Add(AC3A); InverterHistoryInfo PR = new InverterHistoryInfo(); - PR.Name = string.Format("{0}:{1}", item.Key, "PR"); + PR.Name = string.Format("{0}:{1}", item.First().INVERTERName, "PR"); PR.YaxesKey = "PR"; PR.Values = new List(); foreach (var history in temp_item) @@ -591,7 +591,7 @@ namespace SolarPower.Controllers series.Add(PR); InverterHistoryInfo RA1 = new InverterHistoryInfo(); - RA1.Name = string.Format("{0}:{1}", item.Key, "RA1 (%)"); + RA1.Name = string.Format("{0}:{1}", item.First().INVERTERName, "RA1 (%)"); RA1.YaxesKey = "RA1"; RA1.Values = new List(); foreach (var history in temp_item) @@ -608,7 +608,7 @@ namespace SolarPower.Controllers series.Add(RA1); InverterHistoryInfo RA2 = new InverterHistoryInfo(); - RA2.Name = string.Format("{0}:{1}", item.Key, "RA2 (%)"); + RA2.Name = string.Format("{0}:{1}", item.First().INVERTERName, "RA2 (%)"); RA2.YaxesKey = "RA2"; RA2.Values = new List(); foreach (var history in temp_item) @@ -625,7 +625,7 @@ namespace SolarPower.Controllers series.Add(RA2); InverterHistoryInfo RA3 = new InverterHistoryInfo(); - RA3.Name = string.Format("{0}:{1}", item.Key, "RA3 (%)"); + RA3.Name = string.Format("{0}:{1}", item.First().INVERTERName, "RA3 (%)"); RA3.YaxesKey = "RA3"; RA3.Values = new List(); foreach (var history in temp_item) @@ -642,7 +642,7 @@ namespace SolarPower.Controllers series.Add(RA3); InverterHistoryInfo RA4 = new InverterHistoryInfo(); - RA4.Name = string.Format("{0}:{1}", item.Key, "RA4 (%)"); + RA4.Name = string.Format("{0}:{1}", item.First().INVERTERName, "RA4 (%)"); RA4.YaxesKey = "RA4"; RA4.Values = new List(); foreach (var history in temp_item) @@ -659,7 +659,7 @@ namespace SolarPower.Controllers series.Add(RA4); InverterHistoryInfo RA5 = new InverterHistoryInfo(); - RA5.Name = string.Format("{0}:{1}", item.Key, "RA5 (%)"); + RA5.Name = string.Format("{0}:{1}", item.First().INVERTERName, "RA5 (%)"); RA5.YaxesKey = "RA5"; RA5.Values = new List(); foreach (var history in temp_item) @@ -684,8 +684,11 @@ namespace SolarPower.Controllers stationIdWithInverterIdsList = new List(); foreach (var ps in powerStation_Group) { + var powerStation = await powerStationRepository.GetOneAsync(ps.Key); + StationIdWithInverterIds stationIdWithInverterIds = new StationIdWithInverterIds(); stationIdWithInverterIds.PowerStationId = ps.Key; + stationIdWithInverterIds.SiteDBName = powerStation.SiteDB; stationIdWithInverterIds.InverterIds = ps.Select(x => x.InverterId).ToList(); stationIdWithInverterIdsList.Add(stationIdWithInverterIds); @@ -736,7 +739,7 @@ namespace SolarPower.Controllers var temp_item = item.OrderBy(x => x.TIMESTAMP).ToList(); InverterHistoryInfo Irradiance = new InverterHistoryInfo(); - Irradiance.Name = string.Format("{0}:{1}", item.Key, "日照度"); + Irradiance.Name = string.Format("{0}:{1}", item.First().INVERTERName, "日照度"); Irradiance.YaxesKey = "Irradiance"; Irradiance.Values = new List(); foreach (var history in temp_item) @@ -753,7 +756,7 @@ namespace SolarPower.Controllers series.Add(Irradiance); InverterHistoryInfo KWH = new InverterHistoryInfo(); - KWH.Name = string.Format("{0}:{1}", item.Key, "KWH"); + KWH.Name = string.Format("{0}:{1}", item.First().INVERTERName, "KWH"); KWH.YaxesKey = "KWH"; KWH.Values = new List(); foreach (var history in temp_item) @@ -770,7 +773,7 @@ namespace SolarPower.Controllers series.Add(KWH); InverterHistoryInfo TodayKWH = new InverterHistoryInfo(); - TodayKWH.Name = string.Format("{0}:{1}", item.Key, "TodayKWH"); + TodayKWH.Name = string.Format("{0}:{1}", item.First().INVERTERName, "TodayKWH"); TodayKWH.YaxesKey = "TodayKWH"; TodayKWH.Values = new List(); foreach (var history in temp_item) @@ -787,7 +790,7 @@ namespace SolarPower.Controllers series.Add(TodayKWH); InverterHistoryInfo TotalKWH = new InverterHistoryInfo(); - TotalKWH.Name = string.Format("{0}:{1}", item.Key, "TotalKWH"); + TotalKWH.Name = string.Format("{0}:{1}", item.First().INVERTERName, "TotalKWH"); TotalKWH.YaxesKey = "TotalKWH"; TotalKWH.Values = new List(); foreach (var history in temp_item) @@ -805,7 +808,7 @@ namespace SolarPower.Controllers InverterHistoryInfo PR = new InverterHistoryInfo(); - PR.Name = string.Format("{0}:{1}", item.Key, "PR"); + PR.Name = string.Format("{0}:{1}", item.First().INVERTERName, "PR"); PR.YaxesKey = "PR"; PR.Values = new List(); foreach (var history in temp_item) @@ -822,7 +825,7 @@ namespace SolarPower.Controllers series.Add(PR); InverterHistoryInfo RA1 = new InverterHistoryInfo(); - RA1.Name = string.Format("{0}:{1}", item.Key, "RA1 (%)"); + RA1.Name = string.Format("{0}:{1}", item.First().INVERTERName, "RA1 (%)"); RA1.YaxesKey = "RA1"; RA1.Values = new List(); foreach (var history in temp_item) @@ -839,7 +842,7 @@ namespace SolarPower.Controllers series.Add(RA1); InverterHistoryInfo RA2 = new InverterHistoryInfo(); - RA2.Name = string.Format("{0}:{1}", item.Key, "RA2 (%)"); + RA2.Name = string.Format("{0}:{1}", item.First().INVERTERName, "RA2 (%)"); RA2.YaxesKey = "RA2"; RA2.Values = new List(); foreach (var history in temp_item) @@ -856,7 +859,7 @@ namespace SolarPower.Controllers series.Add(RA2); InverterHistoryInfo RA3 = new InverterHistoryInfo(); - RA3.Name = string.Format("{0}:{1}", item.Key, "RA3 (%)"); + RA3.Name = string.Format("{0}:{1}", item.First().INVERTERName, "RA3 (%)"); RA3.YaxesKey = "RA3"; RA3.Values = new List(); foreach (var history in temp_item) @@ -873,7 +876,7 @@ namespace SolarPower.Controllers series.Add(RA3); InverterHistoryInfo RA4 = new InverterHistoryInfo(); - RA4.Name = string.Format("{0}:{1}", item.Key, "RA4 (%)"); + RA4.Name = string.Format("{0}:{1}", item.First().INVERTERName, "RA4 (%)"); RA4.YaxesKey = "RA4"; RA4.Values = new List(); foreach (var history in temp_item) @@ -890,7 +893,7 @@ namespace SolarPower.Controllers series.Add(RA4); InverterHistoryInfo RA5 = new InverterHistoryInfo(); - RA5.Name = string.Format("{0}:{1}", item.Key, "RA5 (%)"); + RA5.Name = string.Format("{0}:{1}", item.First().INVERTERName, "RA5 (%)"); RA5.YaxesKey = "RA5"; RA5.Values = new List(); foreach (var history in temp_item) diff --git a/SolarPower/Controllers/MyBaseController.cs b/SolarPower/Controllers/MyBaseController.cs index 272ff57..e481f88 100644 --- a/SolarPower/Controllers/MyBaseController.cs +++ b/SolarPower/Controllers/MyBaseController.cs @@ -97,16 +97,26 @@ namespace SolarPower.Controllers auth_arr.Add("PowerStation"); } + if (x.Contains("StationOverview") && !auth_arr.Contains("StationOverview")) + { + auth_arr.Add("StationOverview"); + } + auth_arr.Add(x); } } if (myUser.Role.Layer != (int)RoleLayerEnum.PlatformAdmin && !auth_arr.Contains(controllerName)) { - if(auth_arr.Contains("StationOverview") && !auth_arr.Contains("PowerStation")) + //排除條件 + if (auth_arr.Contains("StationOverview") && !auth_arr.Contains("PowerStation")) { //只有電站總覽 且未包含 電站管理 } + else if(controllerName == "User" && (actionName == "ChangePassword" || actionName == "GetPersonalInfo" || actionName == "SavePersonalInfo")) + { + //查詢個人 資訊 及密碼 + } else { filterContext.Result = new RedirectToRouteResult( diff --git a/SolarPower/Controllers/UserController.cs b/SolarPower/Controllers/UserController.cs index 38dc272..dacaa37 100644 --- a/SolarPower/Controllers/UserController.cs +++ b/SolarPower/Controllers/UserController.cs @@ -105,7 +105,6 @@ namespace SolarPower.Controllers "Email", "Phone", "UpdatedBy", - "UpdatedAt", "Id" }; diff --git a/SolarPower/Models/AnalysisInverter.cs b/SolarPower/Models/AnalysisInverter.cs index 7358cab..0a9ab25 100644 --- a/SolarPower/Models/AnalysisInverter.cs +++ b/SolarPower/Models/AnalysisInverter.cs @@ -52,6 +52,7 @@ namespace SolarPower.Models public class StationIdWithInverterIds { public int PowerStationId { get; set; } + public string SiteDBName { get; set; } public List InverterIds { get; set; } } diff --git a/SolarPower/Repository/Implement/CompanyRepository.cs b/SolarPower/Repository/Implement/CompanyRepository.cs index f407c3e..a03065f 100644 --- a/SolarPower/Repository/Implement/CompanyRepository.cs +++ b/SolarPower/Repository/Implement/CompanyRepository.cs @@ -291,6 +291,7 @@ namespace SolarPower.Repository.Implement CASE WHEN cap_id.CompanyId IS NOT NULL THEN 1 ELSE 0 END AS CheckAuth FROM auth_page ap LEFT JOIN (SELECT * FROM company_auth_page WHERE CompanyId = @CompanyId) cap_id ON ap.AuthCode = cap_id.AuthCode + ORDER BY ap.Priority "; result = (await conn.QueryAsync(sql, new { CompanyId = companyId })).ToList(); diff --git a/SolarPower/Repository/Implement/RepositoryBase.cs b/SolarPower/Repository/Implement/RepositoryBase.cs index 9b9e034..31ed10c 100644 --- a/SolarPower/Repository/Implement/RepositoryBase.cs +++ b/SolarPower/Repository/Implement/RepositoryBase.cs @@ -253,7 +253,7 @@ namespace SolarPower.Repository.Implement { try { - var sql = $"SELECT * FROM {tableName}"; + var sql = $"SELECT * FROM {tableName} WHERE Deleted = 0"; result = (await conn.QueryAsync(sql)).ToList(); } @@ -277,7 +277,7 @@ namespace SolarPower.Repository.Implement { try { - var sql = $"SELECT * FROM {tableName} WHERE id = @Id"; + var sql = $"SELECT * FROM {tableName} WHERE id = @Id AND Deleted = 0"; result = await conn.QueryFirstOrDefaultAsync(sql, new { Id = id }); } diff --git a/SolarPower/Repository/Implement/RoleRepository.cs b/SolarPower/Repository/Implement/RoleRepository.cs index 72bfa81..ce59bfb 100644 --- a/SolarPower/Repository/Implement/RoleRepository.cs +++ b/SolarPower/Repository/Implement/RoleRepository.cs @@ -261,13 +261,14 @@ namespace SolarPower.Repository.Implement var sql = @$"SELECT ap2.AuthCode, ap2.MainName, ap2.SubName, ap2.TagName FROM ( - SELECT cap.CompanyId, cap.AuthCode, ap.MainName, ap.SubName, ap.TagName , ap.ControlName + SELECT cap.CompanyId, cap.AuthCode, ap.MainName, ap.SubName, ap.TagName , ap.ControlName, ap.Priority FROM company_auth_page cap LEFT JOIN auth_page ap ON cap.AuthCode = ap.AuthCode WHERE cap.CompanyId = @CompanyId ) ap2 LEFT JOIN role_auth ra ON ap2.AuthCode = ra.AuthCode AND ra.Id = @RoleId WHERE ra.AuthCode IS NULL + ORDER BY ap2.Priority "; result = (await conn.QueryAsync(sql, new { CompanyId = post.SelectedCompanyId, RoleId = post.SelectedRoleId})).ToList(); diff --git a/SolarPower/Services/Implement/MyPowerStationService.cs b/SolarPower/Services/Implement/MyPowerStationService.cs new file mode 100644 index 0000000..59c110a --- /dev/null +++ b/SolarPower/Services/Implement/MyPowerStationService.cs @@ -0,0 +1,26 @@ +using SolarPower.Models; +using SolarPower.Models.PowerStation; +using SolarPower.Repository.Interface; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace SolarPower.Services.Implement +{ + public class MyPowerStationService + { + private readonly IPowerStationRepository powerStationRepository; + + public MyPowerStationService(IPowerStationRepository powerStationRepository) + { + this.powerStationRepository = powerStationRepository; + } + + //public List GetMyPowerStations(MyUser myUser, List CityIds = null, List Where = null, List Order_by = null) + //{ + // List powerStations = new List(); + // return powerStations; + //} + } +} diff --git a/SolarPower/Views/AnalysisInverter/Index.cshtml b/SolarPower/Views/AnalysisInverter/Index.cshtml index 6cabe57..f5ec7f5 100644 --- a/SolarPower/Views/AnalysisInverter/Index.cshtml +++ b/SolarPower/Views/AnalysisInverter/Index.cshtml @@ -157,9 +157,9 @@ var default_compare_col = []; var current_compare_col = []; var Single_day_compare_col = [ - { key: "Irradiance", title: "日照度", default: true }, - { key: "DCKW", title: "直流功率 (KW)", default: true }, - { key: "ACKW", title: "輸出功率 (KW)", default: true }, + { key: "Irradiance", title: "日照度", default: false }, + { key: "DCKW", title: "直流功率 (KW)", default: false }, + { key: "ACKW", title: "輸出功率 (KW)", default: false }, { key: "DC1V", title: "直流電壓1 (V)", default: false }, { key: "DC1A", title: "直流電流1 (A)", default: false }, { key: "DC1KW", title: "直流功率1 (KW)", default: false }, @@ -189,8 +189,8 @@ { key: "RA5", title: "RA5 (%)", default: false } ] var Range_compare_col = [ - { key: "Irradiance", title: "日照度", default: true }, - { key: "KWH", title: "KWH", default: true }, + { key: "Irradiance", title: "日照度", default: false }, + { key: "KWH", title: "KWH", default: false }, { key: "TodayKWH", title: "TodayKWH", default: false }, { key: "TotalKWH", title: "TotalKWH", default: false }, { key: "PR", title: "PR", default: false }, @@ -415,7 +415,7 @@ default_compare_col.push($(this).val()); } } else { - if ($.inArray($(this).val(), default_compare_col) > 0) { + if ($.inArray($(this).val(), default_compare_col) > -1) { default_compare_col.splice($.inArray($(this).val(), default_compare_col), 1); } } @@ -493,9 +493,9 @@ $('#js_list_accordion').append(str); $('#js_list_accordion').find('.card').first().addClass(" border-top-left-radius-0 border-top-right-radius-0"); - if (selected_inverter.length <= 0) { + @*if (selected_inverter.length <= 0) { $('input[name="selectedInverterId[]"]').first().trigger("click"); - } + }*@ $('input[name="selectedInverterId[]"]').each(function () { if ($.inArray(this.value, selected_inverter) > -1) { diff --git a/SolarPower/Views/AnalysisStationInfo/Index.cshtml b/SolarPower/Views/AnalysisStationInfo/Index.cshtml index bde9d1d..e80c67e 100644 --- a/SolarPower/Views/AnalysisStationInfo/Index.cshtml +++ b/SolarPower/Views/AnalysisStationInfo/Index.cshtml @@ -123,7 +123,7 @@ var selected_device = []; var PWS_compare_col = [ { key: "KWH", title: "發電量", default: true }, - { key: "Irradiance", title: "日照度", default: true }, + { key: "Irradiance", title: "日照度", default: false }, { key: "KWHKWP", title: "發電小時", default: false }, { key: "PR", title: "PR %", default: false }, { key: "Temperature", title: "模組溫度", default: false }, @@ -536,9 +536,9 @@ $('#js_list_accordion').find('.card').first().addClass(" border-top-left-radius-0 border-top-right-radius-0"); - if (selected_device.length <= 0) { + @*if (selected_device.length <= 0) { $('input[name="selectedDeviceId[]"]').first().trigger("click"); - } + }*@ $('input[name="selectedDeviceId[]"]').each(function () { if ($.inArray(this.value, selected_device) > -1) { diff --git a/SolarPower/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index 5ea45d4..2b832df 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -165,7 +165,14 @@ } - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview")) + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin + || ViewBag.auths.Contains("StationOverview_UpToDate") + || ViewBag.auths.Contains("StationOverview_Info") + || ViewBag.auths.Contains("StationOverview_InverterInfo") + || ViewBag.auths.Contains("StationOverview_Inverter") + || ViewBag.auths.Contains("StationOverview_History") + || ViewBag.auths.Contains("StationOverview_Exception") + || ViewBag.auths.Contains("StationOverview_OperationRecord")) {
  • @@ -177,7 +184,14 @@
  • } - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStationInfo")) + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin + || ViewBag.auths.Contains("StationOverview_UpToDate") + || ViewBag.auths.Contains("StationOverview_Info") + || ViewBag.auths.Contains("StationOverview_InverterInfo") + || ViewBag.auths.Contains("StationOverview_Inverter") + || ViewBag.auths.Contains("StationOverview_History") + || ViewBag.auths.Contains("StationOverview_Exception") + || ViewBag.auths.Contains("StationOverview_OperationRecord")) {
  • @@ -218,7 +232,10 @@
  • } - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("AnalysisStationCombine") || ViewBag.auths.Contains("AnalysisStationInfo") || ViewBag.auths.Contains("AnalysisInverter")) + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin + || ViewBag.auths.Contains("AnalysisStationCombine") + || ViewBag.auths.Contains("AnalysisStationInfo") + || ViewBag.auths.Contains("AnalysisInverter")) {
  • @@ -253,7 +270,11 @@
  • } - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation"))@*TODO:修改成報表的權限*@ + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin + || ViewBag.auths.Contains("StationReport") + || ViewBag.auths.Contains("ElectricitySoldRecord") + || ViewBag.auths.Contains("PowerGeneration") + || ViewBag.auths.Contains("NoticeSchedule")) {
  • @@ -285,7 +306,7 @@
  • } - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation"))@*TODO:修改成即時告警的權限*@ + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("ExceptionRecord")) {
  • @@ -481,7 +502,7 @@
    - + diff --git a/SolarPower/Views/StationOverview/Index.cshtml b/SolarPower/Views/StationOverview/Index.cshtml index 3961919..36401b6 100644 --- a/SolarPower/Views/StationOverview/Index.cshtml +++ b/SolarPower/Views/StationOverview/Index.cshtml @@ -317,7 +317,7 @@ $('#citytest').empty(); for (var i = 0; i < rel.data.length; i++) { $('#citytest').append(""); ids.push(rel.data[i].cityId); diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index 56074af..0804bf2 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -49,11 +49,14 @@
  • } - + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_InverterInfo")) + { + + } @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationOverview_Inverter")) { diff --git a/SolarPower/Views/User/Index.cshtml b/SolarPower/Views/User/Index.cshtml index 91f2b84..32d79c2 100644 --- a/SolarPower/Views/User/Index.cshtml +++ b/SolarPower/Views/User/Index.cshtml @@ -329,7 +329,7 @@ "autoWidth": false, "responsive": false, "deferLoading": 0, - "order": [[5, "desc"]], + "order": [[6, "desc"]], "columns": [{ "data": null, }, { @@ -425,7 +425,7 @@ "paging": true, "lengthChange": false, "searching": false, - "ordering": true, + "ordering": false, "info": true, "autoWidth": false, "responsive": false, From bc72f947c7e135733a6ebfaef6533d7d48352e76 Mon Sep 17 00:00:00 2001 From: Kai Date: Mon, 30 Aug 2021 15:53:05 +0800 Subject: [PATCH 2/4] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9db=20schema?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/DBSchema/solar_power_schema.sql | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/SolarPower/DBSchema/solar_power_schema.sql b/SolarPower/DBSchema/solar_power_schema.sql index 4c15e63..2657926 100644 --- a/SolarPower/DBSchema/solar_power_schema.sql +++ b/SolarPower/DBSchema/solar_power_schema.sql @@ -401,44 +401,44 @@ INSERT INTO `area` (`Id`, `CityId`, `Name`, `ZipCode`) VALUES (368, 21, '烏坵鄉', '06'); /*!40000 ALTER TABLE `area` ENABLE KEYS */; --- 傾印 資料表 auth_page 結構 +-- 傾印 資料表 solar_power.auth_page 結構 CREATE TABLE IF NOT EXISTS `auth_page` ( `AuthCode` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, `MainName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '大項名稱', `SubName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '功能名稱', `TagName` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '細項功能名稱', `ControlName` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL, + `Priority` int(10) DEFAULT '0', PRIMARY KEY (`AuthCode`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='設定權限頁面'; --- 正在傾印表格 auth_page 的資料 +-- 正在傾印表格 solar_power.auth_page 的資料:~23 rows (近似值) DELETE FROM `auth_page`; /*!40000 ALTER TABLE `auth_page` DISABLE KEYS */; -INSERT INTO `auth_page` (`AuthCode`, `MainName`, `SubName`, `TagName`, `ControlName`) VALUES - ('A', '總覽', '地圖總覽', NULL, 'MapOverview'), - ('B', '總覽', '電站總覽', NULL, 'StationOverview'), - ('C', '總覽', '電站總覽', '即時資訊', 'StationOverview_UpToDate'), - ('D', '總覽', '電站總覽', '基本資料', 'StationOverview_Info'), - ('E', '總覽', '電站總覽', '歷史資料', 'StationOverview_History'), - ('F', '總覽', '電站總覽', '逆變器分析', 'StationOverview_Inverter'), - ('G', '總覽', '電站總覽', '異常記錄', 'StationOverview_Exception'), - ('H', '總覽', '電站總覽', '運維記錄', 'StationOverview_OperationRecord'), - ('J', '總覽', '電站總覽', '顯示發電金額', 'ShowMoney'), - ('K', '電站資訊', '電站資訊', NULL, 'PowerStationInfo'), - ('L', '交叉分析', '合併電站', NULL, 'AnalysisStationCombine'), - ('M', '交叉分析', '電站交叉分析', NULL, 'AnalysisStationInfo'), - ('N', '交叉分析', '逆變器交叉分析', NULL, 'AnalysisInverter'), - ('P', '報表查詢', '電站報表', NULL, 'StationReport'), - ('Q', '報表查詢', '電廠發電效能統計', NULL, 'HHH'), - ('R', '報表查詢', '輸入台電售電紀錄', NULL, 'ElectricitySoldRecord'), - ('S', '報表查詢', '報告發送設定', NULL, 'JJJ'), - ('T', '即時告警', '異常事件查詢', NULL, 'KKK'), - ('U', '運維管理', '電站管理', NULL, 'PowerStation'), - ('V', '運維管理', '定期計畫建立', NULL, 'Operation'), - ('W', '運維管理', '運維作業記錄', NULL, 'OperationRecord'), - ('X', '系統管理', '公司管理', NULL, 'Company'), - ('Y', '系統管理', '帳號管理', NULL, 'User,Role'), - ('Z', '系統管理', '定時任務設定', NULL, 'LLL'); +INSERT INTO `auth_page` (`AuthCode`, `MainName`, `SubName`, `TagName`, `ControlName`, `Priority`) VALUES + ('A', '總覽', '地圖總覽', NULL, 'MapOverview', 1), + ('B', '總覽', '電站總覽', '逆變器監控', 'StationOverview_InverterInfo', 4), + ('C', '總覽', '電站總覽', '即時資訊', 'StationOverview_UpToDate', 2), + ('D', '總覽', '電站總覽', '基本資料', 'StationOverview_Info', 3), + ('E', '總覽', '電站總覽', '歷史資料', 'StationOverview_History', 6), + ('F', '總覽', '電站總覽', '逆變器分析', 'StationOverview_Inverter', 5), + ('G', '總覽', '電站總覽', '異常記錄', 'StationOverview_Exception', 7), + ('H', '總覽', '電站總覽', '運維記錄', 'StationOverview_OperationRecord', 8), + ('J', '', '', '顯示發電金額', 'ShowMoney', 9), + ('K', '運維管理', '電站管理', NULL, 'PowerStationManager', 18), + ('L', '交叉分析', '合併電站', NULL, 'AnalysisStationCombine', 10), + ('M', '交叉分析', '電站交叉分析', NULL, 'AnalysisStationInfo', 11), + ('N', '交叉分析', '逆變器交叉分析', NULL, 'AnalysisInverter', 12), + ('P', '報表查詢', '電站報表', NULL, 'StationReport', 13), + ('Q', '報表查詢', '電廠發電效能統計', NULL, 'PowerGeneration', 15), + ('R', '報表查詢', '台電售電紀錄', NULL, 'ElectricitySoldRecord', 14), + ('S', '報表查詢', '報告發送紀錄', NULL, 'NoticeSchedule', 16), + ('T', '即時告警', '異常事件查詢', NULL, 'ExceptionRecord', 17), + ('U', '運維管理', '定期計畫建立', NULL, 'Operation', 19), + ('V', '運維管理', '運維作業記錄', NULL, 'OperationRecord', 20), + ('W', '系統管理', '公司管理', NULL, 'Company', 21), + ('X', '系統管理', '帳號管理', NULL, 'User,Role', 22), + ('Y', '系統管理', '定時任務設定', NULL, 'LLL', 23); /*!40000 ALTER TABLE `auth_page` ENABLE KEYS */; -- 傾印 資料表 solar_power.city 結構 From 71936b6d2bbfc815b2f9a5e668ef1fbeb82c1b34 Mon Sep 17 00:00:00 2001 From: Kai Date: Mon, 30 Aug 2021 16:01:14 +0800 Subject: [PATCH 3/4] =?UTF-8?q?1.=20=E9=80=86=E8=AE=8A=E5=99=A8=E5=88=86?= =?UTF-8?q?=E6=9E=90=20=E5=B7=A6=E5=81=B4=E9=81=B8=E5=96=AE=20css=20?= =?UTF-8?q?=E8=AA=BF=E6=95=B4=202.=20=E9=9B=BB=E7=AB=99=E7=B8=BD=E8=A6=BDb?= =?UTF-8?q?ug=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Views/AnalysisInverter/Index.cshtml | 4 ++-- SolarPower/Views/StationOverview/Index.cshtml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SolarPower/Views/AnalysisInverter/Index.cshtml b/SolarPower/Views/AnalysisInverter/Index.cshtml index f5ec7f5..0a2e887 100644 --- a/SolarPower/Views/AnalysisInverter/Index.cshtml +++ b/SolarPower/Views/AnalysisInverter/Index.cshtml @@ -466,8 +466,8 @@ '' + '' + '' + - '
    ' + powerStationkey + '
    ' + - '
    ' + powerStationkey + '
    ' + + '
    ' + powerStationkey + '
    ' + + '
    ' + powerStationkey + '
    ' + '
    ' + '' + '
    ' + diff --git a/SolarPower/Views/StationOverview/Index.cshtml b/SolarPower/Views/StationOverview/Index.cshtml index 36401b6..3961919 100644 --- a/SolarPower/Views/StationOverview/Index.cshtml +++ b/SolarPower/Views/StationOverview/Index.cshtml @@ -317,7 +317,7 @@ $('#citytest').empty(); for (var i = 0; i < rel.data.length; i++) { $('#citytest').append(""); ids.push(rel.data[i].cityId); From 562e8cc28c453cfdade0a11bb10663e16c5f9f93 Mon Sep 17 00:00:00 2001 From: Kai Date: Mon, 30 Aug 2021 17:06:02 +0800 Subject: [PATCH 4/4] =?UTF-8?q?1.=20=E6=AC=8A=E9=99=90=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E8=A3=9C=E9=BD=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Views/Shared/_Layout.cshtml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/SolarPower/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index 2b832df..c7f2e3d 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -282,26 +282,41 @@ 報表查詢
      + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("StationReport")) + {
    • 電站報表
    • + } + + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("ElectricitySoldRecord")) + {
    • 台電售電記錄
    • + } + + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerGeneration")) + {
    • 電廠發電效能統計
    • + } + + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("NoticeSchedule")) + {
    • 報告發送記錄
    • + }
    }