From cacf72f99eb57b1c4b07823112812cf3f0614db3 Mon Sep 17 00:00:00 2001 From: Celeste6666 Date: Fri, 3 Feb 2023 11:42:25 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=89=8D=E5=8F=B0]=20=E8=83=BD=E6=BA=90?= =?UTF-8?q?=E7=AE=A1=E7=90=86=20Api=20=E4=BF=AE=E6=94=B9=20&=20=E8=A7=A3?= =?UTF-8?q?=E6=B1=BA=E5=9C=96=E8=A1=A8=E5=9C=96=E8=A1=A8=E5=88=87=E6=8F=9B?= =?UTF-8?q?=E9=8C=AF=E8=AA=A4=20&=20=E5=86=8D=E7=94=9F=E8=83=BD=E6=BA=90?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E8=B3=87=E6=96=99=E5=8F=96=E5=BE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_energyManagement.html | 115 ++++++++++++++++---------------- 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/Frontend/_energyManagement.html b/Frontend/_energyManagement.html index bd597c3..f21ebc1 100644 --- a/Frontend/_energyManagement.html +++ b/Frontend/_energyManagement.html @@ -260,60 +260,63 @@ // 左上方 系統小類卡片區塊 function getSubSysList(type = 0) { subSysList = []; - let url = baseApiUrl + "/api/Device/GetMainSub"; - let sendData = { - building_tag: pageAct.buiTag, - }; - objSendData.Data = sendData; - ytAjax = new YourTeam.Ajax(url, objSendData, function (res) { - if (!res || res.code != "0000" || !res.data) { - - } else { - let strHtml = ''; - $.each(res.data.history_Main_Systems, (index, mainSysObj) => { - $.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => { - subSysList.push(subSysObj); -if ((type == 0 || (type == 3 && mainSysObj.main_system_tag == "ELEV")) && filNotShowSysSub.indexOf(subSysObj.sub_system_tag) == -1) { - strHtml += `
-
-
-

${subSysObj.full_name}用電

-

- ${elecCardConText[type]?.text1} - -

-

- ${elecCardConText[type]?.text2} - -

-
-
-
`; + let url = baseApiUrl + "/api/Energe/GetElecBySubSysTag"; + // let sendData = { + // building_tag: pageAct.buiTag, + // }; + // objSendData.Data = sendData; + ytAjax = new YourTeam.Ajax( + url, + null, + function (res) { + if (!res || res.code != "0000" || !res.data) { + } else { + let strHtml = ""; + $.each(res.data, (index, mainSysObj) => { + if ((type == 0 || (type == 3 && mainSysObj.mainSubTag == "ELEV_EL")) + // && filNotShowSysSub.indexOf(subSysObj.sub_system_tag) == -1 + ) { + const full_name = mainSysObj.system_remark.split("-")[1]; + strHtml += `
+
+
+

${full_name}用電

+

+ ${elecCardConText[type]?.text1} + +

+

+ ${elecCardConText[type]?.text2} + +

+
+
+
`; } - }) - }) - if (type == 3) { - strHtml += `
-
-
-

太陽能設備用電

-

- ${elecCardConText[type]?.text1} - --- -

-

- ${elecCardConText[type]?.text2} - --- -

-
-
-
`; + }); + if (type == 3) { + strHtml += `
+
+
+

太陽能設備用電

+

+ ${elecCardConText[type]?.text1} + --- +

+

+ ${elecCardConText[type]?.text2} + --- +

+
+
+
`; + } + $("#eneSubSysList").html(strHtml); } - console.log(strHtml) - $("#eneSubSysList").html(strHtml); - } - }, null, "POST").send(); - + }, + null, + "POST", + ).send(); } // 取得 對應系統小類的總電錶 @@ -420,7 +423,6 @@ if ((type == 0 || (type == 3 && mainSysObj.main_system_tag == "ELEV")) && filNot $.each(subSysElecList, (idx, elecObj) => { let devPath devPath = elecObj.system_device_tag?.split("_").slice(0, 8).join("/"); - console.log(424, devPath) getElectricMeterNoweDataByBaja(devPath, (data) => { data = data.data; let result = 0; @@ -428,8 +430,7 @@ if ((type == 0 || (type == 3 && mainSysObj.main_system_tag == "ELEV")) && filNot result = data.filter(x => x.name == "P_rec")[0]?.value?.roundDecimal(2); $(`#insPow${elecObj.mainSubTag}`).text(result); result = data.filter(x => x.name == "KWH_rec")[0]?.value?.roundDecimal(2); - console.log(429, data, result) - $(`#insPowPer${elecObj.mainSubTag}`).text((result / totalPow * 100).roundDecimal(2) + " %"); + $(`#insPowPer${elecObj.mainSubTag}`).text((result / result * 100).roundDecimal(2) + " %"); } else { /* result = result ? result.roundDecimal(2) : 0;*/ result = data.filter(x => x.name == "P")[0]?.value?.roundDecimal(2); @@ -471,7 +472,6 @@ if ((type == 0 || (type == 3 && mainSysObj.main_system_tag == "ELEV")) && filNot todayElecChart?.destroy(); return; } - getElectricMeterHourDataByBaja(tarDevNum + "_KWH", n4Sup, yesterday, tomorrow, (data) => { let todayData = data.data.filter(x => x.timestamp.$date.$year == getTimeByType("year") && x.timestamp.$date.$month == getTimeByType("month") && x.timestamp.$date.$day == getTimeByType("date")); chartTodaysElec(todayData); @@ -552,6 +552,7 @@ if ((type == 0 || (type == 3 && mainSysObj.main_system_tag == "ELEV")) && filNot // 圖表 - 今天用電量 (折線圖) function chartTodaysElec(todayData) { + todayElecChart?.destroy(); let todayElecChartCanvas = $('#todayElecChart').get(0).getContext('2d'); let curHour = (new Date()).getHours(); todayData.data = todayData.filter(x => x.timestamp.$time.$hour < curHour); @@ -618,7 +619,7 @@ if ((type == 0 || (type == 3 && mainSysObj.main_system_tag == "ELEV")) && filNot // 圖表 - 今日與30日內平均用電量比較 (長條圖) function chartEveWeeksElec(curWeekData, avgData) { - + elecCompChart?.destroy() let elecCompChartCanvas = $('#elecCompChart').get(0).getContext('2d'); let elecCompChartData = { labels: curWeekData.map(x => dayToChiDay(strToDate(x.timestamp.$cEncStr, "day"))),