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);