From dbac46c03c73344743b45a1127f3753ddf22fed4 Mon Sep 17 00:00:00 2001 From: Kai Date: Tue, 29 Jun 2021 11:34:03 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=E4=B8=BB=E5=9C=96?= =?UTF-8?q?=E9=A1=AF=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PowerStationController.cs | 8 ++++++++ SolarPower/Models/PowerStation.cs | 1 + .../Implement/OperationRepository.cs | 3 ++- .../Implement/PowerStationRepository.cs | 19 +++++++++++++++++++ SolarPower/Views/Operation/Index.cshtml | 10 +++++----- .../Views/Operation/OperationRecord.cshtml | 8 ++++---- SolarPower/Views/PowerStation/Index.cshtml | 2 +- 7 files changed, 40 insertions(+), 11 deletions(-) diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs index 4b809a9..75dbb34 100644 --- a/SolarPower/Controllers/PowerStationController.cs +++ b/SolarPower/Controllers/PowerStationController.cs @@ -1662,7 +1662,9 @@ namespace SolarPower.Controllers updata = new UpdataPowerStationImage() { Id = post.TargetImageId, + PowerStationId = post.PowerStationId, IsMainDisplay = 1, + Image = powerStationImage.Image, UpdatedBy = myUser.Id }; @@ -1932,6 +1934,12 @@ namespace SolarPower.Controllers { apiResult.Code = "0000"; solaramount = await powerStationRepository.GetSolarByCity(myUser, cityid); + + foreach(var solar in solaramount) + { + solar.MainDisplay = Path.Combine(stationImageFilePath, solar.Id.ToString()) + "/" + solar.MainDisplay; + } + apiResult.Data = solaramount; } catch (Exception exception) diff --git a/SolarPower/Models/PowerStation.cs b/SolarPower/Models/PowerStation.cs index e93a7ca..7afca53 100644 --- a/SolarPower/Models/PowerStation.cs +++ b/SolarPower/Models/PowerStation.cs @@ -17,6 +17,7 @@ namespace SolarPower.Models.PowerStation public int AreaId { get; set; } //地區 public string Address { get; set; } //地址 public string Name { get; set; } //名稱 + public string MainDisplay { get; set; } //主要顯示圖片 public string Code { get; set; } //電站代碼 public string SerialNumber { get; set; } //四碼流水號 public byte IsEscrow { get; set; } //是否被代管 diff --git a/SolarPower/Repository/Implement/OperationRepository.cs b/SolarPower/Repository/Implement/OperationRepository.cs index c005d3b..5b7e4be 100644 --- a/SolarPower/Repository/Implement/OperationRepository.cs +++ b/SolarPower/Repository/Implement/OperationRepository.cs @@ -224,8 +224,9 @@ namespace SolarPower.Repository.Implement sql += " AND opr.EndTime >= @StartDate"; } - if (filter.WorkType > -1) + if (filter.WorkType > 0) { + filter.WorkType -= 1; sql += @" AND opr.WorkType = @WorkType"; } else diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 5c3d996..be9c9f3 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -1155,6 +1155,25 @@ namespace SolarPower.Repository.Implement await conn.ExecuteAsync(sql, image, trans); + + var sql_MainDispalyImg = string.Empty; + List powerStationMainDispalyImg = new List() + { + "Id", + "MainDisplay" + }; + + if(image.IsMainDisplay == 1) + { + //修改主資料庫 + sql_MainDispalyImg = GenerateUpdateQuery(powerStationMainDispalyImg); + await conn.ExecuteAsync(sql_MainDispalyImg, new { Id = image.PowerStationId, MainDisplay = image.Image }, trans); + + //修改子資料庫 + sql_MainDispalyImg = GenerateUpdateQueryWithCustomDBNameAndTable(powerStationMainDispalyImg, db_name, "power_station"); + await conn.ExecuteAsync(sql_MainDispalyImg, new { Id = image.PowerStationId, MainDisplay = image.Image }, trans); + } + trans.Commit(); } catch (Exception exception) diff --git a/SolarPower/Views/Operation/Index.cshtml b/SolarPower/Views/Operation/Index.cshtml index 3aa8b67..aafa227 100644 --- a/SolarPower/Views/Operation/Index.cshtml +++ b/SolarPower/Views/Operation/Index.cshtml @@ -51,12 +51,12 @@ -
-
+
+
-
-
+
+
@@ -282,7 +282,7 @@ } $('#CheckPowerStation').empty(); $.each(rel.data, function (index, val) { - $('#CheckPowerStation').append("
"); + $('#CheckPowerStation').append("
"); $('#station_' + val.id).append(""); $('#station_' + val.id).append(""); powerids.push(String(val.id)); diff --git a/SolarPower/Views/Operation/OperationRecord.cshtml b/SolarPower/Views/Operation/OperationRecord.cshtml index 0aa17ee..c8f7f41 100644 --- a/SolarPower/Views/Operation/OperationRecord.cshtml +++ b/SolarPower/Views/Operation/OperationRecord.cshtml @@ -22,10 +22,10 @@
- - - - + + + +
diff --git a/SolarPower/Views/PowerStation/Index.cshtml b/SolarPower/Views/PowerStation/Index.cshtml index dcac41c..ecd2d87 100644 --- a/SolarPower/Views/PowerStation/Index.cshtml +++ b/SolarPower/Views/PowerStation/Index.cshtml @@ -464,7 +464,7 @@ //電站卡片 $('#templateCard').find('.col-xl-2').attr('id', 'card'+val.id).clone().appendTo($('#solarCard' + val.cityId)); $('#card' + val.id).find('#editSolarUrl').attr('href', localurl + '/edit?stationId=' +val.id); - $('#card' + val.id).find('#editSolarUrl').find('#Solarimg').attr('src', '/upload/power_station/' + + val.id+'/main.png'); + $('#card' + val.id).find('#editSolarUrl').find('#Solarimg').attr('src', val.mainDisplay); $('#card' + val.id).find('#solarName').text(val.name); $('#card' + val.id).find('#today_kwh').text(val.kwh); $('#card' + val.id).find('#kwhkwp').text(val.inverterAmount);