diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs index 1a1947d..0534149 100644 --- a/SolarPower/Controllers/PowerStationController.cs +++ b/SolarPower/Controllers/PowerStationController.cs @@ -1182,7 +1182,8 @@ namespace SolarPower.Controllers "TableName" }; await powerStationRepository.AddAnyThing(backFillSchedule, properties, "back_fill_schedule"); - + await powerStationRepository.StationStatus(Device.PowerStationId, 0); + await powerStationRepository.StationStatus(Device.PowerStationId, 0,powerStation.SiteDB + "."); apiResult.Code = "0000"; apiResult.Msg = "新增成功"; } @@ -1234,6 +1235,8 @@ namespace SolarPower.Controllers properties.Add("WarrantyDate"); } await powerStationRepository.UpdateDevice(DeviceInfo, properties, powerStation.SiteDB); + await powerStationRepository.StationStatus(Device.PowerStationId, 0); + await powerStationRepository.StationStatus(Device.PowerStationId, 0, powerStation.SiteDB + "."); apiResult.Code = "0000"; apiResult.Msg = "儲存成功"; } @@ -2465,7 +2468,8 @@ namespace SolarPower.Controllers "TableName" }; await powerStationRepository.AddAnyThing(backFillSchedule, properties, "back_fill_schedule"); - + await powerStationRepository.StationStatus(post.PowerStationId, 0); + await powerStationRepository.StationStatus(post.PowerStationId, 0, powerStation.SiteDB + "."); apiResult.Code = "0000"; apiResult.Msg = "新增成功"; } @@ -2514,6 +2518,8 @@ namespace SolarPower.Controllers properties.Add("WarrantyDate"); } await powerStationRepository.UpdateInverter(inverter, properties, powerStation.SiteDB); + await powerStationRepository.StationStatus(post.PowerStationId, 0); + await powerStationRepository.StationStatus(post.PowerStationId, 0, powerStation.SiteDB + "."); apiResult.Code = "0000"; apiResult.Msg = "更新成功"; } @@ -3177,6 +3183,7 @@ namespace SolarPower.Controllers else { await powerStationRepository.StationStatus(Id,1); + await powerStationRepository.StationStatus(Id, 1, powerStation.SiteDB + "."); apiResult.Msg = "電站啟用成功"; apiResult.Code = "0000"; } @@ -3196,7 +3203,9 @@ namespace SolarPower.Controllers ApiResult apiResult = new ApiResult(); try { + var powerstation = await powerStationRepository.GetOneAsync(Id); await powerStationRepository.StationStatus(Id, 0); + await powerStationRepository.StationStatus(Id, 0,powerstation.SiteDB + "."); apiResult.Msg = "電站停用成功"; apiResult.Code = "0000"; diff --git a/SolarPower/Repository/Implement/CompanyRepository.cs b/SolarPower/Repository/Implement/CompanyRepository.cs index a03065f..d5705b9 100644 --- a/SolarPower/Repository/Implement/CompanyRepository.cs +++ b/SolarPower/Repository/Implement/CompanyRepository.cs @@ -546,6 +546,7 @@ namespace SolarPower.Repository.Implement `CompanyId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '公司編號', `CityId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站縣市', `AreaId` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '電站區域', + `Status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '是否啟用, 0:否 1:是', `HealthStatus` TINYINT(4) UNSIGNED NOT NULL DEFAULT '1' COMMENT '1:設備正常 2:設備斷線 3:設備異常', `Address` VARCHAR(100) NULL DEFAULT NULL COMMENT '電站詳細地址' COLLATE 'utf8mb4_unicode_ci', `Name` VARCHAR(50) NULL DEFAULT NULL COMMENT '名稱' COLLATE 'utf8mb4_unicode_ci', diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 56dad79..af4b7aa 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -1913,7 +1913,7 @@ namespace SolarPower.Repository.Implement { try { - var sql = $@"SELECT Id AS Value, Code AS Text ,Name FROM {db_name}.power_station WHERE Deleted = 0 AND Id !={stationId}"; + var sql = $@"SELECT Id AS Value, Code AS Text ,Name FROM {db_name}.power_station WHERE Deleted = 0 AND Id !={stationId} AND Status = 1"; result = (await conn.QueryAsync(sql)).ToList(); } @@ -5691,7 +5691,7 @@ namespace SolarPower.Repository.Implement } } - public async Task StationStatus(int stationId , int status) + public async Task StationStatus(int stationId , int status , string subDB = "") { using (IDbConnection conn = this._databaseHelper.GetConnection()) { @@ -5700,7 +5700,7 @@ namespace SolarPower.Repository.Implement { try { - var sql = @$"UPDATE power_station + var sql = @$"UPDATE {subDB}power_station SET Status = {status} WHERE Id = {stationId} "; diff --git a/SolarPower/Repository/Interface/IPowerStationRepository.cs b/SolarPower/Repository/Interface/IPowerStationRepository.cs index 8e7415e..aa3b968 100644 --- a/SolarPower/Repository/Interface/IPowerStationRepository.cs +++ b/SolarPower/Repository/Interface/IPowerStationRepository.cs @@ -604,6 +604,6 @@ namespace SolarPower.Repository.Interface Task DropShareDevice(int powerstationId, string DBname); Task DeleteALLPowerStationOperationPersonnel(int stationId); Task> CheckStationStatus(string code, string DBname); - Task StationStatus(int stationId, int status); + Task StationStatus(int stationId, int status, string subDB = ""); } }