From 4480132d2ea59f0be1d3ff8b0f654c47727f6641 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Thu, 23 Sep 2021 13:36:11 +0800 Subject: [PATCH 01/38] =?UTF-8?q?Line=E6=9B=B4=E6=8F=9B=E5=85=A7=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Quartz/Jobs/ExceptionSchedule.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs index 80f7107..7d3468a 100644 --- a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs +++ b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs @@ -80,6 +80,7 @@ namespace SolarPower.Quartz.Jobs var powerstation = await powerStationRepository.GetOneAsync(Exception.PowerStationId); if(powerstation.line_token != null) { + Content = " %0D%0A " + Content.Replace("
", " %0D%0A "); CallLineToken(Content, powerstation.line_token); } } From 7c79b97825e9feba71f26f1157eb87da4bc84029 Mon Sep 17 00:00:00 2001 From: Kai Date: Thu, 23 Sep 2021 13:53:41 +0800 Subject: [PATCH 02/38] =?UTF-8?q?1.=20=E7=B5=B1=E4=B8=80=20=E8=A8=88?= =?UTF-8?q?=E7=AE=97=E6=96=B9=E5=BC=8F=202.=20=E4=BF=AE=E6=94=B9=20?= =?UTF-8?q?=E5=90=88=E4=BD=B5=E9=9B=BB=E7=AB=99=E8=A8=88=E7=AE=97=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Quartz/Jobs/CalcPowerStationJob.cs | 139 +++++++++--------- .../AnalysisStationCombineRepository.cs | 4 +- SolarPower/Views/StationOverview/Index.cshtml | 2 +- 3 files changed, 72 insertions(+), 73 deletions(-) diff --git a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs index 23ddf88..5223923 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 { @@ -139,24 +137,24 @@ namespace SolarPower.Quartz.Jobs { case (int)SolarTypeEnum.SelfSold: //自建躉售 - 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; - } + //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; + //今日發電金額 計算方式: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; + ////總發電金額 計算方式:totalkWh * 授電費率 + calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate; + //calcPowerStation.Total_Money = history.TOTALMONEY; break; case (int)SolarTypeEnum.HireSold: //租建躉售 //找出該電站的所有土地房屋資訊 @@ -170,43 +168,49 @@ namespace SolarPower.Quartz.Jobs } //avgLeaseRate = sumLeaseRate / landBuildings.Count(); - if (lastmoneyhistorybyhour != null) - { - history.TODAYMONEY = lastmoneyhistorybyhour.TODAYMONEY + history.KWH * powerStation.PowerRate; - history.TOTALMONEY = lastmoneyhistorybyhour.TOTALMONEY + history.KWH * powerStation.PowerRate; + //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; + // //今日發電金額計算方式: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; - calcPowerStation.Today_Money = history.KWH * powerStation.PowerRate * sumLeaseRate; - calcPowerStation.Total_Money = history.KWH * powerStation.PowerRate * sumLeaseRate; - } break; case (int)SolarTypeEnum.SelfUse: //自建自用 - 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; - } + //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.TODAYMONEY; + calcPowerStation.Today_Money = history.TodayKWh * powerStation.PowerRate; //總發電金額 計算方式:totalkWh * 授電費率 - calcPowerStation.Total_Money = history.TOTALMONEY; + //calcPowerStation.Total_Money = history.TOTALMONEY; + calcPowerStation.Total_Money = history.TotalKWH * powerStation.PowerRate; break; } #endregion @@ -225,29 +229,24 @@ namespace SolarPower.Quartz.Jobs carbonRate = Convert.ToDouble(await powerStationRepository.GetOneVariableByName("CarbonRate")); history.CARBON = history.KWH * carbonRate; - if (lastmoneyhistorybyhour != null) - { - history.TODAYCARBON = lastmoneyhistorybyhour.TODAYCARBON + history.KWH * carbonRate; - history.TOTALCARBON = lastmoneyhistorybyhour.TOTALCARBON + history.KWH * 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; + //今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值] + //calcPowerStation.Today_Carbon = history.TODAYCARBON; + calcPowerStation.Today_Carbon = history.TodayKWh * carbonRate; - //總減碳量(總發電量 * (0.554/1000)[抓資料庫值] - calcPowerStation.Total_Carbon = history.TOTALCARBON; - } - else - { - history.TODAYCARBON = history.KWH * carbonRate; - history.TOTALCARBON = history.KWH * carbonRate; - - //今日減碳量( 今日發電量 * (0.554/1000)[抓資料庫值] - calcPowerStation.Today_Carbon = history.TODAYCARBON; - - history.CARBON = history.KWH * carbonRate; - //總減碳量(總發電量 * (0.554/1000)[抓資料庫值] - calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate; - } + //總減碳量(總發電量 * (0.554/1000)[抓資料庫值] + //calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate; + calcPowerStation.Total_Carbon = history.TotalKWH * carbonRate; #endregion @@ -269,7 +268,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 { @@ -534,7 +533,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/Repository/Implement/AnalysisStationCombineRepository.cs b/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs index 3ebd463..d6521d6 100644 --- a/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs +++ b/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs @@ -38,8 +38,8 @@ namespace SolarPower.Repository.Implement 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 (8) GROUP BY PowerStationId) a + LEFT JOIN power_station_history_month psm ON a.PowerStationId = psm.PowerStationId AND a.TIMESTAMP = psm.TIMESTAMP ) AS m, ( diff --git a/SolarPower/Views/StationOverview/Index.cshtml b/SolarPower/Views/StationOverview/Index.cshtml index 7a05b9a..04221b5 100644 --- a/SolarPower/Views/StationOverview/Index.cshtml +++ b/SolarPower/Views/StationOverview/Index.cshtml @@ -432,7 +432,7 @@ @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); From d485b2bca9dd26bc9c3ad374e29ebc8678ed33ae Mon Sep 17 00:00:00 2001 From: Kai Date: Thu, 23 Sep 2021 17:49:23 +0800 Subject: [PATCH 03/38] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=E5=94=AE=E9=9B=BB?= =?UTF-8?q?=E6=8A=93=E5=8F=96=E9=9B=BB=E7=AB=99=E7=9A=84=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/ElectricitySoldRecordController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SolarPower/Controllers/ElectricitySoldRecordController.cs b/SolarPower/Controllers/ElectricitySoldRecordController.cs index 0349c60..a1f9d7c 100644 --- a/SolarPower/Controllers/ElectricitySoldRecordController.cs +++ b/SolarPower/Controllers/ElectricitySoldRecordController.cs @@ -46,8 +46,8 @@ namespace SolarPower.Controllers where_entities.Add("Filter", filter); } - //抓出 除了自建自用 - var temp_solarType_where = $@" ps.SolarType != 2"; + + var temp_solarType_where = $@" ps.SolarType = 0"; where.Add(temp_solarType_where); var powerStations = myPowerStationService.GetMyPowerStations(myUser, 1, null, where, where_entities); From 80119fc6de7e143fd2deafd8b879074e79ee0cf0 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Thu, 23 Sep 2021 19:22:48 +0800 Subject: [PATCH 04/38] =?UTF-8?q?=E6=88=91=E5=A4=AA=E5=82=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Views/StationReport/Index.cshtml | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/SolarPower/Views/StationReport/Index.cshtml b/SolarPower/Views/StationReport/Index.cshtml index 56b1443..e5ce673 100644 --- a/SolarPower/Views/StationReport/Index.cshtml +++ b/SolarPower/Views/StationReport/Index.cshtml @@ -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 += "" + inverter.report_date + ""; @@ -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 += "" + inverter.dayKWH + ""; - sta += "" + inverter.dayKWHp + ""; + sta += "" + ((inverter.dayKWHp == null) ? 0 : inverter.dayKWHp) + ""; sta += "" + inverter.tothour + ""; sta += "" + inverter.KWHKWP + ""; - sta += "" + inverter.PR.toFixed(2) + ""; + sta += "" + ((inverter.PR == null) ? 0 : inverter.PR.toFixed(2)) + ""; sta += "" + inverter.irradiance + ""; sta += "" + inverter.temperature + ""; 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) { @@ -1198,7 +1200,7 @@ }) } - + $('#TableBody').empty(); $('#TableBody').append(sta); $('#totbody').append(stb); $('#tothead').append(stc); From 458dff0078725f1f2b956bd0d5587b9d54cd16fc Mon Sep 17 00:00:00 2001 From: Kai Date: Fri, 24 Sep 2021 10:09:15 +0800 Subject: [PATCH 05/38] =?UTF-8?q?1.=20=E8=83=8C=E6=99=AF=E5=9F=B7=E8=A1=8C?= =?UTF-8?q?=E6=97=A5=E6=9C=88=E5=A0=B1=E8=A1=A8=20=E8=BF=B4=E5=9C=88?= =?UTF-8?q?=E5=8A=A0=20try=20catch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Quartz/Jobs/CalcAvgPowerStationJob.cs | 268 ++++++++++-------- 1 file changed, 146 insertions(+), 122 deletions(-) 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); } } From c9e782fc87728ce13438d5132b212bf74d671081 Mon Sep 17 00:00:00 2001 From: Kai Date: Fri, 24 Sep 2021 10:42:03 +0800 Subject: [PATCH 06/38] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=E9=80=86=E8=AE=8A?= =?UTF-8?q?=E5=99=A8=E7=9B=A3=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StationOverviewInfo.cshtml | 18 +++++--- .../StationOverview/_InverterInfo.cshtml | 41 +++++++++++++------ 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index 8b784e3..50841ca 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -2744,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(); @@ -2764,9 +2770,9 @@ 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; 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 @@
    -
From c9f10150608c7f8b3d92feeeab15377b77136be7 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Mon, 27 Sep 2021 09:18:03 +0800 Subject: [PATCH 07/38] =?UTF-8?q?=E4=BF=AE=E5=BE=A9Line=20=E6=AC=A1?= =?UTF-8?q?=E6=95=B8=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Quartz/Jobs/ExceptionSchedule.cs | 22 +++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs index 7d3468a..01967dd 100644 --- a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs +++ b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs @@ -45,14 +45,14 @@ namespace SolarPower.Quartz.Jobs { 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.dev_time}"; + foreach (var user in UserListWithPowerstation) + { NoticeSchedule DaySchedule = new NoticeSchedule() { UserId = user.Id, @@ -77,12 +77,14 @@ namespace SolarPower.Quartz.Jobs }; await noticeScheduleRepository.AddOneAsync(DaySchedule, properties); - var powerstation = await powerStationRepository.GetOneAsync(Exception.PowerStationId); - if(powerstation.line_token != null) - { - Content = " %0D%0A " + Content.Replace("
", " %0D%0A "); - 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); } } } From e50b54cd932009e3721eb06a4575615f953d3c98 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Mon, 27 Sep 2021 10:48:54 +0800 Subject: [PATCH 08/38] =?UTF-8?q?=E5=A0=B1=E8=A1=A8=20=E8=AE=80=E5=8F=96?= =?UTF-8?q?=E8=B3=87=E6=96=99=E9=81=8E=E5=A4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Repository/Implement/StationReportRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolarPower/Repository/Implement/StationReportRepository.cs b/SolarPower/Repository/Implement/StationReportRepository.cs index 8f12dc9..96af591 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: 60); } catch (Exception exception) { From 7b15afbbb97e97dbfe457960d3a0ea8d994b34ce Mon Sep 17 00:00:00 2001 From: b110212000 Date: Mon, 27 Sep 2021 14:15:32 +0800 Subject: [PATCH 09/38] =?UTF-8?q?=E7=BF=94=E5=93=A5=E8=AA=AA=E6=94=B9?= =?UTF-8?q?=E6=88=90300?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Repository/Implement/StationReportRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolarPower/Repository/Implement/StationReportRepository.cs b/SolarPower/Repository/Implement/StationReportRepository.cs index 96af591..3feab29 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,commandTimeout: 60); + a = await conn.QueryAsync(sql,commandTimeout: 300); } catch (Exception exception) { From 2deb6215d5791d05447b940275e00bf0142cae4f Mon Sep 17 00:00:00 2001 From: Kai Date: Mon, 27 Sep 2021 14:23:45 +0800 Subject: [PATCH 10/38] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=20=E5=94=AE?= =?UTF-8?q?=E9=9B=BB=E7=B4=80=E9=8C=84=20=E5=8F=8A=20=E7=99=BC=E9=9B=BB?= =?UTF-8?q?=E6=95=88=E8=83=BD=20=E5=B7=A6=E9=82=8A=E9=9B=BB=E7=AB=99?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/ElectricitySoldRecordController.cs | 2 +- SolarPower/Controllers/PowerGenerationController.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SolarPower/Controllers/ElectricitySoldRecordController.cs b/SolarPower/Controllers/ElectricitySoldRecordController.cs index a1f9d7c..7d5b574 100644 --- a/SolarPower/Controllers/ElectricitySoldRecordController.cs +++ b/SolarPower/Controllers/ElectricitySoldRecordController.cs @@ -47,7 +47,7 @@ namespace SolarPower.Controllers } - 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/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); From c382980d66b217e465cf771548126a6e1f7ab569 Mon Sep 17 00:00:00 2001 From: Kai Date: Mon, 27 Sep 2021 14:58:35 +0800 Subject: [PATCH 11/38] =?UTF-8?q?1.=20=E5=90=88=E4=BD=B5=E9=9B=BB=E7=AB=99?= =?UTF-8?q?bug=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implement/AnalysisStationCombineRepository.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs b/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs index d6521d6..c7ebc26 100644 --- a/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs +++ b/SolarPower/Repository/Implement/AnalysisStationCombineRepository.cs @@ -38,7 +38,7 @@ namespace SolarPower.Repository.Implement SUM(TOTALMONEY) AS All_money, SUM(TOTALKWH) AS All_kwh, SUM(TOTALCARBON) AS All_Carbon - from (SELECT psm.PowerStationId, max(psm.TIMESTAMP) AS TIMESTAMP FROM power_station_history_month psm WHERE PowerStationId IN (8) GROUP BY PowerStationId) a + 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, @@ -74,8 +74,8 @@ namespace SolarPower.Repository.Implement 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, ( @@ -105,8 +105,8 @@ namespace SolarPower.Repository.Implement 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, ( @@ -136,8 +136,8 @@ namespace SolarPower.Repository.Implement 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, ( From d68222387464cf0f2d0c7379d29213f9c9a7218d Mon Sep 17 00:00:00 2001 From: b110212000 Date: Tue, 28 Sep 2021 11:49:58 +0800 Subject: [PATCH 12/38] =?UTF-8?q?=E5=A0=B1=E8=A1=A8=20=E6=94=B9=E6=9C=89?= =?UTF-8?q?=E6=95=88=E6=97=A5=E7=85=A7=E5=B0=8F=E6=99=82=20-=E5=90=AB?= =?UTF-8?q?=E8=BC=B8=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StationReportController.cs | 36 ++++++++++--------- SolarPower/Models/StationReport.cs | 1 + SolarPower/Views/StationReport/Index.cshtml | 20 ++++++----- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/SolarPower/Controllers/StationReportController.cs b/SolarPower/Controllers/StationReportController.cs index 755f851..42a07a9 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); 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/Views/StationReport/Index.cshtml b/SolarPower/Views/StationReport/Index.cshtml index e5ce673..78af90b 100644 --- a/SolarPower/Views/StationReport/Index.cshtml +++ b/SolarPower/Views/StationReport/Index.cshtml @@ -266,7 +266,7 @@ 縣市 平均發電量(kWp) - 發電時間(小時) + 有效發電小時 @@ -783,7 +783,7 @@ str += "日
發電量
(kWh)"; str += "日
發電量
百分比
(%)"; str += "日照小時(hr)"; - str += "kWH/kWP"; + str += "有效發電小時"; str += "PR%"; str += "日
平均
日照度
(W/㎡)"; str += "日
平均
模組溫度
(°C)"; @@ -795,7 +795,7 @@ str += "區域"; str += "電站名稱"; str += "發電量"; - str += "發電小時"; + str += "有效發電小時"; str += "平均日照"; str += "PR"; if (rel.data.showMoney == 1) { @@ -813,7 +813,7 @@ str += "月
發電量
(kWh)"; str += "月
發電量
百分比
(%)"; str += "日照小時(hr)"; - str += "kWH/kWP"; + str += "有效發電小時"; str += "PR%"; str += "月
平均
日照度
(W/㎡)"; str += "月
平均
模組溫度
(°C)"; @@ -940,7 +940,7 @@ }) var stc = ""; stc += "" + '日照小時' + ""; - stc += "" + 'kWH/kWP' + ""; + stc += "" + '有效發電小時' + ""; stc += "" + 'PR%' + ""; stc += "" + '日發電量(kWh)' + ""; if (showmoney == 1) { @@ -1018,7 +1018,7 @@ var stc = ""; stc += "" + '日照平均(日)' + ""; - stc += "" + 'kWH/kWP(日)' + ""; + stc += "" + '有效發電小時(日)' + ""; stc += "" + '發電量平均(kWh)(日)' + ""; stc += "" + '發電量(kWh)(月)' + ""; if (showmoney == 1) { @@ -1138,7 +1138,7 @@ var stc = ""; stc += "" + '日照平均(月)' + ""; - stc += "" + 'kWH/kWP(月)' + ""; + stc += "" + '有效發電小時(月)' + ""; stc += "" + '發電量平均(kWh)(月)' + ""; stc += "" + '發電量(kWh)(年)' + ""; if (showmoney == 1) { @@ -1297,6 +1297,7 @@ city: data.cityName, kwp: data.kwh, hour: data.solarHour, + kwhkwp: data.avgKWHKWP, count : 1 } if (CityArray.length == 0) { @@ -1310,6 +1311,7 @@ n.kwp += cityinfo.kwp; n.hour += cityinfo.hour; n.count += cityinfo.count; + n.kwhkwp += cityinfo.kwhkwp npush = false; } }); @@ -1323,7 +1325,7 @@ StrInfoBody += "" + data.cityName + data.areaName + ""; StrInfoBody += "" + data.powerstationName + ""; StrInfoBody += "" + data.kwh.toFixed(2) + ""; - StrInfoBody += "" + data.solarHour.toFixed(2) + ""; + StrInfoBody += "" + data.avgKWHKWP.toFixed(2) + ""; StrInfoBody += "" + data.avgIrradiance.toFixed(2) + ""; StrInfoBody += "" + data.avgPR.toFixed(2) + ""; if (showmoney == 1) { @@ -1346,7 +1348,7 @@ CityInfoBody += ""; CityInfoBody += "" + data.city + ""; CityInfoBody += "" + (data.kwp / data.count).toFixed(2) + ""; - CityInfoBody += "" + (data.hour / data.count).toFixed(2) + ""; + CityInfoBody += "" + (data.kwhkwp / data.count).toFixed(2) + ""; CityInfoBody += ""; }) //上面 From dc9023cf8524e8d6820f55500682478109462f1e Mon Sep 17 00:00:00 2001 From: Kai Date: Wed, 29 Sep 2021 14:56:38 +0800 Subject: [PATCH 13/38] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=E9=80=86=E8=AE=8A?= =?UTF-8?q?=E5=99=A8=E5=88=86=E6=9E=90=20bug=20fix=202.=20=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E5=9F=B7=E8=A1=8C=20bug=20fix=203.=20=E9=9B=BB?= =?UTF-8?q?=E7=AB=99=E7=B8=BD=E8=A6=BD=20=E5=BA=95=E6=9D=BF=E5=AD=97?= =?UTF-8?q?=E9=AB=94=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Quartz/Jobs/CalcPowerStationJob.cs | 4 ++++ SolarPower/Repository/Implement/PowerStationRepository.cs | 8 ++++---- .../Views/StationOverview/StationOverviewInfo.cshtml | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs index 5223923..2e3364e 100644 --- a/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs +++ b/SolarPower/Quartz/Jobs/CalcPowerStationJob.cs @@ -131,6 +131,8 @@ namespace SolarPower.Quartz.Jobs #region 發電金額 history.MONEY = history.KWH * powerStation.PowerRate; + history.TODAYMONEY = history.TodayKWh * powerStation.PowerRate; + history.TOTALMONEY = history.TotalKWH * powerStation.PowerRate; //即時發電金額 switch (powerStation.SolarType) @@ -229,6 +231,8 @@ namespace SolarPower.Quartz.Jobs 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; diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index cb93614..32d5cf8 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -4473,7 +4473,7 @@ namespace SolarPower.Repository.Implement 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(); } @@ -4504,7 +4504,7 @@ 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, @@ -4523,7 +4523,7 @@ namespace SolarPower.Repository.Implement 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(); } @@ -4554,7 +4554,7 @@ 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, diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index 50841ca..237b047 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -22,12 +22,12 @@

- 新竹巨城站 + 電站名稱

-

27°C
降雨幾率: 15%

+

27°C
降雨幾率: 0%

} - - @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("PowerStation")) + { +
  • + + + 電站管理 + + +
  • + } + @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")) + { +
    • + + 定時任務設定 + +
    • + }*@
  • } From 7193826d636f65eb1ea5b5d87dce1aaa3aeb881d Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 1 Oct 2021 17:05:05 +0800 Subject: [PATCH 19/38] =?UTF-8?q?=E9=80=86=E8=AE=8A=E5=99=A8=E8=A8=88?= =?UTF-8?q?=E7=AE=97---=E9=80=BE=E6=99=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/AnalysisInverterController.cs | 9 ++++++++- SolarPower/Models/ErrorCode.cs | 9 +++++---- .../Repository/Implement/PowerStationRepository.cs | 2 +- .../Repository/Implement/StationReportRepository.cs | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) 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/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/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 32d5cf8..10acb47 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -4475,7 +4475,7 @@ namespace SolarPower.Repository.Implement } 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) { diff --git a/SolarPower/Repository/Implement/StationReportRepository.cs b/SolarPower/Repository/Implement/StationReportRepository.cs index 3feab29..0097d0d 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,commandTimeout: 300); + a = await conn.QueryAsync(sql, commandTimeout: 300); } catch (Exception exception) { From 34891227ae17da697bb3d52d0fdc7743b607032f Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 1 Oct 2021 17:36:48 +0800 Subject: [PATCH 20/38] =?UTF-8?q?=E5=B0=87=20=E7=95=B0=E5=B8=B8=E6=99=82?= =?UTF-8?q?=E9=96=93=20=E6=8B=89=E5=87=BA=20=E5=96=AE=E4=BD=8D=E7=82=BA?= =?UTF-8?q?=E5=88=86=E9=90=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Quartz/Jobs/ExceptionSchedule.cs | 10 +++++++--- SolarPower/appsettings.Development.json | 4 +++- SolarPower/appsettings.json | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs index 01967dd..217919f 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,24 +22,27 @@ 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) diff --git a/SolarPower/appsettings.Development.json b/SolarPower/appsettings.Development.json index a4eacb3..241b221 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 + //"SMTPConfig": { // "Host": "smtp.gmail.com", // "Port": 25, diff --git a/SolarPower/appsettings.json b/SolarPower/appsettings.json index ef0a5ff..5b53310 100644 --- a/SolarPower/appsettings.json +++ b/SolarPower/appsettings.json @@ -38,5 +38,6 @@ "UserName": "ficgreen01@gmail.com", "Password": "qwe2015qwe", "EnableSsl": true - } + }, + "ExceptionTimes": 240 } From aab64ffa9034e6c0192291e75146e6f444b51aca Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 1 Oct 2021 17:38:40 +0800 Subject: [PATCH 21/38] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A8=BB=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/appsettings.Development.json | 2 +- SolarPower/appsettings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SolarPower/appsettings.Development.json b/SolarPower/appsettings.Development.json index 241b221..a50b12a 100644 --- a/SolarPower/appsettings.Development.json +++ b/SolarPower/appsettings.Development.json @@ -38,7 +38,7 @@ "Password": "wswgnluvoodfexrb", "EnableSsl": true }, - "ExceptionTimes": 240 + "ExceptionTimes": 240 //`qɶA() //"SMTPConfig": { // "Host": "smtp.gmail.com", diff --git a/SolarPower/appsettings.json b/SolarPower/appsettings.json index 5b53310..e8efcfa 100644 --- a/SolarPower/appsettings.json +++ b/SolarPower/appsettings.json @@ -39,5 +39,5 @@ "Password": "qwe2015qwe", "EnableSsl": true }, - "ExceptionTimes": 240 + "ExceptionTimes": 240 //`qɶA() } From 9c044a6bab086bb68fa7c16e26a3a832b98b4261 Mon Sep 17 00:00:00 2001 From: Kai Date: Fri, 1 Oct 2021 18:41:53 +0800 Subject: [PATCH 22/38] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=E9=9B=BB=E7=AB=99?= =?UTF-8?q?=E7=B8=BD=E8=A6=BD=20=E7=9A=84=E9=9B=BB=E7=AB=99=E5=90=8D?= =?UTF-8?q?=E7=A8=B1=E5=AF=AC=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Views/StationOverview/StationOverviewInfo.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index 237b047..e49b1d8 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -19,7 +19,7 @@
    -
    +

    電站名稱 From e6617c09a7cfc9212ff4684af209106c51ef78c8 Mon Sep 17 00:00:00 2001 From: Kai Date: Mon, 4 Oct 2021 10:29:32 +0800 Subject: [PATCH 23/38] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=E9=9B=BB=E7=AB=99?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=AC=8A=E9=99=90=202.=20=E4=BF=AE=E6=94=B91?= =?UTF-8?q?5min=E8=83=8C=E6=99=AF=E5=9F=B7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Quartz/Jobs/CalcInverter15minJob.cs | 2 +- SolarPower/Views/Shared/_Layout.cshtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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/Views/Shared/_Layout.cshtml b/SolarPower/Views/Shared/_Layout.cshtml index e98362d..7d43486 100644 --- a/SolarPower/Views/Shared/_Layout.cshtml +++ b/SolarPower/Views/Shared/_Layout.cshtml @@ -348,7 +348,7 @@ } - @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStation")) + @if (ViewBag.myUser.Role.Layer == (int)RoleLayerEnum.PlatformAdmin || ViewBag.auths.Contains("PowerStationManager")) {
  • From 047659c06a1099b64db83778f470799d1e3d6c47 Mon Sep 17 00:00:00 2001 From: Kai Date: Mon, 4 Oct 2021 10:49:38 +0800 Subject: [PATCH 24/38] =?UTF-8?q?1.=20=E4=BF=AE=E6=94=B9=20google=20map=20?= =?UTF-8?q?window=20info?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Views/MapOverview/Index.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index 79aea0f..a8f3d46 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -278,7 +278,7 @@ '
    ' + '
    ' + '
    ' + - '
    今日發電量(kW h):' + item.today_kWh + '
    '+ + '
    今日發電量(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) + '
    ' + From bc0950b8152874bbac6d6a627df6b12baa066b44 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Tue, 5 Oct 2021 17:20:08 +0800 Subject: [PATCH 25/38] =?UTF-8?q?=E5=A0=B1=E8=A1=A8=E5=8C=AF=E5=87=BA?= =?UTF-8?q?=E9=A9=97=E8=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/StationReportController.cs | 42 ++++++++++++++++- .../Implement/StationReportRepository.cs | 46 +++++++++++++++++++ .../Interface/IStationReportRepository.cs | 1 + .../PowerStation/PowerStationEdit.cshtml | 2 +- SolarPower/Views/StationReport/Index.cshtml | 20 +++++++- 5 files changed, 108 insertions(+), 3 deletions(-) diff --git a/SolarPower/Controllers/StationReportController.cs b/SolarPower/Controllers/StationReportController.cs index 42a07a9..b5d7f5a 100644 --- a/SolarPower/Controllers/StationReportController.cs +++ b/SolarPower/Controllers/StationReportController.cs @@ -2186,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/Repository/Implement/StationReportRepository.cs b/SolarPower/Repository/Implement/StationReportRepository.cs index 0097d0d..00adb1f 100644 --- a/SolarPower/Repository/Implement/StationReportRepository.cs +++ b/SolarPower/Repository/Implement/StationReportRepository.cs @@ -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/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/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/StationReport/Index.cshtml b/SolarPower/Views/StationReport/Index.cshtml index 2274b9a..3b2739e 100644 --- a/SolarPower/Views/StationReport/Index.cshtml +++ b/SolarPower/Views/StationReport/Index.cshtml @@ -1225,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 { From 5d125c803e9d2de7eaa0a57c3da40adcfd5a8fa5 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Tue, 5 Oct 2021 18:23:36 +0800 Subject: [PATCH 26/38] =?UTF-8?q?=E7=95=B0=E5=B8=B8=E9=A1=9E=E5=9E=8B:d=20?= =?UTF-8?q?=E9=A1=8D=E5=A4=96=E6=96=B0=E5=A2=9E=20=E7=95=B6=E5=89=8D?= =?UTF-8?q?=E6=95=B8=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Models/Overview.cs | 3 ++- SolarPower/Quartz/Jobs/ExceptionSchedule.cs | 8 ++++++-- SolarPower/Repository/Implement/OverviewRepository.cs | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) 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/Quartz/Jobs/ExceptionSchedule.cs b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs index 217919f..79a6381 100644 --- a/SolarPower/Quartz/Jobs/ExceptionSchedule.cs +++ b/SolarPower/Quartz/Jobs/ExceptionSchedule.cs @@ -53,8 +53,12 @@ namespace SolarPower.Quartz.Jobs $"設備編號:{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() diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index f314d9f..7e13d05 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -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 From e6a8ff5a2a04501ea78b5b78d1a8a0fb40088be6 Mon Sep 17 00:00:00 2001 From: Kai Date: Tue, 5 Oct 2021 18:28:38 +0800 Subject: [PATCH 27/38] =?UTF-8?q?1.=20line=20token=20=E6=8F=9B=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Views/PowerStation/_StationInfo.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@
    - +
    From 434ff6d495ebb31469483a781280692997139e8f Mon Sep 17 00:00:00 2001 From: b110212000 Date: Wed, 6 Oct 2021 10:18:59 +0800 Subject: [PATCH 28/38] =?UTF-8?q?=E7=95=B0=E5=B8=B8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Repository/Implement/PowerStationRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolarPower/Repository/Implement/PowerStationRepository.cs b/SolarPower/Repository/Implement/PowerStationRepository.cs index 10acb47..1e91b32 100644 --- a/SolarPower/Repository/Implement/PowerStationRepository.cs +++ b/SolarPower/Repository/Implement/PowerStationRepository.cs @@ -5338,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) From 1c1bc58f7bcbed91eafb8bf0fbc1271d1d24da2a Mon Sep 17 00:00:00 2001 From: Kai Date: Wed, 6 Oct 2021 10:38:57 +0800 Subject: [PATCH 29/38] =?UTF-8?q?1.=20=E9=9B=BB=E7=AB=99=E8=83=8C=E6=99=AF?= =?UTF-8?q?=E5=9F=B7=E8=A1=8C=20bug=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- solarApp/Service/procStationSvc.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/solarApp/Service/procStationSvc.cs b/solarApp/Service/procStationSvc.cs index e3e9c0f..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 租建計算方式 後再再補上 @@ -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 @@ -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 From 05a0619b00563556aed2a1d7b9057c23a36b71e5 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Wed, 6 Oct 2021 13:49:21 +0800 Subject: [PATCH 30/38] =?UTF-8?q?=E9=9B=BB=E7=AB=99=E8=B3=87=E8=A8=8A?= =?UTF-8?q?=E6=A8=99=E7=B1=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/MyBaseController.cs | 2 +- SolarPower/Views/StationOverview/StationOverviewInfo.cshtml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index e49b1d8..3b96580 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -1,6 +1,6 @@ @{ - ViewData["MainNum"] = "1"; - ViewData["SubNum"] = "2"; + ViewData["MainNum"] = "2"; + //ViewData["SubNum"] = "2"; ViewData["Title"] = "電站總覽"; } @using SolarPower.Models.Role From bad78134b836a3bcd131695478596da95fc9a2a5 Mon Sep 17 00:00:00 2001 From: JiaHao Liu Date: Wed, 6 Oct 2021 15:56:57 +0800 Subject: [PATCH 31/38] =?UTF-8?q?=E8=88=8A=E8=B3=87=E6=96=99=E5=8C=AF?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- solarApp/Service/excelHelper.cs | 179 ++++++++++++++- solarApp/Service/operateCSV.cs | 186 ++++++++++++++++ solarApp/fmExcel.Designer.cs | 102 +++++++-- solarApp/fmExcel.cs | 375 ++++++++++++++++++++++++++++++-- 4 files changed, 802 insertions(+), 40 deletions(-) diff --git a/solarApp/Service/excelHelper.cs b/solarApp/Service/excelHelper.cs index bbeae7c..8bd34b5 100644 --- a/solarApp/Service/excelHelper.cs +++ b/solarApp/Service/excelHelper.cs @@ -6,11 +6,15 @@ using System.Text; using System.Runtime.InteropServices; using System.Data; using Microsoft.Office.Interop; +using MySql.Data.MySqlClient; +using System.Configuration; +using Dapper; namespace solarApp.Service { public class excelHelper { + string Connection1 = ConfigurationManager.ConnectionStrings["mySql"].ConnectionString; void readExcel(string fname, ref System.Data.DataTable dt) { Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(fname); @@ -58,7 +62,180 @@ namespace solarApp.Service //quit and release xlApp.Quit(); Marshal.ReleaseComObject(xlApp); - } + } + + public bool insertDay2DB(DataTable dt, string filename, string inverterID) + { + bool result = false; + StringBuilder ss = new StringBuilder(); + using (MySqlConnection conn = new MySqlConnection(Connection1)) + { + conn.Open(); + int i = 0; + foreach (DataRow row in dt.Rows) + { + //ss.Append(@"INSERT INTO solar_import.auo_taiping(`No.`, `雲端收到時間`, `資料取得時間`, `交流電壓`, `交流電流`, `交流功率`, `溫度`, `累積發電量`, `頻率`, `狀態`, saveDate, filename, inverterID) + ss.Append(@"INSERT INTO solar_import.auo_aimai(`No.`, `雲端收到時間`, `資料取得時間`, `交流電壓`, `交流電流`, `交流功率`, `溫度`, `累積發電量`, `頻率`, `狀態`, saveDate, filename, inverterID) +values( '" + + row.Field("1").ToString() + "' ,'" + + row.Field("2").ToString() + "' ,'" + + row.Field("3").ToString() + "' ,'" + + row.Field("4").ToString() + "' ,'" + + row.Field("5").ToString() + "' ,'" + + row.Field("6").ToString() + "' ,'" + + row.Field("7").ToString() + "' ,'" + + row.Field("8").ToString() + "' ,'" + + row.Field("9").ToString() + "' ,'" ++ row.Field("10").ToString() + "', now(), '"+ filename + "', '" + inverterID + "');"); + + if (i % 10 == 0) + { + conn.Execute(ss.ToString()); + ss.Clear(); + } + i++; + } + if (ss.Length > 0) + { + conn.Execute(ss.ToString()); + ss.Clear(); + } + conn.Clone(); + } + return result; + } + + + public bool insertFile2DB(string[] filename, string station_name) + { + bool result = false; + StringBuilder ss = new StringBuilder(); + using (MySqlConnection conn = new MySqlConnection(Connection1)) + { + conn.Open(); + int i = 0; + foreach (var fullfileName in filename) + { + string[] ff = fullfileName.Split("\\"); + string fname = string.Empty; + fname += ff[ff.Length - 1]; //只抓最後的檔名 + string inverterID = string.Empty; + string[] str = fname.Split("_"); + inverterID = str[str.Length - 3] + "_" + str[str.Length - 2]; + str = inverterID.Split(" "); + inverterID = str[str.Length -1]; + fname = fullfileName.Replace("\\", "/"); + //if (fullfileName == "D:AUO台中太平inverter110") { + // str[0] = "123"; + //} + ss.Append(@"insert into `solar_import`.`auo_file_list`( `station_name`, `filename`, inverterid, `inser_date`) +values( '" + + station_name + "' ,'" + + fname + "' ,'" + + inverterID + "' , now() );"); + + if (i % 10 == 0) + { + conn.Execute(ss.ToString()); + ss.Clear(); + } + i++; + } + if (ss.Length > 0) + { + conn.Execute(ss.ToString()); + ss.Clear(); + } + conn.Clone(); + } + return result; + } + + public bool insertDay2DB_enlux_gong34(DataTable dt, string filename) + { + bool result = false; + StringBuilder ss = new StringBuilder(); + using (MySqlConnection conn = new MySqlConnection(Connection1)) + { + conn.Open(); + int i = 0; + foreach (DataRow row in dt.Rows) + { + //ss.Append(@"INSERT INTO solar_import.auo_taiping(`No.`, `雲端收到時間`, `資料取得時間`, `交流電壓`, `交流電流`, `交流功率`, `溫度`, `累積發電量`, `頻率`, `狀態`, saveDate, filename, inverterID) + ss.Append(@"INSERT INTO solar_import.enlux_gong34(UploadTime, S1_AC, S1_DC, S2_AC, S2_DC, S3_AC, S3_DC, S4_AC, S4_DC, sunshine, temperature, saveDate, filename) +values( '" + + row.Field("1").ToString() + "' ,'" + + row.Field("2").ToString() + "' ,'" + + row.Field("3").ToString() + "' ,'" + + row.Field("4").ToString() + "' ,'" + + row.Field("5").ToString() + "' ,'" + + row.Field("6").ToString() + "' ,'" + + row.Field("7").ToString() + "' ,'" + + row.Field("8").ToString() + "' ,'" + + row.Field("9").ToString() + "' ,'" + + row.Field("10").ToString() + "' ,'" + + row.Field("11").ToString() + "' , now(), '" + filename + "');"); + + if (i % 10 == 0) + { + conn.Execute(ss.ToString()); + ss.Clear(); + } + i++; + } + if (ss.Length > 0) + { + conn.Execute(ss.ToString()); + ss.Clear(); + } + conn.Clone(); + } + return result; + } + + public bool insertFile2DB__enlux_gong34(string[] filename, string station_name) + { + bool result = false; + StringBuilder ss = new StringBuilder(); + using (MySqlConnection conn = new MySqlConnection(Connection1)) + { + conn.Open(); + int i = 0; + foreach (var fullfileName in filename) + { + string[] ff = fullfileName.Split("\\"); + string fname = string.Empty; + fname += ff[ff.Length - 1]; //只抓最後的檔名 + //string inverterID = string.Empty; + //string[] str = fname.Split("_"); + //inverterID = str[str.Length - 3] + "_" + str[str.Length - 2]; + //str = inverterID.Split(" "); + //inverterID = str[str.Length - 1]; + fname = fullfileName.Replace("\\", "/"); + //if (fullfileName == "D:AUO台中太平inverter110") { + // str[0] = "123"; + //} + ss.Append(@"insert into `solar_import`.`enlux_file_list`( `station_name`, `filename`, `inser_date`) +values( '" + + station_name + "' ,'" + + fname + "' , now() );"); + + if (i % 10 == 0) + { + conn.Execute(ss.ToString()); + ss.Clear(); + } + i++; + } + if (ss.Length > 0) + { + conn.Execute(ss.ToString()); + ss.Clear(); + } + conn.Clone(); + } + return result; + } //public void ReadSample() //{ diff --git a/solarApp/Service/operateCSV.cs b/solarApp/Service/operateCSV.cs index 6d5d5ef..f0f9f57 100644 --- a/solarApp/Service/operateCSV.cs +++ b/solarApp/Service/operateCSV.cs @@ -248,6 +248,100 @@ namespace solarApp.Service } + public void taoYuan_createColumnHour(ref DataTable mycsvdt, string filepath) + { + string strpath = filepath; //csv檔案的路徑 + try + { + int intColCount = 0; + bool blnFlag = true; + + DataColumn mydc; + + string strline; + string[] aryline; + StreamReader mysr = new StreamReader(strpath, System.Text.Encoding.Default); + + int rowIndex = 0; + while ((strline = mysr.ReadLine()) != null) + { + rowIndex += 1; + if (rowIndex < 4) continue; + aryline = strline.Split(new char[] { ',' }); + + //給datatable加上列名 + if (blnFlag) + { + blnFlag = false; + intColCount = aryline.Length; + int col = 0; + for (int i = 0; i < aryline.Length; i++) + { + col = i + 1; + mydc = new DataColumn(col.ToString()); + mycsvdt.Columns.Add(mydc); + } + } + break; + } + + } + catch (Exception e) + { + //throw (Stack.GetErrorStack(strpath + "讀取CSV檔案中的資料出錯." + e.Message, "OpenCSVFile(")); + //return false; + } + } + /// + /// 太陽能光電 桃園全虹 + /// + /// + /// + /// + /// + /// + /// + public bool taoYuan_readCsvFile(ref DataTable mycsvdt, string filepath, int intColCount, bool readTitle) + { + string strpath = filepath; //csv檔案的路徑 + try + { + DataColumn mydc; + DataRow mydr; + + string strline; + string[] aryline; + StreamReader mysr = new StreamReader(strpath, System.Text.Encoding.Default); + + int rowIndex = 0; + while ((strline = mysr.ReadLine()) != null) + { + rowIndex += 1; + if (readTitle && rowIndex == 1) { + readTitle = false; + continue; + } + + aryline = strline.Split(new char[] { ',' }); + //填充資料並加入到datatable中 + mydr = mycsvdt.NewRow(); + + for (int i = 0; i < intColCount - 1; i++) + { + mydr[i] = aryline[i]; + } + mycsvdt.Rows.Add(mydr); + } + } + catch (Exception ex) + { + //throw (Stack.GetErrorStack(strpath + "讀取CSV檔案中的資料出錯." + e.Message, " readCsvFile")); + throw ex; + return false; + } + return true; + } + public bool clear_inv(string timeType) { bool result = false; @@ -266,6 +360,98 @@ namespace solarApp.Service return false; } + public void taoYuan_insertHour2DB(ref DataTable dt, string dest_table) + { + List ds; + StringBuilder ss = new StringBuilder(); + using (MySqlConnection conn = new MySqlConnection(Connection1)) + { + conn.Open(); + ss.Clear(); + + int i = 0; + foreach (DataRow row in dt.Rows) //sun_taoyuan + { + ss.Append(@"insert into solar_import."+ dest_table + @"(c1 , c2 , c3 , c4 , c5 , c6 , c7 , c8 , c9 , c10, c11, c12, c13, c14, c15, c16, c17, c18, c19, c20, c21, c22, c23, c24, c25, c26, c27, c28, c29, c30, c31, c32, c33, c34, c35, c36, c37, c38, c39, c40, c41, c42, c43, c44, c45, c46, c47, c48, c49, c50, c51, c52, c53, c54, c55, c56, c57, c58) +values( '" + row.Field("1").ToString() + "', " + + "'" + row.Field("2").ToString() + "' , " + + "'" + row.Field("3").ToString() + "' , " + + "'" + row.Field("4").ToString() + "' , " + + "'" + row.Field("5").ToString() + "' , " + + "'" + row.Field("6").ToString() + "' , " + + "'" + row.Field("7").ToString() + "' , " + + "'" + row.Field("8").ToString() + "' , " + + "'" + row.Field("9").ToString() + "' , " + + "'" + row.Field("10").ToString() + "' ," + + "'" + row.Field("11").ToString() + "' ," + + "'" + row.Field("12").ToString() + "' ," + + "'" + row.Field("13").ToString() + "' ," + + "'" + row.Field("14").ToString() + "' ," + + "'" + row.Field("15").ToString() + "' ," + + "'" + row.Field("16").ToString() + "' ," + + "'" + row.Field("17").ToString() + "' ," + + "'" + row.Field("18").ToString() + "' ," + + "'" + row.Field("19").ToString() + "' ," + + "'" + row.Field("20").ToString() + "' ," + + "'" + row.Field("21").ToString() + "' ," + + "'" + row.Field("22").ToString() + "' ," + + "'" + row.Field("23").ToString() + "' ," + + "'" + row.Field("24").ToString() + "' ," + + "'" + row.Field("25").ToString() + "' ," + + "'" + row.Field("26").ToString() + "' ," + + "'" + row.Field("27").ToString() + "' ," + + "'" + row.Field("28").ToString() + "' ," + + "'" + row.Field("29").ToString() + "' ," + + "'" + row.Field("30").ToString() + "' ," + + "'" + row.Field("31").ToString() + "' ," + + "'" + row.Field("32").ToString() + "' ," + + "'" + row.Field("33").ToString() + "' ," + + "'" + row.Field("34").ToString() + "' ," + + "'" + row.Field("35").ToString() + "' ," + + "'" + row.Field("36").ToString() + "' ," + + "'" + row.Field("37").ToString() + "' ," + + "'" + row.Field("38").ToString() + "' ," + + "'" + row.Field("39").ToString() + "' ," + + "'" + row.Field("40").ToString() + "' ," + + "'" + row.Field("41").ToString() + "' ," + + "'" + row.Field("42").ToString() + "' ," + + "'" + row.Field("43").ToString() + "' ," + + "'" + row.Field("44").ToString() + "' ," + + "'" + row.Field("45").ToString() + "' ," + + "'" + row.Field("46").ToString() + "' ," + + "'" + row.Field("47").ToString() + "' ," + + "'" + row.Field("48").ToString() + "' ," + + "'" + row.Field("49").ToString() + "' ," + + "'" + row.Field("50").ToString() + "' ," + + "'" + row.Field("51").ToString() + "' ," + + "'" + row.Field("52").ToString() + "' ," + + "'" + row.Field("53").ToString() + "' ," + + "'" + row.Field("54").ToString() + "' ," + + "'" + row.Field("55").ToString() + "' ," + + "'" + row.Field("56").ToString() + "' ," + + "'" + row.Field("57").ToString() + "' ," + + "'" + row.Field("58").ToString() + "' );"); + + if (i % 100 == 0) + { + conn.Execute(ss.ToString()); + ss.Clear(); + } + i++; + } + if (ss.Length > 0) + { + conn.Execute(ss.ToString()); + ss.Clear(); + } + //ss.Clear(); + //ss.Append(@"select inv, left(c1, 10) date, count(*) ct from src_inv where c1 <> '欄位名稱' group by inv, left(c1, 10)"); + //ds = conn.Query(ss.ToString()).AsList(); + conn.Clone(); + } + //return ds; + } + public List insertHour2DB(ref DataTable dt) { List ds; StringBuilder ss = new StringBuilder(); diff --git a/solarApp/fmExcel.Designer.cs b/solarApp/fmExcel.Designer.cs index 87afb01..c59d8b3 100644 --- a/solarApp/fmExcel.Designer.cs +++ b/solarApp/fmExcel.Designer.cs @@ -34,7 +34,7 @@ namespace solarApp this.lbSiteID_sensor = new System.Windows.Forms.Label(); this.bt_archive = new System.Windows.Forms.Button(); this.bt_inv_hour_hj = new System.Windows.Forms.Button(); - this.bt_clear_station = new System.Windows.Forms.Button(); + this.bt_read_taiping = new System.Windows.Forms.Button(); this.bt_inv_day_hj = new System.Windows.Forms.Button(); this.fp_site = new System.Windows.Forms.FlowLayoutPanel(); this.btVerifyData = new System.Windows.Forms.Button(); @@ -42,10 +42,15 @@ namespace solarApp this.panel1 = new System.Windows.Forms.Panel(); this.lbSiteName_sensor = new System.Windows.Forms.Label(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.bt_sun_taoyuan = new System.Windows.Forms.Button(); + this.bt_gong34 = new System.Windows.Forms.Button(); + this.bt_AUO_aimai = new System.Windows.Forms.Button(); this.bt_hour_archive_hj = new System.Windows.Forms.Button(); this.bt_day_archive_hj = new System.Windows.Forms.Button(); + this.rt1 = new System.Windows.Forms.RichTextBox(); this.tb1 = new System.Windows.Forms.TabPage(); this.tabControl = new System.Windows.Forms.TabControl(); + this.bt_sun_yadong = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); @@ -91,13 +96,14 @@ namespace solarApp // bt_archive // this.bt_archive.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.bt_archive.Location = new System.Drawing.Point(5, 528); + this.bt_archive.Location = new System.Drawing.Point(3, 640); this.bt_archive.Name = "bt_archive"; this.bt_archive.Size = new System.Drawing.Size(282, 100); this.bt_archive.TabIndex = 8; this.bt_archive.Text = "單日歸檔"; this.bt_archive.UseVisualStyleBackColor = true; this.bt_archive.Visible = false; + this.bt_archive.Click += new System.EventHandler(this.bt_archive_Click); // // bt_inv_hour_hj // @@ -110,16 +116,16 @@ namespace solarApp this.bt_inv_hour_hj.UseVisualStyleBackColor = true; this.bt_inv_hour_hj.Click += new System.EventHandler(this.bt_inv_hour_hj_Click); // - // bt_clear_station + // bt_read_taiping // - this.bt_clear_station.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.bt_clear_station.Location = new System.Drawing.Point(3, 418); - this.bt_clear_station.Name = "bt_clear_station"; - this.bt_clear_station.Size = new System.Drawing.Size(135, 44); - this.bt_clear_station.TabIndex = 6; - this.bt_clear_station.Text = "AUO Insert "; - this.bt_clear_station.UseVisualStyleBackColor = true; - this.bt_clear_station.Click += new System.EventHandler(this.bt_clear_station_Click); + this.bt_read_taiping.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.bt_read_taiping.Location = new System.Drawing.Point(0, 337); + this.bt_read_taiping.Name = "bt_read_taiping"; + this.bt_read_taiping.Size = new System.Drawing.Size(192, 47); + this.bt_read_taiping.TabIndex = 6; + this.bt_read_taiping.Text = "AUO 太平 Read"; + this.bt_read_taiping.UseVisualStyleBackColor = true; + this.bt_read_taiping.Click += new System.EventHandler(this.bt_clear_station_Click); // // bt_inv_day_hj // @@ -154,12 +160,12 @@ namespace solarApp // dataGridView1 // this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Left; this.dataGridView1.Location = new System.Drawing.Point(0, 125); this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.RowHeadersWidth = 51; this.dataGridView1.RowTemplate.Height = 29; - this.dataGridView1.Size = new System.Drawing.Size(1458, 687); + this.dataGridView1.Size = new System.Drawing.Size(629, 687); this.dataGridView1.TabIndex = 1; // // panel1 @@ -195,16 +201,21 @@ namespace solarApp // splitContainer1.Panel1 // this.splitContainer1.Panel1.BackColor = System.Drawing.Color.PaleGoldenrod; + this.splitContainer1.Panel1.Controls.Add(this.bt_sun_yadong); + this.splitContainer1.Panel1.Controls.Add(this.bt_sun_taoyuan); + this.splitContainer1.Panel1.Controls.Add(this.bt_gong34); + this.splitContainer1.Panel1.Controls.Add(this.bt_AUO_aimai); this.splitContainer1.Panel1.Controls.Add(this.bt_hour_archive_hj); this.splitContainer1.Panel1.Controls.Add(this.bt_day_archive_hj); this.splitContainer1.Panel1.Controls.Add(this.bt_archive); this.splitContainer1.Panel1.Controls.Add(this.bt_inv_hour_hj); - this.splitContainer1.Panel1.Controls.Add(this.bt_clear_station); + this.splitContainer1.Panel1.Controls.Add(this.bt_read_taiping); this.splitContainer1.Panel1.Controls.Add(this.bt_inv_day_hj); this.splitContainer1.Panel1.Controls.Add(this.fp_site); // // splitContainer1.Panel2 // + this.splitContainer1.Panel2.Controls.Add(this.rt1); this.splitContainer1.Panel2.Controls.Add(this.dataGridView1); this.splitContainer1.Panel2.Controls.Add(this.panel1); this.splitContainer1.Size = new System.Drawing.Size(1768, 812); @@ -212,6 +223,39 @@ namespace solarApp this.splitContainer1.SplitterWidth = 10; this.splitContainer1.TabIndex = 0; // + // bt_sun_taoyuan + // + this.bt_sun_taoyuan.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.bt_sun_taoyuan.Location = new System.Drawing.Point(3, 523); + this.bt_sun_taoyuan.Name = "bt_sun_taoyuan"; + this.bt_sun_taoyuan.Size = new System.Drawing.Size(213, 47); + this.bt_sun_taoyuan.TabIndex = 13; + this.bt_sun_taoyuan.Text = "太陽能光電-桃園全虹"; + this.bt_sun_taoyuan.UseVisualStyleBackColor = true; + this.bt_sun_taoyuan.Click += new System.EventHandler(this.bt_sun_taoyuan_Click); + // + // bt_gong34 + // + this.bt_gong34.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.bt_gong34.Location = new System.Drawing.Point(0, 443); + this.bt_gong34.Name = "bt_gong34"; + this.bt_gong34.Size = new System.Drawing.Size(189, 47); + this.bt_gong34.TabIndex = 12; + this.bt_gong34.Text = "Envision 工34"; + this.bt_gong34.UseVisualStyleBackColor = true; + this.bt_gong34.Click += new System.EventHandler(this.bt_gong34_Click); + // + // bt_AUO_aimai + // + this.bt_AUO_aimai.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.bt_AUO_aimai.Location = new System.Drawing.Point(0, 390); + this.bt_AUO_aimai.Name = "bt_AUO_aimai"; + this.bt_AUO_aimai.Size = new System.Drawing.Size(189, 47); + this.bt_AUO_aimai.TabIndex = 11; + this.bt_AUO_aimai.Text = "AUO 愛買 read"; + this.bt_AUO_aimai.UseVisualStyleBackColor = true; + this.bt_AUO_aimai.Click += new System.EventHandler(this.bt_AUO_Insert_Click); + // // bt_hour_archive_hj // this.bt_hour_archive_hj.Font = new System.Drawing.Font("Microsoft JhengHei UI", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); @@ -234,6 +278,17 @@ namespace solarApp this.bt_day_archive_hj.UseVisualStyleBackColor = true; this.bt_day_archive_hj.Click += new System.EventHandler(this.bt_day_archive_hj_Click); // + // rt1 + // + this.rt1.BackColor = System.Drawing.SystemColors.MenuText; + this.rt1.Dock = System.Windows.Forms.DockStyle.Fill; + this.rt1.ForeColor = System.Drawing.SystemColors.Window; + this.rt1.Location = new System.Drawing.Point(629, 125); + this.rt1.Name = "rt1"; + this.rt1.Size = new System.Drawing.Size(829, 687); + this.rt1.TabIndex = 2; + this.rt1.Text = ""; + // // tb1 // this.tb1.Controls.Add(this.splitContainer1); @@ -257,6 +312,17 @@ namespace solarApp this.tabControl.Size = new System.Drawing.Size(1782, 853); this.tabControl.TabIndex = 1; // + // bt_sun_yadong + // + this.bt_sun_yadong.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.bt_sun_yadong.Location = new System.Drawing.Point(5, 576); + this.bt_sun_yadong.Name = "bt_sun_yadong"; + this.bt_sun_yadong.Size = new System.Drawing.Size(213, 47); + this.bt_sun_yadong.TabIndex = 14; + this.bt_sun_yadong.Text = "太陽能光電-亞東觀音"; + this.bt_sun_yadong.UseVisualStyleBackColor = true; + this.bt_sun_yadong.Click += new System.EventHandler(this.bt_sun_yadong_Click); + // // fmExcel // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F); @@ -285,7 +351,7 @@ namespace solarApp private System.Windows.Forms.Label lbSiteID_sensor; private System.Windows.Forms.Button bt_archive; private System.Windows.Forms.Button bt_inv_hour_hj; - private System.Windows.Forms.Button bt_clear_station; + private System.Windows.Forms.Button bt_read_taiping; private System.Windows.Forms.Button bt_clear_inv; private System.Windows.Forms.FlowLayoutPanel fp_site; private System.Windows.Forms.Button btVerifyData; @@ -296,8 +362,12 @@ namespace solarApp private System.Windows.Forms.TabPage tb1; private System.Windows.Forms.TabControl tabControl; private System.Windows.Forms.Button bt_inv_day_hj; - private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button bt_AUO_aimai; private System.Windows.Forms.Button bt_hour_archive_hj; private System.Windows.Forms.Button bt_day_archive_hj; + private System.Windows.Forms.RichTextBox rt1; + private System.Windows.Forms.Button bt_gong34; + private System.Windows.Forms.Button bt_sun_taoyuan; + private System.Windows.Forms.Button bt_sun_yadong; } } \ No newline at end of file diff --git a/solarApp/fmExcel.cs b/solarApp/fmExcel.cs index e6eadc2..c6a9a2c 100644 --- a/solarApp/fmExcel.cs +++ b/solarApp/fmExcel.cs @@ -67,40 +67,62 @@ namespace solarApp dataGridView1.DataSource = csvSvc.insertHour2DB(ref dt); MessageBox.Show("OK"); } - protected void ImporExcel() + protected void ImporExcel(string site_name) { string fname = ""; - OpenFileDialog fdlg = new OpenFileDialog(); + //OpenFileDialog fdlg = new OpenFileDialog(); //fdlg.Title = "Excel File Dialog"; - //fdlg.InitialDirectory = @"d:\temp\"; + //fdlg.InitialDirectory = @"d:\"; //fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"; //fdlg.FilterIndex = 2; //fdlg.RestoreDirectory = true; - //if (fdlg.ShowDialog() == DialogResult.OK) - //{ - // fname = fdlg.FileName; - //} - //else return; + string[] fileEntries = new string[0]; + Array.Clear(fileEntries, 0, fileEntries.Length); //取得選取檔案的路徑 - //string dir = Path.GetDirectoryName(fname); + string dir;//= Path.GetDirectoryName(fname); + + using (var fbd = new FolderBrowserDialog()) + { + DialogResult result = fbd.ShowDialog(); + if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath)) + { + //dir = Path.GetDirectoryName(fname); + //fileEntries = Directory.GetFiles(fbd.SelectedPath); + fileEntries = Directory.GetFiles(fbd.SelectedPath, "*.*", SearchOption.AllDirectories); + MessageBox.Show("Files found: " + fileEntries.Length.ToString(), "Message"); + } + } + // 取得路徑下所有檔案 - //string[] fileEntries = System.IO.Directory.GetFiles(dir); - string[] fileEntries = Directory.GetFiles(@"D:\temp\AUO\台中太平\台中太平\inverter", "*.*", SearchOption.AllDirectories); - + //string[] fileEntries = System.IO.Directory.GetFiles(dir); //D:\temp\AUO\台中太平\台中太平\inverter + //string[] fileEntries = Directory.GetFiles(@"D:\AUO\台中太平\inverter", "*.*", SearchOption.AllDirectories); + // dt.Column = colCount; - + solarApp.Service.excelHelper xlsSvc = new Service.excelHelper(); System.Data.DataTable dt = new System.Data.DataTable(); DataColumn mydc; bool isFirst = true; bool isFirstData = true; - - foreach (string fileName in fileEntries) + int x = 0; + + #region save file list + xlsSvc.insertFile2DB(fileEntries, site_name); + #endregion + + foreach (string fullfileName in fileEntries) { Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); - Microsoft.Office.Interop.Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(fileName); + if (fullfileName.Contains("~$")) { rt1.AppendText("\n -- contain ~$ in filename: " + fullfileName.ToString()); continue; } + Microsoft.Office.Interop.Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(fullfileName); Microsoft.Office.Interop.Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1]; Microsoft.Office.Interop.Excel.Range xlRange = xlWorksheet.UsedRange; //dataGridView1.ColumnCount = colCount; //dataGridView1.RowCount = rowCount; + string[] ff = fullfileName.Split("\\"); + string filename = string.Empty; + filename += ff[ff.Length-1]; //只抓最後的檔名 + rt1.AppendText(filename.ToString() + " "); + rt1.SelectionStart = rt1.Text.Length; + rt1.ScrollToCaret(); int rowCount = xlRange.Rows.Count; int colCount = xlRange.Columns.Count; for (int i = 1; i <= rowCount; i++) @@ -111,7 +133,7 @@ namespace solarApp for (int j = 1; j <= colCount; j++) { int col = 0; - col = j + 1; + col = j; mydc = new DataColumn(col.ToString()); dt.Columns.Add(mydc); isFirst = false; @@ -119,6 +141,11 @@ namespace solarApp } #endregion DataRow row = dt.NewRow(); + //只需要 10個欄位的版本 --------------------------------- + if (colCount != 10) { + rt1.AppendText("\n -- unable read file: " + fullfileName.ToString()); + break; + } for (int j = 0; j <= colCount-1; j++) { @@ -126,16 +153,33 @@ namespace solarApp { Microsoft.Office.Interop.Excel.Range range = xlRange.Cells[i, j+1] as Microsoft.Office.Interop.Excel.Range; row[j] = range.Value.ToString(); - isFirstData = false; + if (j == 9) isFirstData = false; } - else if (i == 0) continue; + // else if (i == 1) continue;// 第二個檔案之後的 firstRow 不需要, start from 1 else //從第二個檔案 開始都從第二個 row 開始 { Microsoft.Office.Interop.Excel.Range range = xlRange.Cells[i, j+1] as Microsoft.Office.Interop.Excel.Range; + if (string.IsNullOrEmpty(range.Value) || string.IsNullOrWhiteSpace(range.Value)) + MessageBox.Show("got it!"); + //string ss = range.Value.ToString(); + //ss = ss.Replace("[", "").Replace("]", ""); row[j] = range.Value.ToString(); } + if (j == colCount) + { + if (string.IsNullOrEmpty(row[j].ToString()) || string.IsNullOrWhiteSpace(row[j].ToString())) + MessageBox.Show("empty!"); + } + } + if (string.IsNullOrEmpty(row[5].ToString()) || string.IsNullOrWhiteSpace(row[5].ToString())) + { + MessageBox.Show("empty!"); + } + else + { + if (i == 1) continue;// 第二個檔案之後的 firstRow 不需要, start from 1 + dt.Rows.Add(row); } - dt.Rows.Add(row); } //release com objects to fully kill excel process from running in the background Marshal.ReleaseComObject(xlRange); @@ -148,13 +192,25 @@ namespace solarApp //quit and release xlApp.Quit(); Marshal.ReleaseComObject(xlApp); + + //if (x ==3) break; + string[] str = filename.Split("_"); + string inverterID = str[str.Length - 3] + "_" + str[str.Length - 2]; + str = inverterID.Split(" "); + inverterID = str[str.Length - 1]; + + xlsSvc.insertDay2DB(dt, filename, inverterID); + dt.Rows.Clear(); + x++; } //cleanup GC.Collect(); GC.WaitForPendingFinalizers(); - - MessageBox.Show(" dt.Rows.Count = " + dt.Rows.Count.ToString()); + dataGridView1.DataSource = dt; + //MessageBox.Show(" dt.Rows.Count = " + dt.Rows.Count.ToString()); + + MessageBox.Show(" ok "); //rule of thumb for releasing com objects: // never use two dots, all COM objects must be referenced and released individually // ex: [somthing].[something].[something] is bad @@ -224,7 +280,280 @@ namespace solarApp private void bt_clear_station_Click(object sender, EventArgs e) { - ImporExcel(); + ImporExcel("auo_taiping"); + } + + private void bt_archive_Click(object sender, EventArgs e) + { + + } + + private void bt_AUO_Insert_Click(object sender, EventArgs e) + { + ImporExcel("auo_aimai"); + } + + /// + /// 台中工34 + /// + /// + /// + private void bt_gong34_Click(object sender, EventArgs e) + { + string fname = ""; + //OpenFileDialog fdlg = new OpenFileDialog(); + //fdlg.Title = "Excel File Dialog"; + //fdlg.InitialDirectory = @"d:\"; + //fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"; + //fdlg.FilterIndex = 2; + //fdlg.RestoreDirectory = true; + string[] fileEntries = new string[0]; + Array.Clear(fileEntries, 0, fileEntries.Length); + //取得選取檔案的路徑 + string dir;//= Path.GetDirectoryName(fname); + + using (var fbd = new FolderBrowserDialog()) + { + DialogResult result = fbd.ShowDialog(); + if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath)) + { + //dir = Path.GetDirectoryName(fname); + //fileEntries = Directory.GetFiles(fbd.SelectedPath); + fileEntries = Directory.GetFiles(fbd.SelectedPath, "*.*", SearchOption.AllDirectories); + MessageBox.Show("Files found: " + fileEntries.Length.ToString(), "Message"); + } + } + + // 取得路徑下所有檔案 + //string[] fileEntries = System.IO.Directory.GetFiles(dir); //D:\temp\AUO\台中太平\台中太平\inverter + //string[] fileEntries = Directory.GetFiles(@"D:\AUO\台中太平\inverter", "*.*", SearchOption.AllDirectories); + + // dt.Column = colCount; + solarApp.Service.excelHelper xlsSvc = new Service.excelHelper(); + System.Data.DataTable dt = new System.Data.DataTable(); + DataColumn mydc; + bool isFirst = true; bool isFirstData = true; + int x = 0; + + #region save file list + xlsSvc.insertFile2DB__enlux_gong34(fileEntries, "gong34"); + #endregion + + foreach (string fullfileName in fileEntries) + { + Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); + if (fullfileName.Contains("~$")) { rt1.AppendText("\n -- contain ~$ in filename: " + fullfileName.ToString()); continue; } + Microsoft.Office.Interop.Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(fullfileName); + //Microsoft.Office.Interop.Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1]; + //xl.Worksheet ws = (xl.Worksheet)wb.Sheets[1]; + //foreach (xl.Worksheet ws1 in wb.Sheets) + //{ + // MessageBox.Show(ws1.Name); + // // or whatever you want to do with the worksheet + //} + string[] ff = fullfileName.Split("\\"); + string filename = string.Empty; + filename += ff[ff.Length - 1]; //只抓最後的檔名 + rt1.AppendText(filename.ToString() + " "); + rt1.SelectionStart = rt1.Text.Length; + rt1.ScrollToCaret(); + + foreach (Microsoft.Office.Interop.Excel._Worksheet xlWorksheet in xlWorkbook.Sheets) + { + // MessageBox.Show(xlWorksheet.Name); + Microsoft.Office.Interop.Excel.Range xlRange = xlWorksheet.UsedRange; + //dataGridView1.ColumnCount = colCount; + //dataGridView1.RowCount = rowCount; + rt1.AppendText(" - " + xlWorksheet.Name); + rt1.SelectionStart = rt1.Text.Length; + rt1.ScrollToCaret(); + int rowCount = xlRange.Rows.Count; + int colCount = xlRange.Columns.Count; + for (int i = 1; i <= rowCount; i++) + { + #region dt add column + if (isFirst) + { + for (int j = 1; j <= colCount; j++) + { + int col = 0; + col = j; + mydc = new DataColumn(col.ToString()); + dt.Columns.Add(mydc); + isFirst = false; + } + } + #endregion + DataRow row = dt.NewRow(); + //只需要 11個欄位的版本 --------------------------------- + if (colCount != 11) + { + rt1.AppendText("\n -- unable read file: " + fullfileName.ToString()); + break; + } + + for (int j = 0; j <= colCount - 1; j++) + { + if (isFirstData) // 第一筆資料為 欄位名稱 + { + Microsoft.Office.Interop.Excel.Range range = xlRange.Cells[i, j + 1] as Microsoft.Office.Interop.Excel.Range; + row[j] = range.Value.ToString(); + if (j == 11) isFirstData = false; + } + // else if (i == 1) continue;// 第二個檔案之後的 firstRow 不需要, start from 1 + else //從第二個檔案 開始都從第二個 row 開始 + { + Microsoft.Office.Interop.Excel.Range range = xlRange.Cells[i, j + 1] as Microsoft.Office.Interop.Excel.Range; + if (string.IsNullOrEmpty(range.Value) || string.IsNullOrWhiteSpace(range.Value)) + MessageBox.Show("got it!"); + //string ss = range.Value.ToString(); + //ss = ss.Replace("[", "").Replace("]", ""); + row[j] = range.Value.ToString(); + } + if (j == colCount) + { + if (string.IsNullOrEmpty(row[j].ToString()) || string.IsNullOrWhiteSpace(row[j].ToString())) + MessageBox.Show("empty!"); + } + } + if (string.IsNullOrEmpty(row[5].ToString()) || string.IsNullOrWhiteSpace(row[5].ToString())) + { + MessageBox.Show("empty!"); + } + else + { + if (i == 1) continue;// 第二個檔案之後的 firstRow 不需要, start from 1 + dt.Rows.Add(row); + } + } + //release com objects to fully kill excel process from running in the background + Marshal.ReleaseComObject(xlRange); + Marshal.ReleaseComObject(xlWorksheet); + + xlsSvc.insertDay2DB_enlux_gong34(dt, filename); + dt.Rows.Clear(); + + } //foreach excel.sheet + + //close and release + xlWorkbook.Close(); + Marshal.ReleaseComObject(xlWorkbook); + + //quit and release + xlApp.Quit(); + Marshal.ReleaseComObject(xlApp); + + x++; + }// foreach files + + //cleanup + GC.Collect(); + GC.WaitForPendingFinalizers(); + dataGridView1.DataSource = dt; + //MessageBox.Show(" dt.Rows.Count = " + dt.Rows.Count.ToString()); + + MessageBox.Show(" ok "); + //rule of thumb for releasing com objects: + // never use two dots, all COM objects must be referenced and released individually + // ex: [somthing].[something].[something] is bad + } + + private void bt_sun_taoyuan_Click(object sender, EventArgs e) + { + string fname = ""; + string[] fileEntries = new string[0]; + Array.Clear(fileEntries, 0, fileEntries.Length); + //取得選取檔案的路徑 + string dir;//= Path.GetDirectoryName(fname); + + using (var fbd = new FolderBrowserDialog()) + { + DialogResult result = fbd.ShowDialog(); + if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath)) + { + //dir = Path.GetDirectoryName(fname); + //fileEntries = Directory.GetFiles(fbd.SelectedPath); + fileEntries = Directory.GetFiles(fbd.SelectedPath, "*.*", SearchOption.AllDirectories); + MessageBox.Show("Files found: " + fileEntries.Length.ToString(), "Message"); + } + } + + Service.operateCSV csvSvc = new Service.operateCSV(); // readCsvTxt + System.Data.DataTable dt = new System.Data.DataTable(); + bool isFirst = true; + foreach (string fileName in fileEntries) + { + #region 取得 filename 中的 InvID + string fName = Path.GetFileName(fileName); + rt1.AppendText(fName + " "); + rt1.SelectionStart = rt1.Text.Length; + rt1.ScrollToCaret(); + #endregion + + if (isFirst) + { + //csvSvc.clear_inv("hour"); + csvSvc.taoYuan_createColumnHour(ref dt, fileName); + csvSvc.taoYuan_readCsvFile(ref dt, fileName, dt.Columns.Count, isFirst); + isFirst = false; + } + else + csvSvc.taoYuan_readCsvFile(ref dt, fileName, dt.Columns.Count, isFirst); + } + MessageBox.Show(" 共 " + dt.Rows.Count.ToString()); + + //System.Data.DataTable dt = solarApp.Service.csvHelper.OpenCSV(fname); + csvSvc.taoYuan_insertHour2DB(ref dt, "sun_taoyuan"); + MessageBox.Show("OK"); + } + + private void bt_sun_yadong_Click(object sender, EventArgs e) + { + string fname = ""; + string[] fileEntries = new string[0]; + Array.Clear(fileEntries, 0, fileEntries.Length); + //取得選取檔案的路徑 + string dir;//= Path.GetDirectoryName(fname); + + using (var fbd = new FolderBrowserDialog()) + { + DialogResult result = fbd.ShowDialog(); + if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath)) + { + //dir = Path.GetDirectoryName(fname); + //fileEntries = Directory.GetFiles(fbd.SelectedPath); + fileEntries = Directory.GetFiles(fbd.SelectedPath, "*.*", SearchOption.AllDirectories); + MessageBox.Show("Files found: " + fileEntries.Length.ToString(), "Message"); + } + } + + Service.operateCSV csvSvc = new Service.operateCSV(); // readCsvTxt + System.Data.DataTable dt = new System.Data.DataTable(); + bool isFirst = true; + foreach (string fileName in fileEntries) + { + #region 取得 filename 中的 InvID + string fName = Path.GetFileName(fileName); + rt1.AppendText(fName + " "); + rt1.SelectionStart = rt1.Text.Length; + rt1.ScrollToCaret(); + #endregion + + if (isFirst) + { + //csvSvc.clear_inv("hour"); + csvSvc.taoYuan_createColumnHour(ref dt, fileName); + csvSvc.taoYuan_readCsvFile(ref dt, fileName, dt.Columns.Count, isFirst); + isFirst = false; + } + else + csvSvc.taoYuan_readCsvFile(ref dt, fileName, dt.Columns.Count, isFirst); + } + //MessageBox.Show(" 共 " + dt.Rows.Count.ToString()); + lbSiteName_sensor.Text = " sun 亞東觀音 共:" + dt.Rows.Count.ToString(); + //System.Data.DataTable dt = solarApp.Service.csvHelper.OpenCSV(fname); + csvSvc.taoYuan_insertHour2DB(ref dt, "sun_yadong"); + MessageBox.Show("OK"); } } } From 8cd1e65f52bb4336a4f9ac8c1febdd7f3e62f9a0 Mon Sep 17 00:00:00 2001 From: Kai Date: Thu, 7 Oct 2021 09:51:36 +0800 Subject: [PATCH 32/38] =?UTF-8?q?1.=20=E8=A3=9C=E5=84=9F=E6=A9=9F=E5=88=B6?= =?UTF-8?q?bug=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- solarApp/Service/procStationSvc.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solarApp/Service/procStationSvc.cs b/solarApp/Service/procStationSvc.cs index ce1fc12..3f8c23d 100644 --- a/solarApp/Service/procStationSvc.cs +++ b/solarApp/Service/procStationSvc.cs @@ -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 @@ -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 From 594b248ff1296ffb4c7039f0fc195bdefd348086 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 8 Oct 2021 09:55:48 +0800 Subject: [PATCH 33/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E9=81=8B=E7=B6=AD?= =?UTF-8?q?=E4=BA=BA=E5=93=A1=E7=84=A1=E6=8E=92=E9=99=A4=E4=BB=A5=E5=88=AA?= =?UTF-8?q?=E9=99=A4=E4=BA=BA=E5=93=A1=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Repository/Implement/OperationRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolarPower/Repository/Implement/OperationRepository.cs b/SolarPower/Repository/Implement/OperationRepository.cs index 0e6435c..53add52 100644 --- a/SolarPower/Repository/Implement/OperationRepository.cs +++ b/SolarPower/Repository/Implement/OperationRepository.cs @@ -625,7 +625,7 @@ namespace SolarPower.Repository.Implement { try { - var sql = @$"SELECT us.* FROM power_station_operation_personnel ps LEFT JOIN user us ON ps.UserId = us.Id WHERE PowerStationId = {PowerStationId}"; + var sql = @$"SELECT us.* FROM power_station_operation_personnel ps LEFT JOIN user us ON ps.UserId = us.Id WHERE ps.PowerStationId = {PowerStationId} and ps.Deleted = 0"; result = (await conn.QueryAsync(sql)).ToList(); } catch (Exception exception) From e3441a76f7fc5b0420096b8f7f6c16a0d7ed9d72 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Fri, 8 Oct 2021 10:00:28 +0800 Subject: [PATCH 34/38] =?UTF-8?q?=E4=BF=AE=E5=BE=A9bug-=E5=A6=82=E4=B8=8A?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Repository/Implement/OperationRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SolarPower/Repository/Implement/OperationRepository.cs b/SolarPower/Repository/Implement/OperationRepository.cs index 53add52..6ade5ac 100644 --- a/SolarPower/Repository/Implement/OperationRepository.cs +++ b/SolarPower/Repository/Implement/OperationRepository.cs @@ -625,7 +625,7 @@ namespace SolarPower.Repository.Implement { try { - var sql = @$"SELECT us.* FROM power_station_operation_personnel ps LEFT JOIN user us ON ps.UserId = us.Id WHERE ps.PowerStationId = {PowerStationId} and ps.Deleted = 0"; + var sql = @$"SELECT us.* FROM power_station_operation_personnel ps LEFT JOIN user us ON ps.UserId = us.Id WHERE ps.PowerStationId = {PowerStationId} and ps.Deleted = 0 AND us.Deleted = 0"; result = (await conn.QueryAsync(sql)).ToList(); } catch (Exception exception) From be00cb0bc9a0d1947b16affe83952570060602c2 Mon Sep 17 00:00:00 2001 From: b110212000 Date: Wed, 13 Oct 2021 10:18:01 +0800 Subject: [PATCH 35/38] =?UTF-8?q?=E4=BF=AE=E5=BE=A9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/OperationController.cs | 3 ++- .../Implement/ElectricitySoldRecordRepository.cs | 2 +- SolarPower/Views/PowerStation/_UploadImage.cshtml | 2 +- .../Views/StationOverview/StationOverviewInfo.cshtml | 10 +++++----- SolarPower/Views/StationOverview/_Exception.cshtml | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/SolarPower/Controllers/OperationController.cs b/SolarPower/Controllers/OperationController.cs index 33bc534..04caffd 100644 --- a/SolarPower/Controllers/OperationController.cs +++ b/SolarPower/Controllers/OperationController.cs @@ -643,7 +643,7 @@ namespace SolarPower.Controllers OperationRecordPersonnel operationRecordPersonnel = new OperationRecordPersonnel(); operationRecordPersonnel.OperationRecordId = id; operationRecordPersonnel.UserId = op; - + operationRecordPersonnel.CreatedBy = myUser.Id; insertOperationRecordPersonnels.Add(operationRecordPersonnel); } @@ -651,6 +651,7 @@ namespace SolarPower.Controllers { "OperationRecordId", "UserId", + "CreatedBy" }; await operationRepository.AddOperationRecordPersonnelAsync(insertOperationRecordPersonnels, operationRecordPersonnelProperties); diff --git a/SolarPower/Repository/Implement/ElectricitySoldRecordRepository.cs b/SolarPower/Repository/Implement/ElectricitySoldRecordRepository.cs index 5573c76..8865c1b 100644 --- a/SolarPower/Repository/Implement/ElectricitySoldRecordRepository.cs +++ b/SolarPower/Repository/Implement/ElectricitySoldRecordRepository.cs @@ -122,7 +122,7 @@ namespace SolarPower.Repository.Implement var sql = @$"SELECT aa.StartAt,aa.EndAt,aa.Kwh actualkwh,aa.Money actualMoney,SUM(pd.TODAYKWH) realKWH,SUM(pd.MONEY) realMoney,ps.Estimate_kwh CBAkwh,ps.EstimateEfficacy CBAeff ,ps.GeneratingCapacity capacity ,ps.PowerRate rate FROM power_station_history_day pd - LEFT JOIN ( SELECT er.* FROM electricity_sold_record er WHERE {sqlwhere} AND er.Deleted = 0 ) aa + LEFT JOIN ( SELECT er.* FROM electricity_sold_record er WHERE {sqlwhere} AND er.Deleted = 0 AND er.PowerstationId = {info.PowerstationId}) aa ON aa.PowerstationId = pd.PowerStationId LEFT JOIN power_station ps ON ps.Id = pd.PowerStationId WHERE pd.TIMESTAMP BETWEEN aa.StartAt AND aa.EndAt AND ps.Id = {info.PowerstationId} GROUP BY aa.Id"; diff --git a/SolarPower/Views/PowerStation/_UploadImage.cshtml b/SolarPower/Views/PowerStation/_UploadImage.cshtml index 7c6a288..dd89116 100644 --- a/SolarPower/Views/PowerStation/_UploadImage.cshtml +++ b/SolarPower/Views/PowerStation/_UploadImage.cshtml @@ -41,7 +41,7 @@
    單線圖
    diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index 3b96580..feba4a5 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -319,7 +319,7 @@ labels: chartToday.labels, datasets: [{ type: 'bar', - label: '輸出功率', + label: '發電量', yAxisID: 'A', backgroundColor: 'rgb(103, 180, 172)', order: 3, @@ -411,7 +411,7 @@ labels: chart7day.labels, datasets: [{ type: 'bar', - label: '輸出功率', + label: '發電量', yAxisID: 'A', backgroundColor: 'rgb(103, 180, 172)', order: 3, @@ -503,7 +503,7 @@ labels: chartMonth.labels, datasets: [{ type: 'bar', - label: '輸出功率', + label: '發電量', yAxisID: 'A', backgroundColor: 'rgb(103, 180, 172)', order: 3, @@ -595,7 +595,7 @@ labels: chartYear.labels, datasets: [{ type: 'bar', - label: '輸出功率', + label: '發電量', yAxisID: 'A', backgroundColor: 'rgb(103, 180, 172)', order: 2, @@ -2010,7 +2010,7 @@ }, title: { - text: '逆變器單日kWhkWp' + text: '各逆變器當日有效日照時數' }, xAxis: { categories: HeatMap.xAxis, diff --git a/SolarPower/Views/StationOverview/_Exception.cshtml b/SolarPower/Views/StationOverview/_Exception.cshtml index be88d72..6fb7943 100644 --- a/SolarPower/Views/StationOverview/_Exception.cshtml +++ b/SolarPower/Views/StationOverview/_Exception.cshtml @@ -131,7 +131,7 @@
    - +
    From 781bf9e6600f66b81004d9e50296260663238c3f Mon Sep 17 00:00:00 2001 From: b110212000 Date: Wed, 13 Oct 2021 14:07:45 +0800 Subject: [PATCH 36/38] =?UTF-8?q?=E5=96=AE=E7=B7=9A=E5=9C=96PDF=E4=B8=8A?= =?UTF-8?q?=E5=82=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PowerStation/PowerStationEdit.cshtml | 36 ++++++++++++++++-- SolarPower/wwwroot/img/pdf.png | Bin 0 -> 8183 bytes 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 SolarPower/wwwroot/img/pdf.png diff --git a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml index ea46e76..96f7376 100644 --- a/SolarPower/Views/PowerStation/PowerStationEdit.cshtml +++ b/SolarPower/Views/PowerStation/PowerStationEdit.cshtml @@ -812,7 +812,12 @@ powerStationSingleLineCard = $("#power-station-single-line-card > .row"); powerStationSingleLineCard.empty(); rel.data.forEach(function (value, index) { - CreatePowerStationSingleLineBox(powerStationSingleLineCard, value); + var split = value.image.split("."); + if (split[split.length - 1].toLowerCase() == "pdf") { + CreatePowerStationSingleLineBoxPDF(powerStationSingleLineCard, value); + } else { + CreatePowerStationSingleLineBox(powerStationSingleLineCard, value); + } }); @@ -2870,7 +2875,7 @@ //#region 單線圖 Dropzone var powerStationSingleLineDropzone = new Dropzone("#power-station-single-line-form", { url: "/PowerStation/SavePowerStationSingleLine", - acceptedFiles: "image/*", + acceptedFiles: "image/*,application/pdf", autoProcessQueue: false, parallelUploads: 5, maxFiles: 5, @@ -2914,7 +2919,14 @@ powerStationSingleLineCard = $("#power-station-single-line-card > .row"); powerStationSingleLineCard.empty(); rel.data.forEach(function (value, index) { - CreatePowerStationSingleLineBox(powerStationSingleLineCard, value); + var split = value.image.split("."); + if (split[split.length - 1].toLowerCase() == "pdf") { + CreatePowerStationSingleLineBoxPDF(powerStationSingleLineCard, value); + } else { + CreatePowerStationSingleLineBox(powerStationSingleLineCard, value); + } + + }); }); @@ -2937,6 +2949,24 @@ } //#endregion + //#region 創建單線圖PDFbox + function CreatePowerStationSingleLineBoxPDF(dom, value) { + var str = '
    ' + + '
    ' + + '' + + '...' + + ''+ + '' + + '' + + '' + + '
    ' + + '
    '; + + dom.append(str); + } + //#endregion + + //#region 刪除單線圖 $('#power-station-single-line-card').on("click", "a.del-power-station-single-line-btn", function () { diff --git a/SolarPower/wwwroot/img/pdf.png b/SolarPower/wwwroot/img/pdf.png new file mode 100644 index 0000000000000000000000000000000000000000..5196ca4687953f37eacf7ccc2ab0aed13ed1ce13 GIT binary patch literal 8183 zcmd6Mdpy+JyZ@RoF}Z|PgwPe`nvh(}ElJpvg(?d%t5?{fzP1_sKwd3pFc+TXn+;vZN*mfT*8=&PDT}!Nrli&rkTH z>sIVK(LY*>el-4G8Ew5k6WMD2;8$DTV~>%KC2TLN?N5+MzI|YY_n`brT?G5Z{hVT_ zS>q%5BiVwa#C*bstE8e4>uLFT^R?KfI=JePx|G8bVUoahV|$~Kwup{5kUPu{e|?glKG4#h|7@|hW&N4c zg8aeeG$F4_Y3FO{r{Fx`Yw2v@No8;2vaAG8rjv)l!DbA2qXQD^k9BQxV2=)r#&1t9 zwgfmA)ih7Cx8GSC^k-vC&Gg%N?ni<$zZGNRklhOu|A`?7J{T{6zb@rxRJ5$8PKn~L zmd&IfBLNR6sNEnbZsjp$ud?U>BrZ&ffj9KRyhIJ9u>LW;oGVJ9xsv1fPgWKxcrA z2<`$vBs981*@b`|o;vi%1Xy79NMxmvH1F^u$D#Y##D-`^%U`r0NvmV{yPAe%bZT$Mq zjPnwtKCb!~dC$C~JGPEj?%A^o-|Xq?5;5DN{eOUpW92^pLtYBUE2}F17*LZuz%Gwn z3iw0n=;v4R(p$6;u0Nz&%6Z5BgK4fD_KJVUR5;;5d)j8#cR|=OEdZtrLu_#;qYw36 zd^S&*HZC~orJ9jNf#sd#sTZ_YWzh{wBzh(089_r$KmYLUG+ zt0&hr1SEE5Hu@%g@3-KV%-J85gBN#gk&Q1G4?wRMJ5(m@iNdi;nCD-Q`*PwI!6%Uo z2o$dgDK%;5WB6HE!XI@Zps=w%$xkY$UW7w$IX8W9`lbJevwQE4Kjm$Jlz>zYezx?9 zIkTc@!1?|Omk=AL4m2qkm@;~29$UK5_vxjRRV_x_{Kus3&X(6An4eA@blLMr|FNl5 zj+Nx&>~2v;#j9=VlrsE+8Yd`_RQImyK|9`Vs52?z68buI{%&`=s0a%#>}7X<0&0Zy zX}{Jv_>TMhY3u#(NPn|up}_MmJri20|Lnj2!lnMg%l=9Ft1tkW`k#P*3j_aSk{01O zBvEVM|Dpe{8yaAMPY4$KkC{R%x)T${pa%@>L`^NI1;v%WqCpFwrR0CEjk|K`ZT3h@ zdwom5&7#E@s8zjk$@Xn z*B)Z8`S|)29Z5i$sXKvz*q_YE?7gBRW0LSM)vcX_DoTVk?;~8zw}I1=Hm+rYDc;h4 zHd<3_)uWbFm`uit#;!*s3F$RCod$Y#o6JB#JrP0NAxqajwL@r^RFQ{k9$eZ06#(Vk z)!J_p++SYue!(ue9B)0@zypk*Va7V`vA9Etgd<T`>Vu+B5!|(Gmx_e&@vv&Y@GsxyAJL zVHYr=DHoBr!3sL8xyKY|Rj7=BnNw@Owex5d+U5Hyx4KOMj z$@KixXgZrb7J+}cOB;;em^mPhNd*6N83J<=~@5#RJw}`RfTEJs-&}-!Io9z6TH9a%<sN>%6k4Q=oF=hwwmB${}Zq4QB%7kCAD>+vg zry(=w+}`oSHJ?Su<7m8$#CNu(C~|?a-X?+Q9FSv0)$xuiOcE9x(XUov?{O~aASFsM zj%#jtabg$GnA+6#?R$b+EXz-*=Ccg^+MO3ME@_+SRqJ?lb1Es}dS3B6Y}^&HyX!_b zN7hF1nS>(_Dni9JziLxNm<(6qow%G=ZvK;7ClDCEY%A=MMmxs2ynIoQ(NgTpNW!NH zmeQHf{3}EeA;L1zVTz4d=14p4q3Me$#4;h@xi&v84U4x&i!(j^elT*SS83)V=o5Mb zv}ugBzpl4RPDq}!pgRhoPF_)FoPOMLrhS4-(>t%+mR-T6@p(^Y?C)Ra zDmGF?Ha=>ei0eJ8stk*d0?X34m@C{y<=qo@p+)U!eCpn`lw_a5qy&r5=u~u4qm8u;53tPtO$JrIie!C(JHr{^oa zewZ08rG5(?r4&j~*6(;64eKjjJq%RnHM{`Tl0P}%OD@&6E-|B^m%k30-oJ+~>a5oqfta`$dPfW~3IWBIEkLSj`$#hNU)j@DD8@8_sC z*hWhbLvxRcfw8E{eP|oM8j38J!|+U)4u!Drad75X@)-DSlT{mHpQco=;l)X6FqQ7$ zv9?SSJ@@Ktxtve!1`!(=W4(4H9Ktx4mg{#4#VJJW{qljz=)!i3uWpVvN8KoB`ZAFI zF13Oe0n~bbFX<3gk{Kfa&)yHTWr{38N+Q-X+&u#8WozvnH

    $W5 zMw8Cn%)rYII(u4FUG<=4o}ApG)6IOqX5?nTTYMV zRi?G-Ha8r%LY#XaB&J93UD;q5b{hf``PFP#eY)<v>Bh|Upu~Ny8YeQomq%F zpe3K@A>zF)(L)Oh(nT#fw9L7oRjH~H7oJJ0yLAV#+K@t-@=9qz*5+(V&YC`=q34v+ zC`&)+mZ)L5cNSF$Sl!1ZN+14729}08fc4X*qz1V+j0(D@REZ4+Vy-I)i z<+Ss$_w-09M=zo3yu(egn}pHgniCEkmYZ{`q%zscxsNE2et;XO#9 zO7DN7hGf(;Fzum1x}4b6>Tk<|-cb{!nu1AK{Se7{snoLqJm6g0v9;N}Z$V_5d#;*i z^Uo#ym`7WP-rl&zv6*X6?wc9E)xDUNtq+5uppq*OkZaoGPOlW$PD&6W+qw?z>wH}1 zS+4N4U1B6m8+CsCh&*}3P%xx+u2%wbR3#Qx7;sF&EV|8VcA%Qk*)w~_B;OF_HK{QI z6+bc`je2e=Y1yZEw(}!E%t$l0Y+UPO+5$IjW>dIM;qV3KdjZ1K&rKutq56Kz#&K2- zI4HYRD%e0gk7ty+maDh>aJ&&GA0}+%KT&1>l@c#Op$JMLfj|`{bUQIZG;cw}UA%Q} zN&d5R6b{b}J%F#NJW5T(9D2PvW+8YQ3BFZkf$Rl*0apH{MuSwjNyz9Xl&ZKY@P!tH zzB}O;L0zALvAk6vxSHY?Z#8H=7xhcWW|(8Z{^A*(8G@{mIS=^tAnfiZqZa0wUVfl} zsJr>5-{ftoUIni{%yvbPWe*HknSt!L?=kN?jzb?r0{MfcIM!FuM{9141-%M^tUsmY z?}?uA^j z{|s;+B)78sOp5_pt0%@>uTST^kadD*Rca!TzZ@LL+1(U zu`@wJ(Ags9&iJ<(TqP-M0;y%w8aQ$b+q_5?4u5cCKvoDgS!fd3!QY2HrJ@h!IdQ7q zQEyitXm~0(-}6^*flN`Dt^&J)YU!OVyRO+oEH4) zf{QJbmtjz7jMrR@4tP9DWjHRf;MVfgsx#Lar@4^0C(w@*y-%zMR^18fDy8u3V6%=8 zeW_6dGmW8NsTU2~gc#;jUjt`D#Dlm(8m86_YQ{xmFt>fkMWycFp0MK%4}HZRurJ^njhQ1k zbzOUe1GgtiNGrRE@k#CED8n^HF|;Rs@U7=wv?rD^;p-#mR!r?FA<#MeYg=Jd#%gC?YW;r5(e7t(bi__5 zS{(iuME^iq7xyRX2RE{?ZobKQ?h%dNtfxVzt0Y~^x?|vW+mkR-Hx#^%g$sz!(U=c^ zDW11m@T!tms5RSC>Z%hremR_;VLt4aTzivpLL1b5TYudPMX}!n2(xFL<iE; zgX~@Orb)ro^C3)8D9a~MJWR7wyd!;z4))}4R$#W@%!Ul)XFA5sC{7VxrNaE299co;NA#w)L1 z%b$zbVD*St>(M3Z+Mmrci5v~Y%CV2AKM7uAwxvg2fD%;n{3MevTL@jN5my-(KY1Rhz&{BCRI22!~pK|`|XFb zw?Z!aiPB>wD8`-}Be|kt(zgB&Rl)%%%0x#rcKHqyb!i<{acy*qetdMjY^v86h|vIB zujzZkZz=S)-x71Ci}7Q`T^}^HL5HS$iF!Ps?jwHvp~Tfx5zir%mDLZAXogp4>_R3p zv@t!bHef;&`s%{I@ucaNHjudNR%u%ad$0iqp6P1ZY-Bl3FwgZA)49;!Il0dw!I%L| z&LhCDX6j2Htue1xKyCG$1?qv?VrLBSk+Iy4=uki2T2610s)Gz78_gU`(m2wXU+ZxQ z($QKX$zhozJ#wPdB4rN}i19ye6xjGIXTx(JTYE(Z_B;dwr9!1FMlc2kS-e9My ztcSU4c}jM{ia;vdVoszmz-jOM$m23SfH#hT3 z4L7}lh#%z1bVG%Tjee16A&g}ed8|*pML*MzE~}Pt5tO90=0&)>xCpHhG%YtGI#hc= zy8FmRSD@8;zW1D4m_8;b7_~jNBERw7SUh@R5XG$a5W%NDaP{ECE^NPrq7k1ULMvM4 zh6UCe<>G2+Jhw%%i=4kD8XHo1m@92%r7t-8#3mX#i|!A%Q&U$GW>yYnhqZAJ_ngzj z%vE~0>sK`$Lx-X^y79p>+Ntcl1{!L=K}DDA+zmYoVdK$Rv~Pj^GCHfz^*NvI@m!8h zkA;o|Lf>Aft>kvbEHw}XYz(>IEest>II4c(IVPeutY;0HebZnly}i&et|oJ)fb`DB zb7juKWs2% zl(O<^ZhR#4{fZBxLI=OBGtZLDPKFCESi5vQE=)S|;Ep z@H-77lzpe4-5Mqa9YX+I3w&*Gfyz`7Q0JdTs=u#N;J|+>kNkJxxIQF~ON12{CTaYO z7ZNTevMvV|jop^uP|*ddZhPyMrMf_5FDgWq0%dk6s3Wrmb=n@eEV@IT!YgHKBJ8*@ z3FB0e2Adkzr&N#}(3RNG(vA(00A%~MGqI2JEyehq)b0fP2;pJg99giUV5N#B_5RIJdr&w(bsO}!~-8Q(1+wSlt`(GfBHYWN4==sw^YGH1_Z8ztYD zIAk4q4WKrk;=&UakB<+*fRQ-8gqc^KD!^Ssxs2ad$TKN$raj#$W2m&Wx3mOYEizh* zhdBj}r(dX9S7%c4F`XsLog+#_3xxG~tk*?=vPAmDi5xsHH4tD}7MwM70P6!1R!?iz zwhugm&*p4Q!i!k_&OW$frRGVvmkk+F}L70GJ!52 z0M#lBYTC)iq54;9Y(QHav<0Bcg$rC40f-l$V*^zeR5>s0v};CE4G_stloqqVGjb_w z0uP|3@m6RRdXLG@xJ~L}7qQ=y2M%34T&|^RI=W+n7G)u^T@#wVx6-wlhbKb?Kuikd zSL{|RabjoWKBb2-$HwTUZcEc4HesplIqG%~ek-^a8g=bz)UcWAp>Fi}(sFaDMxDzu zCp6(WX}Q3mxksSx!K(DXDx&>qdul=Z^^ek<7}SFOw>P?x8&rw-M&-b5Te=~@Ivrk@ z000dG8#4enbS+pu0qO{LAZS0hO_T*Md(`!I8|0ZhC!w>fxM2ao5r|jK>O6L-X=*y+ z6f9myQy3zF3Fvz5*G_)0>1$bZJqGsr`*l6)CLA|71maF9_rFAFwN(Z9rOSeiaE=)0 z6}DiiQ>7&UFAqxIhw4+;;5cS66iJ>=O`k{ru9o6YmKOE^WAd7ll`|)hb{Uw}&`>~V zmBqr%6H@q$;IF^GI$s&bzq5I*Q-`g+_5~tueM&hu z8KKpqa>q|J%@Qs~(|CchQ)I>Etn_xF19SG`eu(aQdqnR_SwaKk1ePzBvNQ!#_R(E1 zSev&u3MAVdpgYP4apjqlR<&-xskLtQcV@fu=KVcdtGab*ALf2~ruvdq>(m>&HC3rL z(TyQtZ`iqCruGJy`4k%$**FM-1R3>vLmKU68>;Xx+xjdFsR|YK0b5r=z;{}`oEc@Q z){qXGEs(;$42P)=yhvuP`|XPCT#9YQ+CuyCMNL?I9CG%m*XUD}zW5MheDMfQ@7;+Z z#g+j3qSSB43EhvL299T+qcmfT(#tEQEGeR%rFJHu1jG5p z?y%Z Date: Wed, 13 Oct 2021 16:34:50 +0800 Subject: [PATCH 37/38] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=B3=E6=99=82->?= =?UTF-8?q?=E4=BB=8A=E6=97=A5=20=20=E6=96=B0=E5=A2=9EEmail=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E5=8B=BE=E9=81=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SolarPower/Controllers/OperationController.cs | 239 +++++++++--------- SolarPower/Models/Operation.cs | 1 + SolarPower/Views/MapOverview/Index.cshtml | 6 +- .../Views/Operation/OperationRecord.cshtml | 154 ++++++----- SolarPower/Views/StationOverview/Index.cshtml | 2 +- .../StationOverviewInfo.cshtml | 162 ++++++++---- .../StationOverview/_OperationRecord.cshtml | 32 ++- 7 files changed, 344 insertions(+), 252 deletions(-) diff --git a/SolarPower/Controllers/OperationController.cs b/SolarPower/Controllers/OperationController.cs index 04caffd..88ca4a2 100644 --- a/SolarPower/Controllers/OperationController.cs +++ b/SolarPower/Controllers/OperationController.cs @@ -659,82 +659,83 @@ namespace SolarPower.Controllers } - if (post.WorkPersonIds != null) + if(post.Emailcheck == 1) { - var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); - List noticeSchedules = new List(); - foreach (var person in post.WorkPersonIds) + if (post.WorkPersonIds != null) { - var fixtype = post.WorkType switch + var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); + List noticeSchedules = new List(); + foreach (var person in post.WorkPersonIds) + { + var fixtype = post.WorkType switch + { + 0 => "清洗", + 1 => "巡檢", + 2 => "維修", + _ => "" + }; + var user = await userRepository.GetOneAsync(person); + NoticeSchedule schedule = new NoticeSchedule() + { + EmailType = 3, + Type = 1, + UserId = person, + RecipientName = user.Name, + RecipientEmail = user.Email, + Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime, + Content = "維修項目" + post.FixDo + "
    注意事項 :" + post.Notice, + }; + noticeSchedules.Add(schedule); + } + properties = new List() + { + "UserId", + "EmailType", + "RecipientEmail", + "Subject", + "Content", + "RecipientName", + "Type", + "ExceptionId" + }; + await noticeScheduleRepository.AddAnyThing>(noticeSchedules, properties, "notice_schedule"); + } + + if (post.FixFirm != 0) + { + var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); + var fixtype = operationRecord.WorkType switch { 0 => "清洗", 1 => "巡檢", 2 => "維修", _ => "" }; - var user = await userRepository.GetOneAsync(person); + var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId); + var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync(post.FixFirm, powerstations.SiteDB, "operation_firm"); NoticeSchedule schedule = new NoticeSchedule() { EmailType = 3, Type = 1, - UserId = person, - RecipientName = user.Name, - RecipientEmail = user.Email, + RecipientName = firm.Name, + RecipientEmail = firm.Email, Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime, Content = "維修項目" + post.FixDo + "
    注意事項 :" + post.Notice, }; - noticeSchedules.Add(schedule); + properties = new List() + { + "UserId", + "EmailType", + "RecipientEmail", + "Subject", + "Content", + "RecipientName", + "Type", + "ExceptionId" + }; + await noticeScheduleRepository.AddAnyThing(schedule, properties, "notice_schedule"); } - properties = new List() - { - "UserId", - "EmailType", - "RecipientEmail", - "Subject", - "Content", - "RecipientName", - "Type", - "ExceptionId" - }; - await noticeScheduleRepository.AddAnyThing>(noticeSchedules, properties, "notice_schedule"); } - - if (post.FixFirm != 0) - { - var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); - var fixtype = operationRecord.WorkType switch - { - 0 => "清洗", - 1 => "巡檢", - 2 => "維修", - _ => "" - }; - var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId); - var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync(post.FixFirm, powerstations.SiteDB, "operation_firm"); - NoticeSchedule schedule = new NoticeSchedule() - { - EmailType = 3, - Type = 1, - RecipientName = firm.Name, - RecipientEmail = firm.Email, - Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime, - Content = "維修項目" + post.FixDo + "
    注意事項 :" + post.Notice, - }; - properties = new List() - { - "UserId", - "EmailType", - "RecipientEmail", - "Subject", - "Content", - "RecipientName", - "Type", - "ExceptionId" - }; - await noticeScheduleRepository.AddAnyThing(schedule, properties, "notice_schedule"); - } - - //using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Suppress)) //{ @@ -880,83 +881,89 @@ namespace SolarPower.Controllers } #endregion - - if (post.WorkPersonIds != null) + if (post.Emailcheck == 1) { - var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); - List noticeSchedules = new List(); - foreach (var person in post.WorkPersonIds) + if (post.WorkPersonIds != null) { - var fixtype = operationRecord.WorkType switch + var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); + List noticeSchedules = new List(); + foreach (var person in post.WorkPersonIds) + { + var fixtype = operationRecord.WorkType switch + { + 0 => "清洗", + 1 => "巡檢", + 2 => "維修", + _ => "" + }; + var user = await userRepository.GetOneAsync(person); + NoticeSchedule schedule = new NoticeSchedule() + { + EmailType = 3, + Type = 1, + UserId = person, + RecipientName = user.Name, + RecipientEmail = user.Email, + Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime, + Content = "維修項目:" + post.FixDo + "
    注意事項 :" + post.Notice, + }; + noticeSchedules.Add(schedule); + } + properties = new List() + { + "UserId", + "EmailType", + "RecipientEmail", + "Subject", + "Content", + "RecipientName", + "Type", + "ExceptionId" + }; + await noticeScheduleRepository.AddAnyThing>(noticeSchedules, properties, "notice_schedule"); + } + if (post.FixFirm != 0) + { + var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); + var fixtype = post.WorkType switch { 0 => "清洗", 1 => "巡檢", 2 => "維修", _ => "" }; - var user = await userRepository.GetOneAsync(person); + var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId); + var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync(post.FixFirm, powerstations.SiteDB, "operation_firm"); NoticeSchedule schedule = new NoticeSchedule() { EmailType = 3, Type = 1, - UserId = person, - RecipientName = user.Name, - RecipientEmail = user.Email, + RecipientName = firm.Name, + RecipientEmail = firm.Email, Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime, Content = "維修項目:" + post.FixDo + "
    注意事項 :" + post.Notice, }; - noticeSchedules.Add(schedule); + properties = new List() + { + "UserId", + "EmailType", + "RecipientEmail", + "Subject", + "Content", + "RecipientName", + "Type", + "ExceptionId" + }; + await noticeScheduleRepository.AddAnyThing(schedule, properties, "notice_schedule"); + + + } - properties = new List() - { - "UserId", - "EmailType", - "RecipientEmail", - "Subject", - "Content", - "RecipientName", - "Type", - "ExceptionId" - }; - await noticeScheduleRepository.AddAnyThing>(noticeSchedules, properties, "notice_schedule"); } - if (post.FixFirm != 0) - { - var powerstations = await powerStationRepository.GetOneAsync(post.PowerStationId); - var fixtype = post.WorkType switch - { - 0 => "清洗", - 1 => "巡檢", - 2 => "維修", - _ => "" - }; - var powerstation = await powerStationRepository.GetOneAsync(post.PowerStationId); - var firm = await operationRepository.GetOneWithCustomDBNameAndTableAsync(post.FixFirm, powerstations.SiteDB, "operation_firm"); - NoticeSchedule schedule = new NoticeSchedule() - { - EmailType = 3, - Type = 1, - RecipientName = firm.Name, - RecipientEmail = firm.Email, - Subject = powerstations.Name + "-" + fixtype + "-" + post.WorkTime, - Content = "維修項目:" + post.FixDo + "
    注意事項 :" + post.Notice, - }; - properties = new List() - { - "UserId", - "EmailType", - "RecipientEmail", - "Subject", - "Content", - "RecipientName", - "Type", - "ExceptionId" - }; - await noticeScheduleRepository.AddAnyThing(schedule, properties, "notice_schedule"); - } + #endregion diff --git a/SolarPower/Models/Operation.cs b/SolarPower/Models/Operation.cs index f10b710..a251c26 100644 --- a/SolarPower/Models/Operation.cs +++ b/SolarPower/Models/Operation.cs @@ -293,6 +293,7 @@ namespace SolarPower.Models public string Notice { get; set; } public string Description { get; set; } public IFormFile[] RecordFiles { get; set; } + public byte Emailcheck { get; set; } } public class UpdateOperationRecord : Updated diff --git a/SolarPower/Views/MapOverview/Index.cshtml b/SolarPower/Views/MapOverview/Index.cshtml index a8f3d46..d592df2 100644 --- a/SolarPower/Views/MapOverview/Index.cshtml +++ b/SolarPower/Views/MapOverview/Index.cshtml @@ -20,7 +20,7 @@

    -

    即時總發電量

    +

    今日總發電量

    0.00

    @@ -36,7 +36,7 @@
    -

    即時日照度

    +

    今日日照度

    0.00

    @@ -279,7 +279,7 @@ '
    ' + '
    ' + '
    今日發電量(kW h):' + item.today_kWh.toFixed(2) + '
    '+ - '
    即時日照度(k W/m2):' + item.today_irradiance + '
    '+ + '
    今日日照度(k W/m2):' + item.today_irradiance + '
    '+ '
    有效日照時數(kwh/kwp):' + item.today_kwhkwp.toFixed(2) + '
    ' + '
    裝置容量(kWp):' + item.generatingCapacity.toFixed(3) + '
    ' + '
    掛錶日期:' + item.electricityMeterAt + '
    ' + diff --git a/SolarPower/Views/Operation/OperationRecord.cshtml b/SolarPower/Views/Operation/OperationRecord.cshtml index a19c193..dac2a90 100644 --- a/SolarPower/Views/Operation/OperationRecord.cshtml +++ b/SolarPower/Views/Operation/OperationRecord.cshtml @@ -211,8 +211,13 @@
    +
    +
    + + +
    +
    -
    @@ -707,7 +712,7 @@ $("#work_time_modal-error").hide(); - + $("#EmailcheckBox").prop("checked", false); $("#record-form-modal").modal(); } //#endregion @@ -1038,7 +1043,7 @@ - + $("#EmailcheckBox").prop("checked", false); $("#record-form-modal").modal(); }, 'json'); }); @@ -1057,94 +1062,87 @@ //#region 儲存表單資料 function SaveRecord() { 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"; + 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()); + if (document.querySelector('[id=EmailcheckBox]:checked')) { + formData.append("Emailcheck", 1); + } + else { + formData.append("Emailcheck", 0); + } + $.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; - } - - 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'); - myDropzone.removeAllFiles(); - if (status == 2) { - operationRecordTable.column(10).visible(true); - } - else { - operationRecordTable.column(10).visible(false); - } - operationRecordTable.ajax.reload(); - } + myDropzone.on("successmultiple", function (file, rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; } + + 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'); + myDropzone.removeAllFiles(); + if (status == 2) { + operationRecordTable.column(10).visible(true); + } + else { + operationRecordTable.column(10).visible(false); + } + operationRecordTable.ajax.reload(); } } }); + } } else { diff --git a/SolarPower/Views/StationOverview/Index.cshtml b/SolarPower/Views/StationOverview/Index.cshtml index ede80d0..6f96a5e 100644 --- a/SolarPower/Views/StationOverview/Index.cshtml +++ b/SolarPower/Views/StationOverview/Index.cshtml @@ -94,7 +94,7 @@
    -

    即時日照度

    +

    今日日照度

    0.00

    diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index feba4a5..a8000df 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -951,6 +951,32 @@ $("#work_person_select_modal").val(record.workPersonId); } } + + $("#work_person_select_modal").select2({ dropdownParent: $('#record-form-modal') }); + }); + + //查詢該電站的廠商 + var url_power_station_firm = "/PowerStation/GetFirmSelectOptionList"; + + $.post(url_power_station_firm, send_data, function (rel) { + if (rel.code != "0000") { + toast_error(rel.msg); + return; + } + + $("#fix_firm_select_modal").empty(); + if (rel.data.length > 0) { + + $.each(rel.data, function (index, val) { + $("#fix_firm_select_modal").append($("