From d04644310bea4bf94724c34cadd0439672122fb7 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Mon, 16 Aug 2021 18:44:49 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=86=E8=AE=8A=E5=99=A8=E7=9B=A3=E6=8E=A7(?= =?UTF-8?q?=E5=83=854=E5=80=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/NoticeScheduleController.cs | 3 +- .../Controllers/PowerStationController.cs | 71 +++ SolarPower/Models/PowerStation.cs | 20 + .../Repository/Implement/CompanyRepository.cs | 1 + .../Implement/PowerStationRepository.cs | 27 + .../Interface/IPowerStationRepository.cs | 2 + .../PowerStation/PowerStationEdit.cshtml | 137 ++++- .../Views/PowerStation/_Inverter.cshtml | 546 ++++++++++++++++++ SolarPower/Views/User/Index.cshtml | 4 +- 9 files changed, 807 insertions(+), 4 deletions(-) create mode 100644 SolarPower/Views/PowerStation/_Inverter.cshtml diff --git a/SolarPower/Controllers/NoticeScheduleController.cs b/SolarPower/Controllers/NoticeScheduleController.cs index b5bee75..07f58fc 100644 --- a/SolarPower/Controllers/NoticeScheduleController.cs +++ b/SolarPower/Controllers/NoticeScheduleController.cs @@ -38,7 +38,8 @@ namespace SolarPower.Controllers 0 => "日報表", 1 => "月報表", 2 => "綜合報表", - 3 => "運維", + 3 => "運維通知", + 4 => "異常通知", _ => "" }; a.IsDeliveryName = a.IsDelivery switch diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs index 5b2b420..e10c9c3 100644 --- a/SolarPower/Controllers/PowerStationController.cs +++ b/SolarPower/Controllers/PowerStationController.cs @@ -2775,5 +2775,76 @@ namespace SolarPower.Controllers apiResult.Msg = errorCode.GetString(apiResult.Code); return apiResult; } + + public async Task>> GetInverterInfoList (IdAndDB post) + { + List list = new List(); + ApiResult> apiResult = new ApiResult>(); + try + { + var controllers = await powerStationRepository.GetAllDeviceControllerId(post.Id, post.SiteDB); + if(controllers.Count == 0) + { + apiResult.Code = "0001"; + apiResult.Msg = "該電站沒有控制器"; + return apiResult; + } + var inverters = await powerStationRepository.InverterTable(controllers, post.SiteDB); + if (inverters.Count == 0) + { + apiResult.Code = "0001"; + apiResult.Msg = "該電站沒有啟用的逆變器"; + return apiResult; + } + var inverterIds = inverters.Where(x => x.Enabled == 1 && x.Status == 1).Select(x => x.InverterId).ToList(); + if(inverterIds.Count > 0) + { + var site = "s" + inverterIds[0].Substring(0, 11) + "_inv"; + var inverterss = await powerStationRepository.GetAllInverterInfo(inverterIds, site, post.SiteDB); + foreach(var inverter in inverterss) + { + var info = new InverterInfoList + { + Input = (inverter.DC1W + inverter.DC2W + inverter.DC3W + inverter.DC4W + inverter.DC5W)/1000, + Output = (inverter.AC1W + inverter.AC2W + inverter.AC3W)/1000, + PR = inverter.PR, + TODAYKWH = inverter.TODAYKWH, + Name = inverter.INVERTERName, + ID = inverter.ID, + Type = 1 + }; + + list.Add(info); + } + } + var inverterIdsdd = inverters.Where(x => x.Enabled == 1 && x.Status == 2).Select(x => new { name = x.InverterName , id = x.Id } ).ToList(); + foreach (var inverter in inverterIdsdd) + { + var info = new InverterInfoList + { + Input = 0, + Output = 0, + PR = 0, + TODAYKWH = 0, + Name = inverter.name, + ID = inverter.id, + Type = 2 + }; + list.Add(info); + } + apiResult.Code = "0000"; + apiResult.Data = list; + + } + catch (Exception exception) + { + apiResult.Code = "9999"; + apiResult.Msg = errorCode.GetString(apiResult.Code); + string json = System.Text.Json.JsonSerializer.Serialize(post); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + json); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + } + return apiResult; + } } } diff --git a/SolarPower/Models/PowerStation.cs b/SolarPower/Models/PowerStation.cs index 74c785f..7bdad79 100644 --- a/SolarPower/Models/PowerStation.cs +++ b/SolarPower/Models/PowerStation.cs @@ -687,6 +687,7 @@ namespace SolarPower.Models.PowerStation public string TIMESTAMP { get; set; } public int PowerStationId { get; set; } public string INVERTERID { get; set; } + public string INVERTERName { get; set; } public double Irradiance { get; set; } public double AC1V { get; set; } public double AC1A { get; set; } @@ -740,6 +741,7 @@ namespace SolarPower.Models.PowerStation public double TODAYKWH { get; set; } public double TOTALKWH { get; set; } public double KWHKWP { get; set; } + public int ID { get; set; } } #region 氣象觀測 public class FieldsItem @@ -929,5 +931,23 @@ namespace SolarPower.Models.PowerStation public double INPUT_KWH { get; set; } } + public class InverterInfoList + { + public double Input { get; set; } + public double Output { get; set; } + public double PR { get; set; } + public double TODAYKWH { get; set; } + public string Name { get; set; } + public int ID { get; set; } + public int Type { get; set; } + } + + public class IdAndDB + { + public int Id { get; set; } + public string SiteDB { get; set; } + } + + } diff --git a/SolarPower/Repository/Implement/CompanyRepository.cs b/SolarPower/Repository/Implement/CompanyRepository.cs index e3afe32..6e3771b 100644 --- a/SolarPower/Repository/Implement/CompanyRepository.cs +++ b/SolarPower/Repository/Implement/CompanyRepository.cs @@ -486,6 +486,7 @@ namespace SolarPower.Repository.Implement `InverterId` varchar(50) DEFAULT NULL COMMENT '逆變器UID', `ControllerId` int(10) DEFAULT NULL COMMENT '所屬控制器', `Brand` varchar(50) DEFAULT NULL COMMENT '廠牌', + `BrandNum` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '廠商序號', `Model` varchar(50) DEFAULT NULL COMMENT '型號', `Capacity` double(10,3) DEFAULT NULL COMMENT '裝置容量 kWp', `Pyrheliometer` int(10) DEFAULT NULL COMMENT '日照計設備流水號', diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 94e5e29..50c1d09 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -5037,5 +5037,32 @@ namespace SolarPower.Repository.Implement return result; } } + + public async Task> GetAllInverterInfo(List post,string site_table, string site_db) + { + List result; + using (IDbConnection conn = this._databaseHelper.GetConnection()) + { + try + { + var sql = @$"SELECT b.*,c.InverterName as INVERTERName,c.ID as ID FROM + ( + SELECT MAX(aa.TIMESTAMP) AS maxtime ,aa.INVERTERID from (SELECT * from {site_db}.{site_table} LIMIT 500) aa GROUP BY INVERTERID + ) a + LEFT JOIN + (SELECT * from {site_db}.{site_table} LIMIT 500) b ON a.maxtime = b.TIMESTAMP AND a.INVERTERID = b.INVERTERID + LEFT JOIN {site_db}.inverter c ON b.INVERTERID = c.InverterId + WHERE b.INVERTERID in @ids + "; + + result = (await conn.QueryAsync(sql, new { ids = post })).ToList(); + } + catch (Exception exception) + { + throw exception; + } + return result; + } + } } } diff --git a/SolarPower/Repository/Interface/IPowerStationRepository.cs b/SolarPower/Repository/Interface/IPowerStationRepository.cs index 6a09846..b82dfef 100644 --- a/SolarPower/Repository/Interface/IPowerStationRepository.cs +++ b/SolarPower/Repository/Interface/IPowerStationRepository.cs @@ -587,5 +587,7 @@ namespace SolarPower.Repository.Interface Task AddAfterPurgeSensorAvgHistory(string startDate, string endDate, byte type, List entity, List properties); Task CheckShowMoney(int userid); Task> GetAllInverterRowData(string date, string table_name); + + Task> GetAllInverterInfo(List post, string site_table, string site_db); } } diff --git a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml index cd0ed05..3a06227 100644 --- a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml +++ b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml @@ -58,6 +58,11 @@ 異常設定 +
@@ -79,6 +84,10 @@
@Html.Partial("_Exception")
+ +
+ @Html.Partial("_Inverter") +
@@ -86,6 +95,8 @@ +
+ @section Scripts{ } \ No newline at end of file diff --git a/SolarPower/Views/PowerStation/_Inverter.cshtml b/SolarPower/Views/PowerStation/_Inverter.cshtml new file mode 100644 index 0000000..e4f4dd0 --- /dev/null +++ b/SolarPower/Views/PowerStation/_Inverter.cshtml @@ -0,0 +1,546 @@ +
+
+
    +
  • +
    +
    + ... +
    +

    新竹巨城站

    +

    +
    +
    +
    +
    +

    發電量

    +

    185 kWh

    +

    27°C

    +
    +
    +

    發電金額

    +

    2,5840 NT

    +

    自建躉售

    +
    +
    +

    Pr值

    +

    90 %

    +

    17:50:36

    +
    +
    +
    + +
    +
    +
      +
    • +
      +
      +

      逆變器 022020001010001 (96.6kWp)

      +

      4分鐘前

      +
      +
      +
      +
      +

      設備狀態

      +

      正常

      +

      詳細資料

      +
      +
      +
      +
      +

      輸出功率

      +

      1.7

      +

      kw

      +
      +
      +
      +
      +

      輸入功率

      +

      1.7

      +

      kw

      +
      +
      +
      +
      + PR + 36.3% +
      +
      +
      +
      +
      +
      +
      +

      日發電量

      +

      83.1

      +

      kWh

      +
      +
      +
      +
      +
        +
      • +
        +
        +

        逆變器 022020001010001 (96.6kWp)

        +

        4分鐘前

        +
        +
        +
        +
        +

        設備狀態

        +

        正常

        +

        詳細資料

        +
        +
        +
        +
        +

        輸出功率

        +

        1.7

        +

        kw

        +
        +
        +
        +
        +

        輸入功率

        +

        1.7

        +

        kw

        +
        +
        +
        +
        + PR + 36.3% +
        +
        +
        +
        +
        +
        +
        +

        日發電量

        +

        83.1

        +

        kWh

        +
        +
        +
        +
        +
      • +
      +
    • +
    • +
      +
      +

      逆變器 022020001010001 (96.6kWp)

      +

      4分鐘前

      +
      +
      +
      +
      +

      設備狀態

      +

      正常

      +

      詳細資料

      +
      +
      +
      +
      +

      輸出功率

      +

      1.7

      +

      kw

      +
      +
      +
      +
      +

      輸入功率

      +

      1.7

      +

      kw

      +
      +
      +
      +
      + PR + 36.3% +
      +
      +
      +
      +
      +
      +
      +

      日發電量

      +

      83.1

      +

      kWh

      +
      +
      +
      +
      +
        +
      • +
        +
        +

        逆變器 022020001010001 (96.6kWp)

        +

        4分鐘前

        +
        +
        +
        +
        +

        設備狀態

        +

        正常

        +

        詳細資料

        +
        +
        +
        +
        +

        輸出功率

        +

        1.7

        +

        kw

        +
        +
        +
        +
        +

        輸入功率

        +

        1.7

        +

        kw

        +
        +
        +
        +
        + PR + 36.3% +
        +
        +
        +
        +
        +
        +
        +

        日發電量

        +

        83.1

        +

        kWh

        +
        +
        +
        +
        +
      • +
      +
    • +
    • +
      +
      +

      逆變器 022020001010001 (96.6kWp)

      +

      4分鐘前

      +
      +
      +
      +
      +

      設備狀態

      +

      正常

      +

      詳細資料

      +
      +
      +
      +
      +

      輸出功率

      +

      1.7

      +

      kw

      +
      +
      +
      +
      +

      輸入功率

      +

      1.7

      +

      kw

      +
      +
      +
      +
      + PR + 36.3% +
      +
      +
      +
      +
      +
      +
      +

      日發電量

      +

      83.1

      +

      kWh

      +
      +
      +
      +
      +
    • +
    • +
      +
      +

      逆變器 022020001010001 (96.6kWp)

      +

      4分鐘前

      +
      +
      +
      +
      +

      設備狀態

      +

      正常

      +

      詳細資料

      +
      +
      +
      +
      +

      輸出功率

      +

      1.7

      +

      kw

      +
      +
      +
      +
      +

      輸入功率

      +

      1.7

      +

      kw

      +
      +
      +
      +
      + PR + 36.3% +
      +
      +
      +
      +
      +
      +
      +

      日發電量

      +

      83.1

      +

      kWh

      +
      +
      +
      +
      +
    • +
    +
  • +
+
+
+ + + + + + \ No newline at end of file diff --git a/SolarPower/Views/User/Index.cshtml b/SolarPower/Views/User/Index.cshtml index 7ac90f3..915d12d 100644 --- a/SolarPower/Views/User/Index.cshtml +++ b/SolarPower/Views/User/Index.cshtml @@ -756,7 +756,7 @@ del_btn.parents("tr").remove(); toast_ok(rel.msg); - + userTable.ajax.reload(); }, 'json'); } }); @@ -834,7 +834,7 @@ }); $("#add-user-manager-station-modal").modal(); - + userTable.ajax.reload(); }, 'json'); }