[frontedd] 能源管理 自動須量圖修正 | 歷史資料查詢後正確呈現資料 | 首頁 icon 警示後修改為 gif | 系統監控 供水系統及燈具呈現

This commit is contained in:
Celeste6666 2023-02-11 17:31:11 +08:00
parent bb6b9107ee
commit bc1b2470dd
5 changed files with 577 additions and 533 deletions

View File

@ -208,11 +208,7 @@
</main> </main>
<script> <script>
var tarElePath = ''; var tarElePath = '';
var sysSubList = []; var sysSubList = [];
var viewer3DNodeIds = []; var viewer3DNodeIds = [];
@ -227,29 +223,28 @@
var chartDataCnt = { alarmCnt: 0, recCnt: 0, chkedErrCnt: 0, unChkedErrCnt: 0 }; var chartDataCnt = { alarmCnt: 0, recCnt: 0, chkedErrCnt: 0, unChkedErrCnt: 0 };
var sysIconList = [ var sysIconList = [
{ mainSys: "EE", subSys: "E1", iconClass: "SVG/fuse-box_white.svg" }, { mainSys: "EE", subSys: "E1", iconClass: "./gif/E1_white.png" },
{ mainSys: "EE", subSys: "E2", iconClass: "SVG/electricity_white.svg" }, { mainSys: "EE", subSys: "E2", iconClass: "./gif/E2_white.png" },
{ mainSys: "EE", subSys: "E3", iconClass: "SVG/generator_white.svg" }, { mainSys: "EE", subSys: "E3", iconClass: "./gif/E3_white.png" },
{ mainSys: "EE", subSys: "E4", iconClass: "SVG/electric-meter_white.svg" }, // 電表 { mainSys: "EE", subSys: "E4", iconClass: "./gif/E4-1_white.png" }, // 電表
{ mainSys: "LT", subSys: "L1", iconClass: "SVG/creative_white.svg" }, { mainSys: "LT", subSys: "L1", iconClass: "./gif/L1_white.png" },
{ mainSys: "ME", subSys: "M5", iconClass: "SVG/air-flow_white.svg" }, // 送排風 { mainSys: "LT", subSys: "L2", iconClass: "./gif/L2_white.png" },// 景觀照明 0131目前沒有
{ mainSys: "ME", subSys: "M10", iconClass: "SVG/ice-crystal_white.svg" }, { mainSys: "ME", subSys: "M1", iconClass: "./gif/M1_white.png" },// 儲冰 0131目前沒有
{ mainSys: "ME", subSys: "M12", iconClass: "SVG/leaf_white.svg" }, { mainSys: "ME", subSys: "M5", iconClass: "./gif/M5-2_white.png" }, // 送排風
{ mainSys: "ELEV", subSys: "EL", iconClass: "SVG/lift-sign_white.svg" }, { mainSys: "ME", subSys: "M8", iconClass: "./gif/M8_white.png" },// 排油煙0131目前沒有
{ mainSys: "FE", subSys: "F1", iconClass: "SVG/fire-hydrant_white.svg" }, { mainSys: "ME", subSys: "M10", iconClass: "./gif/M10_white.png" },
{ mainSys: "FE", subSys: "F2", iconClass: "SVG/lamp_white.svg" },// 排煙 0131目前沒有 { mainSys: "ME", subSys: "M12", iconClass: "./gif/M12_white.png" },
{ mainSys: "WP", subSys: "W1", iconClass: "SVG/lamp_white.svg" },// 電子水表0131目前沒有 { mainSys: "ELEV", subSys: "EL", iconClass: "./gif/EL_white.png" },
{ mainSys: "WP", subSys: "W2", iconClass: "SVG/gear_white.svg" }, { mainSys: "FE", subSys: "F1", iconClass: "./gif/F1_white.png" },
{ mainSys: "WP", subSys: "P1", iconClass: "SVG/water-pollution_white.svg" }, { mainSys: "FE", subSys: "F2", iconClass: "./gif/lamp_white.png" }, // 排煙 0131目前沒有
{ mainSys: "S", subSys: "C", iconClass: "SVG/security-camera_white.svg" }, // CCTV { mainSys: "WP", subSys: "W1", iconClass: "./gif/W1_white.png" },// 電子水表0131目前沒有
{ mainSys: "S", subSys: "P", iconClass: "SVG/sos_white.svg" }, // 緊急求救 { mainSys: "WP", subSys: "W2", iconClass: "./gif/W2_white.png" },
{ mainSys: "S", subSys: "R", iconClass: "SVG/key-card_white.svg" }, // 門禁 { mainSys: "WP", subSys: "P1", iconClass: "./gif/P1_white.png" },
{ mainSys: "P", subSys: "PSC", iconClass: "SVG/parking_white.svg" }, // 停管 { mainSys: "S", subSys: "C", iconClass: "./gif/C_white.png" }, // CCTV
{ mainSys: "LT", subSys: "L2", iconClass: "SVG/lamp_white.svg" },// 景觀照明 0131目前沒有 { mainSys: "S", subSys: "P", iconClass: "./gif/P_white.png" }, // 緊急求救
{ mainSys: "ME", subSys: "M1", iconClass: "SVG/lamp_white.svg" },// 儲冰 0131目前沒有 { mainSys: "S", subSys: "R", iconClass: "./gif/R_white.png" }, // 門禁
{ mainSys: "ME", subSys: "M8", iconClass: "SVG/lamp_white.svg" },// 排油煙0131目前沒有 { mainSys: "P", subSys: "PSC", iconClass: "./gif/PSC_white.png" }, // 停管
{ mainSys: "W3", subSys: "W1", iconClass: "SVG/lamp_white.svg" },// 0131目前沒有 { mainSys: "W3", subSys: "W1", iconClass: "./gif/W3_white.png" },// 0131目前沒有
]; ];
var tempSysSubText = [ var tempSysSubText = [
@ -265,25 +260,25 @@
{ text: "緊急發電機", mainSys: "EE", subSys: "E3", },//10 { text: "緊急發電機", mainSys: "EE", subSys: "E3", },//10
{ text: "消防設備", mainSys: "FE", subSys: "F1", }, //11 { text: "消防設備", mainSys: "FE", subSys: "F1", }, //11
{ text: "CCTV系統", mainSys: "S", subSys: "C", }, //12 { text: "CCTV系統", mainSys: "S", subSys: "C", }, //12
{ text: "緊急求救系統", mainSys: "S", subSys: "P", }, //13 { text: "門禁系統", mainSys: "S", subSys: "R", }, //13
{ text: "門禁系統", mainSys: "S", subSys: "R", }, //14 { text: "停管系統", mainSys: "P", subSys: "PSC", }, //14
{ text: "停管系統", mainSys: "P", subSys: "PSC", }, //15 { text: "緊急求救系統", mainSys: "S", subSys: "P", }, //15
{ text: "送排風系統", mainSys: "ME", subSys: "M5", }, // 2 //16 { text: "送排風系統", mainSys: "ME", subSys: "M5", }, //16
//{ text: "景觀照明系統", mainSys: "LT", subSys: "L2", }, //{ text: "景觀照明系統", mainSys: "LT", subSys: "L2", },
//{ text: "儲冰系統", mainSys: "ME", subSys: "M1", }, //{ text: "儲冰系統", mainSys: "ME", subSys: "M1", },
//{ text: "排油煙設備", mainSys: "ME", subSys: "M8", }, // { text: "排油煙設備", mainSys: "ME", subSys: "M8", },
//{ text: "排煙系統", mainSys: "FE", subSys: "F2", }, //{ text: "排煙系統", mainSys: "FE", subSys: "F2", },
//{ text: "電子水錶", mainSys: "WP", subSys: "W1", }, //{ text: "電子水錶", mainSys: "WP", subSys: "W1", },
//{ text: "熱水系統", mainSys: "W3", subSys: "W1", }, // { text: "熱水系統", mainSys: "W3", subSys: "W1", },
]; ];
$(document).ready(function () { $(document).ready(function () {
$(loadEle).Loading("start"); $(loadEle).Loading("start");
$(loadEle).Loading("close");
show3DModel(); show3DModel();
getSubList(); getSubList();
getFirstEletric(); getFirstEletric();
}); });
function demoSubList() { function demoSubList() {
@ -294,7 +289,9 @@
if (isExiNames.indexOf(obj.text) == -1 && $("#sysSubBtnList .dev-group").length < 16) { if (isExiNames.indexOf(obj.text) == -1 && $("#sysSubBtnList .dev-group").length < 16) {
let iconObj = sysIconList.filter(x => x.mainSys == obj.mainSys && x.subSys == obj.subSys)[0]; let iconObj = sysIconList.filter(x => x.mainSys == obj.mainSys && x.subSys == obj.subSys)[0];
strHtml = `<div class="btn-group btn-group-lg col-lg-3 mb-4 dev-group"> strHtml = `<div class="btn-group btn-group-lg col-lg-3 mb-4 dev-group">
<button name="topFunBtn" data-page="alert" type="button" class="btn btn-secondary col-4"><img src="${iconObj.iconClass}" class="w-100"></img></button> <button name="topFunBtn" data-page="alert" type="button" class="btn btn-secondary col-4 d-flex jusity-content-center">
<img src="${iconObj.iconClass}" class="w-100"></img>
</button>
<button id="sysSubCardBtn${obj.subSys}" type="button" class="btn btn-secondary" data-id="${obj.subSys}">${obj.text}</button> <button id="sysSubCardBtn${obj.subSys}" type="button" class="btn btn-secondary" data-id="${obj.subSys}">${obj.text}</button>
</div>`; </div>`;
$("#sysSubBtnList").append(strHtml); $("#sysSubBtnList").append(strHtml);
@ -323,7 +320,9 @@
} }
let iconClass = sysIconList.filter(x => x.mainSys == mainSysObj.main_system_tag && x.subSys == subSysObj.sub_system_tag)[0]?.iconClass; let iconClass = sysIconList.filter(x => x.mainSys == mainSysObj.main_system_tag && x.subSys == subSysObj.sub_system_tag)[0]?.iconClass;
strHtml += `<div class="btn-group btn-group-lg col-lg-3 mb-4 dev-group" data-id="/${pageAct.AreaTag}/${pageAct.buiTag}/${mainSysObj.main_system_tag}/${subSysObj.sub_system_tag}"> strHtml += `<div class="btn-group btn-group-lg col-lg-3 mb-4 dev-group" data-id="/${pageAct.AreaTag}/${pageAct.buiTag}/${mainSysObj.main_system_tag}/${subSysObj.sub_system_tag}">
<button name="topFunBtn" data-page="alert" type="button" class="btn btn-secondary col-4"><img src="${iconClass}" class="w-100"></img></button> <button name="topFunBtn" data-page="alert" type="button" class="btn btn-secondary col-4">
<img src="${iconClass}" class="w-100 "></img>
</button>
<button id="sysSubCardBtn${subSysObj.sub_system_tag}" type="button" class="btn btn-secondary" data-id="${subSysObj.sub_system_tag}">${subSysObj.full_name}</button> <button id="sysSubCardBtn${subSysObj.sub_system_tag}" type="button" class="btn btn-secondary" data-id="${subSysObj.sub_system_tag}">${subSysObj.full_name}</button>
</div>`; </div>`;
}) })
@ -536,7 +535,9 @@
// 圖表 - 這週與上週用電量 (長條圖) // 圖表 - 這週與上週用電量 (長條圖)
function chartEveWeeksElec(curWeekData, prevWeekData) { function chartEveWeeksElec(curWeekData, prevWeekData) {
// console.log(curWeekData.map(x => x.sum),prevWeekData.map(x => x.sum))
let eveWeekElecChartCanvas = $('#eveWeekElecChart').get(0).getContext('2d'); let eveWeekElecChartCanvas = $('#eveWeekElecChart').get(0).getContext('2d');
let eveWeekElecChartData = { let eveWeekElecChartData = {
labels: curWeekData.map(x => dayToChiDay(strToDate(x.timestamp.$cEncStr, "day"))), labels: curWeekData.map(x => dayToChiDay(strToDate(x.timestamp.$cEncStr, "day"))),
datasets: [ datasets: [
@ -566,7 +567,7 @@
} }
] ]
} }
console.log(eveWeekElecChartData) // console.log(eveWeekElecChartData)
let eveWeekElecChartOptions = { let eveWeekElecChartOptions = {
maintainAspectRatio: false, maintainAspectRatio: false,
responsive: true, responsive: true,
@ -592,17 +593,20 @@
return isTodayOrYes + "用電量 : " + tooltipItem.value + " kWH"; return isTodayOrYes + "用電量 : " + tooltipItem.value + " kWH";
}, },
title: function (tooltipItem) { title: function (tooltipItem) {
console.log(tooltipItem)
let result = tooltipItem[0]?.xLabel.toString(); let result = tooltipItem[0]?.xLabel.toString();
return result; return result;
} }
} }
}, },
} }
// console.log(eveWeekElecChartOptions)
if (eveWeekElecChart == null) { if (eveWeekElecChart == null) {
eveWeekElecChart = new Chart(eveWeekElecChartCanvas, { eveWeekElecChart = new Chart(eveWeekElecChartCanvas, {
data: eveWeekElecChartData, data: eveWeekElecChartData,
options: eveWeekElecChartOptions options: eveWeekElecChartOptions
}) })
// console.log(eveWeekElecChart,eveWeekElecChartData, eveWeekElecChartOptions)
} else { } else {
eveWeekElecChart.data.datasets.forEach((dataset) => { eveWeekElecChart.data.datasets.forEach((dataset) => {
if (dataset.order == 1) { if (dataset.order == 1) {
@ -792,21 +796,28 @@
} }
// 從 baja 訂閱 左下角各系統小類異常狀態 // 從 baja 訂閱 左下角各系統小類異常狀態
function getAlarmSub(data) { function getAlarmSub(data) {
$.each(data.data, (idx, alaObj) => { $.each(data.data, (idx, alaObj) => {
if (alaObj.alarmClass.indexOf("_") != -1) { if (alaObj.alarmClass.indexOf("_") != -1) {
let mainSubSys = alaObj.alarmClass.split("_").slice(0, 2).join("/"); let mainSubSys = alaObj.alarmClass.split("_").slice(0, 2).join("/");
$(`.btn-group.dev-group[data-id*='${mainSubSys}'] i`).addClass("blink"); const img = $(`.btn-group.dev-group[data-id*='${mainSubSys}'] img`)[0].src.split('.')
const { length } = img
img[length - 1] = 'gif'
$(`.btn-group.dev-group[data-id*='${mainSubSys}'] img`)[0].src = img.join('.')
// $(`.btn-group.dev-group[data-id*='${mainSubSys}'] img`).addClass("blink");
} }
}) })
$(`.dev-group i.fa-lightbulb-on.blink`).each((idx, ele) => { $(`.dev-group img.blink`).each((idx, ele) => {
let devPath = $(ele).parents(".dev-group").data("id"); let devPath = $(ele).parents(".dev-group").data("id");
let sysPath = devPath.split("/").slice(3, 5).join("/"); let sysPath = devPath.split("/").slice(3, 5).join("/");
let alaDevPath = data.data.map(x => x.alarmClass?.split("_").slice(0, 2).join("/")); let alaDevPath = data.data.map(x => x.alarmClass?.split("_").slice(0, 2).join("/"));
if (alaDevPath.indexOf(sysPath) == -1) { if (alaDevPath.indexOf(sysPath) == -1) {
$(ele).removeClass("blink"); const img = $(`.btn-group.dev-group[data-id*='${mainSubSys}'] img`)[0].src.split('.')
const { length } = img
img[length - 1] = 'png'
$(`.btn-group.dev-group[data-id*='${mainSubSys}'] img`)[0].src = img.join('.')
// $(ele).removeClass("blink");
} }
}) })
} }

View File

@ -57,22 +57,22 @@
<button id="ediAutDemBtn" class="btn btn-success"><i class="fal fa-pencil"></i> 編輯</button> <button id="ediAutDemBtn" class="btn btn-success"><i class="fal fa-pencil"></i> 編輯</button>
</div> </div>
<div class="row align-items-center"> <div class="row align-items-center justify-content-between d-flex flex-column">
<div class="col-sm-12 col-lg-5"> <div class="col d-flex">
<p class="card-text color-white pl-5 pr-3 d-flex justify-content-between"> <p class="card-text color-white d-flex justify-content-between mr-3">
<span>契約容量</span> <span>契約容量</span>
<span><span data-id="contract_capacity"></span> kW</span> <span><span data-id="contract_capacity"></span> kW</span>
</p> </p>
<p class="card-text color-white pl-5 pr-3 d-flex justify-content-between"> <p class="card-text color-white d-flex justify-content-between mr-3">
<span>警戒容量</span> <span>警戒容量</span>
<span><span data-id="warning_capacity"></span> kW</span> <span><span data-id="warning_capacity"></span> kW</span>
</p> </p>
<p class="card-text color-white pl-5 pr-3 d-flex justify-content-between"> <p class="card-text color-white d-flex justify-content-between mr-3">
<span>復歸值</span> <span>復歸值</span>
<span><span data-id="resetting_value"></span> kW</span> <span><span data-id="resetting_value"></span> kW</span>
</p> </p>
</div> </div>
<div class="col-sm-12 col-lg-7" style=" min-height:250px;"> <div class="col" style=" min-height:250px;">
<canvas class="chart" id="autDemChart"></canvas> <canvas class="chart" id="autDemChart"></canvas>
</div> </div>
</div> </div>
@ -354,7 +354,7 @@
if (autDemChart.data.labels.length > 0) { if (autDemChart.data.labels.length > 0) {
// 當 label 還未補齊,則直接替換 array 裡的值,已補齊之後就從後面補值 // 當 label 還未補齊,則直接替換 array 裡的值,已補齊之後就從後面補值
if (autDemChart.data.labels.filter(x => x != "").length > 10) { if (autDemChart.data.labels.filter(x => x != "").length > 35) {
autDemChart.data.labels.push(displayDate(time, "Hms")); autDemChart.data.labels.push(displayDate(time, "Hms"));
} else { } else {
let cnt = autDemChart.data.labels.filter(x => x != "").length; let cnt = autDemChart.data.labels.filter(x => x != "").length;
@ -366,7 +366,7 @@
autDemChart.data.datasets[3].data.push(value); autDemChart.data.datasets[3].data.push(value);
} }
if (autDemChart.data.labels.filter(x => x != "").length > 10) { if (autDemChart.data.labels.filter(x => x != "").length > 35) {
autDemChart.data.labels.shift(); autDemChart.data.labels.shift();
autDemChart.data.datasets[0].data.shift(); autDemChart.data.datasets[0].data.shift();
autDemChart.data.datasets[1].data.shift(); autDemChart.data.datasets[1].data.shift();
@ -387,7 +387,7 @@
autDemChart.data.labels.push(displayDate(time, "Hms")); autDemChart.data.labels.push(displayDate(time, "Hms"));
autDemChart.data.datasets[3].data.push(d.value); autDemChart.data.datasets[3].data.push(d.value);
// 補齊空缺 最多10個 // 補齊空缺 最多10個
for (let i = autDemChart.data.labels.length; i < 10; i++) { for (let i = autDemChart.data.labels.length; i < 35; i++) {
autDemChart.data.labels.push(""); autDemChart.data.labels.push("");
} }

View File

@ -32,7 +32,7 @@
<div class="col-auto"> <div class="col-auto">
<div class="form-group"> <div class="form-group">
<input class="form-control" id="his_startdate" data-val="" type="date" name="date" value=""> <input class="form-control" id="his_startdate" data-val="" type="date" name="date" value="">
<input class="form-control" id="getmonth" type="month" style="display: none"/> <input class="form-control" id="getmonth" type="month" style="display: none" />
</div> </div>
</div> </div>
<div class="col-auto" id="his_enddate" style="display: none"> <div class="col-auto" id="his_enddate" style="display: none">
@ -177,7 +177,7 @@
$.each(res.data.history_Main_Systems, function (index, val) { $.each(res.data.history_Main_Systems, function (index, val) {
if (pageAct.mainStatus) { if (pageAct.mainStatus) {
strHtml += `<li> strHtml += `<li>
<a href="#" data-filter-tags="${val.full_name.toLowerCase() }" data-maintag="${val.main_system_tag}"> <a href="#" data-filter-tags="${val.full_name.toLowerCase()}" data-maintag="${val.main_system_tag}">
<span class="nav-link-text">${val.full_name}</span> <span class="nav-link-text">${val.full_name}</span>
</a> </a>
<ul style="${index == 0 ? `display:block;` : ``}">`; <ul style="${index == 0 ? `display:block;` : ``}">`;
@ -189,7 +189,7 @@
i2 = (val2.device != null && i2 == null) ? index2 : null; i2 = (val2.device != null && i2 == null) ? index2 : null;
strHtml += `<li> strHtml += `<li>
<a href="#" data-filter-tags="${val2.full_name.toLowerCase() }" data-subtag="${val2.sub_system_tag}"> <a href="#" data-filter-tags="${val2.full_name.toLowerCase()}" data-subtag="${val2.sub_system_tag}">
<span class="nav-link-text"> <span class="nav-link-text">
${val2.full_name} ${val2.full_name}
</span> </span>
@ -198,7 +198,7 @@
$.each(val2.device, function (index3, val3) { $.each(val2.device, function (index3, val3) {
strHtml += `<li data-tabname="hisListItem"> strHtml += `<li data-tabname="hisListItem">
<a href="#" onClick="setValue('${val3.device_number}', '${val3.full_name}', null)" data-filter-tags="${val3.full_name.toLowerCase() } ${val3.device_serial_tag.toLowerCase()}" data-devnum="${val3.device_number}"> <a href="#" onClick="setValue('${val3.device_number}', '${val3.full_name}', null)" data-filter-tags="${val3.full_name.toLowerCase()} ${val3.device_serial_tag.toLowerCase()}" data-devnum="${val3.device_number}">
<span class="nav-link-text"> <span class="nav-link-text">
${val3.full_name} ${val3.full_name}
</span> </span>
@ -247,13 +247,13 @@
$.each(res.data, function (index, val) { $.each(res.data, function (index, val) {
if (index == 0) { if (index == 0) {
strHtml += `<button onClick="setValue(null, null, '${val.points}', this)" type="button" class="btn btn-info waves-effect waves-themed">${val.full_name} ${val.points}</button>`; strHtml += `<button onClick="setValue(null, null, '${val.points}', this)" type="button" class="btn btn-info waves-effect waves-themed">${val.full_name || val.points}</button>`;
pageAct.deviceItem = val.points; pageAct.deviceItem = val.points;
pageAct.devicePoiName = val.full_name + ' ' + val.points; pageAct.devicePoiName = val.full_name + ' ' + val.points;
pageAct.deviceComName = val.parent_path; pageAct.deviceComName = val.parent_path;
getData(); getData();
} else { } else {
strHtml += `<button onClick="setValue(null, null, '${val.points}', this)" type="button" class="btn btn-secondary waves-effect waves-themed">${val.full_name} ${val.points}</button>`; strHtml += `<button onClick="setValue(null, null, '${val.points}', this)" type="button" class="btn btn-secondary waves-effect waves-themed">${val.full_name || val.points}</button>`;
} }
}); });
@ -267,6 +267,8 @@
var edt = new Date(new Date().setDate(sdt.getDate() + 1)); var edt = new Date(new Date().setDate(sdt.getDate() + 1));
start = start ?? sdt.toLocaleDateString(); start = start ?? sdt.toLocaleDateString();
end = end ?? edt.toLocaleDateString(); end = end ?? edt.toLocaleDateString();
$(loadEle).Loading("start");
callBackFromHistory()
getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem, getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem,
new Date(start).getTime(), new Date(start).getTime(),
new Date(end).getTime(), new Date(end).getTime(),
@ -275,8 +277,10 @@
callBackFromHistory); callBackFromHistory);
} }
function callBackFromHistory(res) { function callBackFromHistory(res = '{"count":0,"data":[]}') {
// console.log("@H1",res)
res = JSON.parse(res); res = JSON.parse(res);
// console.log("@history",res.data)
loadTable(res.data); loadTable(res.data);
if (historyTable != null) { if (historyTable != null) {
let t = $('#historyTable').dataTable(); let t = $('#historyTable').dataTable();
@ -379,7 +383,7 @@
date = displayDate(date, type); date = displayDate(date, type);
let month = date.split('/')[1]; let month = date.split('/')[1];
let year = date.split('/')[0]; let year = date.split('/')[0];
let day= date.split('/')[2]; let day = date.split('/')[2];
return month + "/" + day + "/" + year; return month + "/" + day + "/" + year;
} }
} }
@ -387,7 +391,8 @@
function loadTable(data) { function loadTable(data) {
if (data) { if (data) {
$.each(data, function (i, v) { $.each(data, function (i, v) {
v.type = pageAct.devicePoiName; // console.log("loadTable",pageAct.devicePoiName.split(" ")[0])
v.type = pageAct.devicePoiName.split(" ")[0];
}); });
} }
@ -412,6 +417,9 @@
"title": "數值", "title": "數值",
"data": "value", "data": "value",
"render": function (data) { "render": function (data) {
if (isNaN(data)) {
return data
}
return data.roundDecimal(2); return data.roundDecimal(2);
} }
}, },
@ -419,6 +427,7 @@
"title": "紀錄時間", "title": "紀錄時間",
"data": "timestamp", "data": "timestamp",
"render": function (data) { "render": function (data) {
// console.log(data)
return displayDate(data, "datetime"); return displayDate(data, "datetime");
} }
} }

View File

@ -376,13 +376,17 @@
function show3DModel(urn) { function show3DModel(urn) {
$(loadEle).Loading("start"); $(loadEle).Loading("start");
launchViewerForHotspot(urn, (viewer, nodeIds) => { launchViewerForHotspot(urn, (viewer, nodeIds) => {
let devDbIds = allDevList.map(x => x.forge_dbid); let devDbIds = allDevList.map(x => x.forge_dbid); // 大類
console.log(allDevList);
let subDevDbId = [];
allDevList.forEach(({ device_nodes }) => {
subDevDbId = [...subDevDbId, ...device_nodes.map(n => n.forge_dbid)]
})
// 從資料庫設定不可視模型的類型,若沒有取道該小類不可視類型,則套用資料庫設定預設類型 // 從資料庫設定不可視模型的類型,若沒有取道該小類不可視類型,則套用資料庫設定預設類型
if (forgeInvType) { if (forgeInvType) {
setInviForge(forgeInvType, devDbIds); setInviForge(forgeInvType, [...devDbIds, ...subDevDbId]);
} else { } else {
setInviForge(forgeInvTypeDef, devDbIds); setInviForge(forgeInvTypeDef, [...devDbIds, ...subDevDbId]);
} }
$(loadEle).Loading("close"); $(loadEle).Loading("close");
@ -435,8 +439,10 @@
} }
} }
} }
if (pageAct.sub_system_tag == "W2") {
getWaterNodeId(); getWaterNodeId();
}
}, () => { }, () => {
$(loadEle).Loading("close"); $(loadEle).Loading("close");
}, "[name=forgeViewer]"); }, "[name=forgeViewer]");
@ -444,20 +450,24 @@
// 供水系統 - 取得欲染色 dbid // 供水系統 - 取得欲染色 dbid
function getWaterNodeId() { function getWaterNodeId() {
let url = baseApiUrl + "/api/Device/GetForgeNodeIdFromVar"; //let url = baseApiUrl + "/api/Device/GetForgeNodeIdFromVar";
let sendData = { forgeNodeKey: "water_wupply" }; //let sendData = { forgeNodeKey: "water_wupply" };
objSendData.Data = sendData; //objSendData.Data = sendData;
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) { //ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
if (!res || res.code != "0000" || !res.data) { // if (!res || res.code != "0000" || !res.data) {
} else { // } else {
if (!isNaN(parseInt(res.data[0]?.system_value))) { // if (!isNaN(parseInt(res.data[0]?.system_value))) {
changeColor(parseInt(res.data[0]?.system_value)) // changeColor(parseInt(res.data[0]?.system_value))
} // }
console.log(res.data) // console.log(res.data)
} // }
}, null, "POST").send(); //}, null, "POST").send();
viewer.model.search("給水", (nodeIds) => {
console.log(nodeIds)
viewer.show(nodeIds)
}, (e) => { console.log(e) })
} }
function getHotspotPoint(callback = null) { function getHotspotPoint(callback = null) {

View File

@ -35,8 +35,8 @@
// } // }
function getHistoryDataByBaja(devicePath, startDate_millisecond, endDate_millisecond, deviceName, company, callback) { function getHistoryDataByBaja(devicePath, startDate_millisecond, endDate_millisecond, deviceName, company, callback) {
var _result = ""; var _result = {};
var _ss = ""; var _ss = [];
var _index = 0; var _index = 0;
require(['baja!'], function (baja) { require(['baja!'], function (baja) {
@ -45,23 +45,37 @@ function getHistoryDataByBaja(devicePath, startDate_millisecond, endDate_millise
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
if (_index == 0) console.log(record.get('timestamp'))
_ss += '{"deviceName":"' + deviceName + '", "value":' + record.get('value') + ', "timestamp":"' + record.get('timestamp') + '"}'; // if (_index == 0)
else // _ss += '{"deviceName":"' + deviceName + '", "value":' + record.get('value') + ', "timestamp":"' + record.get('timestamp').$cEncStr
_ss += ',{"deviceName":"' + deviceName + '", "value":' + record.get('value') + ', "timestamp":"' + record.get('timestamp') + '"}'; // + '"}';
// else
// _ss += ',{"deviceName":"' + deviceName + '", "value":' + record.get('value') + ', "timestamp":"' + record.get('timestamp').$cEncStr
// + '"}';
_ss.push({
deviceName: deviceName, value: record.get('value'), timestamp: record.get('timestamp').$cEncStr
});
_index++; _index++;
}, },
after: function () { after: function () {
_result += '{' + '"count": ' + _index + ', "data":['; _result = { count: _index, data: _ss }
_result += _ss; // _result += '{' + '"count": ' + _index + ', "data":[';
_result += ']}'; // _result += _ss;
// _result += ']}';
if (typeof callback === 'function') { if (typeof callback === 'function') {
// console.log(_result)
_result = JSON.stringify(_result)
callback(_result); callback(_result);
} }
}, },
limit: -1, limit: -1,
offset: 0 offset: 0
}); });
})
.catch(() => {
console.log("error");
// const res = JSON.stringify({count:0, data:[]})
callback()
}); });
}); });
} }