From fa93bb48340be78d2791a0c1e70291d60beb1d48 Mon Sep 17 00:00:00 2001 From: "wanling040@gmail.com" Date: Fri, 12 Aug 2022 13:06:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=BB=E7=AB=99=E7=AE=A1=E7=90=86-=E8=A8=AD?= =?UTF-8?q?=E5=82=99=E7=AE=A1=E7=90=86:=20=E4=BF=AE=E6=94=B9=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E5=99=A8=E5=95=9F=E7=94=A8=E6=99=82=EF=BC=8C=E6=9C=83?= =?UTF-8?q?=E5=87=BA=E7=8F=BE=E9=8C=AF=E8=AA=A4=E8=A8=8A=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/PowerStationController.cs | 6 ++++-- SolarPower/Models/PowerStation.cs | 1 + .../Repository/Implement/PowerStationRepository.cs | 12 ++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs index 6adc78a..d89c2d2 100644 --- a/SolarPower/Controllers/PowerStationController.cs +++ b/SolarPower/Controllers/PowerStationController.cs @@ -2564,14 +2564,16 @@ namespace SolarPower.Controllers { DBName = powerStation.SiteDB, Enabled = post.Enabled, - Status = post.Status + Status = post.Status, + Id = post.Id }; List propertiesForMasterInvs = new List() { "DBName", "Enabled", - "Status" + "Status", + "Id" }; await powerStationRepository.UpdateMasterInverter(inverterForMasterInvs, propertiesForMasterInvs); #endregion diff --git a/SolarPower/Models/PowerStation.cs b/SolarPower/Models/PowerStation.cs index 0ffedd3..13e84ab 100644 --- a/SolarPower/Models/PowerStation.cs +++ b/SolarPower/Models/PowerStation.cs @@ -640,6 +640,7 @@ namespace SolarPower.Models.PowerStation public int Deleted { get; set; }//是否刪除 public int Enabled { get; set; }//是否啟用 public int Status { get; set; }//狀態 + public int Id { get; set; } } /// diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 1e8eb26..e9a5697 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -2045,9 +2045,9 @@ namespace SolarPower.Repository.Implement conn.Open(); try { - string sql = @$"SELECT id, InverterId - FROM {db_name}.inverter - WHERE Deleted = 0 AND Id = {id}"; + string sql = $@"SELECT a.InverterId + FROM solar_master.inv_status a join {db_name}.inverter b on a.inverterid = b.inverterid + WHERE a.Deleted = 0 AND b.Id = {id}"; inverter = (await conn.QueryFirstOrDefaultAsync(sql, commandTimeout: 600)); } @@ -2630,7 +2630,11 @@ namespace SolarPower.Repository.Implement { try { - string sql = GenerateUpdateQueryWithCustomTable(properties, "inv_status"); + string sql = $@"UPDATE solar_master.inv_status a join {entity.DBName}.inverter b on a.inverterid = b.inverterid + SET + a.Enabled = {entity.Enabled}, + a.Status = {entity.Status} + WHERE b.id = {entity.Id}"; count = await conn.ExecuteAsync(sql, entity, trans);