diff --git a/SolarPower/Controllers/AnalysisInverterController.cs b/SolarPower/Controllers/AnalysisInverterController.cs index 5676990..2539ff3 100644 --- a/SolarPower/Controllers/AnalysisInverterController.cs +++ b/SolarPower/Controllers/AnalysisInverterController.cs @@ -914,7 +914,14 @@ namespace SolarPower.Controllers } catch (Exception exception) { - apiResult.Code = "9999"; + if(exception.Message == "Fatal error encountered during command execution.") + { + apiResult.Code = "9984"; + } + else + { + apiResult.Code = "9999"; + } Logger.LogError("【" + controllerName + "/" + actionName + "】"); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); } diff --git a/SolarPower/Controllers/ElectricitySoldRecordController.cs b/SolarPower/Controllers/ElectricitySoldRecordController.cs index 0349c60..7d5b574 100644 --- a/SolarPower/Controllers/ElectricitySoldRecordController.cs +++ b/SolarPower/Controllers/ElectricitySoldRecordController.cs @@ -46,7 +46,7 @@ namespace SolarPower.Controllers where_entities.Add("Filter", filter); } - //抓出 除了自建自用 + var temp_solarType_where = $@" ps.SolarType != 2"; where.Add(temp_solarType_where); diff --git a/SolarPower/Controllers/MyBaseController.cs b/SolarPower/Controllers/MyBaseController.cs index 31afcb1..8556edb 100644 --- a/SolarPower/Controllers/MyBaseController.cs +++ b/SolarPower/Controllers/MyBaseController.cs @@ -177,7 +177,7 @@ namespace SolarPower.Controllers myUser.myPowerStationGroupByCities = myPowerStations; ViewBag.myPowerStationGroupByCities = myPowerStations; - if (controllerName == "PowerStation" && actionName == "Edit") + if (controllerName == "StationOverview" && actionName == "Info") { //電站資訊的各電站 string stationId_param = filterContext.HttpContext.Request.Query["stationId"]; diff --git a/SolarPower/Controllers/PowerGenerationController.cs b/SolarPower/Controllers/PowerGenerationController.cs index 86c1cca..8afaaf4 100644 --- a/SolarPower/Controllers/PowerGenerationController.cs +++ b/SolarPower/Controllers/PowerGenerationController.cs @@ -47,7 +47,7 @@ namespace SolarPower.Controllers where_entities.Add("Filter", filter); } - var temp_solartype_where = @" ps.SolarType = 0"; + var temp_solartype_where = @" ps.SolarType != 2"; where.Add(temp_solartype_where); var powerStations = myPowerStationService.GetMyPowerStations(myUser, 1, null, where, where_entities); diff --git a/SolarPower/Controllers/StationReportController.cs b/SolarPower/Controllers/StationReportController.cs index 755f851..b5d7f5a 100644 --- a/SolarPower/Controllers/StationReportController.cs +++ b/SolarPower/Controllers/StationReportController.cs @@ -420,7 +420,7 @@ namespace SolarPower.Controllers "日發電量(kWh)", "日發電量百分比(%)", "日照小時(hr)", - "kWH/kWP", + "有效發電小時", "PR%", "日平均日照度(W/㎡)", "日平均模組溫度(°C)" @@ -518,7 +518,7 @@ namespace SolarPower.Controllers cell.CellStyle = styleLine12; index++; cell = row.CreateCell(index); - cell.SetCellValue("kWH/kWP平均(日)"); + cell.SetCellValue("平均有效發電小時(日)"); cell.CellStyle = styleLine12; index++; cell = row.CreateCell(index); @@ -666,7 +666,7 @@ namespace SolarPower.Controllers "月發電量(kWh)", "月發電量百分比(%)", "日照小時(hr)", - "kWH/kWP", + "有效發電小時", "PR%", "月平均日照度(W/㎡)", "月平均模組溫度(°C)" @@ -764,7 +764,7 @@ namespace SolarPower.Controllers cell.CellStyle = styleLine12; index++; cell = row.CreateCell(index); - cell.SetCellValue("kWH/kWP平均(月)"); + cell.SetCellValue("平均有效發電小時(月)"); cell.CellStyle = styleLine12; index++; cell = row.CreateCell(index); @@ -1141,7 +1141,7 @@ namespace SolarPower.Controllers index = 0; row = sheet.CreateRow(RowPosition); cell = row.CreateCell(index); - cell.SetCellValue("kWH/kWP:"); + cell.SetCellValue("有效發電小時:"); cell.CellStyle = styleLine12; cell = row.CreateCell(1); cell.SetCellValue(!string.IsNullOrEmpty(kWhkwp) ? Convert.ToDouble(kWhkwp) : 0); @@ -1220,7 +1220,7 @@ namespace SolarPower.Controllers "日發電量(kWh)", "日發電量百分比(%)", "日照小時(hr)", - "kWH/kWP", + "有效發電小時", "PR%", "日平均日照度(W/㎡)", "日平均模組溫度(°C)" @@ -1574,7 +1574,7 @@ namespace SolarPower.Controllers index++; cell = row.CreateCell(index); - cell.SetCellValue(Math.Round(form.SolarHour,2)); + cell.SetCellValue(Math.Round(form.AvgKWHKWP,2)); cell.CellStyle = styleLine12; index++; @@ -1634,7 +1634,8 @@ namespace SolarPower.Controllers City = form.CityName, Count = 1, Kwh = form.Kwh, - SolarHour = form.SolarHour + SolarHour = form.SolarHour, + Kwhkwp = form.AvgKWHKWP }; if( cityArrays.Where(a=>a.City == form.CityName).Count() > 0) { @@ -1642,6 +1643,7 @@ namespace SolarPower.Controllers city.Count += cityinfo.Count; city.Kwh += cityinfo.Kwh; city.SolarHour += cityinfo.SolarHour; + city.Kwhkwp += cityinfo.Kwhkwp; } else { @@ -1659,7 +1661,7 @@ namespace SolarPower.Controllers "區域", "電站名稱", "發電量", - "發電小時", + "有效發電小時", "平均日照", "PR" }; @@ -1708,7 +1710,7 @@ namespace SolarPower.Controllers index++; cell = row.CreateCell(index); - cell.SetCellValue(Math.Round((cityArray.SolarHour / cityArray.Count), 2)); + cell.SetCellValue(Math.Round((cityArray.Kwhkwp / cityArray.Count), 2)); cell.CellStyle = styleLine12; region = new CellRangeAddress(cityRowPosition, cityRowPosition, index, index + 1); sheet.AddMergedRegion(region); @@ -1742,7 +1744,7 @@ namespace SolarPower.Controllers index++; cell = row.CreateCell(index); - cell.SetCellValue("發電時間(小時)"); + cell.SetCellValue("有效發電小時"); cell.CellStyle = styleLine12; region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1); sheet.AddMergedRegion(region); @@ -1919,7 +1921,7 @@ namespace SolarPower.Controllers index++; cell = row.CreateCell(index); - cell.SetCellValue(Math.Round(form.SolarHour, 2)); + cell.SetCellValue(Math.Round(form.AvgKWHKWP, 2)); cell.CellStyle = styleLine12; index++; @@ -1979,7 +1981,8 @@ namespace SolarPower.Controllers City = form.CityName, Count = 1, Kwh = form.Kwh, - SolarHour = form.SolarHour + SolarHour = form.SolarHour, + Kwhkwp = form.AvgKWHKWP }; if (cityArrays.Where(a => a.City == form.CityName).Count() > 0) { @@ -1987,6 +1990,7 @@ namespace SolarPower.Controllers city.Count += cityinfo.Count; city.Kwh += cityinfo.Kwh; city.SolarHour += cityinfo.SolarHour; + city.Kwhkwp += cityinfo.Kwhkwp; } else { @@ -2004,7 +2008,7 @@ namespace SolarPower.Controllers "區域", "電站名稱", "發電量", - "發電小時", + "有效發電小時", "平均日照", "PR" }; @@ -2053,7 +2057,7 @@ namespace SolarPower.Controllers index++; cell = row.CreateCell(index); - cell.SetCellValue(Math.Round((cityArray.SolarHour / cityArray.Count), 2)); + cell.SetCellValue(Math.Round((cityArray.Kwhkwp / cityArray.Count), 2)); cell.CellStyle = styleLine12; region = new CellRangeAddress(cityRowPosition, cityRowPosition, index, index + 1); sheet.AddMergedRegion(region); @@ -2087,7 +2091,7 @@ namespace SolarPower.Controllers index++; cell = row.CreateCell(index); - cell.SetCellValue("發電時間(小時)"); + cell.SetCellValue("有效發電小時"); cell.CellStyle = styleLine12; region = new CellRangeAddress(RowPosition, RowPosition, index, index + 1); sheet.AddMergedRegion(region); @@ -2182,6 +2186,46 @@ namespace SolarPower.Controllers return Path.Combine("\\" + "upload", "report", Datename, "FIC太陽能監控平台" + "_" + "綜合報表" + "_" + postObject.Userid + Datename + ".xlsx"); } - + public async Task>> CheckExcel(Select_table2 post) + { + var ApiResult = new ApiResult>(); + var ErrorMessage = new List(); + foreach (var station in post.PowerStation) + { + var Id = Convert.ToInt32(station.Value); + var table = new Select_table() + { + FormType = post.FormType, + SearchType = post.SearchType, + PowerStation = Id, + Time = post.Time, + Userid = post.Userid + }; + var checkinv = await stationReportRepository.Findhaveinv(table); + var getinvsql = checkinv[0] as IDictionary; + if (getinvsql["mySelect"] == null) + { + ErrorMessage.Add(station.Name + "此時段無逆變器資料"); + } + else + { + var cid = await stationReportRepository.CheckExcelAsync(table); + if (cid == 0) + { + ErrorMessage.Add(station.Name + "此時段資料未建立"); + } + } + } + if(ErrorMessage.Count > 0) + { + ApiResult.Code = "9999"; + ApiResult.Data = ErrorMessage; + } + else + { + ApiResult.Code = "0000"; + } + return ApiResult; + } } } diff --git a/SolarPower/Controllers/UserController.cs b/SolarPower/Controllers/UserController.cs index 834c68e..d45e22d 100644 --- a/SolarPower/Controllers/UserController.cs +++ b/SolarPower/Controllers/UserController.cs @@ -382,9 +382,12 @@ namespace SolarPower.Controllers } #endregion + var website_url = await powerStationRepository.GetOneVariableByName("WebSiteUrl"); + var sendSubject = "新增帳號成功"; - var sendContent = $"您的新密碼為:{random_password}"; + var sendContent = $@"您的新密碼為:{random_password} +
立即前往:{website_url}"; List recipientEmails = new List() { diff --git a/SolarPower/DBSchema/solar_power_schema.sql b/SolarPower/DBSchema/solar_power_schema.sql index bb17a7d..ffb25d7 100644 --- a/SolarPower/DBSchema/solar_power_schema.sql +++ b/SolarPower/DBSchema/solar_power_schema.sql @@ -2212,6 +2212,9 @@ ALTER TABLE `power_station_exception` CHANGE COLUMN `UpperLimit` `UpperLimit` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '上限值' AFTER `Type`, CHANGE COLUMN `LowerLimit` `LowerLimit` DECIMAL(10,2) NULL DEFAULT NULL COMMENT '下限值' AFTER `UpperLimit`; +-- 新增太陽能電站網址 +INSERT INTO `solar_power_test`.`variable` (`Name`, `Value`, `Remark`) VALUES ('WebSiteUrl', 'http://green.fic.com.tw/', '太陽能電站管理系統網址'); + /*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */; /*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/SolarPower/Models/AnalysisStationCombine.cs b/SolarPower/Models/AnalysisStationCombine.cs index d78b9f0..174d1b3 100644 --- a/SolarPower/Models/AnalysisStationCombine.cs +++ b/SolarPower/Models/AnalysisStationCombine.cs @@ -17,6 +17,8 @@ namespace SolarPower.Models public double All_PR { get; set; }//總平均PR public double Now_Carbon { get; set; }//現減炭 public double All_Carbon { get; set; }//總減炭 + public double All_irradiance { get; set; } + public double Now_irradiance { get; set; } } public class ChartInput { diff --git a/SolarPower/Models/ErrorCode.cs b/SolarPower/Models/ErrorCode.cs index bb221c5..3b83845 100644 --- a/SolarPower/Models/ErrorCode.cs +++ b/SolarPower/Models/ErrorCode.cs @@ -17,10 +17,11 @@ namespace SolarPower.Models { { "0000", "OK" }, { "0001", "傳入參數錯誤。" }, - { "0002","請先刪除相關逆變器"}, - { "0003","請先刪除相關設備"}, - { "0004","請先移除相關逆變器綁定"}, - { "9985","該電站尚無逆變器資料"}, + { "0002", "請先刪除相關逆變器"}, + { "0003", "請先刪除相關設備"}, + { "0004", "請先移除相關逆變器綁定"}, + { "9984", "連線逾時"}, + { "9985", "該電站尚無逆變器資料"}, { "9986", "該帳號已被註冊,請重新輸入"}, { "9987", "查無該運維作業記錄檔案"}, { "9988", "查無該資料紀錄"}, diff --git a/SolarPower/Models/Operation.cs b/SolarPower/Models/Operation.cs index fcbb6c9..f10b710 100644 --- a/SolarPower/Models/Operation.cs +++ b/SolarPower/Models/Operation.cs @@ -99,11 +99,11 @@ namespace SolarPower.Models public string UpdatedAt { get { return Convert.ToDateTime(updatedAt).ToString("yyyy-MM-dd HH:mm:ss"); } set { updatedAt = value; } } //修改時間 private string lastCreateTime; public string LastCreateTime { get { return Convert.ToDateTime(lastCreateTime).ToString("yyyy-MM-dd HH:mm:ss"); } set { lastCreateTime = value; } } + public string PowerStationName { get; set; } } public class OperationPlanTable : OperationCreatePlan { public string TypeName { get; set; } - public string PowerStationName { get; set; } public string Schedule { get; set; } public string EmailTypeName { get; set; } public string CreatedPerson { get; set; } diff --git a/SolarPower/Models/Overview.cs b/SolarPower/Models/Overview.cs index 7e12750..5c19206 100644 --- a/SolarPower/Models/Overview.cs +++ b/SolarPower/Models/Overview.cs @@ -199,7 +199,8 @@ namespace SolarPower.Models public string errMsg { get; set; }//錯誤原因 public string PowerStationName { get; set; }//電站名稱 public int PowerStationId { get; set; }//電站流水號 - public string normalTime { get; set; } + public string normalTime { get; set; }//賦歸時間 + public string errMsgT { get; set; } //errMsgType } public class UserPowerStationTo diff --git a/SolarPower/Models/StationReport.cs b/SolarPower/Models/StationReport.cs index f540ad3..55a57a1 100644 --- a/SolarPower/Models/StationReport.cs +++ b/SolarPower/Models/StationReport.cs @@ -106,6 +106,7 @@ namespace SolarPower.Models public double Kwh { get; set; } public double SolarHour { get; set; } public int Count { get; set; } + public double Kwhkwp { get; set; } } diff --git a/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs index aff119a..06398f5 100644 --- a/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs +++ b/SolarPower/Quartz/Jobs/CalcAvgPowerStationJob.cs @@ -8,6 +8,7 @@ using SolarPower.Models.PowerStation; using SolarPower.Repository.Interface; using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Net.Http; using System.Threading.Tasks; @@ -870,40 +871,83 @@ namespace SolarPower.Quartz.Jobs #region 寄送日月報 var users = userRepository.GetAllAsync(); + var ttt = new List() { + "s506488@gmail.com", + "cesarliuc@gmail.com" + }; foreach (var user in users.Result) { - List powerstations = new List(); - powerstations = await noticeScheduleRepository.GetPowerStationOperationPersonnel(user.Id); - if (powerstations.Count == 0) + try { - continue; - } - List sentdaypowerstations = powerstations.Where(x => x.EmailDayReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList(); - List sentMaxpowerstations = powerstations.Where(x => x.EmailComplexReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList(); + logger.LogInformation("【CalcAvgPowerStationJob】【開始產生使用者[{0}({1})]的日月報】", user.Account, user.Name); - Controllers.StationReportController stationReportController = new Controllers.StationReportController(powerStationRepository, stationReportRepository); - //日報表 - if (sentdaypowerstations.Count != 0) - { - Excel dayexcel = new Excel() + List powerstations = new List(); + powerstations = await noticeScheduleRepository.GetPowerStationOperationPersonnel(user.Id); + if (powerstations.Count == 0) { - FormType = 0, - PowerStation = sentdaypowerstations, - SearchType = 0, - Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"), - Userid = user.Id - }; - var stationReportName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(dayexcel, Formatting.Indented)); - if (stationReportName != "") + continue; + } + List sentdaypowerstations = powerstations.Where(x => x.EmailDayReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList(); + List sentMaxpowerstations = powerstations.Where(x => x.EmailComplexReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList(); + + Controllers.StationReportController stationReportController = new Controllers.StationReportController(powerStationRepository, stationReportRepository); + //日報表 + if (sentdaypowerstations.Count != 0) { - NoticeSchedule DaySchedule = new NoticeSchedule() + Excel dayexcel = new Excel() + { + FormType = 0, + PowerStation = sentdaypowerstations, + SearchType = 0, + Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"), + Userid = user.Id + }; + var stationReportName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(dayexcel, Formatting.Indented)); + if (stationReportName != "") + { + NoticeSchedule DaySchedule = new NoticeSchedule() + { + UserId = user.Id, + EmailType = 0, + RecipientEmail = user.Email, + Subject = "日報表", + Attachment = stationReportName, + RecipientName = user.Name, + Type = 1 + }; + List properties = new List() + { + "UserId", + "EmailType", + "RecipientEmail", + "Subject", + "Attachment", + "RecipientName", + "Type" + }; + await noticeScheduleRepository.AddOneAsync(DaySchedule, properties); + } + } + //綜合報表 每日 + if (sentMaxpowerstations.Count != 0) + { + Select_table2 maxdayexcel = new Select_table2() + { + FormType = 0, + PowerStation = sentMaxpowerstations, + SearchType = 0, + Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"), + Userid = user.Id + }; + var stationMaxReportName = stationReportController.ExportExcelmaxtableBackDownload(JsonConvert.SerializeObject(maxdayexcel, Formatting.Indented)); + NoticeSchedule MaxSchedule = new NoticeSchedule() { UserId = user.Id, - EmailType = 0, + EmailType = 2, RecipientEmail = user.Email, - Subject = "日報表", - Attachment = stationReportName, + Subject = "綜合報表", + Attachment = stationMaxReportName, RecipientName = user.Name, Type = 1 }; @@ -917,120 +961,100 @@ namespace SolarPower.Quartz.Jobs "RecipientName", "Type" }; - await noticeScheduleRepository.AddOneAsync(DaySchedule, properties); + await noticeScheduleRepository.AddOneAsync(MaxSchedule, properties); + + if (DateTime.Now.ToString("dd") == "01") + { + Select_table2 maxmonthexcel = new Select_table2() + { + FormType = 0, + PowerStation = sentMaxpowerstations, + SearchType = 0, + Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"), + Userid = user.Id + }; + var stationReportmaxmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(maxmonthexcel, Formatting.Indented)); + NoticeSchedule MaxmonthSchedule = new NoticeSchedule() + { + RecipientEmail = user.Email, + Subject = "綜合報表", + Attachment = stationReportmaxmonthName, + RecipientName = user.Name, + Type = 1, + UserId = user.Id, + EmailType = 2 + }; + List properties2 = new List() + { + "UserId", + "EmailType", + "RecipientEmail", + "Subject", + "Attachment", + "RecipientName", + "Type" + }; + await noticeScheduleRepository.AddOneAsync(MaxmonthSchedule, properties2); + } + } - } - //綜合報表 每日 - if (sentMaxpowerstations.Count != 0) - { - Select_table2 maxdayexcel = new Select_table2() - { - FormType = 0, - PowerStation = sentMaxpowerstations, - SearchType = 0, - Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"), - Userid = user.Id - }; - var stationMaxReportName = stationReportController.ExportExcelmaxtableBackDownload(JsonConvert.SerializeObject(maxdayexcel, Formatting.Indented)); - NoticeSchedule MaxSchedule = new NoticeSchedule() - { - UserId = user.Id, - EmailType = 2, - RecipientEmail = user.Email, - Subject = "綜合報表", - Attachment = stationMaxReportName, - RecipientName = user.Name, - Type = 1 - }; - List properties = new List() - { - "UserId", - "EmailType", - "RecipientEmail", - "Subject", - "Attachment", - "RecipientName", - "Type" - }; - await noticeScheduleRepository.AddOneAsync(MaxSchedule, properties); if (DateTime.Now.ToString("dd") == "01") { - Select_table2 maxmonthexcel = new Select_table2() + List sentmonthpowerstations = powerstations.Where(x => x.EmailMonthReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList(); + if (sentmonthpowerstations.Count == 0) { - FormType = 0, - PowerStation = sentMaxpowerstations, - SearchType = 0, + break; + } + Excel monthexcel = new Excel() + { + FormType = 1, + PowerStation = sentmonthpowerstations, + SearchType = 2, Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"), Userid = user.Id }; - var stationReportmaxmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(maxmonthexcel, Formatting.Indented)); - NoticeSchedule MaxmonthSchedule = new NoticeSchedule() + var stationReportmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(monthexcel, Formatting.Indented)); + if (stationReportmonthName != "") { - RecipientEmail = user.Email, - Subject = "綜合報表", - Attachment = stationReportmaxmonthName, - RecipientName = user.Name, - Type = 1, - UserId = user.Id, - EmailType = 2 - }; - List properties2 = new List() - { - "UserId", - "EmailType", - "RecipientEmail", - "Subject", - "Attachment", - "RecipientName", - "Type" - }; - await noticeScheduleRepository.AddOneAsync(MaxmonthSchedule, properties2); + NoticeSchedule MonthSchedule = new NoticeSchedule() + { + RecipientEmail = user.Email, + Subject = "月報表", + Attachment = stationReportmonthName, + RecipientName = user.Name, + Type = 1, + UserId = user.Id, + EmailType = 1 + }; + List properties2 = new List() + { + "UserId", + "EmailType", + "RecipientEmail", + "Subject", + "Attachment", + "RecipientName", + "Type" + }; + await noticeScheduleRepository.AddOneAsync(MonthSchedule, properties2); + } + } + logger.LogInformation("【CalcAvgPowerStationJob】【產生完成使用者[{0}({1})]的日月報】", user.Account, user.Name); } - - if (DateTime.Now.ToString("dd") == "01") + catch (Exception exception) { - List sentmonthpowerstations = powerstations.Where(x => x.EmailMonthReport == 1).Select(a => new Excelpowerstation { Name = a.Name, Value = a.PowerStationId.ToString() }).ToList(); - if (sentmonthpowerstations.Count == 0) + logger.LogError("【CalcAvgPowerStationJob】【產生失敗使用者[{0}({1})]的日月報】", user.Account, user.Name); + logger.LogError("【CalcAvgPowerStationJob】[Exception] - {0}", exception.Message); + if (exception.InnerException != null) { - break; - } - Excel monthexcel = new Excel() - { - FormType = 1, - PowerStation = sentmonthpowerstations, - SearchType = 2, - Time = DateTime.Now.AddDays(-1).ToString("yyyy-MM"), - Userid = user.Id - }; - var stationReportmonthName = stationReportController.ExportExcelBackDownload(JsonConvert.SerializeObject(monthexcel, Formatting.Indented)); - if (stationReportmonthName != "") - { - NoticeSchedule MonthSchedule = new NoticeSchedule() - { - RecipientEmail = user.Email, - Subject = "月報表", - Attachment = stationReportmonthName, - RecipientName = user.Name, - Type = 1, - UserId = user.Id, - EmailType = 1 - }; - List properties2 = new List() - { - "UserId", - "EmailType", - "RecipientEmail", - "Subject", - "Attachment", - "RecipientName", - "Type" - }; - await noticeScheduleRepository.AddOneAsync(MonthSchedule, properties2); + logger.LogError("【CalcAvgPowerStationJob】[InnerException] - {0}", exception.InnerException.Message); } + var line = new StackTrace(exception, true).GetFrame(0).GetFileLineNumber(); + logger.LogError("【CalcAvgPowerStationJob】[錯誤行數] - {0}", line); } } diff --git a/SolarPower/Quartz/Jobs/CalcInverter15minJob.cs b/SolarPower/Quartz/Jobs/CalcInverter15minJob.cs index 279746a..9a49fb4 100644 --- a/SolarPower/Quartz/Jobs/CalcInverter15minJob.cs +++ b/SolarPower/Quartz/Jobs/CalcInverter15minJob.cs @@ -162,7 +162,7 @@ namespace SolarPower.Quartz.Jobs await powerStationRepository.UpdateInvStatus(update_invStatusErr.Key, null, update_invStatusErr.Select(x => x.InverterId).ToList(), 2); } - logger.LogError("【CalcInverter15minJob】檢測完成逆變器狀態"); + logger.LogInformation("【CalcInverter15minJob】檢測完成逆變器狀態"); } catch(Exception exception) { diff --git a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs index 871e0d4..2e3364e 100644 --- a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs +++ b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs @@ -84,8 +84,6 @@ namespace SolarPower.Quartz.Jobs logger.LogError("【{0}】{1}", "CalcPowerStationJob", ex.Message); observation = null; } - - #endregion #region step2. 從電站的DB及電站編號找出該電站的控制器 @@ -103,7 +101,7 @@ namespace SolarPower.Quartz.Jobs if (string.IsNullOrEmpty(exist)) { - logger.LogError("【CalcPowerStationJob】【查無電站[{0}]的s{0}01_station資料表】", powerStation.Code); + logger.LogError($"【CalcPowerStationJob】【查無電站[{powerStation.Code}]的s{powerStation.Code}01_station資料表】"); } else { @@ -131,16 +129,34 @@ namespace SolarPower.Quartz.Jobs #endregion #region 發電金額 - //發電金額 + + history.MONEY = history.KWH * powerStation.PowerRate; + history.TODAYMONEY = history.TodayKWh * powerStation.PowerRate; + history.TOTALMONEY = history.TotalKWH * powerStation.PowerRate; + + //即時發電金額 switch (powerStation.SolarType) { case (int)SolarTypeEnum.SelfSold: //自建躉售 - //今日發電金額 計算方式:todaykWh * 授電費率 - calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate; - history.MONEY = history.KWH * powerStation.PowerRate; - //總發電金額 計算方式:totalkWh * 授電費率 + //if (lastmoneyhistorybyhour != null) + //{ + // history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate; + // history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate; + //} + //else + //{ + // history.TODAYMONEY = history.KWH * powerStation.PowerRate; + // history.TOTALMONEY = history.KWH * powerStation.PowerRate; + //} + + //今日發電金額 計算方式:todaykWh * 授電費率 + calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate; + //calcPowerStation.Today_Money = history.TODAYMONEY; + + ////總發電金額 計算方式:totalkWh * 授電費率 calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate; + //calcPowerStation.Total_Money = history.TOTALMONEY; break; case (int)SolarTypeEnum.HireSold: //租建躉售 //找出該電站的所有土地房屋資訊 @@ -154,20 +170,48 @@ namespace SolarPower.Quartz.Jobs } //avgLeaseRate = sumLeaseRate / landBuildings.Count(); - //今日發電金額計算方式:todaykWh * 出借費率(各個土地房屋租借比率平均) - calcPowerStation.Today_Money = history.TodayKWh * sumLeaseRate; + //if (lastmoneyhistorybyhour != null) + //{ + // history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate; + // history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate; + + // //今日發電金額計算方式:todaykWh * 出借費率(各個土地房屋租借比率平均) + // calcPowerStation.Today_Money = lastmoneyhistorybyhour.TODAYMONEY + (history.KWH * powerStation.PowerRate * sumLeaseRate); + // //總發電金額 計算方式:totalkWh * 授電費率 + // calcPowerStation.Total_Money = lastmoneyhistorybyhour.TOTALMONEY + (history.KWH * powerStation.PowerRate * sumLeaseRate); + //} + //else + //{ + // history.TODAYMONEY = history.KWH * powerStation.PowerRate; + // history.TOTALMONEY = history.KWH * powerStation.PowerRate; + + // calcPowerStation.Today_Money = history.KWH * powerStation.PowerRate * sumLeaseRate; + // calcPowerStation.Total_Money = history.KWH * powerStation.PowerRate * sumLeaseRate; + //} + + calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate * sumLeaseRate; + calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate * sumLeaseRate; - history.MONEY = history.KWH * sumLeaseRate; - //總發電金額 計算方式:totalkWh * 授電費率 - calcPowerStation.Total_Money = history.TotalKWH * sumLeaseRate; break; case (int)SolarTypeEnum.SelfUse: //自建自用 - //今日發電金額 計算方式:todaykWh * 授電費率 + + //if (lastmoneyhistorybyhour != null) + //{ + // history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate; + // history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate; + //} + //else + //{ + // history.TODAYMONEY = history.KWH * powerStation.PowerRate; + // history.TOTALMONEY = history.KWH * powerStation.PowerRate; + //} + + //今日發電金額 計算方式:todaykWh * 授電費率 + //calcPowerStation.Today_Money = history.TODAYMONEY; calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate; - history.MONEY = history.KWH * powerStation.PowerRate; - //總發電金額 計算方式:totalkWh * 授電費率 + //calcPowerStation.Total_Money = history.TOTALMONEY; calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate; break; } @@ -186,28 +230,28 @@ namespace SolarPower.Quartz.Jobs #region 減碳量 carbonRate = Convert.ToDouble(await powerStationRepository.GetOneVariableByName("CarbonRate")); + history.CARBON = history.KWH * carbonRate; + history.TODAYCARBON = history.TodayKWh * carbonRate; + history.TOTALCARBON = history.TotalKWH * carbonRate; + //if (lastmoneyhistorybyhour != null) + //{ + // history.TODAYCARBON = lastmoneyhistorybyhour.TODAYCARBON + history.KWH * carbonRate; + // history.TOTALCARBON = lastmoneyhistorybyhour.TOTALCARBON + history.KWH * carbonRate; + //} + //else + //{ + // history.TODAYCARBON = history.KWH * carbonRate; + // history.TOTALCARBON = history.KWH * carbonRate; + //} + //今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值] + //calcPowerStation.Today_Carbon = history.TODAYCARBON; calcPowerStation.Today_Carbon = history.TodayKWh * carbonRate; - history.CARBON = history.KWH * carbonRate; //總減碳量(總發電量 * (0.554/1000)[抓資料庫值] + //calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate; calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate; - if (lastmoneyhistorybyhour != null) - { - history.TODAYCARBON = lastmoneyhistorybyhour.TODAYCARBON + history.KWH * carbonRate; - history.TOTALCARBON = lastmoneyhistorybyhour.TOTALCARBON + history.KWH * carbonRate; - history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate; - history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate; - } - else - { - history.TODAYCARBON = history.KWH * carbonRate; - history.TOTALCARBON = history.KWH * carbonRate; - history.TODAYMONEY = history.KWH * powerStation.PowerRate; - history.TOTALMONEY = history.KWH * powerStation.PowerRate; - } - #endregion #region 發電時間 @@ -228,7 +272,7 @@ namespace SolarPower.Quartz.Jobs var sensoravg_table_exist = await powerStationRepository.ExistTable(powerStation.SiteDB, sensoravg_table_name); if (string.IsNullOrEmpty(sensoravg_table_exist)) { - logger.LogError("【CalcPowerStationJob】【查無電站[0]的s{0}01_sensoravg資料表】", powerStation.Code); + logger.LogError($"【CalcPowerStationJob】【查無電站[{powerStation.Code}]的s{powerStation.Code}01_sensoravg資料表】"); } else { @@ -493,7 +537,7 @@ namespace SolarPower.Quartz.Jobs var exist_meter_table = await powerStationRepository.ExistTable(powerStation.SiteDB, meter_table_name); if (string.IsNullOrEmpty(exist_meter_table)) { - logger.LogError("【CalcPowerStationJob】【查無電站[{0}]的s{0}01_meter資料表】", powerStation.Code); + logger.LogError($"【CalcPowerStationJob】【查無電站[{powerStation.Code}]的s{powerStation.Code}01_meter資料表】"); } else { diff --git a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs index 80f7107..79a6381 100644 --- a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs +++ b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; using Newtonsoft.Json.Linq; using Quartz; using SolarPower.Models; @@ -21,38 +22,45 @@ namespace SolarPower.Quartz.Jobs private readonly INoticeScheduleRepository noticeScheduleRepository; private readonly IUserRepository userRepository; private readonly IPowerStationRepository powerStationRepository; + private readonly IConfiguration Configuration; - public ExceptionSchedule(ILogger logger, IOverviewRepository overviewRepository,INoticeScheduleRepository noticeScheduleRepository,IUserRepository userRepository,IPowerStationRepository powerStationRepository) + public ExceptionSchedule(ILogger logger, IOverviewRepository overviewRepository,INoticeScheduleRepository noticeScheduleRepository,IUserRepository userRepository,IPowerStationRepository powerStationRepository, IConfiguration Configuration) { this.logger = logger; this.overviewRepository = overviewRepository; this.noticeScheduleRepository = noticeScheduleRepository; this.userRepository = userRepository; this.powerStationRepository = powerStationRepository; + this.Configuration = Configuration; } public async Task Execute(IJobExecutionContext context) { try { + var ExceptionTimes = this.Configuration.GetValue("ExceptionTimes"); var ExceptionList = await overviewRepository.GetEmailExceptionList(); if(ExceptionList.Count > 0 ) { - var ExceptionListex = ExceptionList.Where(x => x.normalTime == "1970-01-01 08:00:00" && DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).Hours >= 4).ToList(); + var ExceptionListex = ExceptionList.Where(x => x.normalTime == "1970-01-01 08:00:00" && DateTime.Now.Subtract(DateTime.Parse(x.dev_time)).Minutes >= ExceptionTimes).ToList(); foreach (var Exception in ExceptionListex) { var UserListWithPowerstation = await overviewRepository.GetUserListWithPowerstation(Exception.PowerStationId); - foreach (var user in UserListWithPowerstation) - { - var Content = $"電站名稱:{Exception.PowerStationName}" + "
" + + var Content = $"電站名稱:{Exception.PowerStationName}" + "
" + $"設備編號:{Exception.errDevice}" + "
" + $"異常ID編號:{Exception.id}" + "
" + $"異常類別:{Exception.alarmClassName}" + "
" + - $"設備訊息:{Exception.errMsg}" + "
" + - $"發生時間:{Exception.dev_time}" ; + $"設備訊息:{Exception.errMsg}" + "
"; + if(Exception.errMsgT == "d") + { + Content += $"當前數值:{Exception.errValue}" + "
"; + } + Content += $"發生時間:{Exception.dev_time}"; + foreach (var user in UserListWithPowerstation) + { NoticeSchedule DaySchedule = new NoticeSchedule() { UserId = user.Id, @@ -77,11 +85,14 @@ namespace SolarPower.Quartz.Jobs }; await noticeScheduleRepository.AddOneAsync(DaySchedule, properties); - var powerstation = await powerStationRepository.GetOneAsync(Exception.PowerStationId); - if(powerstation.line_token != null) - { - CallLineToken(Content, powerstation.line_token); - } + + } + + var powerstation = await powerStationRepository.GetOneAsync(Exception.PowerStationId); + if (powerstation.line_token != null) + { + Content = " %0D%0A " + Content.Replace("
", " %0D%0A "); + CallLineToken(Content, powerstation.line_token); } } } diff --git a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs index c527148..cba78bf 100644 --- a/SolarPower/Quartz/Jobs/OperationScheduleJob.cs +++ b/SolarPower/Quartz/Jobs/OperationScheduleJob.cs @@ -158,7 +158,7 @@ namespace SolarPower.Quartz.Jobs { //Get所有運維人員 var personal = await operationRepository.GetOperationPersonnel(a.PowerStationId); - var Title = $@"編號:{a.PlanId} - {WorkType}單 - 作業紀錄建立通知"; + var Title = $@"電站:{a.PowerStationName} - {WorkType}單 - 編號:{a.PlanId}"; var content = $@" {noticeName} {Environment.NewLine} 內容描述:{a.Description}"; await operationRepository.InsertNoticeSchedule(personal, Title, content); diff --git a/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs b/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs index 3ebd463..d6e6847 100644 --- a/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs +++ b/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs @@ -17,6 +17,8 @@ namespace SolarPower.Repository.Implement tableName = "power_station"; } + + public async Task GetPowerStationInfoList(ChartInput post) { var a = new AnalysisStationCombine(); @@ -32,14 +34,33 @@ namespace SolarPower.Repository.Implement { case 0: string timerange = Convert.ToDateTime(post.Timerange).ToString("yyyy-MM-dd"); - sql = $@"SELECT m.*,n.*,o.* FROM + var today = ""; + if(timerange == DateTime.Now.ToString("yyyy-MM-dd")) + { + today = @$" SELECT + AVG(a.today_irradiance) AS Now_irradiance + FROM + power_station a + WHERE a.Id IN @ids "; + } + else + { + today = $@" SELECT + AVG(a.Irradiance) AS Now_irradiance + FROM + sensor_history_day a + WHERE a.PowerStationId IN @ids AND DATE_FORMAT(a.TIMESTAMP,'%Y-%m-%d') = '{timerange}'"; + } + + + sql = $@"SELECT m.*,n.*,o.*,p.* FROM ( SELECT SUM(TOTALMONEY) AS All_money, SUM(TOTALKWH) AS All_kwh, SUM(TOTALCARBON) AS All_Carbon - from power_station_history_month - WHERE PowerStationId IN @ids + from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN @ids GROUP BY PowerStationId) a + LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP ) AS m, ( @@ -60,22 +81,47 @@ namespace SolarPower.Repository.Implement ( SELECT AVG(avg_kwhkwp) AS All_KWH_KWP, - AVG(avg_PR) AS All_PR + AVG(avg_PR) AS All_PR, + AVG(avg_irradiance) as All_irradiance from power_station WHERE Id IN @ids ) - AS o"; + AS o, + ( + {today} + ) AS p"; break; case 1: var time = post.Timerange.Split('-'); - sql = $@"SELECT m.*,n.*,o.* FROM + var ttot = ""; + if(time[1].Replace(" ","") == DateTime.Now.ToString("yyyy/MM/dd")) + { + ttot = @$"SELECT + AVG(c.Now_irradiance) AS Now_irradiance + FROM + (SELECT AVG(a.today_irradiance) AS Now_irradiance FROM power_station a WHERE a.Id IN (1) + UNION + SELECT AVG(b.Irradiance) AS Now_irradiance FROM sensor_history_day b + WHERE b.PowerStationId IN (1) AND DATE_FORMAT(b.TIMESTAMP, '%Y/%m/%d') BETWEEN '{time[0].Replace(" ", "")}' AND '{Convert.ToDateTime(time[1].Replace(" ", "")).AddDays(-1).ToString("yyyy/MM/dd")}') c"; + } + else + { + ttot = @$" SELECT + AVG(a.Irradiance) AS Now_irradiance + FROM + sensor_history_day a + WHERE a.PowerStationId IN @ids AND DATE_FORMAT(a.TIMESTAMP, '%Y/%m/%d') BETWEEN '{time[0].Replace(" ", "")}' AND '{time[1].Replace(" ", "")}'"; + } + + + sql = $@"SELECT m.*,n.*,o.*,p.* FROM ( SELECT SUM(TOTALMONEY) AS All_money, SUM(TOTALKWH) AS All_kwh, SUM(TOTALCARBON) AS All_Carbon - from power_station_history_month - WHERE PowerStationId IN @ids + from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN @ids GROUP BY PowerStationId) a + LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP ) AS m, ( @@ -92,21 +138,25 @@ namespace SolarPower.Repository.Implement ( SELECT AVG(avg_kwhkwp) AS All_KWH_KWP, - AVG(avg_PR) AS All_PR + AVG(avg_PR) AS All_PR, + AVG(avg_irradiance) as All_irradiance from power_station WHERE Id IN @ids ) - AS o"; + AS o, + ( + {ttot} + ) AS p"; break; case 2: - sql = $@"SELECT m.*,n.*,o.* FROM + sql = $@"SELECT m.*,n.*,o.*,p.* FROM ( SELECT SUM(TOTALMONEY) AS All_money, SUM(TOTALKWH) AS All_kwh, SUM(TOTALCARBON) AS All_Carbon - from power_station_history_month - WHERE PowerStationId IN @ids + from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN @ids GROUP BY PowerStationId) a + LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP ) AS m, ( @@ -123,21 +173,28 @@ namespace SolarPower.Repository.Implement ( SELECT AVG(avg_kwhkwp) AS All_KWH_KWP, - AVG(avg_PR) AS All_PR + AVG(avg_PR) AS All_PR, + AVG(avg_irradiance) as All_irradiance from power_station WHERE Id IN @ids ) - AS o"; + AS o, + ( + SELECT + AVG(a.Irradiance) AS Now_irradiance + from sensor_history_month a + WHERE PowerStationId IN @ids AND DATE_FORMAT(TIMESTAMP, '%Y-%m') = '{post.Timerange}' + ) AS p"; break; case 3: - sql = $@"SELECT m.*,n.*,o.* FROM + sql = $@"SELECT m.*,n.*,o.*,p.* FROM ( SELECT SUM(TOTALMONEY) AS All_money, SUM(TOTALKWH) AS All_kwh, SUM(TOTALCARBON) AS All_Carbon - from power_station_history_month - WHERE PowerStationId IN @ids + from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN @ids GROUP BY PowerStationId) a + LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP ) AS m, ( @@ -155,11 +212,18 @@ namespace SolarPower.Repository.Implement ( SELECT AVG(avg_kwhkwp) AS All_KWH_KWP, - AVG(avg_PR) AS All_PR + AVG(avg_PR) AS All_PR, + AVG(avg_irradiance) as All_irradiance from power_station WHERE Id IN @ids ) - AS o"; + AS o, + ( + SELECT + AVG(a.Irradiance) AS Now_irradiance + from sensor_history_month a + WHERE PowerStationId IN @ids AND DATE_FORMAT(TIMESTAMP, '%Y') = '{post.Timerange}' + ) AS p"; break; } @@ -192,57 +256,51 @@ namespace SolarPower.Repository.Implement switch (post.SeacrhType) { case 0: - sql = $@"SELECT DATE_FORMAT(ps.TIMESTAMP,'%h %p') AS `Time`, - SUM(ps.KWH) AS KWH, - SUM(sh.Irradiance) AS Irradiance, - AVG(sh.Temperature) AS Temperature - FROM power_station_history_hour ps - LEFT JOIN sensor_history_hour sh - ON sh.TIMESTAMP = ps.TIMESTAMP AND sh.PowerStationId = ps.PowerStationId - WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') = '{post.Timerange}' - GROUP BY ps.TIMESTAMP"; + sql = $@"SELECT DATE_FORMAT(p.TIMESTAMP,'%h %p') AS `Time`, + SUM(p.KWH) AS KWH, + SUM(s.Irradiance) AS Irradiance, + AVG(s.Temperature) AS Temperature + FROM (SELECT * FROM power_station_history_hour ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') = '{post.Timerange}') p + LEFT JOIN (SELECT * FROM sensor_history_hour sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') = '{post.Timerange}') s + ON p.TIMESTAMP = s.TIMESTAMP AND p.PowerStationId = s.PowerStationId + GROUP BY p.TIMESTAMP"; break; case 1: var time = post.Timerange.Replace(" ","").Split('-'); sql = $@"SELECT - DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') AS `Time`, - SUM(ps.TODAYKWH) AS KWH, - SUM(sh.Irradiance) AS Irradiance, - AVG(sh.Temperature) AS Temperature - FROM power_station_history_day ps - LEFT JOIN sensor_history_day sh - ON sh.TIMESTAMP = ps.TIMESTAMP - WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') BETWEEN '{time[0].Replace('/', '-')}' AND '{time[1].Replace('/', '-')}' - GROUP BY ps.TIMESTAMP"; + DATE_FORMAT(p.TIMESTAMP,'%Y-%m-%d') AS `Time`, + SUM(p.TODAYKWH) AS KWH, + SUM(s.Irradiance) AS Irradiance, + AVG(s.Temperature) AS Temperature + FROM (SELECT * FROM power_station_history_day ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') BETWEEN '{time[0].Replace('/', '-')}' AND '{time[1].Replace('/', '-')}') p + LEFT JOIN (SELECT * FROM sensor_history_day sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m-%d') BETWEEN '{time[0].Replace('/', '-')}' AND '{time[1].Replace('/', '-')}') s + ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId + GROUP BY p.TIMESTAMP"; break; case 2: sql = $@"SELECT - DATE_FORMAT(ps.TIMESTAMP,'%Y-%m-%d') AS `Time`, - SUM(ps.TODAYKWH) AS KWH, - SUM(sh.Irradiance) AS Irradiance, - AVG(sh.Temperature) AS Temperature - FROM power_station_history_day ps - LEFT JOIN sensor_history_day sh - ON sh.TIMESTAMP = ps.TIMESTAMP - WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m') = '{post.Timerange}' - GROUP BY ps.TIMESTAMP"; + DATE_FORMAT(p.TIMESTAMP,'%Y-%m-%d') AS `Time`, + SUM(p.TODAYKWH) AS KWH, + SUM(s.Irradiance) AS Irradiance, + AVG(s.Temperature) AS Temperature + FROM (SELECT * FROM power_station_history_day ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y-%m') = '{post.Timerange}') p + LEFT JOIN (SELECT * FROM sensor_history_day sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y-%m') = '{post.Timerange}') s + ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId + GROUP BY p.TIMESTAMP"; break; case 3: sql = $@"SELECT - DATE_FORMAT(ps.TIMESTAMP,'%Y-%m') AS `Time`, - SUM(ps.MONTHKWH) AS KWH, - SUM(sh.Irradiance) AS Irradiance, - AVG(sh.Temperature) AS Temperature - FROM power_station_history_month ps - LEFT JOIN sensor_history_month sh - ON sh.TIMESTAMP = ps.TIMESTAMP - WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y') = '{post.Timerange}' - GROUP BY ps.TIMESTAMP"; + DATE_FORMAT(p.TIMESTAMP,'%Y-%m') AS `Time`, + SUM(p.MONTHKWH) AS KWH, + SUM(s.Irradiance) AS Irradiance, + AVG(s.Temperature) AS Temperature + FROM (SELECT * FROM power_station_history_month ps WHERE ps.PowerStationId IN @ids AND DATE_FORMAT(ps.TIMESTAMP,'%Y') = '{post.Timerange}') p + LEFT JOIN (SELECT * FROM sensor_history_month sh WHERE sh.PowerStationId IN @ids AND DATE_FORMAT(sh.TIMESTAMP,'%Y') = '{post.Timerange}') s + ON s.TIMESTAMP = p.TIMESTAMP AND p.PowerStationId = s.PowerStationId + GROUP BY p.TIMESTAMP"; break; } a = (await conn.QueryAsync(sql,new { ids = post.StationIds})).ToList(); - - } catch (Exception exception) { diff --git a/SolarPower/Repository/Implement/OperationRepository.cs b/SolarPower/Repository/Implement/OperationRepository.cs index c752ecf..0e6435c 100644 --- a/SolarPower/Repository/Implement/OperationRepository.cs +++ b/SolarPower/Repository/Implement/OperationRepository.cs @@ -604,7 +604,8 @@ namespace SolarPower.Repository.Implement { try { - var sql = @$"SELECT * FROM operation_plan_create opc + var sql = @$"SELECT opc.*,ps.Name AS PowerStationName FROM operation_plan_create opc + LEFT JOIN power_station ps ON opc.PowerStationId = ps.Id WHERE opc.Deleted = 0"; result = (await conn.QueryAsync(sql)).ToList(); } diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index d239653..7e13d05 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -605,7 +605,7 @@ namespace SolarPower.Repository.Implement //range2 = $" DATE_FORMAT(C.TIMESTAMP,'%Y') = '{post.HistoryRange}'"; break; case 3: - select = "DATE_FORMAT(V.TIMESTAMP,'%Y') AS TIMESTAMP, MAX(KWH) AS KWH, SUM(SOLARHOUR) AS SOLARHOUR, SUM(SOLARHOUR-PSValue) AS DiffSOLARHOUR, AVG(PR) AS PR, AVG(Irradiance) AS Irradiance, AVG(Temp) AS Temp"; + select = "DATE_FORMAT(V.TIMESTAMP,'%Y') AS TIMESTAMP, MAX(KWH) AS KWH, SUM(SOLARHOUR) AS SOLARHOUR, SUM(SOLARHOUR-PSValue) AS DiffSOLARHOUR, AVG(PR) AS PR, AVG(Irradiance) AS Irradiance, AVG(Temp) AS Temp ,AVG(KWHKWP) AS KWHKWP "; kwh = "C.TOTALKWH"; usedb = "power_station_history_month"; pyrdb = "sensor_history_month"; @@ -663,7 +663,7 @@ namespace SolarPower.Repository.Implement select a.id, site_id, `timestamp`, FROM_UNIXTIME((`timestamp` / 1000), '%Y-%m-%d %H:%i:%s') dev_time , a.sourceState err_status, FROM_UNIXTIME( (a.normalTime / 1000), '%Y-%m-%d %H:%i:%s') normalTime, a.alarmClass, b.alarmClass as alarmClassName,ps.Name as PowerStationName,ps.Id as PowerStationId, errDevice, err_valueKind, errValue, FROM_UNIXTIME( (a.lastUpdate / 1000), '%Y-%m-%d %H:%i:%s') lastUpdate, - case when c.errMsg_tw is null then d.errMsg_tw else c.errMsg_tw end errMsg + case when c.errMsg_tw is null then d.errMsg_tw else c.errMsg_tw end errMsg ,case when c.errMsg is null then d.errMsg else c.errMsg end errMsgT from err_main a join alarmorion_orionalarmclass b on a.alarmclass = b.id left join ref_err_device c on trim(b.alarmClass) = c.deviceType diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 5cfe027..1e91b32 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -4420,6 +4420,7 @@ namespace SolarPower.Repository.Implement var temp_sql = $@"SELECT FROM_UNIXTIME(inv.TIMESTAMP/1000, '%H:%i') AS TIMESTAMP, inv.INVERTERID, + i.InverterName AS INVERTERName, sen.{entity.Sensor} AS Irradiance, ((inv.DC1W + inv.DC2W + inv.DC3W + inv.DC4W + inv.DC5W) / 1000) AS DCKW, ((inv.AC1W + inv.AC2W + inv.AC3W) / 1000) AS ACKW, @@ -4466,14 +4467,15 @@ namespace SolarPower.Repository.Implement inv.RA5 FROM {table_name} inv LEFT JOIN {sensor_table_name} sen ON FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d %H:%i') = FROM_UNIXTIME(sen.TIMESTAMP/1000, '%Y-%m-%d %H:%i') + LEFT JOIN {entity.SiteDB}.inverter i ON inv.INVERTERID = i.InverterId WHERE FROM_UNIXTIME(inv.TIMESTAMP/1000, '%Y-%m-%d') = @NowDay - AND INVERTERID IN ('{inverterIds}')"; + AND inv.INVERTERID IN ('{inverterIds}')"; sql_perSiteDB.Add(temp_sql); } - sql = string.Join(" UNION ", sql_perSiteDB); + sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC"; - result = (await conn.QueryAsync(sql, new { NowDay = nowDay })).ToList(); + result = (await conn.QueryAsync(sql, new { NowDay = nowDay }, commandTimeout: 300)).ToList(); } catch (Exception exception) { @@ -4502,7 +4504,8 @@ namespace SolarPower.Repository.Implement var temp_sql = $@"SELECT DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP, - INVERTERID, + inv.INVERTERID, + i.InverterName AS INVERTERName, inv.Irradiance, inv.KWH, inv.TODAYKWH, @@ -4513,13 +4516,14 @@ namespace SolarPower.Repository.Implement inv.RA4, inv.RA5 FROM inverter_history_day inv + LEFT JOIN {entity.SiteDBName}.inverter i ON inv.INVERTERID = i.InverterId WHERE inv.PowerStationId = {entity.PowerStationId} AND inv.INVERTERID IN ('{inverterIds}') AND inv.TIMESTAMP BETWEEN @StartDay AND @EndDay"; sql_perSiteDB.Add(temp_sql); } - sql = string.Join(" UNION ", sql_perSiteDB); + sql = "SELECT * FROM (" + string.Join(" UNION ", sql_perSiteDB) + ") a ORDER BY a.TIMESTAMP ASC"; result = (await conn.QueryAsync(sql, new { StartDay = startDay, EndDay = endDay })).ToList(); } @@ -4550,7 +4554,8 @@ namespace SolarPower.Repository.Implement var temp_sql = $@"SELECT DATE_FORMAT(inv.TIMESTAMP, '%Y-%m-%d') AS TIMESTAMP, - INVERTERID, + inv.INVERTERID, + i.InverterName AS INVERTERName, inv.KWH, inv.TODAYKWH, inv.PR, @@ -4560,6 +4565,7 @@ namespace SolarPower.Repository.Implement inv.RA4, inv.RA5 FROM inverter_history_month inv + LEFT JOIN {entity.SiteDBName}.inverter i ON inv.INVERTERID = i.InverterId WHERE inv.PowerStationId = {entity.PowerStationId} AND inv.INVERTERID IN ('{inverterIds}') AND DATE_FORMAT(inv.TIMESTAMP, '%Y') = @Year"; @@ -5332,7 +5338,7 @@ namespace SolarPower.Repository.Implement SELECT api.Item, api.ItemName FROM apicall api LEFT join - (SELECT * FROM {dbname}.power_station_exception ex WHERE ex.Deleted = 0) a + (SELECT * FROM {dbname}.power_station_exception ex WHERE ex.Deleted = 0 AND ex.PowerStationId = {powerStationId}) a ON a.`Type` = api.Item WHERE api.PowerStationId = {powerStationId} AND ISNULL(a.Id) diff --git a/SolarPower/Repository/Implement/StationReportRepository.cs b/SolarPower/Repository/Implement/StationReportRepository.cs index 8f12dc9..00adb1f 100644 --- a/SolarPower/Repository/Implement/StationReportRepository.cs +++ b/SolarPower/Repository/Implement/StationReportRepository.cs @@ -243,7 +243,7 @@ namespace SolarPower.Repository.Implement break; } - a = await conn.QueryAsync(sql); + a = await conn.QueryAsync(sql, commandTimeout: 300); } catch (Exception exception) { @@ -257,6 +257,52 @@ namespace SolarPower.Repository.Implement } } + public async Task CheckExcelAsync(Select_table post) + { + using (IDbConnection conn = _databaseHelper.GetConnection()) + { + int a; + conn.Open(); + try + { + string sql = ""; + switch ( post.FormType ) + { + case 0: + sql = @$"select Id from power_station_history_day where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') = '{post.Time}'"; + break; + case 1: + if(post.SearchType == 2) + { + sql = @$"select Id from power_station_history_month where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m') = '{post.Time}'"; + } + else + { + var times = post.Time.Replace('-', 'a').Replace('/', '-').Replace(" ", "").Split('a'); + sql = @$"select Id from power_station_history_day where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{times[0]}' AND '{times[1]}'"; + } + break; + case 3: + sql = @$"select Id from power_station_history_month where powerstationid = {post.PowerStation} and DATE_FORMAT(`TIMESTAMP`,'%Y') = '{post.Time}'"; + break; + } + a = await conn.QueryFirstOrDefaultAsync(sql); + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + return a; + } + } + + + + public async Task> GetHire (PsIdAndSiteDB post) { List result = new List(); diff --git a/SolarPower/Repository/Implement/UserRepository.cs b/SolarPower/Repository/Implement/UserRepository.cs index fb0a999..d2f6c1f 100644 --- a/SolarPower/Repository/Implement/UserRepository.cs +++ b/SolarPower/Repository/Implement/UserRepository.cs @@ -437,7 +437,7 @@ namespace SolarPower.Repository.Implement END AS EscrowName FROM power_station ps LEFT JOIN company c ON ps.CompanyId = c.Id - WHERE ps.Id NOT IN (SELECT psop.PowerStationId FROM power_station_operation_personnel psop WHERE psop.UserId = @UserId AND psop.Deleted = 0)"; + WHERE ps.Id NOT IN (SELECT psop.PowerStationId FROM power_station_operation_personnel psop WHERE psop.UserId = @UserId AND psop.Deleted = 0) AND ps.Deleted = 0 "; if (!isPlatformLayer) { diff --git a/SolarPower/Repository/Interface/IStationReportRepository.cs b/SolarPower/Repository/Interface/IStationReportRepository.cs index c3f1f8a..3edc23f 100644 --- a/SolarPower/Repository/Interface/IStationReportRepository.cs +++ b/SolarPower/Repository/Interface/IStationReportRepository.cs @@ -13,5 +13,6 @@ namespace SolarPower.Repository.Interface Task> GetHire(PsIdAndSiteDB post); Task> GetMaxtablebody(Select_table2 post); Task Findhaveinv(Select_table post); + Task CheckExcelAsync(Select_table post); } } diff --git a/SolarPower/Views/AnalysisStationCombine/Index.cshtml b/SolarPower/Views/AnalysisStationCombine/Index.cshtml index a118405..bcde727 100644 --- a/SolarPower/Views/AnalysisStationCombine/Index.cshtml +++ b/SolarPower/Views/AnalysisStationCombine/Index.cshtml @@ -111,22 +111,25 @@ } -
-
-

