diff --git a/SolarPower/Controllers/StationOverviewController.cs b/SolarPower/Controllers/StationOverviewController.cs index 9e308a4..1204986 100644 --- a/SolarPower/Controllers/StationOverviewController.cs +++ b/SolarPower/Controllers/StationOverviewController.cs @@ -808,6 +808,7 @@ namespace SolarPower.Controllers a.TIMESTAMP = Convert.ToDateTime(a.TIMESTAMP).ToString("HH tt", CultureInfo.InvariantCulture); break; case 1: + case 4: a.TOTALTIME = Convert.ToDateTime(a.TIMESTAMP).ToString("yyyy-MM"); a.TIMESTAMP = Convert.ToDateTime(a.TIMESTAMP).ToString("yyyy-MM-dd"); break; diff --git a/SolarPower/Helper/DatabaseHelper.cs b/SolarPower/Helper/DatabaseHelper.cs index 2d4529e..5d3b384 100644 --- a/SolarPower/Helper/DatabaseHelper.cs +++ b/SolarPower/Helper/DatabaseHelper.cs @@ -36,11 +36,19 @@ namespace SolarPower.Helper var databaseStr = ed.AESDecrypt(dbConfig.Database); var rootStr = ed.AESDecrypt(dbConfig.Root); var passwordStr = ed.AESDecrypt(dbConfig.Password); + // FIC 測試機 1 + //var serverStr = ed.AESEncrypt("localhost"); MWAxcj1mgmbZ8tB6NgApnQ== + //var portStr = ed.AESEncrypt("3306"); CY1x+1WYXRCBab3wKnBCOQ== + // var databaseStr = ed.AESEncrypt("solar_master"); CEyYZnO8B5+yTXQcFSsiBA== + //var rootStr = ed.AESEncrypt("root"); 4koIJVzfp6veImONCwQy3A== + //var passwordStr = ed.AESEncrypt("P@ssw0rd"); y4uPqlH9ncTgR/I07qpwaA== + + // FIC 測試機 2 //var serverStr = ed.AESEncrypt("localhost"); //var portStr = ed.AESEncrypt("3306"); //var databaseStr = ed.AESEncrypt("solar_master"); //var rootStr = ed.AESEncrypt("webUser"); - //var passwordStr = ed.AESEncrypt("ficAdmin99"); + //var passwordStr = ed.AESEncrypt("ficAdmin99"); var connStr = $"server={serverStr};port={portStr};database={databaseStr};user={rootStr};password={passwordStr};charset=utf8;Allow User Variables=True;"; diff --git a/SolarPower/Models/Overview.cs b/SolarPower/Models/Overview.cs index 62af16c..b698e4d 100644 --- a/SolarPower/Models/Overview.cs +++ b/SolarPower/Models/Overview.cs @@ -182,10 +182,17 @@ namespace SolarPower.Models public double SOLARHOUR { get; set; } public double Irradiance { get; set; } public double PR { get; set; } + /// + /// 總計PR + /// + public double avgPR { get; set; } public double Temp { get; set; } public double DiffSOLARHOUR { get; set; } public string TOTALTIME { get; set; } public double KWHKWP { get; set; } + /// + /// 累計日照 + /// public double IrrDay { get; set; } } diff --git a/SolarPower/Repository/Implement/OverviewRepository.cs b/SolarPower/Repository/Implement/OverviewRepository.cs index 43e9abb..a578e5f 100644 --- a/SolarPower/Repository/Implement/OverviewRepository.cs +++ b/SolarPower/Repository/Implement/OverviewRepository.cs @@ -654,7 +654,7 @@ namespace SolarPower.Repository.Implement //pyrdb = "sensor_history_month"; //timeGroup = "%Y-%m"; //range = ""; - //out_group = " GROUP BY DATE_FORMAT(V.TIMESTAMP,'%Y')"; + //out_group = " GROUP BY DATE_FORMAT(V.TIMESTAMP,'%Y')";4 select = "DATE_FORMAT(c.TIMESTAMP,'%Y') AS TIMESTAMP, MAX(KWH) AS KWH, SUM(SOLARHOUR) AS SOLARHOUR, 0 AS DiffSOLARHOUR, AVG(PR) AS PR, AVG(Irradiance) AS Irradiance, AVG(Temp) AS Temp ,AVG(KWHKWP) AS KWHKWP "; kwh = "C.TOTALKWH"; usedb = "power_station_history_month"; @@ -664,37 +664,78 @@ namespace SolarPower.Repository.Implement out_group = " GROUP BY DATE_FORMAT(V.TIMESTAMP,'%Y')"; break; } + + string sql = string.Empty; try { switch (post.GroupType) { - case 0: // today - hour - sql = $@" SELECT C.TIMESTAMP, C.KWH AS KWH,C.SOLARHOUR, C.PR, - P.Irradiance, P.Temperature AS Temp , C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR - FROM power_station_history_hour C - LEFT JOIN sensor_history_hour P ON P.`TIMESTAMP` =C.`TIMESTAMP` AND P.PowerStationId = C.PowerStationId - WHERE C.PowerStationId = {post.PowerstationId}{range2} "; break; - case 1: // day - case 2: // month - sql = $@" SELECT C.TIMESTAMP, {kwh} AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR - FROM {usedb} C - LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP,'{timeGroup}') = DATE_FORMAT(C.TIMESTAMP,'{timeGroup}') AND P.PowerStationId = C.PowerStationId - WHERE C.PowerStationId = {post.PowerstationId}{range}"; break; + case 0: // today - hour - 選擇同一天 + case 4: // date-range 選擇不同天 + if (!string.IsNullOrEmpty(post.HistoryRange)) + { + string d1 = post.HistoryRange.Substring(0, 10).Replace("/", "-"); + string d2 = post.HistoryRange.Substring(13, 10).Replace("/", "-"); + if (d1 == d2) + { // range 查詢同一天 + range2 = @$" AND DATE_FORMAT(C.`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{ d1 }' AND '{ d2 }'"; + sql = $@" SELECT C.TIMESTAMP, C.KWH AS KWH,C.SOLARHOUR, C.PR, + P.Irradiance, P.Temperature AS Temp , C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR + FROM power_station_history_hour C + LEFT JOIN sensor_history_hour P ON P.`TIMESTAMP` =C.`TIMESTAMP` AND P.PowerStationId = C.PowerStationId + WHERE C.PowerStationId = {post.PowerstationId}{range2} "; + } + else + { // range 查詢不同天 + //string endDate = DateTime.Parse(d2).AddDays(1).ToString("yyyy-MM-dd"); + range = @$" AND DATE_FORMAT(C.`TIMESTAMP`,'%Y-%m-%d') BETWEEN '{ d1 }' AND '{ d2 }'"; - case 3: // yeat - //sql = $@"SELECT left(c.`TIMESTAMP`, 4) AS `TIMESTAMP`, round(avg(monthKWH), 3) AS KWH, SUM(SOLARHOUR) AS SOLARHOUR, 0 AS DiffSOLARHOUR, AVG(PR) AS PR, round(AVG(KWHKWP), 3) AS KWHKWP - // FROM power_station_history_month C - // LEFT JOIN sensor_history_month P ON P.`TIMESTAMP` = C.`TIMESTAMP` AND P.PowerStationId = C.PowerStationId - // WHERE C.PowerStationId = C.PowerStationId = {post.PowerstationId} - // GROUP BY left(c.`TIMESTAMP`, 4) ORDER BY C.`TIMESTAMP` "; - sql = $@" - SELECT left(c.`TIMESTAMP`, 4) AS `TIMESTAMP`, sum(monthKWH) AS KWH, SUM(SOLARHOUR) AS SOLARHOUR, 0 AS DiffSOLARHOUR, AVG(PR) AS PR, - AVG(Irradiance) AS Irradiance, AVG(Temperature) AS Temp ,AVG(KWHKWP) AS KWHKWP - FROM power_station_history_month C - LEFT JOIN sensor_history_month P ON P.`TIMESTAMP` = C.`TIMESTAMP` AND P.PowerStationId = C.PowerStationId - WHERE C.PowerStationId = {post.PowerstationId} - GROUP BY left(c.`TIMESTAMP`, 4) ORDER BY C.`TIMESTAMP` "; break; + //sql = $@" SELECT left(C.`TIMESTAMP`, 10) `TIMESTAMP`, C.TODAYKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR + // FROM power_station_history_day C + // LEFT JOIN sensor_history_day P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m-%d') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m-%d') AND P.PowerStationId = C.PowerStationId + // join power_station_history_month m on DATE_FORMAT(P.TIMESTAMP, '%Y-%m') = DATE_FORMAT(m.TIMESTAMP, '%Y-%m') AND m.PowerStationId = C.PowerStationId + // WHERE C.PowerStationId = {post.PowerstationId}{range} order by C.TIMESTAMP"; + sql = $@" SELECT C.TIMESTAMP, C.TODAYKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR + FROM power_station_history_day C + LEFT JOIN sensor_history_day P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m-%d') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m-%d') AND P.PowerStationId = C.PowerStationId + WHERE C.PowerStationId = {post.PowerstationId}{range} order by C.TIMESTAMP"; break; + } + } + break; + case 1: // day 沒有 dateRange - 月 + sql = $@" SELECT C.TIMESTAMP, {kwh} AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR + FROM {usedb} C + LEFT JOIN {pyrdb} P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m-%d') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m-%d') AND P.PowerStationId = C.PowerStationId + WHERE C.PowerStationId = {post.PowerstationId}{range} order by C.TIMESTAMP"; break; + case 2: // month 單月 + //sql = $@" SELECT C.TIMESTAMP, C.MONTHKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR + // FROM power_station_history_month C + // LEFT JOIN sensor_history_month P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m') AND P.PowerStationId = C.PowerStationId + // WHERE C.PowerStationId = {post.PowerstationId}{range}"; + sql = $@" SELECT C.TIMESTAMP, C.MONTHKWH AS KWH, C.SOLARHOUR, C.PR, P.Irradiance, P.Temperature AS Temp ,C.KWHKWP, P.IrrDay, 0 AS DiffSOLARHOUR, C.PR avgPR + FROM power_station_history_month C + LEFT JOIN sensor_history_month P ON DATE_FORMAT(P.TIMESTAMP, '%Y-%m') = DATE_FORMAT(C.TIMESTAMP, '%Y-%m') AND P.PowerStationId = C.PowerStationId + WHERE C.PowerStationId = {post.PowerstationId}{range}"; + break; + + case 3: // year + //sql = $@"SELECT left(c.`TIMESTAMP`, 4) AS `TIMESTAMP`, round(avg(monthKWH), 3) AS KWH, SUM(SOLARHOUR) AS SOLARHOUR, 0 AS DiffSOLARHOUR, AVG(PR) AS PR, round(AVG(KWHKWP), 3) AS KWHKWP + // FROM power_station_history_month C + // LEFT JOIN sensor_history_month P ON P.`TIMESTAMP` = C.`TIMESTAMP` AND P.PowerStationId = C.PowerStationId + // WHERE C.PowerStationId = C.PowerStationId = {post.PowerstationId} + // GROUP BY left(c.`TIMESTAMP`, 4) ORDER BY C.`TIMESTAMP` "; + //sql = $@" SELECT left(c.`TIMESTAMP`, 4) AS `TIMESTAMP`, sum(monthKWH) AS KWH, SUM(SOLARHOUR) AS SOLARHOUR, 0 AS DiffSOLARHOUR, AVG(PR) AS PR, + // AVG(Irradiance) AS Irradiance, AVG(Temperature) AS Temp ,AVG(KWHKWP) AS KWHKWP + // FROM power_station_history_month C + // LEFT JOIN sensor_history_month P ON P.`TIMESTAMP` = C.`TIMESTAMP` AND P.PowerStationId = C.PowerStationId + // WHERE C.PowerStationId = {post.PowerstationId} + // GROUP BY left(c.`TIMESTAMP`, 4) ORDER BY C.`TIMESTAMP` "; + sql = $@" select left(c.`TIMESTAMP`, 4) AS `TIMESTAMP`, sum(monthKWH) AS KWH, round(AVG(PR), 2) AS PR , round(AVG(PR), 2) AS avgPR + FROM power_station_history_month C + WHERE C.PowerStationId = {post.PowerstationId} + group by left(c.`TIMESTAMP`, 4) "; + break; } diff --git a/SolarPower/Startup.cs b/SolarPower/Startup.cs index a94360e..072a41f 100644 --- a/SolarPower/Startup.cs +++ b/SolarPower/Startup.cs @@ -121,8 +121,8 @@ namespace SolarPower #region pqӶqBPRBkWP 30饭B(Cѭ2I) services.AddSingleton(); services.AddSingleton( - //new JobSchedule(jobType: typeof(CalcAvgPowerStationJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:CalcAvgPowerStationJob")) - new JobSchedule(jobType: typeof(CalcAvgPowerStationJob), cronExpression: "0 03 7 ? * * *") + new JobSchedule(jobType: typeof(CalcAvgPowerStationJob), cronExpression: Configuration.GetValue("BackgroundServiceCron:CalcAvgPowerStationJob")) + //new JobSchedule(jobType: typeof(CalcAvgPowerStationJob), cronExpression: "0 03 7 ? * * *") ); #endregion diff --git a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml index 7ba58a2..9fae923 100644 --- a/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml +++ b/SolarPower/Views/StationOverview/StationOverviewInfo.cshtml @@ -184,6 +184,40 @@ GetPowerStationCollapse(filter); });*@ + //#region Date-Picker add by jiahao 2022-05-21 + datepicker = $('#date-range-history').daterangepicker({ + autoUpdateInput: false, + locale: { format: 'YYYY-MM-DD' }, + //miniDate: new Date(Date.setDate(Date.getDate() - 30)), + //maxDate: Date.getDate(), + opens: 'left' + }, function (start, end, label) { + }); + + $('#date-range-history').on('apply.daterangepicker', function (ev, picker) { + $(this).val(picker.startDate.format('YYYY-MM-DD') + ' ~ ' + picker.endDate.format('YYYY-MM-DD')); + $(this).trigger('change'); + }); + + $('#date-range-history').on('cancel.daterangepicker', function (ev, picker) { + $(this).val(''); + $(this).trigger('change'); + }); + //#endregion + + //#region 預設近今天 + var today = new Date(); + //var dateLimit = new Date(new Date().setDate(today.getDate() - 7)); + var today_format = today.toISOString().slice(0, 10).replace(/-/g, "/"); + //var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "/"); + //datepicker.data('daterangepicker').setStartDate(dateLimit_format); + datepicker.data('daterangepicker').setStartDate(today_format); + datepicker.data('daterangepicker').setEndDate(today_format); + //$('#date-range-history').val(dateLimit_format + ' - ' + today_format); + $('#date-range-history').val(today_format + ' ~ ' + today_format); + //alert(" date-range-history = "+$('#date-range-history').val()); + //#endregion + //#region 預先載入公司下拉式選單select_option var url_company_select_option = "/Company/GetCompanySelectOptionList"; $.get(url_company_select_option, function (rel) { @@ -682,11 +716,11 @@ //#endregion $('#carouselExampleIndicators').carousel({ - interval: 10000 + interval: 11000 }) $('#carousel-chart').carousel({ - interval: 10000 + interval: 11000 }) //#endregion @@ -789,7 +823,7 @@ }); $('#date-range-record').on('apply.daterangepicker', function (ev, picker) { - $(this).val(picker.startDate.format('YYYY/MM/DD') + ' - ' + picker.endDate.format('YYYY/MM/DD')); + $(this).val(picker.startDate.format('YYYY/MM/DD') + ' ~ ' + picker.endDate.format('YYYY/MM/DD')); $(this).trigger('change'); }); @@ -2308,13 +2342,16 @@ document.getElementById("ToMonth").style.display = "none";//隱藏 document.getElementById("ToYear").style.display = "none";//隱藏 - document.getElementById("DateGet").style.display = "";//隱藏 + //document.getElementById("DateGet").style.display = "";//隱藏 + document.getElementById("date-range-history").style.display = "";//隱藏 document.getElementById("MonthGet").style.display = "none";//隱藏 document.getElementById("YearGet").style.display = "none";//隱藏 var today = new Date(); var today_format = today.toISOString().slice(0, 10).replace(/-/g, "-"); - $('#DateGet').val(today_format); - historyRange = $('#DateGet').val(); + //$('#DateGet').val(today_format); + //historyRange = $('#DateGet').val(); + $('#date-range-history').val(today_format + ' - ' + today_format); + historyRange = $('#date-range-history').val(); groupType = type; getTable(); break; @@ -2323,7 +2360,8 @@ document.getElementById("ToMonth").style.display = "";//隱藏 document.getElementById("ToYear").style.display = "none";//隱藏 - document.getElementById("DateGet").style.display = "none";//隱藏 + //document.getElementById("DateGet").style.display = "none";//隱藏 + document.getElementById("date-range-history").style.display = "none";//隱藏 document.getElementById("MonthGet").style.display = "";//隱藏 document.getElementById("YearGet").style.display = "none";//隱藏 var today = new Date(); @@ -2338,7 +2376,8 @@ document.getElementById("ToMonth").style.display = "none";//隱藏 document.getElementById("ToYear").style.display = "";//隱藏 - document.getElementById("DateGet").style.display = "none";//隱藏 + //document.getElementById("DateGet").style.display = "none";//隱藏 + document.getElementById("date-range-history").style.display = "none";//隱藏 document.getElementById("MonthGet").style.display = "none";//隱藏 document.getElementById("YearGet").style.display = "";//隱藏 var today = new Date(); @@ -2353,7 +2392,8 @@ document.getElementById("ToMonth").style.display = "none";//隱藏 document.getElementById("ToYear").style.display = "none";//隱藏 - document.getElementById("DateGet").style.display = "none";//隱藏 + //document.getElementById("DateGet").style.display = "none";//隱藏 + document.getElementById("date-range-history").style.display = "none";//隱藏 document.getElementById("MonthGet").style.display = "none";//隱藏 document.getElementById("YearGet").style.display = "none";//隱藏 @@ -2371,19 +2411,21 @@ //#region 選擇今昨日 function getday(post) { - if (post == 0) { + if (post == 0) { //今天 var today = new Date(); var today_format = today.toISOString().slice(0, 10).replace(/-/g, "-"); - $('#DateGet').val(today_format); + //$('#DateGet').val(today_format); + $('#date-range-history').val(today_format + ' - ' + today_format); } else - { + { // 昨天 var today = new Date(); var dateLimit = new Date(new Date().setDate(today.getDate() - 1)); var dateLimit_format = dateLimit.toISOString().slice(0, 10).replace(/-/g, "-"); - $('#DateGet').val(dateLimit_format); + //$('#DateGet').val(dateLimit_format); + $('#date-range-history').val(dateLimit_format + ' - ' + dateLimit_format); } - historyRange = $('#DateGet').val(); + historyRange = $('#date-range-history').val(); getTable(); } //#endregion @@ -2424,16 +2466,30 @@ } //#endregion - - function Historyclick() { + console.log("date-range-history = " + $('#date-range-history').val()); + function Historyclick() { switch (groupType) { - case 0: historyRange = $('#DateGet').val(); break; + case 0: + timeAll = $('#date-range-history').val().split('~'); + time1 = timeAll[0].trim(); + time2 = timeAll[1].trim(); + historyRange = time1 + ' - ' + time2; + //alert("historyRange = " + historyRange); + if (time1 != time2) { + groupType = 4; // 採用 月報格式 + // alert("groupType = " + groupType); + } + break; case 1: historyRange = $('#MonthGet').val(); break; case 2: historyRange = $('#YearGet').val(); break; + case 4: timeAll = $('#date-range-history').val().split('~'); + time1 = timeAll[0].trim(); + time2 = timeAll[1].trim(); + historyRange = time1 + ' - ' + time2; break; } getTable(); } - console.log(" before onChange event"); + //$('#DateGet').on('change', function () { // console.log(" in onChange event"); // historyRange = $('#DateGet').val(); @@ -2457,8 +2513,10 @@ { var today = new Date(); var today_format = today.toISOString().slice(0, 10).replace(/-/g, "-"); - $('#DateGet').val(today_format); - historyRange = $('#DateGet').val(); + //$('#DateGet').val(today_format); + //historyRange = $('#DateGet').val(); + $('#date-range-history').val(today_format + ' - ' + today_format); + historyRange = $('#date-range-history').val(); } var send_data = { @@ -2466,7 +2524,7 @@ HistoryRange: historyRange, PowerstationId: stationId } - //0:日 1:月 2:年 3:歷年 + //0:日 1:月 2:年 3:歷年 4:dateRange 選擇不同天(採用月的方式顯示) var Nurl = "/StationOverview/GetTotalTableToHistory"; $.post(Nurl, send_data, function (rel) { if (rel.code != "0000") { @@ -2478,8 +2536,9 @@ var TimestampALL; var kwhALL = 0; var diffSOLARHOURALL = 0; - var irradianceALL = 0; - var prALL; + var irradianceALL = 0; + var pr = 0; + var avgPR = 0; var tempALL = 0; var listmonth = new Array(0); var listkwh = new Array(0); @@ -2498,14 +2557,25 @@ $.each(rel.data, function (index, val) { + // console.log('回傳 = ' + val); + TimestampALL = val.totaltime; kwhALL += val.kwh; //diffSOLARHOURALL += val.diffSOLARHOUR; irradianceALL += val.irradiance; irr_day = val.irrDay; - prALL = val.pr; + pr = val.pr; + avgPR += val.pr; + //rowCT++; + //console.log('avgPR = ' + avgPR) + ' rowCT = ' + rowCT;; + //if (typeof (val) == 'object') { + //if (val && typeof (val) != "undefined") { + // alert('val.PR = ' + val.pr); + // avgPR += val.pr; + // rowCT++; + //} tempALL += val.temp; - + //暫時先執行到這--->取kwhkwp if (val.length != 0) { @@ -2526,7 +2596,7 @@ '' + val.kwh.toFixed(2) + '' + '' + val.kwhkwp.toFixed(2) + '' + '' + val.irrDay.toFixed(2) + '' + - '' + val.irradiance.toFixed(2) + '' + + //'' + val.irradiance.toFixed(2) + '' + '' + val.pr.toFixed(2) + '' + '' + val.temp.toFixed(2) + '' + ''); @@ -2556,7 +2626,7 @@ '' + val.kwh.toFixed(2) + '' + '' + val.kwhkwp.toFixed(2) + '' + - '' + val.irradiance.toFixed(2) + '' + + //'' + val.irradiance.toFixed(2) + '' + '' + val.pr.toFixed(2) + '' + '' + val.temp.toFixed(2) + '' + ''); @@ -2673,134 +2743,12 @@ }], }); - @*$('#history-kWh-convas-div').empty(); - $('#history-kWh-convas-div').append(''); - var ctx_history_kWh = document.getElementById('history-kWh').getContext('2d'); - var myhistorykwh = new Chart(ctx_history_kWh, { - type: 'bar', - data: { - labels: listmonth, - datasets: [ - { - type: 'line', - label: '溫度(℃)', - yAxisID: 'E', - borderColor: 'rgb(255, 192, 0)', - pointBackgroundColor: 'rgb(255, 192, 0)', - pointBorderColor: 'rgb(255, 192, 0)', - pointBorderWidth: 1, - borderWidth: 2, - pointRadius: 4, - pointHoverRadius: 5, - fill: false, - data: listtemperature - }, { - type: 'line', - label: '日照度(kWh/㎡)', - yAxisID: 'B', - borderColor: 'rgba(190, 45, 45,1)', - pointBackgroundColor: 'rgb(190, 45, 45,1)', - pointBorderColor: 'rgb(190, 45, 45,1)', - pointBorderWidth: 1, - borderWidth: 2, - pointRadius: 4, - pointHoverRadius: 5, - fill: false, - data: listirradiance - },{ - type: 'bar', - label: 'PR(%)', - yAxisID: 'D', - backgroundColor: 'rgba(68, 114, 196)', - borderWidth: 1, - data: listpr - },{ - type: 'bar', - label: '日均發電度數', - yAxisID: 'C', - backgroundColor: 'rgba(165, 165, 165)', - borderWidth: 1, - data: listkwhkwp - },{ - type: 'bar', - backgroundColor: 'rgba(103, 180, 172, 1)', - borderWidth: 1, - label: '發電量(kWh)', - yAxisID: 'A', - data: listkwh - }] - }, - options: { - title: { - display: true, - text: '發電量及日照度' - }, - legend: { - display: true, - position: 'bottom' - }, - scales: { - yAxes: [{ - id: 'A', - type: 'linear', - position: 'left', - ticks: { - min: 0 - }, - scaleLabel: { - display: true, - labelString: 'kWh' - } - }, { - id: 'B', - type: 'linear', - position: 'right', - ticks: { - min: 0 - }, - scaleLabel: { - display: true, - labelString: 'kWh/㎡' - } - }, { - id: 'C', - type: 'linear', - position: 'right', - ticks: { - min: 0 - }, - scaleLabel: { - display: true, - labelString: 'hr' - } - }, { - id: 'D', - type: 'linear', - position: 'right', - ticks: { - min: 0 - }, - scaleLabel: { - display: true, - labelString: 'PR(%)' - } - }, { - id: 'E', - type: 'linear', - position: 'right', - ticks: { - min: 0 - }, - scaleLabel: { - display: true, - labelString: '℃' - } - }] - } - } - });*@ - - + if (groupType == 0) { + avgPR = pr; + } else { + avgPR = avgPR / rel.data.length; + } + //alert('avgPR = ' + avgPR + ' rowCT=' + rel.data.length); if (rel.data.length == 0) { $('#HistoryTotalTable').append('' + '' + '無資料' + '' + ''); @@ -2814,7 +2762,7 @@ '' + kwhkwp + '' + //'' + irradianceALL.toFixed(2) + '' + // 改成累積日照 by jiahao 2022-04-30 00:444 '' + irr_day.toFixed(2) + '' + - '' + prALL.toFixed(2) + '' + + '' + avgPR.toFixed(2) + '' + '' + tempALL.toFixed(2) + '' + ''); } @@ -2883,7 +2831,7 @@ } catch (e) { } if (!xmlhttp) { - window.alert(""); + // window.alert(""); } } diff --git a/SolarPower/Views/StationOverview/_History.cshtml b/SolarPower/Views/StationOverview/_History.cshtml index 618856d..6156175 100644 --- a/SolarPower/Views/StationOverview/_History.cshtml +++ b/SolarPower/Views/StationOverview/_History.cshtml @@ -25,20 +25,21 @@
@* -
- - +
+ + +
- *@ - + + *@ + - +
@@ -85,7 +86,7 @@ 發電量(kWh) 有效發電小時 累積日照量(W/m2) - 日照量(W/m2) + @*日照量(W/m2)*@ PR(%) 溫度(℃) diff --git a/SolarPower/appsettings.Development.json b/SolarPower/appsettings.Development.json index 67ee146..d477624 100644 --- a/SolarPower/appsettings.Development.json +++ b/SolarPower/appsettings.Development.json @@ -16,12 +16,21 @@ // "Password": "y4uPqlH9ncTgR/I07qpwaA==" //}, "mySql": "server=210.61.91.43;user=idafenweb;Database=solar_master;Port=10068;password=P@ssw0rd;charset='utf8';pooling=true;sslmode=none;", + // + //"DBConfig": { + // "Server": "AVXfxd+IRlLtJ0MCi9HU1g==", + // "port": "CrEmevYrUsSo7Mkb7Gxn8A==", + // "Database": "CEyYZnO8B5+yTXQcFSsiBA==", + // "Root": "Aph7AzoiwAmmBHCfS1rqeQ==", + // "Password": "8WMHBEWuT0XoAB4kzduQHA==" + //}, + // FIC woG "DBConfig": { - "Server": "AVXfxd+IRlLtJ0MCi9HU1g==", - "port": "CrEmevYrUsSo7Mkb7Gxn8A==", + "Server": "MWAxcj1mgmbZ8tB6NgApnQ==", + "port": "CY1x+1WYXRCBab3wKnBCOQ==", "Database": "CEyYZnO8B5+yTXQcFSsiBA==", - "Root": "Aph7AzoiwAmmBHCfS1rqeQ==", - "Password": "8WMHBEWuT0XoAB4kzduQHA==" + "Root": "4koIJVzfp6veImONCwQy3A==", + "Password": "y4uPqlH9ncTgR/I07qpwaA==" }, "BackgroundServiceCron": { "CalcPowerStationJob": "0 5 * * * ?", diff --git a/SolarPower/appsettings.json b/SolarPower/appsettings.json index 83eefa0..b3ccdc1 100644 --- a/SolarPower/appsettings.json +++ b/SolarPower/appsettings.json @@ -10,6 +10,7 @@ "LoginExpireMinute": 60, //nJɶA() "GoBackDay": 1, //v(I(C))A^Ѽ "mySql": "server=60.251.164.103;user=webuser;Database=solar_master;Port=11306;password=FICadmin99;charset='utf8';pooling=true;sslmode=none;", + //"DBConfig": { // "Server": "MVgHWzR3rGDgD57TUoFunA==", // "port": "r4AoXMUDodcQjIzofGNCcg==", @@ -17,13 +18,22 @@ // "Root": "mWlR2HshQNhRRE34jg4kdg==", // "Password": "y4uPqlH9ncTgR/I07qpwaA==" //}, + // FIC woG "DBConfig": { - "Server": "AVXfxd+IRlLtJ0MCi9HU1g==", - "port": "CrEmevYrUsSo7Mkb7Gxn8A==", + "Server": "MWAxcj1mgmbZ8tB6NgApnQ==", + "port": "CY1x+1WYXRCBab3wKnBCOQ==", "Database": "CEyYZnO8B5+yTXQcFSsiBA==", - "Root": "Aph7AzoiwAmmBHCfS1rqeQ==", - "Password": "8WMHBEWuT0XoAB4kzduQHA==" + "Root": "pBX64+ALGFnLiHGRFXNh7w==", + "Password": "bOlWkSFsV3qNLkZTJ3UPog==" }, + // + //"DBConfig": { + // "Server": "AVXfxd+IRlLtJ0MCi9HU1g==", + // "port": "CrEmevYrUsSo7Mkb7Gxn8A==", + // "Database": "CEyYZnO8B5+yTXQcFSsiBA==", + // "Root": "Aph7AzoiwAmmBHCfS1rqeQ==", + // "Password": "8WMHBEWuT0XoAB4kzduQHA==" + //}, "BackgroundServiceCron": { "CalcPowerStationJob": "0 5 * * * ?", "CalcAvgPowerStationJob": "0 0 2 * * ?", diff --git a/solarApp/App.config b/solarApp/App.config index 1210e63..12a99f8 100644 --- a/solarApp/App.config +++ b/solarApp/App.config @@ -2,7 +2,8 @@ - + + diff --git a/solarApp/fmArchive.Designer.cs b/solarApp/fmArchive.Designer.cs index 0327a3b..6971fd8 100644 --- a/solarApp/fmArchive.Designer.cs +++ b/solarApp/fmArchive.Designer.cs @@ -29,11 +29,13 @@ namespace solarApp /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + this.components = new System.ComponentModel.Container(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); + this.bt_lackStation = new System.Windows.Forms.Button(); this.bt_sensor_lackData = new System.Windows.Forms.Button(); this.btInvDay_oldData = new System.Windows.Forms.Button(); this.bt_rpt_invDay = new System.Windows.Forms.Button(); @@ -71,7 +73,7 @@ namespace solarApp this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.label4 = new System.Windows.Forms.Label(); - this.bt_lackStation = new System.Windows.Forms.Button(); + this.timer1 = new System.Windows.Forms.Timer(this.components); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); @@ -149,6 +151,18 @@ namespace solarApp this.splitContainer1.SplitterWidth = 10; this.splitContainer1.TabIndex = 0; // + // bt_lackStation + // + this.bt_lackStation.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.bt_lackStation.Location = new System.Drawing.Point(300, 735); + this.bt_lackStation.Name = "bt_lackStation"; + this.bt_lackStation.Size = new System.Drawing.Size(107, 44); + this.bt_lackStation.TabIndex = 15; + this.bt_lackStation.Text = "LackData"; + this.bt_lackStation.UseVisualStyleBackColor = true; + this.bt_lackStation.Visible = false; + this.bt_lackStation.Click += new System.EventHandler(this.bt_lackStation_Click); + // // bt_sensor_lackData // this.bt_sensor_lackData.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); @@ -158,6 +172,7 @@ namespace solarApp this.bt_sensor_lackData.TabIndex = 14; this.bt_sensor_lackData.Text = "LackData"; this.bt_sensor_lackData.UseVisualStyleBackColor = true; + this.bt_sensor_lackData.Visible = false; this.bt_sensor_lackData.Click += new System.EventHandler(this.bt_sensor_lackData_Click); // // btInvDay_oldData @@ -309,8 +324,8 @@ namespace solarApp // this.gv_inv_detail.AllowUserToAddRows = false; this.gv_inv_detail.AllowUserToDeleteRows = false; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - this.gv_inv_detail.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.gv_inv_detail.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.gv_inv_detail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.gv_inv_detail.Dock = System.Windows.Forms.DockStyle.Fill; this.gv_inv_detail.Location = new System.Drawing.Point(768, 75); @@ -326,8 +341,8 @@ namespace solarApp // this.gv_rpt_invDay.AllowUserToAddRows = false; this.gv_rpt_invDay.AllowUserToDeleteRows = false; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); - this.gv_rpt_invDay.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.gv_rpt_invDay.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle2; this.gv_rpt_invDay.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.gv_rpt_invDay.Dock = System.Windows.Forms.DockStyle.Left; this.gv_rpt_invDay.Location = new System.Drawing.Point(0, 75); @@ -564,17 +579,6 @@ namespace solarApp this.label4.TabIndex = 9; this.label4.Text = "Site_Name"; // - // bt_lackStation - // - this.bt_lackStation.Font = new System.Drawing.Font("Microsoft JhengHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.bt_lackStation.Location = new System.Drawing.Point(300, 735); - this.bt_lackStation.Name = "bt_lackStation"; - this.bt_lackStation.Size = new System.Drawing.Size(107, 44); - this.bt_lackStation.TabIndex = 15; - this.bt_lackStation.Text = "LackData"; - this.bt_lackStation.UseVisualStyleBackColor = true; - this.bt_lackStation.Click += new System.EventHandler(this.bt_lackStation_Click); - // // fmArchive // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F); @@ -652,5 +656,6 @@ namespace solarApp private System.Windows.Forms.Button btInvDay_oldData; private System.Windows.Forms.Button bt_sensor_lackData; private System.Windows.Forms.Button bt_lackStation; + private System.Windows.Forms.Timer timer1; } } \ No newline at end of file diff --git a/solarApp/fmArchive.cs b/solarApp/fmArchive.cs index 65b17e4..5b1598f 100644 --- a/solarApp/fmArchive.cs +++ b/solarApp/fmArchive.cs @@ -71,6 +71,14 @@ namespace solarApp // dtselect_station1.Value = DateTime.Today.AddDays(-1); dtSelect1.Value = System.DateTime.Today.AddDays(-1); dtSelect2.Value = System.DateTime.Today.AddDays(-1); + + //#region 自動執行 + // Run this procedure in an appropriate event. + //counter = 0; + //timer1.Interval = 600; + //timer1.Enabled = true; + // Hook up timer's tick event handler. + //#endregion } private void rb_site_CheckedChanged(object sender, EventArgs e) diff --git a/solarApp/fmArchive.resx b/solarApp/fmArchive.resx index f298a7b..d731088 100644 --- a/solarApp/fmArchive.resx +++ b/solarApp/fmArchive.resx @@ -57,4 +57,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + \ No newline at end of file