diff --git a/SolarPower/Controllers/ElectricitySoldRecordController.cs b/SolarPower/Controllers/ElectricitySoldRecordController.cs index 6f54833..b54e935 100644 --- a/SolarPower/Controllers/ElectricitySoldRecordController.cs +++ b/SolarPower/Controllers/ElectricitySoldRecordController.cs @@ -543,6 +543,7 @@ namespace SolarPower.Controllers cell.CellStyle = style0; cell = row.CreateCell(5); + cell.SetCellValue(bill.Result.TPCMeterNumber); region = new CellRangeAddress(18, 18, 5, 6); sheet.AddMergedRegion(region); cell.CellStyle = style14body; diff --git a/SolarPower/Controllers/PowerStationController.cs b/SolarPower/Controllers/PowerStationController.cs index 323d12d..c07a2b6 100644 --- a/SolarPower/Controllers/PowerStationController.cs +++ b/SolarPower/Controllers/PowerStationController.cs @@ -347,10 +347,8 @@ namespace SolarPower.Controllers SerialNumber = tempSerialNumber, IsEscrow = post.IsEscrow, EscrowName = post.EscrowName, - ElectricityMeterAt = post.ElectricityMeterAt, EstimatedRecoveryTime = post.EstimatedRecoveryTime, GeneratingCapacity = post.GeneratingCapacity, - PowerRate = post.PowerRate, Coordinate = post.Coordinate, InverterBrand = post.InverterBrand, InverterProductModel = post.InverterProductModel, @@ -378,10 +376,8 @@ namespace SolarPower.Controllers "SerialNumber", "IsEscrow", "EscrowName", - "ElectricityMeterAt", "EstimatedRecoveryTime", "GeneratingCapacity", - "PowerRate", "Coordinate", "InverterBrand", "InverterProductModel", @@ -486,10 +482,8 @@ namespace SolarPower.Controllers Name = post.Name, IsEscrow = post.IsEscrow, EscrowName = post.EscrowName, - ElectricityMeterAt = post.ElectricityMeterAt, EstimatedRecoveryTime = post.EstimatedRecoveryTime, GeneratingCapacity = post.GeneratingCapacity, - PowerRate = post.PowerRate, Coordinate = post.Coordinate, InverterBrand = post.InverterBrand, InverterProductModel = post.InverterProductModel, @@ -514,10 +508,8 @@ namespace SolarPower.Controllers "Name", "IsEscrow", "EscrowName", - "ElectricityMeterAt", "EstimatedRecoveryTime", "GeneratingCapacity", - "PowerRate", "Coordinate", "InverterBrand", "InverterProductModel", @@ -649,7 +641,11 @@ namespace SolarPower.Controllers var split = post.BoEFile.FileName.Split("."); boeFileName = DateTime.Now.ToString("yyyyMMddHHmmss") + "." + split[split.Length - 1]; - var fullPath = Path.Combine(powerSationSaveAsPath, "boe_file", boeFileName); + FolderFunction folderFunction = new FolderFunction(); + var fileSaveAsPath = Path.Combine(powerSationSaveAsPath, "boe_file"); + folderFunction.CreateFolder(fileSaveAsPath, 0); + + var fullPath = Path.Combine(fileSaveAsPath, boeFileName); using (var stream = new FileStream(fullPath, FileMode.Create)) { @@ -664,13 +660,20 @@ namespace SolarPower.Controllers BoEFile = boeFileName, //自訂檔名 BoEDiscountRate = post.BoEDiscountRate, BoEDeviceRegisterNumber = post.BoEDeviceRegisterNumber, + BoERegisterPostAt = post.BoERegisterPostAt, BoERentRatio = post.BoERentRatio, TPCContractNumber = post.TPCContractNumber, TPCContractAt = post.TPCContractAt, TPCSellDeadline = post.TPCSellDeadline, + ElectricityMeterAt = post.ElectricityMeterAt, + PowerRate = post.PowerRate, TPCMeterReading = post.TPCMeterReading, TPCPurchaseElectricityAt = post.TPCPurchaseElectricityAt, TPCSellElectricityAt = post.TPCSellElectricityAt, + TPCInvoiceBuyer = post.TPCInvoiceBuyer, + GUINumber = post.GUINumber, + TPCInvoiceAddress = post.TPCInvoiceAddress, + TPCMeterNumber = post.TPCMeterNumber, UpdatedBy = myUser.Id }; @@ -681,13 +684,20 @@ namespace SolarPower.Controllers "BoEFile", "BoEDiscountRate", "BoEDeviceRegisterNumber", + "BoERegisterPostAt", "BoERentRatio", "TPCContractNumber", "TPCContractAt", "TPCSellDeadline", + "ElectricityMeterAt", + "PowerRate", "TPCMeterReading", "TPCPurchaseElectricityAt", "TPCSellElectricityAt", + "TPCInvoiceBuyer", + "GUINumber", + "TPCInvoiceAddress", + "TPCMeterNumber", "UpdatedBy", }; diff --git a/SolarPower/DBSchema/solar_power_schema.sql b/SolarPower/DBSchema/solar_power_schema.sql index b81787a..a7e41be 100644 --- a/SolarPower/DBSchema/solar_power_schema.sql +++ b/SolarPower/DBSchema/solar_power_schema.sql @@ -2119,6 +2119,38 @@ ALTER TABLE `power_station` ADD COLUMN `TPCInvoiceBuyer` VARCHAR(100) NULL DEFAULT NULL COMMENT '台電發票買受人' AFTER `TPCContractNumber`, ADD COLUMN `TPCInvoiceAddress` VARCHAR(100) NULL DEFAULT NULL COMMENT '台電發票地址' AFTER `TPCInvoiceBuyer`; +-- 新增其他sensor歸檔hour 20210824 +ALTER TABLE `sensor_history_hour` + ADD COLUMN `EnvTemperature` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '環境溫度計' AFTER `Temperature`, + ADD COLUMN `Humidity` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '環境濕度計' AFTER `EnvTemperature`, + ADD COLUMN `Vane` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '風速計' AFTER `Humidity`, + ADD COLUMN `Dust` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '落塵計' AFTER `Vane`; + +-- 新增其他sensor歸檔day 20210824 +ALTER TABLE `sensor_history_day` + ADD COLUMN `EnvTemperature` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '環境溫度計' AFTER `Temperature`, + ADD COLUMN `Humidity` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '環境濕度計' AFTER `EnvTemperature`, + ADD COLUMN `Vane` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '風速計' AFTER `Humidity`, + ADD COLUMN `Dust` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '落塵計' AFTER `Vane`; + +-- 新增其他sensor歸檔month 20210824 +ALTER TABLE `sensor_history_month` + ADD COLUMN `EnvTemperature` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '環境溫度計' AFTER `Temperature`, + ADD COLUMN `Humidity` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '環境濕度計' AFTER `EnvTemperature`, + ADD COLUMN `Vane` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '風速計' AFTER `Humidity`, + ADD COLUMN `Dust` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '落塵計' AFTER `Vane`; + +-- 修改裝置容量、受電費率,並新增登記發文日期、台電電號 +ALTER TABLE `power_station` + CHANGE COLUMN `GeneratingCapacity` `GeneratingCapacity` DECIMAL(10,4) NOT NULL DEFAULT '0.0000' COMMENT '電廠發電容量,單位(千瓦)' AFTER `EstimatedRecoveryTime`, + CHANGE COLUMN `PowerRate` `PowerRate` DECIMAL(10,4) NOT NULL DEFAULT '0.0000' COMMENT '受電費率' AFTER `GeneratingCapacity`, + ADD COLUMN `BoERegisterPostAt` TIMESTAMP NULL DEFAULT NULL COMMENT '能源局登記發文日期' AFTER `BoERentRatio`, + ADD COLUMN `TPCMeterNumber` VARCHAR(50) NULL DEFAULT NULL COMMENT '台電電號' AFTER `TPCSellElectricityAt`; + +-- 修改土地與房屋資訊的租金比例 20210824 +ALTER TABLE `land_building` + CHANGE COLUMN `LeaseRate` `LeaseRate` DECIMAL(5,2) UNSIGNED NOT NULL DEFAULT 0 COMMENT '租金比例(%)' AFTER `Purpose`; + -- 新增逆變器及設備保固日期 20210824 ALTER TABLE `inverter` ADD COLUMN `WarrantyDate` TIMESTAMP NULL DEFAULT NULL COMMENT '保固日期' AFTER `Pyrheliometer`; diff --git a/SolarPower/Models/ElectricitySoldRecord.cs b/SolarPower/Models/ElectricitySoldRecord.cs index b98851f..85a54b1 100644 --- a/SolarPower/Models/ElectricitySoldRecord.cs +++ b/SolarPower/Models/ElectricitySoldRecord.cs @@ -41,6 +41,7 @@ namespace SolarPower.Models public string GUINumber { get; set; } public string TPCInvoiceBuyer { get; set; } public string TPCInvoiceAddress { get; set; } + public string TPCMeterNumber { get; set; } public string Name { get; set; } public string Logo { get; set; } private string startAt; diff --git a/SolarPower/Models/PowerStation.cs b/SolarPower/Models/PowerStation.cs index 6def08b..5ee250f 100644 --- a/SolarPower/Models/PowerStation.cs +++ b/SolarPower/Models/PowerStation.cs @@ -12,9 +12,21 @@ namespace SolarPower.Models.PowerStation HireSold = 1, //租建躉售 SelfUse = 2 //自建自用 } + + public enum SensorTypeEnum + { + PYR = 1, //日照計 + MTR = 2, //模組溫度計 + ETR = 3, //環境溫度計 + EMM = 4, //環境濕度計 + VAN = 5, //風速計 + FOM = 6, //落塵計 + PWR = 7 //電錶 + } + public class PowerStation : Created { - private string electricityMeterAt = "", tpcContractAt = "", tpcPurchaseElectricityAt = "", tpcSellElectricityAt = ""; + private string electricityMeterAt = "", tpcContractAt = "", tpcPurchaseElectricityAt = "", tpcSellElectricityAt = "", boeRegisterPostAt = ""; public int Id { get; set; } public byte HealthStatus { get; set; } //狀態 @@ -62,6 +74,21 @@ namespace SolarPower.Models.PowerStation public int BoEDiscountRate { get; set; } //能源局折扣率 public string BoEDeviceRegisterNumber { get; set; } //能源局設備登記編號 public int BoERentRatio { get; set; } //能源局租金比例 + public string BoERegisterPostAt //台電簽約日期 + { + get + { + if (!string.IsNullOrEmpty(boeRegisterPostAt)) + { + return Convert.ToDateTime(boeRegisterPostAt).ToString("yyyy-MM-dd"); + } + else + { + return null; + } + } + set { boeRegisterPostAt = value; } + } public string TPCContractNumber { get; set; } //台電契約編號 public string TPCContractAt //台電簽約日期 { @@ -110,6 +137,10 @@ namespace SolarPower.Models.PowerStation } set { tpcPurchaseElectricityAt = value; } } + public string TPCMeterNumber { get; set; } //台電電號 + public string GUINumber { get; set; } + public string TPCInvoiceBuyer { get; set; } + public string TPCInvoiceAddress { get; set; } public List LandBuildings { get; set; } //土地房屋資料 public byte SolarType { get; set; } //電站類型 public double kwh { get; set; } // @@ -162,7 +193,7 @@ namespace SolarPower.Models.PowerStation } public string Landowner { get; set; } //地主姓名 public string Purpose { get; set; } //房屋用途 - public int LeaseRate { get; set; } //租金比例 + public double LeaseRate { get; set; } //租金比例 public string Coordinate { get; set; } //經緯度 public string Phone { get; set; } //電話 public string CreatorName { get; set; } //創建者名稱 @@ -185,10 +216,10 @@ namespace SolarPower.Models.PowerStation //public string Code { get; set; } public byte IsEscrow { get; set; } //是否被代管 public string EscrowName { get; set; } //被代管公司 - public string ElectricityMeterAt { get; set; } //台電掛錶日 + //public string ElectricityMeterAt { get; set; } //台電掛錶日 public int EstimatedRecoveryTime { get; set; } //預計回收年限 public double GeneratingCapacity { get; set; } //發電容量 - public double PowerRate { get; set; } //授電費率 + //public double PowerRate { get; set; } //授電費率 public string Coordinate { get; set; } //座標 public List OperationPersonnelIds { get; set; } //運維人員編號 public string InverterBrand { get; set; } //逆變器廠牌 @@ -213,10 +244,10 @@ namespace SolarPower.Models.PowerStation public string Name { get; set; } //名稱 public byte IsEscrow { get; set; } //是否被代管 public string EscrowName { get; set; } //被代管公司 - public string ElectricityMeterAt { get; set; } //台電掛錶日 + //public string ElectricityMeterAt { get; set; } //台電掛錶日 public int EstimatedRecoveryTime { get; set; } //預計回收年限 public double GeneratingCapacity { get; set; } //發電容量 - public double PowerRate { get; set; } //授電費率 + //public double PowerRate { get; set; } //授電費率 public string Coordinate { get; set; } //座標 public string InverterBrand { get; set; } //逆變器廠牌 public string InverterProductModel { get; set; } //逆變器型號 @@ -237,13 +268,20 @@ namespace SolarPower.Models.PowerStation public IFormFile BoEFile { get; set; } public int BoEDiscountRate { get; set; } public string BoEDeviceRegisterNumber { get; set; } + public string BoERegisterPostAt { get; set; } public int BoERentRatio { get; set; } public string TPCContractNumber { get; set; } public string TPCContractAt { get; set; } public int TPCSellDeadline { get; set; } + public string ElectricityMeterAt { get; set; } + public double PowerRate { get; set; } public int TPCMeterReading { get; set; } public string TPCPurchaseElectricityAt { get; set; } public string TPCSellElectricityAt { get; set; } + public string TPCInvoiceBuyer { get; set; } + public string GUINumber { get; set; } + public string TPCInvoiceAddress { get; set; } + public string TPCMeterNumber { get; set; } } public class UpdateBoETPCInfo : Updated @@ -252,13 +290,20 @@ namespace SolarPower.Models.PowerStation public string BoEFile { get; set; } public int BoEDiscountRate { get; set; } public string BoEDeviceRegisterNumber { get; set; } + public string BoERegisterPostAt { get; set; } public int BoERentRatio { get; set; } public string TPCContractNumber { get; set; } public string TPCContractAt { get; set; } public int TPCSellDeadline { get; set; } + public string ElectricityMeterAt { get; set; } + public double PowerRate { get; set; } public int TPCMeterReading { get; set; } public string TPCPurchaseElectricityAt { get; set; } public string TPCSellElectricityAt { get; set; } + public string TPCInvoiceBuyer { get; set; } + public string GUINumber { get; set; } + public string TPCInvoiceAddress { get; set; } + public string TPCMeterNumber { get; set; } } public class PostLandBuildingInfo @@ -269,7 +314,7 @@ namespace SolarPower.Models.PowerStation public string LeaseNotarizationAt { get; set; } public string Landowner { get; set; } public string Purpose { get; set; } - public int LeaseRate { get; set; } + public double LeaseRate { get; set; } public string Coordinate { get; set; } public string Phone { get; set; } } @@ -280,7 +325,7 @@ namespace SolarPower.Models.PowerStation public string LeaseNotarizationAt { get; set; } public string Landowner { get; set; } public string Purpose { get; set; } - public int LeaseRate { get; set; } + public double LeaseRate { get; set; } public string Coordinate { get; set; } public string Phone { get; set; } } diff --git a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs index 2ad2e7e..58ac4ad 100644 --- a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs +++ b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs @@ -40,8 +40,6 @@ namespace SolarPower.Quartz.Jobs var DateTimeNow = DateTime.Now; var dateTime = DateTimeNow.AddHours(-1).ToString("yyyy-MM-dd HH"); - var hasException = false; - Root2 observation = null; if (this.environment.IsDevelopment()) @@ -226,223 +224,331 @@ namespace SolarPower.Quartz.Jobs sensorHistory.PowerStationId = powerStation.Id; sensorHistory.Timestamp = Convert.ToDateTime(dateTime + ":00:00").ToString("yyyy-MM-dd HH:mm:ss"); - - //1. 找出該電站所有日照計設備(包含共享 - logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的日照計設備資訊】", powerStation.Code, dateTime); - var deviceInfos = await powerStationRepository.GetListPyrheliometerByPowerStationId(powerStation.Id, powerStation.SiteDB); - logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的日照計設備資訊】", powerStation.Code, dateTime); - logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的日照計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(deviceInfos)); - - if (deviceInfos != null && deviceInfos.Count() > 0) + //1. 計算該電站sensor平均值 - 日照計(PYR) + try { - //2. 計算該電站所有日照計設的每小時的平均在依照日照計數量平均 - logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的日照計的日照度】", powerStation.Code, dateTime); - var pyrheliometerHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(dateTime, deviceInfos, 0); + logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的日照計設備資訊】", powerStation.Code, dateTime); + var deviceInfos = await powerStationRepository.GetListPyrheliometerByPowerStationId(powerStation.Id, powerStation.SiteDB); + logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的日照計設備資訊】", powerStation.Code, dateTime); + logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的日照計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(deviceInfos)); - if (pyrheliometerHistory != null) + if (deviceInfos != null && deviceInfos.Count() > 0) { - calcPowerStation.Today_irradiance = pyrheliometerHistory.Irradiance; + logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的日照計的平均值】", powerStation.Code, dateTime); + var pyrheliometerHistory = await powerStationRepository.CalcSensorHistoryPerHour(dateTime, deviceInfos, Convert.ToInt32(SensorTypeEnum.PYR)); - sensorHistory.Irradiance = pyrheliometerHistory.Irradiance; + if (pyrheliometerHistory != null) + { + calcPowerStation.Today_irradiance = pyrheliometerHistory.Irradiance; - pyrheliometerHistory.Timestamp = Convert.ToDateTime(pyrheliometerHistory.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss"); - pyrheliometerHistory.PowerStationId = powerStation.Id; - pyrheliometerHistoriesHour.Add(pyrheliometerHistory); - } - logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的日照計的日照度】", powerStation.Code, dateTime); - } + sensorHistory.Irradiance = pyrheliometerHistory.Irradiance; - //2. 計算該電站所有模組溫度計設的每小時的平均在依照溫度計數量平均 - // 找出該電站所有模組溫度計設備(包含共享 - logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的模組溫度計設備資訊】", powerStation.Code, dateTime); - var tempdeviceInfos = await powerStationRepository.GetListTempByPowerStationId(powerStation.Id, powerStation.SiteDB); - logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的模組溫度計設備資訊】", powerStation.Code, dateTime); - logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的模組溫度計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(tempdeviceInfos)); - if (tempdeviceInfos != null && tempdeviceInfos.Count() > 0) - { - logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的模組溫度計的平均溫度】", powerStation.Code, dateTime); - var tempHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(dateTime, tempdeviceInfos, 1); - if (tempHistory != null) - { - tempHistory.Timestamp = Convert.ToDateTime(tempHistory.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss"); - tempHistory.PowerStationId = powerStation.Id; - TempHistoriesHour.Add(tempHistory); - - sensorHistory.Temperature = tempHistory.Temperature; - - logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的模組溫度計的平均溫度】", powerStation.Code, dateTime); + //pyrheliometerHistory.Timestamp = Convert.ToDateTime(pyrheliometerHistory.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss"); + //pyrheliometerHistory.PowerStationId = powerStation.Id; + //pyrheliometerHistoriesHour.Add(pyrheliometerHistory); + } + logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的日照計的平均值】", powerStation.Code, dateTime); } } + catch (Exception ex) + { + logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的日照計的平均值】", powerStation.Code, dateTime); + logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message); + } - //3. 計算該電站 - 環境溫度計(ETR) - //logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的環境溫度計設備資訊】", powerStation.Code, dateTime); - //var ETRdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, "ETR", powerStation.SiteDB); - //logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的環境溫度計設備資訊】", powerStation.Code, dateTime); - //logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的環境溫度計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(tempdeviceInfos)); - //if (ETRdeviceInfos != null && ETRdeviceInfos.Count() > 0) - //{ - // logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的環境溫度計的平均溫度】", powerStation.Code, dateTime); - // var ETRHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(dateTime, tempdeviceInfos, 1); - // if (ETRHistory != null) - // { - // sensorHistory.EnvTemperature = ETRHistory.EnvTemperature; - // logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的環境溫度計的平均溫度】", powerStation.Code, dateTime); - // } - //} + //2. 計算該電站sensor平均值 - 模組溫度計(MTR) + try + { + logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的模組溫度計設備資訊】", powerStation.Code, dateTime); + var tempdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, "MTR", powerStation.SiteDB); + logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的模組溫度計設備資訊】", powerStation.Code, dateTime); + logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的模組溫度計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(tempdeviceInfos)); + if (tempdeviceInfos != null && tempdeviceInfos.Count() > 0) + { + logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的模組溫度計的平均值】", powerStation.Code, dateTime); + var tempHistory = await powerStationRepository.CalcSensorHistoryPerHour(dateTime, tempdeviceInfos, Convert.ToInt32(SensorTypeEnum.MTR)); + if (tempHistory != null) + { + //tempHistory.Timestamp = Convert.ToDateTime(tempHistory.Timestamp + ":00:00").ToString("yyyy-MM-dd HH:mm:ss"); + //tempHistory.PowerStationId = powerStation.Id; + //TempHistoriesHour.Add(tempHistory); + + sensorHistory.Temperature = tempHistory.Temperature; + + logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的模組溫度計的平均值】", powerStation.Code, dateTime); + } + } + } + catch (Exception ex) + { + logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的模組溫度計的平均值】", powerStation.Code, dateTime); + logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message); + } + + //3. 計算該電站sensor平均值 - 環境溫度計(ETR) + try + { + logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的環境溫度計設備資訊】", powerStation.Code, dateTime); + var ETRdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, SensorTypeEnum.ETR.ToString(), powerStation.SiteDB); + logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的環境溫度計設備資訊】", powerStation.Code, dateTime); + logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的環境溫度計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(ETRdeviceInfos)); + if (ETRdeviceInfos != null && ETRdeviceInfos.Count() > 0) + { + logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的環境溫度計的平均值】", powerStation.Code, dateTime); + var ETRHistory = await powerStationRepository.CalcSensorHistoryPerHour(dateTime, ETRdeviceInfos, Convert.ToInt32(SensorTypeEnum.ETR)); + if (ETRHistory != null) + { + sensorHistory.EnvTemperature = ETRHistory.EnvTemperature; + logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的環境溫度計的平均溫度】", powerStation.Code, dateTime); + } + } + } + catch (Exception ex) + { + logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的環境溫度計的平均值】", powerStation.Code, dateTime); + logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message); + } + + //4. 計算該電站 - 環境濕度計(EMM) + try + { + logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的環境濕度計設備資訊】", powerStation.Code, dateTime); + var EMMdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, SensorTypeEnum.EMM.ToString(), powerStation.SiteDB); + logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的環境濕度計設備資訊】", powerStation.Code, dateTime); + logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的環境濕度計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(EMMdeviceInfos)); + if (EMMdeviceInfos != null && EMMdeviceInfos.Count() > 0) + { + logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的環境濕度計的平均值】", powerStation.Code, dateTime); + var EMMHistory = await powerStationRepository.CalcSensorHistoryPerHour(dateTime, EMMdeviceInfos, Convert.ToInt32(SensorTypeEnum.EMM)); + if (EMMHistory != null) + { + sensorHistory.Humidity = EMMHistory.Humidity; + logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的環境濕度計的平均值】", powerStation.Code, dateTime); + } + } + } + catch (Exception ex) + { + logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的環境濕度計的平均值】", powerStation.Code, dateTime); + logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message); + } + + //5. 計算該電站 - 風速計(VAN) + try + { + logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的風速計設備資訊】", powerStation.Code, dateTime); + var VANdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, SensorTypeEnum.VAN.ToString(), powerStation.SiteDB); + logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的風速計設備資訊】", powerStation.Code, dateTime); + logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的風速計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(VANdeviceInfos)); + if (VANdeviceInfos != null && VANdeviceInfos.Count() > 0) + { + logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的風速計的平均值】", powerStation.Code, dateTime); + var VANHistory = await powerStationRepository.CalcSensorHistoryPerHour(dateTime, VANdeviceInfos, Convert.ToInt32(SensorTypeEnum.VAN)); + if (VANHistory != null) + { + sensorHistory.Vane = VANHistory.Vane; + logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的風速計的平均值】", powerStation.Code, dateTime); + } + } + } + catch (Exception ex) + { + logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的風速計的平均值】", powerStation.Code, dateTime); + logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message); + } - //4. 計算該電站 - 風速計(VAN) - //logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的風速計設備資訊】", powerStation.Code, dateTime); - //var VANdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, "ETR", powerStation.SiteDB); - //logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的風速計設備資訊】", powerStation.Code, dateTime); - //logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的風速計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(tempdeviceInfos)); - //if (VANdeviceInfos != null && VANdeviceInfos.Count() > 0) - //{ - // logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的風速計的平均溫度】", powerStation.Code, dateTime); - // var VANHistory = await powerStationRepository.GetPyrheliometerHistoryPerHour(dateTime, tempdeviceInfos, 1); - // if (VANHistory != null) - // { - // sensorHistory.EnvTemperature = VANHistory.Vane; - // logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的環境溫度計的平均溫度】", powerStation.Code, dateTime); - // } - //} //5. 計算該電站 - 落塵計(FOM) - //6. 計算該電站 - 環境濕度計(EMM) + try + { + logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的落塵計設備資訊】", powerStation.Code, dateTime); + var FOMdeviceInfos = await powerStationRepository.GetDeviceListByPowerStationIdAndType(powerStation.Id, SensorTypeEnum.FOM.ToString(), powerStation.SiteDB); + logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的落塵計設備資訊】", powerStation.Code, dateTime); + logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的落塵計設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(FOMdeviceInfos)); + if (FOMdeviceInfos != null && FOMdeviceInfos.Count() > 0) + { + logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的落塵計的平均%】", powerStation.Code, dateTime); + var FOMHistory = await powerStationRepository.CalcSensorHistoryPerHour(dateTime, FOMdeviceInfos, Convert.ToInt32(SensorTypeEnum.FOM)); + if (FOMHistory != null) + { + sensorHistory.Dust = FOMHistory.Dust; + logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的落塵計的平均值】", powerStation.Code, dateTime); + } + } + } + catch (Exception ex) + { + logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的落塵計的平均值】", powerStation.Code, dateTime); + logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message); + } + sensorHistoriesHour.Add(sensorHistory); calcPowerStations.Add(calcPowerStation); #endregion #region step2-3. 計算該電站所有逆變器每小時值 - logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateTime); - var controllers = await powerStationRepository.GetAllDeviceControllerId(powerStation.Id, powerStation.SiteDB); - var inverters = await powerStationRepository.InverterTable(controllers, powerStation.SiteDB); - var inverterIds = inverters.Where(x => x.Enabled == 1 && x.Status != 0).Select(x => x.InverterId).ToList(); - logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateTime); - logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的逆變器設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(inverterIds)); - - var inverter_table_name = String.Format("s{0}01_inv", powerStation.Code); - var full_inverter_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, inverter_table_name); - var exist_inverter_table = await powerStationRepository.ExistTable(powerStation.SiteDB, inverter_table_name); - - if (!string.IsNullOrEmpty(exist_inverter_table) && inverterIds != null && inverterIds.Count() > 0) + try { - logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime); - var inverterHistories = await powerStationRepository.CalcInverterHisyortHourData(dateTime, powerStation.SiteDB, full_inverter_table_name, inverterIds); - //取得日照計要找的欄位資訊 - var pyrheliometer = await powerStationRepository.GetFirstPyrheliometerInfo(powerStation.Id, powerStation.SiteDB); - var pyrheliometerValue = await powerStationRepository.GetFirstPyrheliometerValue(dateTime, pyrheliometer.DBName, pyrheliometer.TableName, pyrheliometer.ColName); - foreach (var inverterHistory in inverterHistories) + logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateTime); + var controllers = await powerStationRepository.GetAllDeviceControllerId(powerStation.Id, powerStation.SiteDB); + var inverters = await powerStationRepository.InverterTable(controllers, powerStation.SiteDB); + var inverterIds = inverters.Where(x => x.Enabled == 1 && x.Status != 0).Select(x => x.InverterId).ToList(); + logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的逆變器設備資訊】", powerStation.Code, dateTime); + logger.LogInformation("【CalcPowerStationJob】【電站[{0}]在{1}的逆變器設備資訊】 - {2}", powerStation.Code, dateTime, System.Text.Json.JsonSerializer.Serialize(inverterIds)); + + var inverter_table_name = String.Format("s{0}01_inv", powerStation.Code); + var full_inverter_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, inverter_table_name); + var exist_inverter_table = await powerStationRepository.ExistTable(powerStation.SiteDB, inverter_table_name); + + if (!string.IsNullOrEmpty(exist_inverter_table) && inverterIds != null && inverterIds.Count() > 0) { - inverterHistory.Irradiance = pyrheliometerValue; - inverterHistory.DC1KW = inverterHistory.DC1W / 1000; - inverterHistory.DC2KW = inverterHistory.DC2W / 1000; - inverterHistory.DC3KW = inverterHistory.DC3W / 1000; - inverterHistory.DC4KW = inverterHistory.DC4W / 1000; - inverterHistory.DC5KW = inverterHistory.DC5W / 1000; + logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime); + var inverterHistories = await powerStationRepository.CalcInverterHisyortHourData(dateTime, powerStation.SiteDB, full_inverter_table_name, inverterIds); + //取得日照計要找的欄位資訊 + var pyrheliometer = await powerStationRepository.GetFirstPyrheliometerInfo(powerStation.Id, powerStation.SiteDB); + var pyrheliometerValue = await powerStationRepository.GetFirstPyrheliometerValue(dateTime, pyrheliometer.DBName, pyrheliometer.TableName, pyrheliometer.ColName); + foreach (var inverterHistory in inverterHistories) + { + inverterHistory.Irradiance = pyrheliometerValue; + inverterHistory.DC1KW = inverterHistory.DC1W / 1000; + inverterHistory.DC2KW = inverterHistory.DC2W / 1000; + inverterHistory.DC3KW = inverterHistory.DC3W / 1000; + inverterHistory.DC4KW = inverterHistory.DC4W / 1000; + inverterHistory.DC5KW = inverterHistory.DC5W / 1000; - inverterHistory.DCKW = (inverterHistory.DC1W + inverterHistory.DC2W + inverterHistory.DC3W + inverterHistory.DC4W + inverterHistory.DC5W) / 1000; - inverterHistory.ACKW = (inverterHistory.AC1W + inverterHistory.AC2W + inverterHistory.AC3W) / 1000; + inverterHistory.DCKW = (inverterHistory.DC1W + inverterHistory.DC2W + inverterHistory.DC3W + inverterHistory.DC4W + inverterHistory.DC5W) / 1000; + inverterHistory.ACKW = (inverterHistory.AC1W + inverterHistory.AC2W + inverterHistory.AC3W) / 1000; - inverterHistory.TIMESTAMP = Convert.ToDateTime(inverterHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss"); - inverterHistory.PowerStationId = powerStation.Id; + inverterHistory.TIMESTAMP = Convert.ToDateTime(inverterHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss"); + inverterHistory.PowerStationId = powerStation.Id; - inverterHistoriesHour.Add(inverterHistory); + inverterHistoriesHour.Add(inverterHistory); + } + logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime); } - logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime); + } + catch (Exception ex) + { + logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的逆變器的資訊】", powerStation.Code, dateTime); + logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message); } #endregion #region step2-4. 計算該電站所有sensoravg - var seneoravg_table_name = String.Format("s{0}01_sensoravg", powerStation.Code); - var full_seneoravg_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, seneoravg_table_name); - var exist_seneoravg_table = await powerStationRepository.ExistTable(powerStation.SiteDB, seneoravg_table_name); - if (!string.IsNullOrEmpty(exist_seneoravg_table)) + try { - logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的sensor avg的資訊】", powerStation.Code, dateTime); - var sensorAvgHistory = await powerStationRepository.CalcSensorAvgHistory(dateTime, full_seneoravg_table_name); - logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的sensor avg的資訊】", powerStation.Code, dateTime); - if (sensorAvgHistory != null) + var seneoravg_table_name = String.Format("s{0}01_sensoravg", powerStation.Code); + var full_seneoravg_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, seneoravg_table_name); + var exist_seneoravg_table = await powerStationRepository.ExistTable(powerStation.SiteDB, seneoravg_table_name); + if (!string.IsNullOrEmpty(exist_seneoravg_table)) { - sensorAvgHistory.PowerStationId = powerStation.Id; - sensorAvgHistory.TIMESTAMP = Convert.ToDateTime(sensorAvgHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss"); + logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的sensor avg的資訊】", powerStation.Code, dateTime); + var sensorAvgHistory = await powerStationRepository.CalcSensorAvgHistory(dateTime, full_seneoravg_table_name); + logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的sensor avg的資訊】", powerStation.Code, dateTime); - sensorAvgHistoryHour.Add(sensorAvgHistory); + if (sensorAvgHistory != null) + { + sensorAvgHistory.PowerStationId = powerStation.Id; + sensorAvgHistory.TIMESTAMP = Convert.ToDateTime(sensorAvgHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss"); + + sensorAvgHistoryHour.Add(sensorAvgHistory); + } } } + catch (Exception ex) + { + logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的sensor avg的資訊】", powerStation.Code, dateTime); + logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message); + } #endregion #region step2-5. 計算該電站meter - var meter_table_name = String.Format("s{0}01_meter", powerStation.Code); - var full_meter_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, meter_table_name); - var exist_meter_table = await powerStationRepository.ExistTable(powerStation.SiteDB, meter_table_name); - if (!string.IsNullOrEmpty(exist_meter_table)) + try { - logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的meter的資訊】", powerStation.Code, dateTime); - var meterHistory = await powerStationRepository.CalcMeterHistory(dateTime, full_meter_table_name); - logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的meter的資訊】", powerStation.Code, dateTime); - - if (meterHistory != null) + var meter_table_name = String.Format("s{0}01_meter", powerStation.Code); + var full_meter_table_name = String.Format("`{0}`.`{1}`", powerStation.SiteDB, meter_table_name); + var exist_meter_table = await powerStationRepository.ExistTable(powerStation.SiteDB, meter_table_name); + if (!string.IsNullOrEmpty(exist_meter_table)) { - meterHistory.PowerStationId = powerStation.Id; - meterHistory.TIMESTAMP = Convert.ToDateTime(meterHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss"); + logger.LogInformation("【CalcPowerStationJob】【開始計算電站[{0}]在{1}的meter的資訊】", powerStation.Code, dateTime); + var meterHistory = await powerStationRepository.CalcMeterHistory(dateTime, full_meter_table_name); + logger.LogInformation("【CalcPowerStationJob】【計算完成電站[{0}]在{1}的meter的資訊】", powerStation.Code, dateTime); - meterHistoriesHour.Add(meterHistory); + if (meterHistory != null) + { + meterHistory.PowerStationId = powerStation.Id; + meterHistory.TIMESTAMP = Convert.ToDateTime(meterHistory.TIMESTAMP + ":00:00").ToString("yyyy-MM-dd HH:mm:ss"); + + meterHistoriesHour.Add(meterHistory); + } } } + catch (Exception ex) + { + logger.LogError("【CalcPowerStationJob】【計算失敗電站[{0}]在{1}的meter的資訊】", powerStation.Code, dateTime); + logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message); + } #endregion #region 確認是否有觀測站(沒有則新增) - if (powerStation.WeathersStationId == null) + try { - var weatherStationId = ""; - double shortLocation = 9999; - foreach (var Location in observation.Records.Location) + if (powerStation.WeathersStationId == null) { - - if (powerStation.Coordinate != null) + var weatherStationId = ""; + double shortLocation = 9999; + foreach (var Location in observation.Records.Location) { - var powerLocation = powerStation.Coordinate.Split(','); - var nowLocation = Math.Sqrt(Math.Pow(Convert.ToDouble(powerLocation[0]) - Convert.ToDouble(Location.Lat), 2) + Math.Pow(Convert.ToDouble(powerLocation[1]) - Convert.ToDouble(Location.Lon), 2)); - if (nowLocation < shortLocation) + + if (powerStation.Coordinate != null) { - shortLocation = nowLocation; - weatherStationId = Location.StationId; - calcPowerStation.TodayWeatherTemp = Convert.ToDouble(Location.WeatherElement[0].ElementValue); + var powerLocation = powerStation.Coordinate.Split(','); + var nowLocation = Math.Sqrt(Math.Pow(Convert.ToDouble(powerLocation[0]) - Convert.ToDouble(Location.Lat), 2) + Math.Pow(Convert.ToDouble(powerLocation[1]) - Convert.ToDouble(Location.Lon), 2)); + if (nowLocation < shortLocation) + { + shortLocation = nowLocation; + weatherStationId = Location.StationId; + calcPowerStation.TodayWeatherTemp = Convert.ToDouble(Location.WeatherElement[0].ElementValue); + } } } + + calcPowerStation.WeathersStationId = weatherStationId; } - calcPowerStation.WeathersStationId = weatherStationId; + WeatherObservation weatherObservation = new WeatherObservation(); + if (powerStation.WeathersStationId != null && observation != null) + { + foreach (var Location in observation.Records.Location) + { + if (Location.StationId == powerStation.WeathersStationId) + { + calcPowerStation.TodayWeatherTemp = Convert.ToDouble(Location.WeatherElement[0].ElementValue); + weatherObservation.PowerStationId = powerStation.Id; + weatherObservation.Temp = Convert.ToDouble(Location.WeatherElement[0].ElementValue); + weatherObservation.ObsTime = !string.IsNullOrEmpty(Location.Time.ObsTime) ? Convert.ToInt32(Location.Time.ObsTime.Substring(0, 4)) >= 1971 ? Location.Time.ObsTime : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + calcPowerStation.WeathersStationId = powerStation.WeathersStationId; + break; + } + } + weatherObservations.Add(weatherObservation); + } + + logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的天氣預報的資訊】", powerStation.Code, dateTime); + var weather = await powerStationRepository.SelectNowWeather(powerStation.CityId); + logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的天氣預報的資訊】", powerStation.Code, dateTime); + if (weather != null) + { + calcPowerStation.TodayWeather = weather.WeatherKey; + calcPowerStation.RateOfRain = weather.PoP; + } + } + catch (Exception ex) + { + logger.LogError("【CalcPowerStationJob】【取得失敗電站[{0}]在{1}的天氣預報的資訊】", powerStation.Code, dateTime); + logger.LogError("【CalcPowerStationJob】【失敗原因】- {0}", ex.Message); } #endregion - - WeatherObservation weatherObservation = new WeatherObservation(); - if (powerStation.WeathersStationId != null && observation != null) - { - foreach (var Location in observation.Records.Location) - { - if (Location.StationId == powerStation.WeathersStationId) - { - - calcPowerStation.TodayWeatherTemp = Convert.ToDouble(Location.WeatherElement[0].ElementValue); - weatherObservation.PowerStationId = powerStation.Id; - weatherObservation.Temp = Convert.ToDouble(Location.WeatherElement[0].ElementValue); - weatherObservation.ObsTime = !string.IsNullOrEmpty(Location.Time.ObsTime) ? Convert.ToInt32(Location.Time.ObsTime.Substring(0, 4)) >= 1971 ? Location.Time.ObsTime : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); - calcPowerStation.WeathersStationId = powerStation.WeathersStationId; - break; - } - } - weatherObservations.Add(weatherObservation); - } - - logger.LogInformation("【CalcPowerStationJob】【開始取得電站[{0}]在{1}的天氣預報的資訊】", powerStation.Code, dateTime); - var weather = await powerStationRepository.SelectNowWeather(powerStation.CityId); - logger.LogInformation("【CalcPowerStationJob】【取得成功電站[{0}]在{1}的天氣預報的資訊】", powerStation.Code, dateTime); - if (weather != null) - { - calcPowerStation.TodayWeather = weather.WeatherKey; - calcPowerStation.RateOfRain = weather.PoP; - } } catch (Exception exception) { @@ -478,24 +584,29 @@ namespace SolarPower.Quartz.Jobs await powerStationRepository.AddPowerStationHistory(powerStationHistoriesHour, history_properties); #endregion - #region step4. 將Pyrheliometer History INSERT 到 sensor_history_hour 資料表 - List pyrheliometer_history_properties = new List() + #region step4. 將sensor History INSERT 到 sensor_history_hour 資料表 + List sensor_history_properties = new List() { "PowerStationId", "TIMESTAMP", - "Irradiance" + "Irradiance", + "Temperature", + "EnvTemperature", + "Humidity", + "Vane", + "Dust" }; - await powerStationRepository.AddPyrheliometerHistory(pyrheliometerHistoriesHour, pyrheliometer_history_properties); + await powerStationRepository.AddSensorHistoryHour(sensorHistoriesHour, sensor_history_properties); - List Temp_history_properties = new List() - { - "PowerStationId", - "TIMESTAMP", - "Temperature" - }; + //List Temp_history_properties = new List() + //{ + // "PowerStationId", + // "TIMESTAMP", + // "Temperature" + //}; - await powerStationRepository.AddTempHistory(TempHistoriesHour, Temp_history_properties); + //await powerStationRepository.AddTempHistory(TempHistoriesHour, Temp_history_properties); #endregion #region step5. calcPowerStations UPDATE 到 power_station 資料表 diff --git a/SolarPower/Repository/Implement/CompanyRepository.cs b/SolarPower/Repository/Implement/CompanyRepository.cs index 74d8840..179f1f8 100644 --- a/SolarPower/Repository/Implement/CompanyRepository.cs +++ b/SolarPower/Repository/Implement/CompanyRepository.cs @@ -540,72 +540,74 @@ namespace SolarPower.Repository.Implement -- 傾印 資料表 power_station 結構 CREATE TABLE IF NOT EXISTS `power_station` ( - `Id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `Deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否刪除, 0:否 1:是', - `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 '電站區域', - `HealthStatus` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '1:設備正常 2:設備斷線 3:設備異常', - `Address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站詳細地址', - `Name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '名稱', - `MainDisplay` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '主要顯示圖片', - `Code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站代碼,縣市+區域+四碼流水號', - `SerialNumber` varchar(4) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '四碼流水號', - `IsEscrow` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否為代管,0:否 1:是', - `EscrowName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '代管名稱', - `ElectricityMeterAt` timestamp NULL DEFAULT NULL COMMENT '台電掛錶日', - `EstimatedRecoveryTime` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '預估回收時間', - `GeneratingCapacity` decimal(10,1) NOT NULL DEFAULT '0.0' COMMENT '電廠發電容量,單位(千瓦)', - `PowerRate` decimal(10,3) NOT NULL DEFAULT '0.000' COMMENT '受電費率', - `Coordinate` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '座標', - `InverterBrand` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逆變器廠牌', - `InverterProductModel` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '逆變器型號', - `InverterAmount` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '逆變器數量', - `PhotovoltaicPanelBrand` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板廠牌', - `PhotovoltaicPanelProductModel` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板型號', - `PhotovoltaicPanelSpecification` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '光電板規格', - `PhotovoltaicPanelAmount` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '光電板數量', - `BoEFileName` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局原檔案名', - `BoEFile` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局檔案', - `BoEDiscountRate` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '能源局折扣率', - `BoEDeviceRegisterNumber` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '能源局設備登記編號', - `BoERentRatio` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '能源局租金比率,單位(%)', - `GUINumber` varchar(16) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '統一編號', - `TPCContractNumber` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '台電契約編號', - `TPCInvoiceBuyer` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '台電發票買受人', - `TPCInvoiceAddress` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '台電發票地址', - `TPCContractAt` timestamp NULL DEFAULT NULL COMMENT '台電簽約日期', - `TPCSellDeadline` int(10) unsigned DEFAULT '0' COMMENT '台電售電期限,單位(年)', - `TPCMeterReading` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '台電每期抄錶日', - `TPCPurchaseElectricityAt` timestamp NULL DEFAULT NULL COMMENT '台電正式購電日', - `TPCSellElectricityAt` timestamp NULL DEFAULT NULL COMMENT '台電正式售電日', - `SolarType` tinyint(4) NOT NULL DEFAULT '0' COMMENT '電站類型', - `kwh` decimal(10,3) unsigned NOT NULL DEFAULT '0.000', - `Today_kwh` decimal(10,3) unsigned NOT NULL DEFAULT '0.000' COMMENT '今日發電量', - `Total_kwh` decimal(10,3) unsigned NOT NULL DEFAULT '0.000' COMMENT '總發電量', - `today_kwhkwp` decimal(10,3) DEFAULT NULL COMMENT '今日kwhkwp', - `avg_kwhkwp` decimal(10,3) DEFAULT NULL COMMENT '30天平均kwhkwp', - `today_money` decimal(10,2) DEFAULT NULL COMMENT '今日金額', - `total_money` decimal(10,2) DEFAULT NULL COMMENT '總金額', - `today_PR` decimal(5,2) DEFAULT NULL COMMENT '電站Pr值', - `avg_PR` decimal(5,2) DEFAULT NULL COMMENT '平均Pr值', - `today_carbon` decimal(10,2) DEFAULT NULL COMMENT '今日減碳量', - `total_carbon` decimal(10,2) DEFAULT NULL COMMENT '總減碳量', - `today_irradiance` decimal(5,2) DEFAULT NULL COMMENT '今日日照度', - `avg_irradiance` decimal(5,2) DEFAULT NULL COMMENT '平均日照度', - `SolarHour` decimal(5,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '總運轉小時', - `SiteDB` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '電站 DB name: solar_com', - `TodayWeather` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '今日天氣', - `TodayWeatherTemp` decimal(5,2) unsigned NOT NULL DEFAULT '0.00' COMMENT '今日溫度', - `WeathersStationId` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '氣象站編號', - `RateOfRain` varchar(50) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '今日降雨率', - `line_token` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL, - `Estimate_kwh` decimal(10,2) DEFAULT '0.00' COMMENT '預估發電度數', - `EstimateEfficacy` decimal(10,2) DEFAULT '0.00' COMMENT '預估發電效能', - `CreatedBy` int(10) unsigned NOT NULL COMMENT '建立者', - `CreatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '建立時間', - `UpdatedBy` int(10) unsigned DEFAULT NULL COMMENT '修改者', - `UpdatedAt` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改時間', + `Id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + `Deleted` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '是否刪除, 0:否 1:是', + `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 '電站區域', + `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', + `MainDisplay` VARCHAR(50) NULL DEFAULT NULL COMMENT '主要顯示圖片' COLLATE 'utf8mb4_unicode_ci', + `Code` VARCHAR(50) NULL DEFAULT NULL COMMENT '電站代碼,縣市+區域+四碼流水號' COLLATE 'utf8mb4_unicode_ci', + `SerialNumber` VARCHAR(4) NULL DEFAULT NULL COMMENT '四碼流水號' COLLATE 'utf8mb4_unicode_ci', + `IsEscrow` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '是否為代管,0:否 1:是', + `EscrowName` VARCHAR(50) NULL DEFAULT NULL COMMENT '代管名稱' COLLATE 'utf8mb4_unicode_ci', + `ElectricityMeterAt` TIMESTAMP NULL DEFAULT NULL COMMENT '台電掛錶日', + `EstimatedRecoveryTime` VARCHAR(10) NULL DEFAULT NULL COMMENT '預估回收時間' COLLATE 'utf8mb4_unicode_ci', + `GeneratingCapacity` DECIMAL(10,4) NOT NULL DEFAULT '0.0000' COMMENT '電廠發電容量,單位(千瓦)', + `PowerRate` DECIMAL(10,4) NOT NULL DEFAULT '0.0000' COMMENT '受電費率', + `Coordinate` VARCHAR(50) NULL DEFAULT NULL COMMENT '座標' COLLATE 'utf8mb4_unicode_ci', + `InverterBrand` VARCHAR(50) NULL DEFAULT NULL COMMENT '逆變器廠牌' COLLATE 'utf8mb4_unicode_ci', + `InverterProductModel` VARCHAR(50) NULL DEFAULT NULL COMMENT '逆變器型號' COLLATE 'utf8mb4_unicode_ci', + `InverterAmount` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '逆變器數量', + `PhotovoltaicPanelBrand` VARCHAR(50) NULL DEFAULT NULL COMMENT '光電板廠牌' COLLATE 'utf8mb4_unicode_ci', + `PhotovoltaicPanelProductModel` VARCHAR(50) NULL DEFAULT NULL COMMENT '光電板型號' COLLATE 'utf8mb4_unicode_ci', + `PhotovoltaicPanelSpecification` VARCHAR(100) NULL DEFAULT NULL COMMENT '光電板規格' COLLATE 'utf8mb4_unicode_ci', + `PhotovoltaicPanelAmount` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '光電板數量', + `BoEFileName` VARCHAR(255) NULL DEFAULT NULL COMMENT '能源局原檔案名' COLLATE 'utf8mb4_unicode_ci', + `BoEFile` VARCHAR(255) NULL DEFAULT NULL COMMENT '能源局檔案' COLLATE 'utf8mb4_unicode_ci', + `BoEDiscountRate` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '能源局折扣率', + `BoEDeviceRegisterNumber` VARCHAR(50) NULL DEFAULT NULL COMMENT '能源局設備登記編號' COLLATE 'utf8mb4_unicode_ci', + `BoERentRatio` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '能源局租金比率,單位(%)', + `BoERegisterPostAt` TIMESTAMP NULL DEFAULT NULL COMMENT '能源局登記發文日期', + `GUINumber` VARCHAR(16) NULL DEFAULT NULL COMMENT '統一編號' COLLATE 'utf8mb4_unicode_ci', + `TPCContractNumber` VARCHAR(50) NULL DEFAULT NULL COMMENT '台電契約編號' COLLATE 'utf8mb4_unicode_ci', + `TPCInvoiceBuyer` VARCHAR(100) NULL DEFAULT NULL COMMENT '台電發票買受人' COLLATE 'utf8mb4_unicode_ci', + `TPCInvoiceAddress` VARCHAR(100) NULL DEFAULT NULL COMMENT '台電發票地址' COLLATE 'utf8mb4_unicode_ci', + `TPCContractAt` TIMESTAMP NULL DEFAULT NULL COMMENT '台電簽約日期', + `TPCSellDeadline` INT(10) UNSIGNED NULL DEFAULT '0' COMMENT '台電售電期限,單位(年)', + `TPCMeterReading` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '台電每期抄錶日', + `TPCPurchaseElectricityAt` TIMESTAMP NULL DEFAULT NULL COMMENT '台電正式購電日', + `TPCSellElectricityAt` TIMESTAMP NULL DEFAULT NULL COMMENT '台電正式售電日', + `TPCMeterNumber` VARCHAR(50) NULL DEFAULT NULL COMMENT '台電電號' COLLATE 'utf8mb4_unicode_ci', + `SolarType` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '電站類型', + `kwh` DECIMAL(10,3) UNSIGNED NOT NULL DEFAULT '0.000', + `Today_kwh` DECIMAL(10,3) UNSIGNED NOT NULL DEFAULT '0.000' COMMENT '今日發電量', + `Total_kwh` DECIMAL(10,3) UNSIGNED NOT NULL DEFAULT '0.000' COMMENT '總發電量', + `today_kwhkwp` DECIMAL(10,3) NULL DEFAULT NULL COMMENT '今日kwhkwp', + `avg_kwhkwp` DECIMAL(10,3) NULL DEFAULT NULL COMMENT '30天平均kwhkwp', + `today_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日金額', + `total_money` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '總金額', + `today_PR` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '電站Pr值', + `avg_PR` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '平均Pr值', + `today_carbon` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '今日減碳量', + `total_carbon` DECIMAL(10,2) NOT NULL COMMENT '總減碳量', + `today_irradiance` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '今日日照度', + `avg_irradiance` DECIMAL(5,2) NULL DEFAULT NULL COMMENT '平均日照度', + `SolarHour` DECIMAL(10,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '總運轉小時', + `SiteDB` VARCHAR(20) NULL DEFAULT NULL COMMENT '電站 DB name: solar_com' COLLATE 'utf8mb4_unicode_ci', + `TodayWeather` VARCHAR(20) NULL DEFAULT NULL COMMENT '今日天氣' COLLATE 'utf8mb4_unicode_ci', + `TodayWeatherTemp` DECIMAL(5,2) UNSIGNED NOT NULL DEFAULT '0.00' COMMENT '今日溫度', + `WeathersStationId` VARCHAR(50) NULL DEFAULT NULL COMMENT '氣象站編號' COLLATE 'utf8mb4_unicode_ci', + `RateOfRain` VARCHAR(50) NULL DEFAULT NULL COMMENT '今日降雨率' COLLATE 'utf8mb4_unicode_ci', + `line_token` VARCHAR(255) NULL DEFAULT NULL COLLATE 'utf8mb4_unicode_ci', + `Estimate_kwh` DECIMAL(10,2) NULL DEFAULT '0.00' COMMENT '預估發電度數', + `EstimateEfficacy` DECIMAL(10,2) NULL DEFAULT '0.00' COMMENT '預估發電效能', + `CreatedBy` INT(10) UNSIGNED NOT NULL COMMENT '建立者', + `CreatedAt` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '建立時間', + `UpdatedBy` INT(10) UNSIGNED NULL DEFAULT NULL COMMENT '修改者', + `UpdatedAt` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改時間', PRIMARY KEY (`Id`) USING BTREE, KEY `IDX_01` (`Deleted`) USING BTREE, KEY `IDX_02` (`CompanyId`) USING BTREE, diff --git a/SolarPower/Repository/Implement/ElectricitySoldRecordRepository.cs b/SolarPower/Repository/Implement/ElectricitySoldRecordRepository.cs index e7ca7e0..3329af4 100644 --- a/SolarPower/Repository/Implement/ElectricitySoldRecordRepository.cs +++ b/SolarPower/Repository/Implement/ElectricitySoldRecordRepository.cs @@ -81,7 +81,7 @@ namespace SolarPower.Repository.Implement BillInfo a = new BillInfo(); try { - var sql = @$"SELECT es.Money,ps.GUINumber,ps.TPCInvoiceBuyer,ps.TPCInvoiceAddress,cp.Name,cp.Logo,ps.Id, + var sql = @$"SELECT es.Money,ps.GUINumber,ps.TPCInvoiceBuyer,ps.TPCInvoiceAddress, ps.TPCMeterNumber,cp.Name,cp.Logo,ps.Id, es.StartAt,es.EndAt,es.Kwh,ps.PowerRate,ps.Name as PowerName FROM electricity_sold_record es LEFT JOIN power_station ps diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 91d0537..d25863a 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -2315,15 +2315,17 @@ namespace SolarPower.Repository.Implement { try { - var sql = $@"SELECT * - FROM {db_name}.device d - WHERE d.PowerStationId = @PowerStationId AND d.`Type` = 'MTR' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0 - UNION - SELECT d.* - FROM {db_name}.sharedevice sd - LEFT JOIN {db_name}.device d ON sd.DeviceId = d.Id - WHERE sd.PowerStationId = @PowerStationId AND d.`Type` = 'MTR' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0 - "; + var sql = $@"SELECT temp.* + FROM (SELECT * + FROM {db_name}.device d + WHERE d.PowerStationId = @PowerStationId AND d.`Type` = 'MTR' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0 + UNION + SELECT d.* + FROM {db_name}.sharedevice sd + LEFT JOIN {db_name}.device d ON sd.DeviceId = d.Id + WHERE sd.PowerStationId = @PowerStationId AND d.`Type` = 'MTR' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0 + ) temp + ORDER BY temp.ColName"; result = (await conn.QueryAsync(sql, new { PowerStationId = powerStationId })).ToList(); } @@ -2342,15 +2344,17 @@ namespace SolarPower.Repository.Implement { try { - var sql = $@"SELECT * - FROM {db_name}.device d - WHERE d.PowerStationId = @PowerStationId AND d.`Type` = '{type}' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0 - UNION - SELECT d.* - FROM {db_name}.sharedevice sd - LEFT JOIN {db_name}.device d ON sd.DeviceId = d.Id - WHERE sd.PowerStationId = @PowerStationId AND d.`Type` = '{type}' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0 - "; + var sql = $@"SELECT temp.* + FROM (SELECT * + FROM {db_name}.device d + WHERE d.PowerStationId = @PowerStationId AND d.`Type` = '{type}' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0 + UNION + SELECT d.* + FROM {db_name}.sharedevice sd + LEFT JOIN {db_name}.device d ON sd.DeviceId = d.Id + WHERE sd.PowerStationId = @PowerStationId AND d.`Type` = '{type}' AND d.Deleted = 0 AND d.Enabled = 1 AND d.Status != 0 + ) temp + ORDER BY temp.ColName"; result = (await conn.QueryAsync(sql, new { PowerStationId = powerStationId })).ToList(); } @@ -2362,17 +2366,32 @@ namespace SolarPower.Repository.Implement } } - public async Task GetPyrheliometerHistoryPerHour(string dateTime, List deviceInfos, int type) + public async Task CalcSensorHistoryPerHour(string dateTime, List deviceInfos, int type) { + SensorTypeEnum SensorTypeEnum = (SensorTypeEnum)type; var typename = ""; - if (type == 1) + switch (SensorTypeEnum) { - typename = "Temperature";//1為溫度計 - } - else if (type == 0) - { - typename = "Irradiance";//0為日照計 + case SensorTypeEnum.PYR: //日照計 + typename = "Irradiance"; + break; + case SensorTypeEnum.MTR: //模組溫度計 + typename = "Temperature"; + break; + case SensorTypeEnum.ETR: //環境溫度計 + typename = "EnvTemperature"; + break; + case SensorTypeEnum.EMM: //環境濕度計 + typename = "Humidity"; + break; + case SensorTypeEnum.VAN: //風速計 + typename = "Vane"; + break; + case SensorTypeEnum.FOM: //落塵計 + typename = "Dust"; + break; } + PyrheliometerHistory result; using (IDbConnection conn = this._databaseHelper.GetConnection()) { @@ -2407,7 +2426,7 @@ namespace SolarPower.Repository.Implement } } - public async Task AddPyrheliometerHistory(List entity, List properties) + public async Task AddSensorHistoryHour(List entity, List properties) { int count; using (IDbConnection conn = _databaseHelper.GetConnection()) @@ -2511,10 +2530,13 @@ namespace SolarPower.Repository.Implement PowerStationId, DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP, AVG(p.Irradiance) AS Irradiance, - AVG(p.Temperature) AS Temperature + AVG(p.Temperature) AS Temperature, + AVG(p.EnvTemperature) AS EnvTemperature, + AVG(p.Humidity) AS Humidity, + AVG(p.Vane) AS Vane, + AVG(p.Dust) AS Dust FROM sensor_history_hour p WHERE DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') = @NowDay - AND p.Irradiance != 0 AND PowerStationId = @PowerStationId GROUP BY DATE_FORMAT(p.TIMESTAMP, '%Y-%m-%d') "; @@ -2575,10 +2597,13 @@ namespace SolarPower.Repository.Implement PowerStationId, DATE_FORMAT(p.TIMESTAMP, '%Y-%m') AS TIMESTAMP, AVG(p.Irradiance) AS Irradiance, - AVG(p.Temperature) AS Temperature + AVG(p.Temperature) AS Temperature, + AVG(p.EnvTemperature) AS EnvTemperature, + AVG(p.Humidity) AS Humidity, + AVG(p.Vane) AS Vane, + AVG(p.Dust) AS Dust FROM sensor_history_hour p WHERE DATE_FORMAT(p.TIMESTAMP, '%Y-%m') = @Month - AND p.Irradiance != 0 AND PowerStationId = @PowerStationId GROUP BY DATE_FORMAT(p.TIMESTAMP, '%Y-%m') "; diff --git a/SolarPower/Repository/Implement/RoleRepository.cs b/SolarPower/Repository/Implement/RoleRepository.cs index b59c0b6..72bfa81 100644 --- a/SolarPower/Repository/Implement/RoleRepository.cs +++ b/SolarPower/Repository/Implement/RoleRepository.cs @@ -132,7 +132,7 @@ namespace SolarPower.Repository.Implement if (!string.IsNullOrEmpty(filter.Name)) { - sql += @" AND Name LIKE CONCAT('%', @Name, '%')"; + sql += @" AND r.Name LIKE CONCAT('%', @Name, '%')"; } result = (await conn.QueryAsync(sql, filter)).ToList(); diff --git a/SolarPower/Repository/Implement/UserRepository.cs b/SolarPower/Repository/Implement/UserRepository.cs index 69f3ee3..fb0a999 100644 --- a/SolarPower/Repository/Implement/UserRepository.cs +++ b/SolarPower/Repository/Implement/UserRepository.cs @@ -267,7 +267,7 @@ namespace SolarPower.Repository.Implement if (!string.IsNullOrEmpty(filter.Name)) { - sql += @" AND Name LIKE CONCAT('%', @Name, '%')"; + sql += @" AND u.Name LIKE CONCAT('%', @Name, '%')"; } if (filter.SelectedRoleId > 0) diff --git a/SolarPower/Repository/Interface/IPowerStationRepository.cs b/SolarPower/Repository/Interface/IPowerStationRepository.cs index 44c244e..a0f1843 100644 --- a/SolarPower/Repository/Interface/IPowerStationRepository.cs +++ b/SolarPower/Repository/Interface/IPowerStationRepository.cs @@ -511,9 +511,9 @@ namespace SolarPower.Repository.Interface Task> GetListPyrheliometerByPowerStationId(int powerStationId, string db_name); Task> GetListTempByPowerStationId(int powerStationId, string db_name); Task> GetDeviceListByPowerStationIdAndType(int powerStationId, string type, string db_name); - Task GetPyrheliometerHistoryPerHour(string dateTime, List deviceInfos, int Type); + Task CalcSensorHistoryPerHour(string dateTime, List deviceInfos, int Type); Task AddTempHistory(List entity, List properties); - Task AddPyrheliometerHistory(List entity, List properties); + Task AddSensorHistoryHour(List entity, List properties); Task CalcAvgPyrheliometerHistory30day(string nowDay, int powerStationId); Task CalcPyrheliometerHistoryDayDataByPowerStationId(string nowDay, int powerStationId); Task AddPyrheliometerHistoryDayList(List entity, List properties); diff --git a/SolarPower/Views/ElectricitySoldRecord/Index.cshtml b/SolarPower/Views/ElectricitySoldRecord/Index.cshtml index 66e59f4..e4b1515 100644 --- a/SolarPower/Views/ElectricitySoldRecord/Index.cshtml +++ b/SolarPower/Views/ElectricitySoldRecord/Index.cshtml @@ -398,7 +398,7 @@ '
' + '' + '
' + - '

' + inverter.powerStationName + '

' + + '
' + inverter.powerStationName + '
' + '' + ''; } @@ -408,7 +408,7 @@ '
' + '' + '
' + - '

' + inverter.powerStationName + '

' + + '
' + inverter.powerStationName + '
' + '' + ''; } diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index 6f99561..7aa745d 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -21,11 +21,11 @@

即時總發電量

-

126,161.72

+

0.00

平均發電量

-

4,069.73

+

0.00

@@ -37,11 +37,11 @@

即時平均日照度

-

126,161.72

+

0.00

平均日照度(30天)

-

4,069.73

+

0.00

@@ -53,11 +53,11 @@

即時平均 PR 值

-

119.04

+

0.00

平均 PR 值(30天)

-

3.84

+

0.00

@@ -69,11 +69,11 @@

即時平均有效日照時數

-

140.39

+

0.00

平均有效日照時數 (30天)

-

4.53

+

0.00

@@ -85,11 +85,11 @@

今日減碳量

-

6,091.78

+

0.00

總減碳量

-

985.98

+

0.00

@@ -119,7 +119,7 @@

電站總數

-

52

+

0

@@ -131,7 +131,7 @@

總裝置容量

-

1288.63

+

0.00

MWp

diff --git a/SolarPower/Views/NoticeSchedule/Index.cshtml b/SolarPower/Views/NoticeSchedule/Index.cshtml index c58a73a..5f8f33c 100644 --- a/SolarPower/Views/NoticeSchedule/Index.cshtml +++ b/SolarPower/Views/NoticeSchedule/Index.cshtml @@ -502,7 +502,7 @@ '
' + '' + '
' + - '

' + inverter.powerStationName + '

' + + '
' + inverter.powerStationName + '
' + '' + ''; } @@ -512,7 +512,7 @@ '
' + '' + '
' + - '

' + inverter.powerStationName + '

' + + '
' + inverter.powerStationName + '
' + '' + ''; } diff --git a/SolarPower/Views/Operation/Index.cshtml b/SolarPower/Views/Operation/Index.cshtml index b3ae91c..8a3d197 100644 --- a/SolarPower/Views/Operation/Index.cshtml +++ b/SolarPower/Views/Operation/Index.cshtml @@ -297,7 +297,7 @@ "info": true, "autoWidth": false, "responsive": true, - "order": [[9, "desc"]], + "order": [[8, "desc"]], "columns": [{ "data": "planId" }, { diff --git a/SolarPower/Views/PowerGeneration/Index.cshtml b/SolarPower/Views/PowerGeneration/Index.cshtml index eb62c43..8ad6541 100644 --- a/SolarPower/Views/PowerGeneration/Index.cshtml +++ b/SolarPower/Views/PowerGeneration/Index.cshtml @@ -416,7 +416,7 @@ '
' + '' + '
' + - '

' + inverter.powerStationName + '

' + + '
' + inverter.powerStationName + '
' + '' + ''; } @@ -426,7 +426,7 @@ '
' + '' + '
' + - '

' + inverter.powerStationName + '

' + + '
' + inverter.powerStationName + '
' + '' + ''; } diff --git a/SolarPower/Views/PowerStation/Index.cshtml b/SolarPower/Views/PowerStation/Index.cshtml index ba45d87..56e1a40 100644 --- a/SolarPower/Views/PowerStation/Index.cshtml +++ b/SolarPower/Views/PowerStation/Index.cshtml @@ -474,7 +474,7 @@ $('#solarTable' + val.cityId).find('tbody').append('' + '' + val.id + '' + '' + val.name + '' + - '' + val.generatingCapacity + '' + + '' + val.generatingCapacity.toFixed(2) + '' + '' + val.inverterAmount + '' + '' + val.electricityMeterAt + '' + '' + diff --git a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml index 8db507f..6b24bfd 100644 --- a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml +++ b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml @@ -128,24 +128,26 @@ if (stationId == 'new') { //#region 電站基本資料 $("#address_detail_text").hide(); + $("#select_solar_tpye").attr('disabled', false); + $("#power_station_code_text").hide(); $("#power_station_name_text").hide(); - $("#electricity_meter_at_text").hide(); - $("#estimated_recovery_time_text").hide(); - $("#created_by_title").hide(); - $("#created_by_text").hide(); + $("#check_escrow").attr('disabled', false); + $("#escrow_name_text").hide(); $("#generating_capacity_text").hide(); - $("#escrow_name_text").hide(); - $("#power_rate_text").hide(); + $("#estimate_efficacy_text").hide(); + $("#estimate_kwh_text").hide(); + $("#estimated_recovery_time_text").hide(); + $("#coordinate_text").hide(); + $("#line_token_text").hide(); + + $("#created_by_title").hide(); + $("#created_by_text").hide(); $("#created_at_title").hide(); $("#created_at_text").hide(); - $("#line_token_text").hide(); - $("#estimate_kwh_text").hide(); - $("#estimate_efficacy_text").hide(); - //逆變器 $("#inverter_brand_text").hide(); @@ -161,9 +163,7 @@ $("#edit-station-info-btn").hide(); $("#canecl-station-info-btn").hide(); - $("#check_escrow").attr('disabled', false); - $("#select_solar_tpye").attr('disabled', false); @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser) { @@ -743,6 +743,9 @@ return data; } + }, + "error": function (xhr, error, thrown) { + console.log(xhr); } }); @@ -1037,18 +1040,18 @@ cancelButtonText: "否" }).then(function (result) { if (result.value) { - PostPowerStationDate(); + PostPowerStationData(); } }); } else { - PostPowerStationDate(); + PostPowerStationData(); } } else { - PostPowerStationDate(); + PostPowerStationData(); } @@ -1056,7 +1059,7 @@ } //#endregion - function PostPowerStationDate() { + function PostPowerStationData() { var url = "/PowerStation/SavePowerStationInfo"; var send_data = { @@ -1066,7 +1069,6 @@ Address: $("#address_detail").val(), Name: $("#power_station_name").val(), IsEscrow: $('#check_escrow').is(':checked') ? 1 : 0, - ElectricityMeterAt: $("#electricity_meter_at").val(), EstimatedRecoveryTime: $("#estimated_recovery_time").val(), GeneratingCapacity: $("#generating_capacity").val(), EscrowName: $('#check_escrow').is(':checked') ? $("#escrow_name").val() : "", @@ -1119,13 +1121,20 @@ } formData.append("BoEDiscountRate", $("#BoE_discount_rate").val()); formData.append("BoEDeviceRegisterNumber", $("#BoE_device_register_number").val()); - formData.append("BoERentRatio", $("#BoE_rent_ratio").val()); + formData.append("BoERegisterPostAt", $("#BoE_register_post_at").val()); + @*formData.append("BoERentRatio", $("#BoE_rent_ratio").val());*@ formData.append("TPCContractNumber", $("#TPC_contract_number").val()); formData.append("TPCContractAt", $("#TPC_contract_at").val()); formData.append("TPCSellDeadline", $("#TPC_sell_deadline").val()); - formData.append("TPCMeterReading", $("#TPC_meter_reading").val()); - formData.append("TPCPurchaseElectricityAt", $("#TPC_purchase_electricity_at").val()); + formData.append("ElectricityMeterAt", $("#electricity_meter_at").val()); + formData.append("PowerRate", $("#power_rate").val()); + @*formData.append("TPCMeterReading", $("#TPC_meter_reading").val());*@ + @*formData.append("TPCPurchaseElectricityAt", $("#TPC_purchase_electricity_at").val());*@ formData.append("TPCSellElectricityAt", $("#TPC_sell_electricity_at").val()); + formData.append("TPCInvoiceBuyer", $("#TPC_invoice_buyer").val()); + formData.append("GUINumber", $("#GUI_number").val()); + formData.append("TPCInvoiceAddress", $("#TPC_invoice_address").val()); + formData.append("TPCMeterNumber", $("#TPC_meter_number").val()); $.ajax({ type: "POST", @@ -1192,24 +1201,24 @@ //#region 電站基本資料 文字 $("#address_detail_text").show(); + $("#power_station_code_text").show(); $("#power_station_name_text").show(); - $("#electricity_meter_at_text").show(); - $("#estimated_recovery_time_text").show(); - $("#created_by_title").show(); - $("#created_by_text").show(); + $("#escrow_name_text").show(); $("#generating_capacity_text").show(); - $("#escrow_name_text").show(); - $("#power_rate_text").show(); + $("#estimate_efficacy_text").show(); + $("#estimate_kwh_text").show(); + $("#estimated_recovery_time_text").show(); + $("#coordinate_text").show(); + $("#line_token_text").show(); + + $("#created_by_title").show(); + $("#created_by_text").show(); $("#created_at_title").show(); $("#created_at_text").show(); - $("#line_token_text").show(); - $("#estimate_kwh_text").show(); - $("#estimate_efficacy_text").show(); - //逆變器 $("#inverter_brand_text").show(); $("#inverter_product_model_text").show(); @@ -1226,22 +1235,21 @@ $("#select_city").attr("disabled", true); $("#select_area").attr("disabled", true); $("#address_detail").hide(); - $("#power_station_name").hide(); - $("#check_escrow").attr("disabled", true); - $("#electricity_meter_at").hide(); - $("#estimated_recovery_time").hide(); - $("#select_solar_tpye").attr("disabled", true); - $("#generating_capacity").hide(); + $("#power_station_name").hide(); + $("#check_escrow").attr("disabled", true); $("#escrow_name").hide(); - $("#power_rate").hide(); - $("#coordinate").hide(); - $("#power_station_operation_personnel").attr("disabled", true); - $("#line_token").hide(); + $("#generating_capacity").hide(); $("#estimate_kwh").hide(); $("#estimate_efficacy").hide(); + $("#estimated_recovery_time").hide(); + + $("#power_station_operation_personnel").attr("disabled", true); + + $("#coordinate").hide(); + $("#line_token").hide(); @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser) { @@ -1282,6 +1290,7 @@ //#region 電站基本資料 文字 $("#address_detail_text").hide(); + $("#power_station_name_text").hide(); $("#electricity_meter_at_text").hide(); $("#estimated_recovery_time_text").hide(); @@ -1315,17 +1324,20 @@ $("#select_city").attr("disabled", true); $("#select_area").attr("disabled", true); $("#address_detail").show(); - $("#power_station_name").show(); - $("#check_escrow").attr("disabled", false); - $("#electricity_meter_at").show(); - $("#estimated_recovery_time").show(); - $("#select_solar_tpye").attr("disabled", false); - $("#generating_capacity").show(); + $("#power_station_name").show(); + $("#check_escrow").attr("disabled", false); $("#escrow_name").show(); - $("#power_rate").show(); + + $("#generating_capacity").show(); + $("#estimate_kwh").show(); + $("#estimate_efficacy").show(); + $("#estimated_recovery_time").show(); + $("#coordinate").show(); + $("#line_token").show(); + $("#power_station_operation_personnel").attr("disabled", false); $("#power_station_operation_personnel > option").each(function () { @@ -1361,11 +1373,6 @@ }); }); - - $("#line_token").show(); - $("#estimate_kwh").show(); - $("#estimate_efficacy").show(); - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser) { @@ -1407,16 +1414,23 @@ //觀看 //#region 能源局與台電資料 文字 $("#link-boe-file").show(); - $("#BoE_discount_rate_text").show(); + @*$("#BoE_discount_rate_text").show();*@ + @*$("#BoE_rent_ratio_text").show();*@ + $("#BoE_register_post_at_text").show(); $("#BoE_device_register_number_text").show(); - $("#BoE_rent_ratio_text").show(); $("#TPC_contract_number_text").show(); $("#TPC_contract_at_text").show(); $("#TPC_sell_deadline_text").show(); - $("#TPC_meter_reading_text").show(); - $("#TPC_purchase_electricity_at_text").show(); + $("#electricity_meter_at_text").show(); + $("#power_rate_text").show(); $("#TPC_sell_electricity_at_text").show(); + $("#TPC_invoice_buyer_text").show(); + $("#GUI_number_text").show(); + $("#TPC_invoice_address_text").show(); + $("#TPC_meter_number_text").show(); + @*$("#TPC_meter_reading_text").show();*@ + @*$("#TPC_purchase_electricity_at_text").show();*@ $("#BOE_TPC_created_by_title").show(); $("#BOE_TPC_created_by_text").show(); @@ -1426,16 +1440,23 @@ //#region 能源局與台電資料 input $("#BoE_file").hide(); - $("#BoE_discount_rate").hide(); + $("#BoE_register_post_at").hide(); $("#BoE_device_register_number").hide(); - $("#BoE_rent_ratio").hide(); + @*$("#BoE_discount_rate").hide();*@ + @*$("#BoE_rent_ratio").hide();*@ $("#TPC_contract_number").hide(); $("#TPC_contract_at").hide(); $("#TPC_sell_deadline").hide(); - $("#TPC_meter_reading").hide(); - $("#TPC_purchase_electricity_at").hide(); + $("#electricity_meter_at").hide(); + $("#power_rate").hide(); $("#TPC_sell_electricity_at").hide(); + $("#TPC_invoice_buyer").hide(); + $("#GUI_number").hide(); + $("#TPC_invoice_address").hide(); + $("#TPC_meter_number").hide(); + @*$("#TPC_meter_reading").hide();*@ + @*$("#TPC_purchase_electricity_at").hide();*@ //#endregion //#region 能源局與台電btn @@ -1447,16 +1468,21 @@ //修改 //#region 能源局與台電資料 文字 $("#link-boe-file").hide(); - $("#BoE_discount_rate_text").hide(); + @*$("#BoE_discount_rate_text").hide();*@ + $("#BoE_register_post_at_text").hide(); $("#BoE_device_register_number_text").hide(); - $("#BoE_rent_ratio_text").hide(); + @*$("#BoE_rent_ratio_text").hide();*@ $("#TPC_contract_number_text").hide(); $("#TPC_contract_at_text").hide(); $("#TPC_sell_deadline_text").hide(); - $("#TPC_meter_reading_text").hide(); - $("#TPC_purchase_electricity_at_text").hide(); + $("#electricity_meter_at_text").hide(); + $("#power_rate_text").hide(); $("#TPC_sell_electricity_at_text").hide(); + $("#TPC_invoice_buyer_text").hide(); + $("#GUI_number_text").hide(); + $("#TPC_invoice_address_text").hide(); + $("#TPC_meter_number_text").hide(); $("#BOE_TPC_created_by_title").hide(); $("#BOE_TPC_created_by_text").hide(); @@ -1466,16 +1492,21 @@ //#region 能源局與台電資料 input $("#BoE_file").show(); - $("#BoE_discount_rate").show(); + @*$("#BoE_discount_rate").show();*@ + $("#BoE_register_post_at").show(); $("#BoE_device_register_number").show(); - $("#BoE_rent_ratio").show(); + @*$("#BoE_rent_ratio").show();*@ $("#TPC_contract_number").show(); $("#TPC_contract_at").show(); $("#TPC_sell_deadline").show(); - $("#TPC_meter_reading").show(); - $("#TPC_purchase_electricity_at").show(); + $("#electricity_meter_at").show(); + $("#power_rate").show(); $("#TPC_sell_electricity_at").show(); + $("#TPC_invoice_buyer").show(); + $("#GUI_number").show(); + $("#TPC_invoice_address").show(); + $("#TPC_meter_number").show(); //#endregion //#region 能源局與台電btn @@ -1490,12 +1521,12 @@ //觀看 //#region 土地房屋資料 文字 $("#land_building_address_text_" + selectedLandBuildingId).show(); - $("#land_building_coordinate_text_" + selectedLandBuildingId).show(); + @*$("#land_building_coordinate_text_" + selectedLandBuildingId).show();*@ $("#lease_notarization_at_text_" + selectedLandBuildingId).show(); $("#land_building_lease_Rate_text_" + selectedLandBuildingId).show(); $("#land_building_landowner_text_" + selectedLandBuildingId).show(); - $("#land_building_phone_text_" + selectedLandBuildingId).show(); - $("#land_building_purpose_text_" + selectedLandBuildingId).show(); + @*$("#land_building_phone_text_" + selectedLandBuildingId).show();*@ + @*$("#land_building_purpose_text_" + selectedLandBuildingId).show();*@ $("#land_building_created_by_title_" + selectedLandBuildingId).show(); $("#land_building_created_by_text_" + selectedLandBuildingId).show(); $("#land_building_created_at_title_" + selectedLandBuildingId).show(); @@ -1504,12 +1535,12 @@ //#region 土地房屋資料 input $("#land_building_address_" + selectedLandBuildingId).hide(); - $("#land_building_coordinate_" + selectedLandBuildingId).hide(); + @*$("#land_building_coordinate_" + selectedLandBuildingId).hide();*@ $("#lease_notarization_at_" + selectedLandBuildingId).hide(); $("#land_building_lease_Rate_" + selectedLandBuildingId).hide(); $("#land_building_landowner_" + selectedLandBuildingId).hide(); - $("#land_building_phone_" + selectedLandBuildingId).hide(); - $("#land_building_purpose_" + selectedLandBuildingId).hide(); + @*$("#land_building_phone_" + selectedLandBuildingId).hide();*@ + @*$("#land_building_purpose_" + selectedLandBuildingId).hide();*@ //#endregion //#region 土地房屋資料 btn @@ -1522,12 +1553,12 @@ //修改 //#region 土地房屋資料 文字 $("#land_building_address_text_" + selectedLandBuildingId).hide(); - $("#land_building_coordinate_text_" + selectedLandBuildingId).hide(); + @*$("#land_building_coordinate_text_" + selectedLandBuildingId).hide();*@ $("#lease_notarization_at_text_" + selectedLandBuildingId).hide(); $("#land_building_lease_Rate_text_" + selectedLandBuildingId).hide(); $("#land_building_landowner_text_" + selectedLandBuildingId).hide(); - $("#land_building_phone_text_" + selectedLandBuildingId).hide(); - $("#land_building_purpose_text_" + selectedLandBuildingId).hide(); + @*$("#land_building_phone_text_" + selectedLandBuildingId).hide();*@ + @*$("#land_building_purpose_text_" + selectedLandBuildingId).hide();*@ $("#land_building_created_by_title_" + selectedLandBuildingId).hide(); $("#land_building_created_by_text_" + selectedLandBuildingId).hide(); $("#land_building_created_at_title_" + selectedLandBuildingId).hide(); @@ -1536,12 +1567,12 @@ //#region 土地房屋資料 input $("#land_building_address_" + selectedLandBuildingId).show(); - $("#land_building_coordinate_" + selectedLandBuildingId).show(); + @*$("#land_building_coordinate_" + selectedLandBuildingId).show();*@ $("#lease_notarization_at_" + selectedLandBuildingId).show(); $("#land_building_lease_Rate_" + selectedLandBuildingId).show(); $("#land_building_landowner_" + selectedLandBuildingId).show(); - $("#land_building_phone_" + selectedLandBuildingId).show(); - $("#land_building_purpose_" + selectedLandBuildingId).show(); + @*$("#land_building_phone_" + selectedLandBuildingId).show();*@ + @*$("#land_building_purpose_" + selectedLandBuildingId).show();*@ //#endregion //#region 土地房屋資料 btn @@ -1590,13 +1621,12 @@ $("#address_detail_text").html(powerStationData.address); $("#power_station_code_text").html(powerStationData.code); $("#power_station_name_text").html(powerStationData.name); - $("#electricity_meter_at_text").html(powerStationData.electricityMeterAt); + $("#estimated_recovery_time_text").html(powerStationData.estimatedRecoveryTime); $("#created_by_text").html(powerStationData.creatorName); $("#generating_capacity_text").html(powerStationData.generatingCapacity); $("#escrow_name_text").html(powerStationData.escrowName); - $("#power_rate_text").html(powerStationData.powerRate); $("#coordinate_text").html(powerStationData.coordinate); $("#created_at_text").html(powerStationData.createdAt); $("#power_station_operation_personnel").val(powerStationData.operationPersonnelIds).trigger("change"); @@ -1654,31 +1684,46 @@ function SetBoETPCInfo() { //#region 能源局與台電資料 文字 $("#link-boe-file").html(powerStationData.boEFileName).attr("href", powerStationData.boEFile); - $("#BoE_discount_rate_text").html(powerStationData.boEDiscountRate); + @*$("#BoE_discount_rate_text").html(powerStationData.boEDiscountRate);*@ + $("#BoE_register_post_at_text").html(powerStationData.boERegisterPostAt); $("#BoE_device_register_number_text").html(powerStationData.boEDeviceRegisterNumber); - $("#BoE_rent_ratio_text").html(powerStationData.boERentRatio); + @*$("#BoE_rent_ratio_text").html(powerStationData.boERentRatio);*@ $("#TPC_contract_number_text").html(powerStationData.tpcContractNumber); $("#TPC_contract_at_text").html(powerStationData.tpcContractAt); $("#TPC_sell_deadline_text").html(powerStationData.tpcSellDeadline); + $("#electricity_meter_at_text").html(powerStationData.electricityMeterAt); + $("#power_rate_text").html(powerStationData.powerRate); $("#TPC_meter_reading_text").html(powerStationData.tpcMeterReading); $("#TPC_purchase_electricity_at_text").html(powerStationData.tpcPurchaseElectricityAt); $("#TPC_sell_electricity_at_text").html(powerStationData.tpcSellElectricityAt); + $("#TPC_invoice_buyer_text").html(powerStationData.tpcInvoiceBuyer); + $("#GUI_number_text").html(powerStationData.guiNumber); + $("#TPC_invoice_address_text").html(powerStationData.tpcInvoiceAddress); + $("#TPC_meter_number_text").html(powerStationData.tpcMeterNumber); + $("#BOE_TPC_created_by_text").html(powerStationData.creatorName); $("#BOE_TPC_created_at_text").html(powerStationData.createdAt); //#endregion //#region 能源局與台電資料 input - $("#BoE_discount_rate").val(powerStationData.boEDiscountRate); + @*$("#BoE_discount_rate").val(powerStationData.boEDiscountRate);*@ + $("#BoE_register_post_at").val(powerStationData.boERegisterPostAt); $("#BoE_device_register_number").val(powerStationData.boEDeviceRegisterNumber); - $("#BoE_rent_ratio").val(powerStationData.boERentRatio); + @*$("#BoE_rent_ratio").val(powerStationData.boERentRatio);*@ $("#TPC_contract_number").val(powerStationData.tpcContractNumber); $("#TPC_contract_at").val(powerStationData.tpcContractAt); $("#TPC_sell_deadline").val(powerStationData.tpcSellDeadline); + $("#electricity_meter_at").val(powerStationData.electricityMeterAt); + $("#power_rate").val(powerStationData.powerRate); $("#TPC_meter_reading").val(powerStationData.tpcMeterReading); $("#TPC_purchase_electricity_at").val(powerStationData.tpcPurchaseElectricityAt); $("#TPC_sell_electricity_at").val(powerStationData.tpcSellElectricityAt); + $("#TPC_invoice_buyer").val(powerStationData.tpcInvoiceBuyer); + $("#GUI_number").val(powerStationData.guiNumber); + $("#TPC_invoice_address").val(powerStationData.tpcInvoiceAddress); + $("#TPC_meter_number").val(powerStationData.tpcMeterNumber); //#endregion } //#endregion @@ -1744,12 +1789,19 @@ '' + '' + '
' + + '' + + '
' + + '' + + '' + + '
' + + '
' + + @*'
' + '' + '
' + '' + '' + '
' + - '
' + + '' +*@ '' + '
' + '
' + @@ -1759,38 +1811,31 @@ '' + '
' + '
' + - '
' + - '' + - '
' + - '' + - '' + - '
' + - '
' + '' + '
' + '
' + - '' + + '' + '
' + '' + '' + '
' + '
' + - '
' + + @*'
' + '' + '
' + '' + '' + '
' + - '
' + + '
' +*@ '
' + '
' + - '
' + + @*'
' + '' + '
' + '' + '' + '
' + - '
' + + '
' +*@ '
' + '
' + '
' + @@ -1846,11 +1891,17 @@ '
' + '
' + '
' + + '' + + '
' + + '' + + '
' + + '
' + + @*'
' + '' + '
' + '' + '
' + - '
' + + '' +*@ '' + '
' + '
' + @@ -1859,34 +1910,28 @@ '' + '
' + '
' + - '
' + - '' + - '
' + - '' + - '
' + - '
' + '' + '
' + '
' + - '' + + '' + '
' + '' + '
' + '
' + - '
' + + @*'
' + '' + '
' + '' + '
' + - '
' + + '
' +*@ '
' + '
' + - '
' + + @*'
' + '' + '
' + '' + '
' + - '
' + + '
' +*@ '
' + '
' + '
' + diff --git a/SolarPower/Views/PowerStation/_StationInfo.cshtml b/SolarPower/Views/PowerStation/_StationInfo.cshtml index 528e8a1..8f9d8ce 100644 --- a/SolarPower/Views/PowerStation/_StationInfo.cshtml +++ b/SolarPower/Views/PowerStation/_StationInfo.cshtml @@ -90,37 +90,45 @@
- +
- - + +
- +
- - + +
- + +
+ + +
+
+
+
-
- -
- - -
-
-
+
-
- -
- - -
-
+
-
- -
- - -
-
-
+ +
@@ -228,10 +220,13 @@
-
+
+
+ mm +
@@ -284,11 +279,18 @@
+ @*
+ +
+ + +
+
*@
- +
- - + +
@@ -298,13 +300,13 @@
-
- -
- - -
-
+ @*
+ +
+ + +
+
*@
@@ -331,18 +333,34 @@
+ @*
+ +
+ + +
+
*@ + @*
+ +
+ + +
+
*@
- +
- - + +
- +
- - + +
@@ -352,6 +370,42 @@
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index 5a774c9..dee90d7 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -1731,17 +1731,16 @@ $("#city_name_text").html(powerStationData.cityName); $("#area_name_text").html(powerStationData.areaName); $("#address_detail_text").html(powerStationData.address); + $("#power_station_code_text").html(powerStationData.code); $("#power_station_name_text").html(powerStationData.name); - $("#electricity_meter_at_text").html(powerStationData.electricityMeterAt); - $("#estimated_recovery_time_text").html(powerStationData.estimatedRecoveryTime); - $("#created_by_text").html(powerStationData.creatorName); - - $("#generating_capacity_text").html(powerStationData.generatingCapacity); $("#escrow_name_text").html(powerStationData.escrowName); - $("#power_rate_text").html(powerStationData.powerRate); + $("#created_by_text").html(powerStationData.creatorName); + + $("#generating_capacity_text").html(powerStationData.generatingCapacity); + $("#estimated_recovery_time_text").html(powerStationData.estimatedRecoveryTime); + $("#coordinate_text").html(powerStationData.coordinate); - $("#created_at_text").html(powerStationData.createdAt); $("#power_station_operation_personnel").val(powerStationData.operationPersonnelIds).trigger("change"); $("#power_station_operation_personnel").attr("disabled", true); @@ -1749,6 +1748,7 @@ $("#estimate_kwh_text").html(powerStationData.estimate_kwh); $("#estimate_efficacy_text").html(powerStationData.estimateEfficacy); + $("#created_at_text").html(powerStationData.createdAt); @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformUser) { @@ -1785,16 +1785,23 @@ //#region 設定能源局與台電資料 function SetBoETPCInfo() { $("#link-boe-file").html(powerStationData.boEFileName).attr("href", powerStationData.boEFile); - $("#BoE_discount_rate_text").html(powerStationData.boEDiscountRate); + @*$("#BoE_discount_rate_text").html(powerStationData.boEDiscountRate);*@ + $("#BoE_register_post_at_text").html(powerStationData.boERegisterPostAt); $("#BoE_device_register_number_text").html(powerStationData.boEDeviceRegisterNumber); - $("#BoE_rent_ratio_text").html(powerStationData.boERentRatio); + @*$("#BoE_rent_ratio_text").html(powerStationData.boERentRatio);*@ $("#TPC_contract_number_text").html(powerStationData.tpcContractNumber); $("#TPC_contract_at_text").html(powerStationData.tpcContractAt); $("#TPC_sell_deadline_text").html(powerStationData.tpcSellDeadline); + $("#electricity_meter_at_text").html(powerStationData.electricityMeterAt); + $("#power_rate_text").html(powerStationData.powerRate); $("#TPC_meter_reading_text").html(powerStationData.tpcMeterReading); $("#TPC_purchase_electricity_at_text").html(powerStationData.tpcPurchaseElectricityAt); $("#TPC_sell_electricity_at_text").html(powerStationData.tpcSellElectricityAt); + $("#TPC_invoice_buyer_text").html(powerStationData.tpcInvoiceBuyer); + $("#GUI_number_text").html(powerStationData.guiNumber); + $("#TPC_invoice_address_text").html(powerStationData.tpcInvoiceAddress); + $("#TPC_meter_number_text").html(powerStationData.tpcMeterNumber); $("#BOE_TPC_created_by_text").html(powerStationData.creatorName); $("#BOE_TPC_created_at_text").html(powerStationData.createdAt); } @@ -1825,7 +1832,7 @@ var appendStr = ""; appendStr += '
' + - '
' + + '
' + '
土地房屋資料
' + '
'; @@ -1839,11 +1846,17 @@ '
' + '
' + '
' + + '' + + '
' + + '' + + '
' + + '
' + + @*'
' + '' + '
' + '' + '
' + - '
' + + '
' +*@ '
' + '
' + '
' + @@ -1852,34 +1865,29 @@ '' + '
' + '
' + - '
' + - '' + - '
' + - '' + - '
' + - '
' + + '' + '
' + '
' + - '' + + '' + '
' + '' + '
' + '
' + - '
' + + @*'
' + '' + '
' + '' + '
' + - '
' + + '
' +*@ '
' + '
' + - '
' + + @*'
' + '' + '
' + '' + '
' + - '
' + + '
' +*@ '
' + '
' + '
' + diff --git a/SolarPower/Views/StationOverview/_Info.cshtml b/SolarPower/Views/StationOverview/_Info.cshtml index d8133c8..c8228d1 100644 --- a/SolarPower/Views/StationOverview/_Info.cshtml +++ b/SolarPower/Views/StationOverview/_Info.cshtml @@ -70,35 +70,43 @@
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
-
- -
+
+ +
@@ -115,29 +123,14 @@
-
- -
- -
-
-
- -
- -
-
-
-
@@ -251,16 +253,30 @@
+ @*
+ +
+ +
+
+
+ +
+ +
+
*@
- +
- +
- +
- +
@@ -269,6 +285,38 @@
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
diff --git a/SolarPower/Views/StationReport/Index.cshtml b/SolarPower/Views/StationReport/Index.cshtml index 33b94ed..6d9f426 100644 --- a/SolarPower/Views/StationReport/Index.cshtml +++ b/SolarPower/Views/StationReport/Index.cshtml @@ -614,7 +614,7 @@ '
' + '' + '
' + - '

' + inverter.powerStationName + '

' + + '
' + inverter.powerStationName + '
' + '
' + ''; } @@ -624,7 +624,7 @@ '
' + '' + '
' + - '

' + inverter.powerStationName + '

' + + '
' + inverter.powerStationName + '
' + '
' + ''; } diff --git a/SolarPower/wwwroot/upload/power_station/boe_file/20210825094522.pdf b/SolarPower/wwwroot/upload/power_station/boe_file/20210825094522.pdf new file mode 100644 index 0000000..96fcfb5 Binary files /dev/null and b/SolarPower/wwwroot/upload/power_station/boe_file/20210825094522.pdf differ