有效日照時數

-
hr
-
-
-
-

當日有效日照時數

-

0.00

+ else + { +
+
+

日照度

+
k W/m2
-
-

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

-

0.00

+
+
+

當日日照度

+

0.00

+
+
+

平均日照度(30天)

+

0.00

+
-
+ }

PR值

@@ -143,7 +146,22 @@
- +
+
+

有效日照時數

+
hr
+
+
+
+

當日有效日照時數

+

0.00

+
+
+

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

+

0.00

+
+
+

減碳量

@@ -310,7 +328,7 @@ $("#today_kwhkwp_label").html(timename + "有效日照時數"); $("#today_PR_label").html(timename + "PR值"); $("#today_carbon_label").html(timename + "減碳量"); - + $("#today_irradiance_label").html(timename + "日照度"); if (type == 1) { timerange = $('#DateGettext').val(); @@ -412,7 +430,7 @@ $('#total_kwhkwp').html(rel.data.all_KWH_KWP.toFixed(2)); $('#total_PR').html(rel.data.all_PR.toFixed(2)); $('#total_carbon').html(rel.data.all_Carbon.toFixed(2)); - $('#total_irradiance').html(rel.data.all_Carbon.toFixed(2)); + $('#total_irradiance').html(rel.data.all_irradiance.toFixed(2)); $('#today_kwh').html(rel.data.now_kwh.toFixed(2)); @@ -420,7 +438,7 @@ $('#today_kwhkwp').html(rel.data.now_KWH_KWP.toFixed(2)); $('#today_PR').html(rel.data.now_PR.toFixed(2)); $('#today_carbon').html(rel.data.now_Carbon.toFixed(2)); - $('#today_irradiance').html(rel.data.now_Carbon.toFixed(2)); + $('#today_irradiance').html(rel.data.now_irradiance.toFixed(2)); chart(); }) diff --git a/SolarPower/Views/AnalysisStationInfo/Index.cshtml b/SolarPower/Views/AnalysisStationInfo/Index.cshtml index e00674a..4cc50c0 100644 --- a/SolarPower/Views/AnalysisStationInfo/Index.cshtml +++ b/SolarPower/Views/AnalysisStationInfo/Index.cshtml @@ -124,10 +124,10 @@ var PWS_compare_col = [ { key: "KWH", title: "發電量", default: true }, { key: "Irradiance", title: "日照度", default: false }, - { key: "KWHKWP", title: "發電小時", default: false }, + { key: "KWHKWP", title: "有效日照時數", default: false }, { key: "PR", title: "PR %", default: false }, { key: "Temperature", title: "模組溫度", default: false }, - { key: "SolarHour", title: "日照小時", default: false } + { key: "SolarHour", title: "日照小時", default: false }, ] var PWR_compare_col = [ { key: "OUTPUT_KWH", title: "輸出發電量(kWh)", default: true }, diff --git a/SolarPower/Views/Company/Index.cshtml b/SolarPower/Views/Company/Index.cshtml index d46f785..3aee15d 100644 --- a/SolarPower/Views/Company/Index.cshtml +++ b/SolarPower/Views/Company/Index.cshtml @@ -250,6 +250,9 @@ 'render': function (data, type, full, meta) { return ''; } + },{ + 'targets': 8, + 'visible': false }], "language": { "emptyTable": "查無資料", diff --git a/SolarPower/Views/ExceptionRecord/Index.cshtml b/SolarPower/Views/ExceptionRecord/Index.cshtml index bfd136a..33c3170 100644 --- a/SolarPower/Views/ExceptionRecord/Index.cshtml +++ b/SolarPower/Views/ExceptionRecord/Index.cshtml @@ -1,7 +1,7 @@ @{ ViewData["MainNum"] = "5"; ViewData["SubNum"] = "1"; - ViewData["Title"] = "異常記錄查詢"; + ViewData["Title"] = "即時告警管理"; } @using SolarPower.Models.Role @model RoleLayerEnum diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index eb128a3..a8f3d46 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -36,7 +36,7 @@
-

即時平均日照度

+

即時日照度

0.00

@@ -52,7 +52,7 @@
-

即時平均 PR 值

+

今日 PR 值

0.00

@@ -68,7 +68,7 @@
-

即時平均有效日照時數

+

今日有效日照時數(kwh/kwp)

0.00

@@ -278,10 +278,10 @@ '
' + '
' + '
' + - '
即時總發電量:' + item.today_kWh + '
'+ - '
即時平均日照度:' + item.today_irradiance + '
'+ - '
發電小時:' + item.solarHour + '
' + - '
裝置容量:' + item.generatingCapacity.toFixed(3) + '
' + + '
今日發電量(kW h):' + item.today_kWh.toFixed(2) + '
'+ + '
即時日照度(k W/m2):' + item.today_irradiance + '
'+ + '
有效日照時數(kwh/kwp):' + item.today_kwhkwp.toFixed(2) + '
' + + '
裝置容量(kWp):' + item.generatingCapacity.toFixed(3) + '
' + '
掛錶日期:' + item.electricityMeterAt + '
' + '
天氣:' + item.wx + '
'+ '
' + diff --git a/SolarPower/Views/Operation/OperationRecord.cshtml b/SolarPower/Views/Operation/OperationRecord.cshtml index d1c0204..a19c193 100644 --- a/SolarPower/Views/Operation/OperationRecord.cshtml +++ b/SolarPower/Views/Operation/OperationRecord.cshtml @@ -148,15 +148,16 @@
- +
- + +
@@ -164,7 +165,7 @@
- +
@@ -179,9 +180,10 @@
- + +
@@ -291,6 +293,7 @@ $(function () { //#region Date-Picker + datepicker = $('#date-range').daterangepicker({ autoUpdateInput: false, locale: { format: 'YYYY/MM/DD' }, @@ -597,6 +600,20 @@ //#endregion }); + $('#work_person_select_modal').change(function () { + if ($('#work_person_select_modal').val().length == 0) { + $('#work_person_select_modal-error').show(); + } else { + $('#work_person_select_modal-error').hide(); + } + }); + + $('#work_time_modal').change(function () { + $("#work_time_modal-error").hide(); + }); + + + function getPowerStationCheckBox() { var send_data = { cityIds: ids @@ -675,15 +692,19 @@ //#region 新增維修單 function AddRecord() { selected_id = 0; + selected_work_type = 2; + record = undefined; $("#record-form-modal .modal-title .main-title").html("維修單"); $("#record-form-modal .modal-title .sub-title").html(""); $("#power_station_select_modal").attr("disabled", false); + $("#power_station_select_modal").val($("#power_station_select_modal option:first").val()).trigger('change'); $(".fix-div").show(); $("#record-form").trigger("reset"); $("input[name=status_modal][value='" + 0 + "']").prop('checked', true); //狀態 $("#record_files_div > .row").empty(); - + $('#work_person_select_modal-error').hide(); + $("#work_time_modal-error").hide(); @@ -994,6 +1015,8 @@ } $("input[name=status_modal][value='" + status + "']").prop('checked', true); //狀態 $('#work_person_select_modal').val(record.workPersonIds).trigger("change"); + + selected_work_type = work_type; if (work_type != 2) { $(".fix-div").hide(); } else { @@ -1024,7 +1047,7 @@ //#region 表單驗證 $("#record-form").validate({ rules: { - work_person_select_modal: { + work_time_modal: { required: true } }, @@ -1033,70 +1056,82 @@ //#region 儲存表單資料 function SaveRecord() { - Swal.fire( - { - title: "儲存", - text: "你確定是否儲存此筆資料?\r\n 儲存成功後將會發送Email至負責人員及廠商", - type: "warning", - icon: 'warning', - showCancelButton: true, - confirmButtonText: "是", - cancelButtonText: "否" - }).then(function (result) { - if (result.value) { - if ($("#record-form").valid()) { - var url = "/Operation/SaveOperationRecord"; + if ($('#work_person_select_modal').val().length > 0 && $("#work_time_modal").val() != "") { + Swal.fire( + { + title: "儲存", + text: "你確定是否儲存此筆資料?\r\n 儲存成功後將會發送Email至負責人員及廠商", + type: "warning", + icon: 'warning', + showCancelButton: true, + confirmButtonText: "是", + cancelButtonText: "否" + }).then(function (result) { + if (result.value) { + if ($("#record-form").valid()) { + var url = "/Operation/SaveOperationRecord"; - var formData = new FormData(); + var formData = new FormData(); - @*var work_person_ids = $.map($("#work_person_select_modal").val(), function (item) { - return parseInt(item); - }) *@ + @*var work_person_ids = $.map($("#work_person_select_modal").val(), function (item) { + return parseInt(item); + }) *@ - formData.append("Id", selected_id); - formData.append("PowerStationId", $("#power_station_select_modal").val()); - formData.append("WorkType", selected_work_type); - formData.append("ErrorCode", $("#error_code_modal").val()); - formData.append("FixDo", $("#fix_do_modal").val()); - formData.append("FixFirm", $("#fix_firm_select_modal").val()); - formData.append("Status", $("input[name=status_modal]:checked").val()); - $("#work_person_select_modal").val().forEach(function (item) { - formData.append("WorkPersonIds", parseInt(item)); - }); - formData.append("WorkTime", $("#work_time_modal").val()); - formData.append("Notice", $("#notice_textarea_modal").val()); - formData.append("Description", $("#description_textarea_modal").val()); + formData.append("Id", selected_id); + formData.append("PowerStationId", $("#power_station_select_modal").val()); + formData.append("WorkType", selected_work_type); + formData.append("ErrorCode", $("#error_code_modal").val()); + formData.append("FixDo", $("#fix_do_modal").val()); + formData.append("FixFirm", $("#fix_firm_select_modal").val()); + formData.append("Status", $("input[name=status_modal]:checked").val()); + $("#work_person_select_modal").val().forEach(function (item) { + formData.append("WorkPersonIds", parseInt(item)); + }); + formData.append("WorkTime", $("#work_time_modal").val()); + formData.append("Notice", $("#notice_textarea_modal").val()); + formData.append("Description", $("#description_textarea_modal").val()); - $.ajax({ - type: "POST", - url: url, - data: formData, - cache: false, - contentType: false, - processData: false, - success: function (rel) { - if (rel.code != "0000") { - toast_error(rel.msg); - return; - } + $.ajax({ + type: "POST", + url: url, + data: formData, + cache: false, + contentType: false, + processData: false, + success: function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } - var myDropzone = Dropzone.forElement("#record-file-form"); + var myDropzone = Dropzone.forElement("#record-file-form"); - if (myDropzone.files.length > 0) { + if (myDropzone.files.length > 0) { - selected_id = rel.data; + selected_id = rel.data; - myDropzone.processQueue(); + myDropzone.processQueue(); - myDropzone.on("successmultiple", function (file, rel) { - if (rel.code != "0000") { - toast_error(rel.msg); - return; - } + myDropzone.on("successmultiple", function (file, rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } - toast_ok(rel.msg); + toast_ok(rel.msg); + $('#record-form-modal').modal('hide'); + recordFileDropzone.removeAllFiles(); + if (status == 2) { + operationRecordTable.column(10).visible(true); + } + else { + operationRecordTable.column(10).visible(false); + } + operationRecordTable.ajax.reload(); + }); + } else { $('#record-form-modal').modal('hide'); - recordFileDropzone.removeAllFiles(); + myDropzone.removeAllFiles(); if (status == 2) { operationRecordTable.column(10).visible(true); } @@ -1104,29 +1139,25 @@ operationRecordTable.column(10).visible(false); } operationRecordTable.ajax.reload(); - }); - } else { - $('#record-form-modal').modal('hide'); - myDropzone.removeAllFiles(); - if (status == 2) { - operationRecordTable.column(10).visible(true); } - else { - operationRecordTable.column(10).visible(false); - } - operationRecordTable.ajax.reload(); } - } - }); + }); + } } - } - }); - - - - - - + }); + } + else + { + if ($('#work_person_select_modal').val().length == 0) + { + $('#work_person_select_modal-error').show(); + } + if ($("#work_time_modal").val() == "") + { + $("#work_time_modal-error").show(); + } + + } } //#endregion diff --git a/SolarPower/Views/PowerStation/Index.cshtml b/SolarPower/Views/PowerStation/Index.cshtml index ade8cdc..cd0b781 100644 --- a/SolarPower/Views/PowerStation/Index.cshtml +++ b/SolarPower/Views/PowerStation/Index.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["MainNum"] = "6"; + ViewData["MainNum"] = "8"; ViewData["SubNum"] = "1"; ViewData["Title"] = "電站管理"; } @@ -135,7 +135,6 @@ - @@ -353,8 +352,7 @@ } $('#solarTable' + val.cityId).find('tbody').append('' + - '' + - '' + + '' + '' + '' + diff --git a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml index 38a9bf5..ea46e76 100644 --- a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml +++ b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml @@ -1,5 +1,5 @@ @{ - ViewData["MainNum"] = "6"; + ViewData["MainNum"] = "8"; ViewData["SubNum"] = "1"; ViewData["Title"] = "電站管理"; } diff --git a/SolarPower/Views/PowerStation/_StationInfo.cshtml b/SolarPower/Views/PowerStation/_StationInfo.cshtml index e77332e..f15bea0 100644 --- a/SolarPower/Views/PowerStation/_StationInfo.cshtml +++ b/SolarPower/Views/PowerStation/_StationInfo.cshtml @@ -151,7 +151,7 @@
- +
diff --git a/SolarPower/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index 731544d..7d43486 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -154,12 +154,12 @@ --> } @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin - || ViewBag.auths.Contains("AnalysisStationCombine") - || ViewBag.auths.Contains("AnalysisStationInfo") - || ViewBag.auths.Contains("AnalysisInverter")) + || ViewBag.auths.Contains("AnalysisStationCombine") + || ViewBag.auths.Contains("AnalysisStationInfo") + || ViewBag.auths.Contains("AnalysisInverter")) {
  • @@ -282,10 +282,10 @@
  • } @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin - || ViewBag.auths.Contains("StationReport") - || ViewBag.auths.Contains("ElectricitySoldRecord") - || ViewBag.auths.Contains("PowerGeneration") - || ViewBag.auths.Contains("NoticeSchedule")) + || ViewBag.auths.Contains("StationReport") + || ViewBag.auths.Contains("ElectricitySoldRecord") + || ViewBag.auths.Contains("PowerGeneration") + || ViewBag.auths.Contains("NoticeSchedule")) {
  • @@ -295,38 +295,38 @@
  • @@ -348,8 +348,23 @@ } - - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation") || ViewBag.auths.Contains("Operation") || ViewBag.auths.Contains("OperationRecord")) + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStationManager")) + { +
  • + + + 電站管理 + + +
  • + } + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("Operation") || ViewBag.auths.Contains("OperationRecord")) {
  • @@ -357,14 +372,7 @@ 運維管理
      - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation")) - { -
    • - - 電站管理 - -
    • - } + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("Operation")) {
    • @@ -410,21 +418,21 @@
    • } @*@if (ViewBag.auths.Contains("User")) - { -
    • - - 功能清單 - -
    • - } - @if (ViewBag.auths.Contains("User")) - { -
    • - - 定時任務設定 - -
    • - }*@ + { +
    • + + 功能清單 + +
    • + } + @if (ViewBag.auths.Contains("User")) + { +
    • + + 定時任務設定 + +
    • + }*@
  • } diff --git a/SolarPower/Views/StationOverview/Index.cshtml b/SolarPower/Views/StationOverview/Index.cshtml index 3c2ed0a..ede80d0 100644 --- a/SolarPower/Views/StationOverview/Index.cshtml +++ b/SolarPower/Views/StationOverview/Index.cshtml @@ -94,7 +94,7 @@
    -

    即時平均日照度

    +

    即時日照度

    0.00

    @@ -110,7 +110,7 @@
    -

    即時平均 PR 值

    +

    今日 PR 值

    0.00

    @@ -126,7 +126,7 @@
    -

    即時平均有效日照時數

    +

    今日有效日照時數(kwh/kwp)

    0.00

    @@ -425,13 +425,14 @@ $('#card_' + val.id).find('#stationtype').html(type); var time = new Date(val.createdAt); $('#card_' + val.id).find('#editSolarUrl').attr('href', localurl + '/Info?stationId=' + val.id); - $('#card_' + val.id).find('#date').html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes()); + @*$('#card_' + val.id).find('#date').html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());*@ + $('#card_' + val.id).find('#date').html(val.electricityMeterAt); $('#card_' + val.id).find('#today_kwh').html(val.today_kWh.toFixed(2)); $('#card_' + val.id).find('#Capacity').html(val.generatingCapacity.toFixed(3)); @if (ViewBag.myUser.Role.Auths.Contains("ShowMoney")) { - $('#card_' + val.id).find('#PowerRate').html((val.today_kWh * val.powerRate).toFixed()); + $('#card_' + val.id).find('#PowerRate').html((val.today_Money).toFixed()); } $('#card_' + val.id).find('#PR').html(val.today_PR); diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index f7a0cdd..3b96580 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -1,11 +1,10 @@ @{ - ViewData["MainNum"] = "1"; - ViewData["SubNum"] = "2"; + ViewData["MainNum"] = "2"; + //ViewData["SubNum"] = "2"; ViewData["Title"] = "電站總覽"; } @using SolarPower.Models.Role @model RoleLayerEnum - @*
    ' + '' + '' + - '' + + '' + '' + '' + '' + ''); listmonth.push(val.timestamp); - listkwh.push(val.kwh.toFixed(2)); + listkwh.push(parseFloat(val.kwh.toFixed(2))); listcolor.push(color); listcolor2.push(color2); - listirradiance.push(val.irradiance.toFixed(2)); - listtemperature.push(val.temp.toFixed(2)); - listsolarhour.push(val.solarhour.toFixed(2)); - listpr.push(val.pr.toFixed(2)); + listirradiance.push(parseFloat(val.irradiance.toFixed(2))); + listtemperature.push(parseFloat(val.temp.toFixed(2))); + listsolarhour.push(parseFloat(val.solarhour.toFixed(2))); + listpr.push(parseFloat(val.pr.toFixed(2))); + listkwhkwp.push(parseFloat(val.kwhkwp.toFixed(2))); } else { + if (groupType == 0 && kwhkwp < val.kwhkwp.toFixed(2)) { + kwhkwp = val.kwhkwp.toFixed(2); + } + if (groupType != 0) { + ALLkwhkwp += val.kwhkwp; + kwhkwp = (ALLkwhkwp / times).toFixed(2); + times++; + } diffSOLARHOURALL += val.diffSOLARHOUR; $('#HistoryDetailTable').append('' + '' + '' + - '' + + '' + '' + '' + '' + ''); listmonth.push(val.timestamp); - listkwh.push(val.kwh.toFixed(2)); + listkwh.push(parseFloat(val.kwh.toFixed(2))); listcolor.push(color); listcolor2.push(color2); - listirradiance.push(val.irradiance.toFixed(2)); - listtemperature.push(val.temp.toFixed(2)); - listsolarhour.push(val.solarhour.toFixed(2)); - listpr.push(val.pr.toFixed(2)); + listirradiance.push(parseFloat(val.irradiance.toFixed(2))); + listtemperature.push(parseFloat(val.temp.toFixed(2))); + listsolarhour.push(parseFloat(val.solarhour.toFixed(2))); + listpr.push(parseFloat(val.pr.toFixed(2))); + listkwhkwp.push(parseFloat(val.kwhkwp.toFixed(2))); } @@ -2451,7 +2483,105 @@ tempALL = tempALL / rel.data.length; + $('#history-kWh-convas-div').empty(); + $('#history-kWh-convas-div').append('
    '); + chart = new Highcharts.Chart({ + lang: { //匯出相關中文名稱配置 + printChart: '列印圖表', + downloadJPEG: '下載JPEG檔案', + downloadPDF: '下載PDF檔案', + downloadPNG: '下載PNG檔案', + downloadSVG: '下載SVG檔案', + downloadCSV: '下載CSV檔案', + downloadXLS: '下載XLS檔案', + viewData: '檢視資料表格', + viewFullscreen: '全屏檢視' + }, + chart: { + renderTo: 'history-kWh', + height: 600, + animation: false + }, + title: { + text: '發電量及日照度' + }, + xAxis: { + categories: listmonth, + }, + yAxis: [{ + title: { + text: "kWh" + }, + id: "A", + opposite: false, + showEmpty: false + }, { + title: { + text: "kWh/㎡" + }, + id: "B", + opposite: true, + showEmpty: false + }, { + title: { + text: "hr" + }, + id: "C", + opposite: true, + showEmpty: false + }, { + title: { + text: "PR(%)" + }, + id: "D", + opposite: true, + showEmpty: false + }, { + title: { + text: "溫度(℃)" + }, + id: "E", + opposite: true, + showEmpty: false + }], + + series: [{ + type: 'spline', + name: "溫度(℃)", + data: listtemperature, + yAxis: "E", + color: "rgb(255, 192, 0)", + zIndex: 4 + }, { + type: 'spline', + name: "日照度(kWh/㎡)", + data: listirradiance, + yAxis: "B", + color: "rgb(190, 45, 45)", + zIndex: 3 + }, { + type: 'column', + name: "PR(%)", + data: listpr, + yAxis: "D", + color: 'rgb(68, 114, 196)' + }, { + type: 'column', + name: "有效日照時數", + data: listkwhkwp, + yAxis: "C", + color: "rgb(165, 165, 165)" + }, { + type: 'column', + name: "發電量(kWh)", + data: listkwh, + yAxis: "A", + color: "rgb(103, 180, 172)" + }], + }); + + @*$('#history-kWh-convas-div').empty(); $('#history-kWh-convas-div').append(''); var ctx_history_kWh = document.getElementById('history-kWh').getContext('2d'); var myhistorykwh = new Chart(ctx_history_kWh, { @@ -2494,11 +2624,11 @@ data: listpr },{ type: 'bar', - label: '發電小時', + label: '有效日照時數', yAxisID: 'C', backgroundColor: 'rgba(165, 165, 165)', borderWidth: 1, - data: listsolarhour + data: listkwhkwp },{ type: 'bar', backgroundColor: 'rgba(103, 180, 172, 1)', @@ -2576,7 +2706,7 @@ }] } } - }); + });*@ @@ -2589,7 +2719,7 @@ $('#HistoryTotalTable').append('' + '' + '' + - '' + + '' + '' + '' + '' + @@ -2614,9 +2744,15 @@ return; } $("#Invertercard-Name").html(rel.data.name); - $("#Invertercard-kwh").html(rel.data.kwh); - $("#Invertercard-money").html(rel.data.today_Money.toFixed()); - $("#Invertercard-pr").html(rel.data.today_PR); + $("#Invertercard-kwh").html(rel.data.kwh.toFixed(2)); + @if (ViewBag.myUser.Role.Auths.Contains("ShowMoney")) + { + + $("#Invertercard-money").html(rel.data.today_Money.toFixed()); + + } + $("#Invertercard-Capacity").html(rel.data.generatingCapacity.toFixed(3)); + $("#Invertercard-pr").html(rel.data.today_PR.toFixed(2)); var str = "
    " + "
    " $('#prbar').remove(); @@ -2634,12 +2770,12 @@ break; } $("#Invertercard-type").html(TypeName); - var time = new Date(rel.data.createdAt); - $("#Invertercard-date").html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes()); - + @*var time = new Date(rel.data.createdAt); + $("#Invertercard-date").html(time.getMonth() + "/" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes());*@ + $("#Invertercard-date").html(rel.data.electricityMeterAt); var urlPath = "../upload/power_station/" + rel.data.id + "/" + rel.data.mainDisplay; - var xmlhttp; + var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest();//其他浏览器 } @@ -2853,7 +2989,7 @@ ACDetail += ""; } ACDetail += ""; - ACDetail += ""; + ACDetail += ""; ACDetail += ""; ACDetail += ""; ACDetail += ""; @@ -2892,7 +3028,7 @@ }) - + } diff --git a/SolarPower/Views/StationOverview/_History.cshtml b/SolarPower/Views/StationOverview/_History.cshtml index e13f240..b6dbe1a 100644 --- a/SolarPower/Views/StationOverview/_History.cshtml +++ b/SolarPower/Views/StationOverview/_History.cshtml @@ -60,7 +60,7 @@ - + @@ -84,7 +84,7 @@ - + diff --git a/SolarPower/Views/StationOverview/_InverterInfo.cshtml b/SolarPower/Views/StationOverview/_InverterInfo.cshtml index 3918e43..a1f5b9f 100644 --- a/SolarPower/Views/StationOverview/_InverterInfo.cshtml +++ b/SolarPower/Views/StationOverview/_InverterInfo.cshtml @@ -6,25 +6,43 @@
    ...
    -

    新竹巨城站

    -

    +

    新竹巨城站

    +
    +

    27°C

    +
    -

    發電量

    -

    185 kWh

    -

    27°C

    +
    +

    發電量

    +

    0.00 kWh

    +
    + @if (ViewBag.myUser.Role.Auths.Contains("ShowMoney")) + { +
    + @*

    發電金額

    *@ +

    0 NT

    +
    + }
    -

    發電金額

    -

    2,5840 NT

    -

    自建躉售

    +
    +

    裝置容量

    +

    0.00 kWp

    +
    +
    +

    自建躉售

    +
    -

    PR值

    -

    90 %

    -

    17:50:36

    +
    +

    PR值

    +

    0 %

    +
    +
    +

    06-30 17:50

    +
    @@ -32,7 +50,6 @@
      -
    diff --git a/SolarPower/Views/StationOverview/_UpToDate.cshtml b/SolarPower/Views/StationOverview/_UpToDate.cshtml index 542cbc3..0002ad9 100644 --- a/SolarPower/Views/StationOverview/_UpToDate.cshtml +++ b/SolarPower/Views/StationOverview/_UpToDate.cshtml @@ -39,7 +39,7 @@
    -

    即時平均日照度

    +

    即時日照度

    0.00

    @@ -55,7 +55,7 @@
    -

    即時平均 PR 值

    +

    今日 PR 值

    0.00

    @@ -71,7 +71,7 @@
    -

    即時平均有效日照時數

    +

    今日有效日照時數(kwh/kwp)

    0.00

    diff --git a/SolarPower/Views/StationReport/Index.cshtml b/SolarPower/Views/StationReport/Index.cshtml index 56b1443..3b2739e 100644 --- a/SolarPower/Views/StationReport/Index.cshtml +++ b/SolarPower/Views/StationReport/Index.cshtml @@ -266,7 +266,7 @@
    - + @@ -303,7 +303,7 @@ var haveinvertName = []; var nowform; var xxx; - + var button; $(function () { //#region 預設初始值 $('#collapse').trigger("click"); @@ -533,7 +533,7 @@ } $(e).removeClass("btn-outline-success").addClass("btn-success"); if (nowform != null && nowform != 2) { - Dateform(nowform); + Dateform(nowform, button); } } //#endregion @@ -783,7 +783,7 @@ str += ""; str += ""; str += ""; - str += ""; + str += ""; str += ""; str += ""; str += ""; @@ -795,7 +795,7 @@ str += ""; str += ""; str += ""; - str += ""; + str += ""; str += ""; str += ""; if (rel.data.showMoney == 1) { @@ -813,7 +813,7 @@ str += ""; str += ""; str += ""; - str += ""; + str += ""; str += ""; str += ""; str += ""; @@ -838,7 +838,7 @@ $(".btn-report").removeClass("btn-success").addClass("btn-primary"); } $(e).removeClass("btn-primary").addClass("btn-success"); - + button = e; $('#hiretable').hide(); @@ -897,11 +897,12 @@ } $('#TableBody').empty(); $('#totbody').empty(); + haveinvertName = []; return; } - var sta = ""; - $('#TableBody').empty(); + //var sta = ""; + $('#totbody').empty(); $('#tothead').empty(); if (form == 0) {//日報表 @@ -911,7 +912,7 @@ var kWhkwp = 0; var ntd = 0; var ntdone = 0; - + var sta = ""; $.each(rel.data, function (index, inverter) { sta += ""; sta += ""; @@ -939,7 +940,7 @@ }) var stc = ""; stc += ""; - stc += ""; + stc += ""; stc += ""; stc += ""; if (showmoney == 1) { @@ -961,6 +962,7 @@ stb += ""; + $('#TableBody').empty(); $('#TableBody').append(sta); $('#totbody').append(stb); $('#tothead').append(stc); @@ -974,7 +976,7 @@ var monthmoney = 0; var monthmoneyone = 0; var monthday = 0; - + var sta = ""; var check_hire = false; var sitedb = ""; $.each(rel.data, function (index, inverter) { @@ -988,10 +990,10 @@ } }); sta += ""; - sta += ""; + sta += ""; sta += ""; sta += ""; - sta += ""; + sta += ""; sta += ""; sta += ""; if (showmoney == 1) { @@ -1016,7 +1018,7 @@ var stc = ""; stc += ""; - stc += ""; + stc += ""; stc += ""; stc += ""; if (showmoney == 1) { @@ -1078,7 +1080,7 @@ }) } - + $('#TableBody').empty(); $('#TableBody').append(sta); $('#totbody').append(stb); $('#tothead').append(stc); @@ -1094,7 +1096,7 @@ var monthmoney = 0; var monthmoneyone = 0; var monthday = 0; - + var sta = ""; var check_hire = false; var sitedb = ""; $.each(rel.data, function (index, inverter) { @@ -1136,7 +1138,7 @@ var stc = ""; stc += ""; - stc += ""; + stc += ""; stc += ""; stc += ""; if (showmoney == 1) { @@ -1198,7 +1200,7 @@ }) } - + $('#TableBody').empty(); $('#TableBody').append(sta); $('#totbody').append(stb); $('#tothead').append(stc); @@ -1223,7 +1225,25 @@ PowerStation: selecterd_invert } if (send_data.FormType != null && send_data.PowerStation.length != 0 && send_data.FormType != 2) { - window.location = "/StationReport/ExportExcel?post=" + JSON.stringify(send_data); + $.post("/StationReport/CheckExcel", send_data, function (rel) { + if (rel.code == "0000") { + window.location = "/StationReport/ExportExcel?post=" + JSON.stringify(send_data); + return; + } + else + { + var text = "原因如下:"; + $.each(rel.data, function (index, val) { + text += index + 1 + "." + val + ""; + }); + Swal.fire( + { + title: "Excel匯出失敗", + icon: 'warning', + html: text, + }); + } + }, 'json'); } else { @@ -1295,6 +1315,7 @@ city: data.cityName, kwp: data.kwh, hour: data.solarHour, + kwhkwp: data.avgKWHKWP, count : 1 } if (CityArray.length == 0) { @@ -1308,6 +1329,7 @@ n.kwp += cityinfo.kwp; n.hour += cityinfo.hour; n.count += cityinfo.count; + n.kwhkwp += cityinfo.kwhkwp npush = false; } }); @@ -1321,7 +1343,7 @@ StrInfoBody += ""; StrInfoBody += ""; StrInfoBody += ""; - StrInfoBody += ""; + StrInfoBody += ""; StrInfoBody += ""; StrInfoBody += ""; if (showmoney == 1) { @@ -1344,7 +1366,7 @@ CityInfoBody += ""; CityInfoBody += ""; CityInfoBody += ""; - CityInfoBody += ""; + CityInfoBody += ""; CityInfoBody += ""; }) //上面 diff --git a/SolarPower/appsettings.Development.json b/SolarPower/appsettings.Development.json index a4eacb3..a50b12a 100644 --- a/SolarPower/appsettings.Development.json +++ b/SolarPower/appsettings.Development.json @@ -37,7 +37,9 @@ "UserName": "shanghohui@gmail.com", "Password": "wswgnluvoodfexrb", "EnableSsl": true - } + }, + "ExceptionTimes": 240 //`qɶA() + //"SMTPConfig": { // "Host": "smtp.gmail.com", // "Port": 25, diff --git a/SolarPower/appsettings.json b/SolarPower/appsettings.json index ef0a5ff..e8efcfa 100644 --- a/SolarPower/appsettings.json +++ b/SolarPower/appsettings.json @@ -38,5 +38,6 @@ "UserName": "ficgreen01@gmail.com", "Password": "qwe2015qwe", "EnableSsl": true - } + }, + "ExceptionTimes": 240 //`qɶA() } diff --git a/solarApp/Service/procStationSvc.cs b/solarApp/Service/procStationSvc.cs index 3325749..ce1fc12 100644 --- a/solarApp/Service/procStationSvc.cs +++ b/solarApp/Service/procStationSvc.cs @@ -129,7 +129,7 @@ namespace solarApp.Service string sql = @" select id as PowerStationID from solar_master.power_station where `code` = @siteID"; var ds = conn.Query(sql, new { siteID = _siteID }).AsList(); - _powerStationID = (ds.Count > 0) ? ds[0][0].ToString() : "0"; + _powerStationID = (ds.Count > 0) ? ds[0].ToString() : "0"; #region hour -- solar_type 計費類別:0 自建、1 租建、2自建 ------------ 1 租建計算方式 後再再補上 @@ -158,21 +158,21 @@ namespace solarApp.Service select b.id PowerStationId, concat(FROM_UNIXTIME(`TIMESTAMP`/1000, '%Y-%m-%d %H'), ':00:00') reportdate, a.siteid, a.siteType, a.KWH, TODAYKWH, TOTALKWH, KWHKWP , PR, MP, a.SOLARHOUR , - CASE - WHEN b.SolarType = 1 THEN a.KWH * c.LeaseRate + /* CASE + WHEN b.SolarType = 1 THEN a.KWH * PowerRate * c.LeaseRate ELSE a.KWH * PowerRate END MONEY, CASE - WHEN b.SolarType = 1 THEN a.TODAYKWH * c.LeaseRate + WHEN b.SolarType = 1 THEN a.TODAYKWH * PowerRate * c.LeaseRate ELSE a.TODAYKWH * PowerRate END TODAYMONEY, CASE - WHEN b.SolarType = 1 THEN a.TOTALKWH * c.LeaseRate + WHEN b.SolarType = 1 THEN a.TOTALKWH * PowerRate * c.LeaseRate ELSE a.TOTALKWH * PowerRate - END TOTALMONEY, - -- (a.KWH * PowerRate) MONEY, - -- (a.TODAYKWH * PowerRate) TODAYMONEY, - -- (a.TOTALKWH * PowerRate) TOTALMONEY, + END TOTALMONEY,*/ + (a.KWH * PowerRate) MONEY, + (a.TODAYKWH * PowerRate) TODAYMONEY, + (a.TOTALKWH * PowerRate) TOTALMONEY, (a.KWH * CarbonRate) CARBON, (a.TODAYKWH * CarbonRate) TODAYCARBON, round((a.TOTALKWH * CarbonRate), 3) TOTALCARBON from " + _siteDB + ".s" + _siteID01 + @"_station a join (select id, `code` siteID, PowerRate, (select `value` from solar_master.`variable` where `name` = 'CarbonRate') as CarbonRate, SolarType @@ -187,7 +187,7 @@ namespace solarApp.Service GROUP BY lb.PowerStationId ) c ON a.siteID = c.siteID where FROM_UNIXTIME(`TIMESTAMP`/1000,'%Y-%m-%d') = @date1 and a.SITEID = @siteID "; - int ct = conn.Execute(sql, new { date1 = _date1, siteID = _siteID }); + //int ct = conn.Execute(sql, new { date1 = _date1, siteID = _siteID }); #endregion hour @@ -196,16 +196,16 @@ namespace solarApp.Service PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON) select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, a.TODAYKWH, a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR, - CASE - WHEN b.SolarType = 1 THEN a.KWH * c.LeaseRate + /*CASE + WHEN b.SolarType = 1 THEN a.KWH * PowerRate * c.LeaseRate ELSE a.KWH * PowerRate END MONEY, CASE - WHEN b.SolarType = 1 THEN a.TOTALKWH * c.LeaseRate + WHEN b.SolarType = 1 THEN a.TOTALKWH * PowerRate * c.LeaseRate ELSE a.TOTALKWH * PowerRate - END TOTALMONEY, - -- (KWH * PowerRate) MONEY, - -- (a.TOTALKWH * PowerRate) TOTALMONEY, + END TOTALMONEY,*/ + (KWH * PowerRate) MONEY, + (a.TOTALKWH * PowerRate) TOTALMONEY, (KWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON from ( @@ -229,7 +229,7 @@ namespace solarApp.Service WHERE ps.Code = @siteID GROUP BY lb.PowerStationId ) c ON a.siteID = c.siteID"; - conn.Execute(sql, new { date1 = _date1, siteID = _siteID }); + //conn.Execute(sql, new { date1 = _date1, siteID = _siteID }); #endregion day #region month @@ -240,16 +240,16 @@ namespace solarApp.Service PR, MP, SOLARHOUR, MONEY, TOTALMONEY, CARBON, TOTALCARBON) select b.id PowerStationId, a.reportdate, b.siteID, a.siteType, TODAYKWH as monthKwh , a.TOTALKWH, a.KWHKWP, a.PR, a.MP, a.SOLARHOUR, - CASE + /*CASE WHEN b.SolarType = 1 THEN a.TODAYKWH * c.LeaseRate ELSE a.TODAYKWH * PowerRate END MONEY, CASE WHEN b.SolarType = 1 THEN a.TOTALKWH * c.LeaseRate ELSE a.TOTALKWH * PowerRate - END TOTALMONEY, - -- (TODAYKWH * PowerRate) MONEY, - -- (a.TOTALKWH * PowerRate) TOTALMONEY, + END TOTALMONEY,*/ + (TODAYKWH * PowerRate) MONEY, + (a.TOTALKWH * PowerRate) TOTALMONEY, (TODAYKWH * CarbonRate) CARBON, round((a.TOTALKWH * CarbonRate), 4) TOTALCARBON from (
    編號 電站名稱 裝置容量(kWp) 逆變器數量
    ' + val.id + '' + val.name + '' + val.name + '' + val.generatingCapacity.toFixed(3) + '' + val.inverterAmount + '
    ' + val.timestamp + '' + val.kwh.toFixed(2) + '' + val.solarhour.toFixed(2) + '' + val.kwhkwp.toFixed(2) + '' + val.irradiance.toFixed(2) + '' + val.pr.toFixed(2) + '' + val.temp.toFixed(2) + '
    ' + val.timestamp + '' + val.kwh.toFixed(2) + '' + val.diffSOLARHOUR.toFixed(2) + '' + val.kwhkwp.toFixed(2) + '' + val.irradiance.toFixed(2) + '' + val.pr.toFixed(2) + '' + val.temp.toFixed(2) + '
    ' + TimestampALL + '' + kwhALL.toFixed(2) + '' + diffSOLARHOURALL.toFixed(2) + '' + kwhkwp + '' + irradianceALL.toFixed(2) + '' + prALL.toFixed(2) + '' + tempALL.toFixed(2) + '
    輸出功率 " + ((rel.data.aC1W + rel.data.aC2W + rel.data.aC3W) / 1000).toFixed(2) + " KW輸出功率 " + ((rel.data.aC1W + rel.data.aC2W + rel.data.aC3W) / 1000).toFixed(2) + " KW
    PR " + rel.data.pr.toFixed(2) + " %
    時間 發電量(kWh)發電小時有效日照時數 日照度(kWh/m2) PR(%) 溫度(℃)
    時間 發電量(kWh)發電小時有效日照時數 日照度(kWh/m2) PR(%) 溫度(℃)
    縣市 平均發電量(kWp)發電時間(小時)有效發電小時

    發電量
    (kWh)

    發電量
    百分比
    (%)
    日照小時(hr)kWH/kWP有效發電小時PR%
    平均
    日照度
    (W/㎡)

    平均
    模組溫度
    (°C)
    區域電站名稱發電量發電小時有效發電小時平均日照PR
    發電量
    (kWh)

    發電量
    百分比
    (%)
    日照小時(hr)kWH/kWP有效發電小時PR%
    平均
    日照度
    (W/㎡)

    平均
    模組溫度
    (°C)
    " + inverter.report_date + "
    " + '日照小時' + "" + 'kWH/kWP' + "" + '有效發電小時' + "" + 'PR%' + "" + '日發電量(kWh)' + "
    " + inverter.dayKWH + "" + inverter.dayKWHp + "" + ((inverter.dayKWHp == null) ? 0 : inverter.dayKWHp) + "" + inverter.tothour + "" + inverter.KWHKWP + "" + inverter.PR.toFixed(2) + "" + ((inverter.PR == null) ? 0 : inverter.PR.toFixed(2)) + "" + inverter.irradiance + "" + inverter.temperature + "
    " + '日照平均(日)' + "" + 'kWH/kWP(日)' + "" + '有效發電小時(日)' + "" + '發電量平均(kWh)(日)' + "" + '發電量(kWh)(月)' + "
    " + '日照平均(月)' + "" + 'kWH/kWP(月)' + "" + '有效發電小時(月)' + "" + '發電量平均(kWh)(月)' + "" + '發電量(kWh)(年)' + "" + data.cityName + data.areaName + "" + data.powerstationName + "" + data.kwh.toFixed(2) + "" + data.solarHour.toFixed(2) + "" + data.avgKWHKWP.toFixed(2) + "" + data.avgIrradiance.toFixed(2) + "" + data.avgPR.toFixed(2) + "
    " + data.city + "" + (data.kwp / data.count).toFixed(2) + "" + (data.hour / data.count).toFixed(2) + "" + (data.kwhkwp / data.count).toFixed(2) + "