Merge branch 'master' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS
This commit is contained in:
commit
283f53f22a
1579
Frontend/_alert.html
1579
Frontend/_alert.html
File diff suppressed because it is too large
Load Diff
@ -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");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -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("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,445 +1,454 @@
|
|||||||
<main id="js-page-content" role="main" class="page-content">
|
<main id="js-page-content" role="main" class="page-content">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12 col-xl-2">
|
<div class="col-sm-12 col-xl-2">
|
||||||
<div class="rounded border border-white">
|
<div class="rounded border border-white">
|
||||||
<div class="d-flex position-relative py-3 px-4">
|
<div class="d-flex position-relative py-3 px-4">
|
||||||
<i class="fal fa-search color-success-700 position-absolute pos-left fs-lg px-3 py-2 mt-1 ml-4"></i>
|
<i class="fal fa-search color-success-700 position-absolute pos-left fs-lg px-3 py-2 mt-1 ml-4"></i>
|
||||||
<input type="text" id="js_nested_list_filter" class="form-control shadow-inset-1 pl-6 border-success" placeholder="輸入兩字以上">
|
<input type="text" id="js_nested_list_filter" class="form-control shadow-inset-1 pl-6 border-success" placeholder="輸入兩字以上">
|
||||||
</div>
|
|
||||||
<!-- nav-menu-reset will reset the font colors -->
|
|
||||||
<ul id="js_nested_list" class="nav-menu nav-menu-reset nav-menu-compact mb-sm-4 mb-md-0 rounded border border-white" data-nav-accordion="true">
|
|
||||||
</ul>
|
|
||||||
<div class="filter-message js-filter-message m-0 text-left pl-4 py-3 fw-500"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-12 col-xl-10">
|
|
||||||
<h1 class="p-2 mb-0">歷史資料瀏覽</h1>
|
|
||||||
<div class="row bg-dark p-2 mb-5">
|
|
||||||
<div class="col-auto">
|
|
||||||
<div class="btn-group">
|
|
||||||
<button type="button" onclick="setDateType('day', this)" class="btn btn-secondary waves-effect waves-themed">日期</button>
|
|
||||||
<button type="button" onclick="setDateType('range', this)" class="btn btn-secondary waves-effect waves-themed">日區間</button>
|
|
||||||
<button type="button" onclick="setDateType('month', this)" class="btn btn-secondary waves-effect waves-themed">月</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<div class="btn-group">
|
|
||||||
<button type="button" onclick="setDateType('today', this)" class="btn btn-secondary waves-effect waves-themed">今天</button>
|
|
||||||
<button type="button" onclick="setDateType('ytd', this)" class="btn btn-secondary waves-effect waves-themed">昨天</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<div class="form-group">
|
|
||||||
<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"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-auto" id="his_enddate" style="display: none">
|
|
||||||
<div class="form-group">
|
|
||||||
<input class="form-control" type="date" data-val="" name="date" value="">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<a href="#" onclick="searchDate()" class="btn btn-info">查詢</a>
|
|
||||||
<a href="#" onclick="exportExcel()" class="btn btn-info waves-effect waves-themed">
|
|
||||||
<span class="fal fa-file-excel mr-1"></span>
|
|
||||||
匯出
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="row-cols-1 mb-2">
|
|
||||||
<div id="devPointsList" class="btn-group">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<div class="frame-wrap">
|
|
||||||
<table id="historyTable" class="table table-bordered table-striped text-center m-0 w-100">
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<!-- nav-menu-reset will reset the font colors -->
|
||||||
|
<ul id="js_nested_list" class="nav-menu nav-menu-reset nav-menu-compact mb-sm-4 mb-md-0 rounded border border-white" data-nav-accordion="true">
|
||||||
|
</ul>
|
||||||
|
<div class="filter-message js-filter-message m-0 text-left pl-4 py-3 fw-500"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-sm-12 col-xl-10">
|
||||||
|
<h1 class="p-2 mb-0">歷史資料瀏覽</h1>
|
||||||
|
<div class="row bg-dark p-2 mb-5">
|
||||||
|
<div class="col-auto">
|
||||||
|
<div class="btn-group">
|
||||||
|
<button type="button" onclick="setDateType('day', this)" class="btn btn-secondary waves-effect waves-themed">日期</button>
|
||||||
|
<button type="button" onclick="setDateType('range', this)" class="btn btn-secondary waves-effect waves-themed">日區間</button>
|
||||||
|
<button type="button" onclick="setDateType('month', this)" class="btn btn-secondary waves-effect waves-themed">月</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<div class="btn-group">
|
||||||
|
<button type="button" onclick="setDateType('today', this)" class="btn btn-secondary waves-effect waves-themed">今天</button>
|
||||||
|
<button type="button" onclick="setDateType('ytd', this)" class="btn btn-secondary waves-effect waves-themed">昨天</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<div class="form-group">
|
||||||
|
<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" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto" id="his_enddate" style="display: none">
|
||||||
|
<div class="form-group">
|
||||||
|
<input class="form-control" type="date" data-val="" name="date" value="">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto">
|
||||||
|
<a href="#" onclick="searchDate()" class="btn btn-info">查詢</a>
|
||||||
|
<a href="#" onclick="exportExcel()" class="btn btn-info waves-effect waves-themed">
|
||||||
|
<span class="fal fa-file-excel mr-1"></span>
|
||||||
|
匯出
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row-cols-1 mb-2">
|
||||||
|
<div id="devPointsList" class="btn-group">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div class="frame-wrap">
|
||||||
|
<table id="historyTable" class="table table-bordered table-striped text-center m-0 w-100">
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var historyTable = null;
|
var historyTable = null;
|
||||||
$(function () {
|
$(function () {
|
||||||
initList();
|
initList();
|
||||||
|
|
||||||
// default list filter
|
|
||||||
initApp.listFilter($('#js_default_list'), $('#js_default_list_filter'));
|
|
||||||
// custom response message
|
|
||||||
initApp.listFilter($('#js-list-msg'), $('#js-list-msg-filter'));
|
|
||||||
//accordion filter
|
|
||||||
initApp.listFilter($('#js_list_accordion'), $('#js_list_accordion_filter'));
|
|
||||||
// nested list filter
|
|
||||||
initApp.listFilter($('#js_nested_list'), $('#js_nested_list_filter'));
|
|
||||||
//init navigation
|
|
||||||
initApp.buildNavigation($('#js_nested_list'));
|
|
||||||
|
|
||||||
loadTable(null);
|
// default list filter
|
||||||
$(`[onclick="setDateType('day', this)"]`).click();
|
initApp.listFilter($('#js_default_list'), $('#js_default_list_filter'));
|
||||||
$(`[onclick="setDateType('today', this)"]`).click();
|
// custom response message
|
||||||
|
initApp.listFilter($('#js-list-msg'), $('#js-list-msg-filter'));
|
||||||
|
//accordion filter
|
||||||
|
initApp.listFilter($('#js_list_accordion'), $('#js_list_accordion_filter'));
|
||||||
|
// nested list filter
|
||||||
|
initApp.listFilter($('#js_nested_list'), $('#js_nested_list_filter'));
|
||||||
|
//init navigation
|
||||||
|
initApp.buildNavigation($('#js_nested_list'));
|
||||||
|
|
||||||
onEvent('change', '#his_startdate', function () {
|
loadTable(null);
|
||||||
let today = displayDate(new Date(Date.now()), 'date').replaceAll('/', '-');
|
$(`[onclick="setDateType('day', this)"]`).click();
|
||||||
let ytd = displayDate(new Date(new Date().setDate(new Date(Date.now()).getDate() - 1)), 'date').replaceAll('/', '-');
|
$(`[onclick="setDateType('today', this)"]`).click();
|
||||||
|
|
||||||
if (pageAct.dateType == 'range') {
|
onEvent('change', '#his_startdate', function () {
|
||||||
if ($('#his_startdate').val() > $('#his_enddate input').val() && ($('#his_startdate').val() != "" && $('#his_enddate input').val() != "")) {
|
let today = displayDate(new Date(Date.now()), 'date').replaceAll('/', '-');
|
||||||
console.log('aaaa');
|
let ytd = displayDate(new Date(new Date().setDate(new Date(Date.now()).getDate() - 1)), 'date').replaceAll('/', '-');
|
||||||
$('#his_startdate').val($('#his_startdate').data('val'));
|
|
||||||
toast_error('不可選擇大於結束時間');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$('#his_startdate').data('val', $('#his_startdate').val());
|
|
||||||
$('#his_enddate input').data('val', $('#his_enddate input').val());
|
|
||||||
|
|
||||||
$(`[onclick="setDateType('today', this)"]`).addClass('btn-secondary');
|
if (pageAct.dateType == 'range') {
|
||||||
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-info');
|
if ($('#his_startdate').val() > $('#his_enddate input').val() && ($('#his_startdate').val() != "" && $('#his_enddate input').val() != "")) {
|
||||||
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
|
console.log('aaaa');
|
||||||
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
|
$('#his_startdate').val($('#his_startdate').data('val'));
|
||||||
|
toast_error('不可選擇大於結束時間');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#his_startdate').data('val', $('#his_startdate').val());
|
||||||
|
$('#his_enddate input').data('val', $('#his_enddate input').val());
|
||||||
|
|
||||||
if ($('#his_startdate').val() == $('#his_enddate input').val()) {
|
$(`[onclick="setDateType('today', this)"]`).addClass('btn-secondary');
|
||||||
if ($('#his_startdate').val() == today) {
|
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-info');
|
||||||
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
|
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
|
||||||
$(`[onclick="setDateType('today', this)"]`).addClass('btn-info');
|
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
|
||||||
}
|
|
||||||
else if ($('#his_startdate').val() == ytd) {
|
if ($('#his_startdate').val() == $('#his_enddate input').val()) {
|
||||||
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-secondary');
|
if ($('#his_startdate').val() == today) {
|
||||||
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-info');
|
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
|
||||||
}
|
$(`[onclick="setDateType('today', this)"]`).addClass('btn-info');
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ($(this).val() == today) {
|
|
||||||
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
|
|
||||||
$(`[onclick="setDateType('today', this)"]`).addClass('btn-info');
|
|
||||||
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
|
|
||||||
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
|
|
||||||
}
|
}
|
||||||
else if ($(this).val() == ytd) {
|
else if ($('#his_startdate').val() == ytd) {
|
||||||
$(`[onclick="setDateType('today', this)"]`).addClass('btn-secondary');
|
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-secondary');
|
||||||
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-info');
|
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-info');
|
||||||
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-secondary');
|
|
||||||
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-info');
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
}
|
||||||
onEvent('change', '#his_enddate input', function () {
|
}
|
||||||
let today = displayDate(new Date(Date.now()), 'date').replaceAll('/', '-');
|
else if ($(this).val() == today) {
|
||||||
let ytd = displayDate(new Date(new Date().setDate(new Date(Date.now()).getDate() - 1)), 'date').replaceAll('/', '-');
|
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
|
||||||
|
$(`[onclick="setDateType('today', this)"]`).addClass('btn-info');
|
||||||
if ($('#his_startdate').val() > $('#his_enddate input').val() && ($('#his_startdate').val() != "" && $('#his_enddate input').val() != "")) {
|
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
|
||||||
console.log('bbbb');
|
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
|
||||||
$('#his_enddate input').val($('#his_enddate input').data('val'));
|
}
|
||||||
toast_error('不可選擇大於結束時間');
|
else if ($(this).val() == ytd) {
|
||||||
}
|
$(`[onclick="setDateType('today', this)"]`).addClass('btn-secondary');
|
||||||
else {
|
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-info');
|
||||||
$('#his_startdate').data('val', $('#his_startdate').val());
|
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-secondary');
|
||||||
$('#his_enddate input').data('val', $('#his_enddate input').val());
|
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-info');
|
||||||
|
}
|
||||||
$(`[onclick="setDateType('today', this)"]`).addClass('btn-secondary');
|
|
||||||
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-info');
|
|
||||||
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
|
|
||||||
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
|
|
||||||
|
|
||||||
if ($('#his_startdate').val() == $('#his_enddate input').val()) {
|
|
||||||
if ($('#his_startdate').val() == today) {
|
|
||||||
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
|
|
||||||
$(`[onclick="setDateType('today', this)"]`).addClass('btn-info');
|
|
||||||
}
|
|
||||||
else if ($('#his_startdate').val() == ytd) {
|
|
||||||
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-secondary');
|
|
||||||
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-info');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function initList() {
|
onEvent('change', '#his_enddate input', function () {
|
||||||
let sendData = {
|
let today = displayDate(new Date(Date.now()), 'date').replaceAll('/', '-');
|
||||||
building_tag: pageAct.buiTag
|
let ytd = displayDate(new Date(new Date().setDate(new Date(Date.now()).getDate() - 1)), 'date').replaceAll('/', '-');
|
||||||
}
|
|
||||||
objSendData.Data = sendData;
|
|
||||||
let url = baseApiUrl + "/api/History/GetMainSub";
|
|
||||||
function success(res) {
|
|
||||||
let strHtml = ``;
|
|
||||||
let i1 = null, i2 = null, first = true;
|
|
||||||
|
|
||||||
$.each(res.data.history_Main_Systems, function (index, val) {
|
if ($('#his_startdate').val() > $('#his_enddate input').val() && ($('#his_startdate').val() != "" && $('#his_enddate input').val() != "")) {
|
||||||
if (pageAct.mainStatus) {
|
console.log('bbbb');
|
||||||
strHtml += `<li>
|
$('#his_enddate input').val($('#his_enddate input').data('val'));
|
||||||
<a href="#" data-filter-tags="${val.full_name.toLowerCase() }" data-maintag="${val.main_system_tag}">
|
toast_error('不可選擇大於結束時間');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#his_startdate').data('val', $('#his_startdate').val());
|
||||||
|
$('#his_enddate input').data('val', $('#his_enddate input').val());
|
||||||
|
|
||||||
|
$(`[onclick="setDateType('today', this)"]`).addClass('btn-secondary');
|
||||||
|
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-info');
|
||||||
|
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
|
||||||
|
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
|
||||||
|
|
||||||
|
if ($('#his_startdate').val() == $('#his_enddate input').val()) {
|
||||||
|
if ($('#his_startdate').val() == today) {
|
||||||
|
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
|
||||||
|
$(`[onclick="setDateType('today', this)"]`).addClass('btn-info');
|
||||||
|
}
|
||||||
|
else if ($('#his_startdate').val() == ytd) {
|
||||||
|
$(`[onclick="setDateType('ytd', this)"]`).removeClass('btn-secondary');
|
||||||
|
$(`[onclick="setDateType('ytd', this)"]`).addClass('btn-info');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function initList() {
|
||||||
|
let sendData = {
|
||||||
|
building_tag: pageAct.buiTag
|
||||||
|
}
|
||||||
|
objSendData.Data = sendData;
|
||||||
|
let url = baseApiUrl + "/api/History/GetMainSub";
|
||||||
|
function success(res) {
|
||||||
|
let strHtml = ``;
|
||||||
|
let i1 = null, i2 = null, first = true;
|
||||||
|
|
||||||
|
$.each(res.data.history_Main_Systems, function (index, val) {
|
||||||
|
if (pageAct.mainStatus) {
|
||||||
|
strHtml += `<li>
|
||||||
|
<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;` : ``}">`;
|
||||||
|
|
||||||
i1 = (val.history_Sub_systems != null && i1 == null) ? index : null;
|
i1 = (val.history_Sub_systems != null && i1 == null) ? index : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$.each(val.history_Sub_systems, function (index2, val2) {
|
$.each(val.history_Sub_systems, function (index2, val2) {
|
||||||
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>
|
||||||
</a>
|
</a>
|
||||||
<ul style="${(i1 != null ? index == i1 : first) && index2 == i2 ? `display:block;` : ``}">`;
|
<ul style="${(i1 != null ? index == i1 : first) && index2 == i2 ? `display:block;` : ``}">`;
|
||||||
|
|
||||||
$.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>
|
||||||
</a>
|
</a>
|
||||||
</li>`;
|
</li>`;
|
||||||
|
|
||||||
if (pageAct.mainStatus) {
|
if (pageAct.mainStatus) {
|
||||||
if (index == i1 && index2 == i2 && first) {
|
if (index == i1 && index2 == i2 && first) {
|
||||||
first = false;
|
first = false;
|
||||||
pageAct.deviceNumber = val3.device_number;
|
pageAct.deviceNumber = val3.device_number;
|
||||||
pageAct.deviceName = val3.full_name;
|
pageAct.deviceName = val3.full_name;
|
||||||
devPointsList();
|
devPointsList();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (index2 == i2 && first) {
|
|
||||||
first = false;
|
|
||||||
pageAct.deviceNumber = val3.device_number;
|
|
||||||
pageAct.deviceName = val3.full_name;
|
|
||||||
devPointsList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
strHtml += `</ul> </li>`;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (pageAct.mainStatus) {
|
|
||||||
strHtml += `</ul> </li>`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#js_nested_list').html(strHtml);
|
|
||||||
$(`[data-tabname="hisListItem"]`).YTTab();
|
|
||||||
}
|
|
||||||
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function devPointsList() {
|
|
||||||
let sendData = {
|
|
||||||
device_number: pageAct.deviceNumber
|
|
||||||
}
|
|
||||||
objSendData.Data = sendData;
|
|
||||||
let url = baseApiUrl + "/api/History/GetDevPoi";
|
|
||||||
function success(res) {
|
|
||||||
let strHtml = ``;
|
|
||||||
|
|
||||||
$.each(res.data, function (index, val) {
|
|
||||||
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>`;
|
|
||||||
pageAct.deviceItem = val.points;
|
|
||||||
pageAct.devicePoiName = val.full_name + ' ' + val.points;
|
|
||||||
pageAct.deviceComName = val.parent_path;
|
|
||||||
getData();
|
|
||||||
} 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>`;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#devPointsList').html(strHtml);
|
|
||||||
}
|
|
||||||
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
|
|
||||||
}
|
|
||||||
|
|
||||||
function getData(start = null, end = null) {
|
|
||||||
var sdt = new Date();
|
|
||||||
var edt = new Date(new Date().setDate(sdt.getDate() + 1));
|
|
||||||
start = start ?? sdt.toLocaleDateString();
|
|
||||||
end = end ?? edt.toLocaleDateString();
|
|
||||||
getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem,
|
|
||||||
new Date(start).getTime(),
|
|
||||||
new Date(end).getTime(),
|
|
||||||
pageAct.deviceName,
|
|
||||||
pageAct.deviceComName,
|
|
||||||
callBackFromHistory);
|
|
||||||
}
|
|
||||||
|
|
||||||
function callBackFromHistory(res) {
|
|
||||||
res = JSON.parse(res);
|
|
||||||
loadTable(res.data);
|
|
||||||
if (historyTable != null) {
|
|
||||||
let t = $('#historyTable').dataTable();
|
|
||||||
|
|
||||||
t.fnClearTable();
|
|
||||||
if (res.data.length > 0)
|
|
||||||
t.fnAddData(res.data);
|
|
||||||
}
|
|
||||||
$(loadEle).Loading("close");
|
|
||||||
}
|
|
||||||
|
|
||||||
function setValue(deviceNumber, deviceName, deviceItem, elem) {
|
|
||||||
btnSelCss(elem);
|
|
||||||
|
|
||||||
if ((deviceNumber != null && deviceNumber != undefined) && (deviceName != null && deviceName != undefined)) {
|
|
||||||
pageAct.deviceNumber = deviceNumber;
|
|
||||||
pageAct.deviceName = deviceName;
|
|
||||||
devPointsList();
|
|
||||||
}
|
|
||||||
else if (deviceItem != null && deviceItem != undefined) {
|
|
||||||
pageAct.devicePoiName = $(elem).text();
|
|
||||||
pageAct.deviceItem = deviceItem;
|
|
||||||
getData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function setDateType(type, elem) {
|
|
||||||
btnSelCss(elem);
|
|
||||||
|
|
||||||
pageAct.dateType = type;
|
|
||||||
let now = formatDate(new Date(Date.now()), "date");
|
|
||||||
let ytd = formatDate(new Date(new Date().setDate(new Date().getDate() - 1)), "date");
|
|
||||||
let tmr = formatDate(new Date(new Date().setDate(new Date().getDate() + 1)), "date");
|
|
||||||
|
|
||||||
if (type == "day" || type == "today" || type == "ytd") {
|
|
||||||
let date = type == "ytd" ? ytd : now;
|
|
||||||
$('#his_startdate').css('display', 'block');
|
|
||||||
$('#his_enddate').css('display', 'none');
|
|
||||||
$('#getmonth').css('display', 'none');
|
|
||||||
$('#his_startdate').val(date);
|
|
||||||
|
|
||||||
if (type == "today")
|
|
||||||
getData(formatDate(now, "date", true), formatDate(tmr, "date", true));
|
|
||||||
else if (type == "ytd")
|
|
||||||
getData(formatDate(ytd, "date", true), formatDate(now, "date", true));
|
|
||||||
else {
|
|
||||||
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
|
|
||||||
$(`[onclick="setDateType('today', this)"]`).addClass('btn-info');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (type == "range") {
|
|
||||||
$(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
|
|
||||||
$(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
|
|
||||||
|
|
||||||
$('#his_startdate').css('display', 'block');
|
|
||||||
$('#his_enddate').css('display', 'block');
|
|
||||||
$('#getmonth').css('display', 'none');
|
|
||||||
$('#his_startdate').val(now);
|
|
||||||
$('#his_startdate').data('val', now);
|
|
||||||
$('#his_enddate input').val(tmr);
|
|
||||||
$('#his_enddate input').data('val', tmr);
|
|
||||||
}
|
|
||||||
else if (type == "month") {
|
|
||||||
$(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
|
|
||||||
$(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
|
|
||||||
|
|
||||||
$('#his_startdate').css('display', 'none');
|
|
||||||
$('#his_enddate').css('display', 'none');
|
|
||||||
$('#getmonth').css('display', 'block');
|
|
||||||
$('#getmonth').val(now.substr(0, 7));
|
|
||||||
}
|
|
||||||
else if (type == "ytd") {
|
|
||||||
$('#his_startdate').css('display', 'block');
|
|
||||||
$('#his_enddate').css('display', 'none');
|
|
||||||
$('#getmonth').css('display', 'none');
|
|
||||||
$('#his_startdate').val(ytd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function searchDate() {
|
|
||||||
let start = new Date($('#his_startdate').val());
|
|
||||||
let end = new Date(new Date().setDate(new Date($('#his_enddate input').val()).getDate() + 1));
|
|
||||||
|
|
||||||
if (pageAct.dateType == "day")
|
|
||||||
end = new Date(new Date().setDate(start.getDate() + 1));
|
|
||||||
else if (pageAct.dateType == "month") {
|
|
||||||
start = new Date($('#getmonth').val());
|
|
||||||
end = new Date(new Date().setDate(start.getDate() + 30));
|
|
||||||
}
|
|
||||||
else if (pageAct.dateType != "range")
|
|
||||||
return;
|
|
||||||
|
|
||||||
getData(formatDate(start, "date", true), formatDate(end, "date", true));
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatDate(date, type, send = false) {
|
|
||||||
if (!send)
|
|
||||||
return displayDate(date, type).replaceAll("/", "-");
|
|
||||||
else {
|
|
||||||
date = displayDate(date, type);
|
|
||||||
let month = date.split('/')[1];
|
|
||||||
let year = date.split('/')[0];
|
|
||||||
let day= date.split('/')[2];
|
|
||||||
return month + "/" + day + "/" + year;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadTable(data) {
|
|
||||||
if (data) {
|
|
||||||
$.each(data, function (i, v) {
|
|
||||||
v.type = pageAct.devicePoiName;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let tag = "#historyTable";
|
|
||||||
|
|
||||||
let column_defs = [
|
|
||||||
{ "targets": [0], "width": "20%", "sortable": true },
|
|
||||||
{ "targets": [1], "width": "20%", "sortable": true },
|
|
||||||
{ "targets": [2], "width": "20%", "sortable": true }
|
|
||||||
];
|
|
||||||
|
|
||||||
let columns = [
|
|
||||||
{
|
|
||||||
"title": "類別",
|
|
||||||
"data": "type"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "設備名稱",
|
|
||||||
"data": "deviceName",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "數值",
|
|
||||||
"data": "value",
|
|
||||||
"render": function (data) {
|
|
||||||
return data.roundDecimal(2);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "紀錄時間",
|
|
||||||
"data": "timestamp",
|
|
||||||
"render": function (data) {
|
|
||||||
return displayDate(data, "datetime");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
];
|
else {
|
||||||
|
if (index2 == i2 && first) {
|
||||||
historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
|
first = false;
|
||||||
}
|
pageAct.deviceNumber = val3.device_number;
|
||||||
|
pageAct.deviceName = val3.full_name;
|
||||||
function exportExcel() {
|
devPointsList();
|
||||||
let url = baseApiUrl + "/History/OpeExportExcel";
|
}
|
||||||
objSendData.Data = $('#historyTable').dataTable().fnGetData();
|
}
|
||||||
|
});
|
||||||
$.each(objSendData.Data, function (i, v) {
|
strHtml += `</ul> </li>`;
|
||||||
v.starttime = (pageAct.dateType == "month" ? new Date($('#getmonth').val()) : new Date($('#his_startdate').val()));
|
|
||||||
v.endtime = $('#his_enddate input').val() === "" ? null : new Date($('#his_enddate input').val());
|
|
||||||
v.dateType = pageAct.dateType;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
|
if (pageAct.mainStatus) {
|
||||||
if (rel.code == "0000")
|
strHtml += `</ul> </li>`;
|
||||||
location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + cookies.get("JWT-Authorization");
|
}
|
||||||
}, null, "POST").send();
|
});
|
||||||
|
|
||||||
|
$('#js_nested_list').html(strHtml);
|
||||||
|
$(`[data-tabname="hisListItem"]`).YTTab();
|
||||||
}
|
}
|
||||||
|
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function devPointsList() {
|
||||||
|
let sendData = {
|
||||||
|
device_number: pageAct.deviceNumber
|
||||||
|
}
|
||||||
|
objSendData.Data = sendData;
|
||||||
|
let url = baseApiUrl + "/api/History/GetDevPoi";
|
||||||
|
function success(res) {
|
||||||
|
let strHtml = ``;
|
||||||
|
|
||||||
|
$.each(res.data, function (index, val) {
|
||||||
|
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>`;
|
||||||
|
pageAct.deviceItem = val.points;
|
||||||
|
pageAct.devicePoiName = val.full_name + ' ' + val.points;
|
||||||
|
pageAct.deviceComName = val.parent_path;
|
||||||
|
getData();
|
||||||
|
} 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>`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#devPointsList').html(strHtml);
|
||||||
|
}
|
||||||
|
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getData(start = null, end = null) {
|
||||||
|
var sdt = new Date();
|
||||||
|
var edt = new Date(new Date().setDate(sdt.getDate() + 1));
|
||||||
|
start = start ?? sdt.toLocaleDateString();
|
||||||
|
end = end ?? edt.toLocaleDateString();
|
||||||
|
$(loadEle).Loading("start");
|
||||||
|
callBackFromHistory()
|
||||||
|
getHistoryDataByBaja(pageAct.deviceNumber + "_" + pageAct.deviceItem,
|
||||||
|
new Date(start).getTime(),
|
||||||
|
new Date(end).getTime(),
|
||||||
|
pageAct.deviceName,
|
||||||
|
pageAct.deviceComName,
|
||||||
|
callBackFromHistory);
|
||||||
|
}
|
||||||
|
|
||||||
|
function callBackFromHistory(res = '{"count":0,"data":[]}') {
|
||||||
|
// console.log("@H1",res)
|
||||||
|
res = JSON.parse(res);
|
||||||
|
// console.log("@history",res.data)
|
||||||
|
loadTable(res.data);
|
||||||
|
if (historyTable != null) {
|
||||||
|
let t = $('#historyTable').dataTable();
|
||||||
|
|
||||||
|
t.fnClearTable();
|
||||||
|
if (res.data.length > 0)
|
||||||
|
t.fnAddData(res.data);
|
||||||
|
}
|
||||||
|
$(loadEle).Loading("close");
|
||||||
|
}
|
||||||
|
|
||||||
|
function setValue(deviceNumber, deviceName, deviceItem, elem) {
|
||||||
|
btnSelCss(elem);
|
||||||
|
|
||||||
|
if ((deviceNumber != null && deviceNumber != undefined) && (deviceName != null && deviceName != undefined)) {
|
||||||
|
pageAct.deviceNumber = deviceNumber;
|
||||||
|
pageAct.deviceName = deviceName;
|
||||||
|
devPointsList();
|
||||||
|
}
|
||||||
|
else if (deviceItem != null && deviceItem != undefined) {
|
||||||
|
pageAct.devicePoiName = $(elem).text();
|
||||||
|
pageAct.deviceItem = deviceItem;
|
||||||
|
getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setDateType(type, elem) {
|
||||||
|
btnSelCss(elem);
|
||||||
|
|
||||||
|
pageAct.dateType = type;
|
||||||
|
let now = formatDate(new Date(Date.now()), "date");
|
||||||
|
let ytd = formatDate(new Date(new Date().setDate(new Date().getDate() - 1)), "date");
|
||||||
|
let tmr = formatDate(new Date(new Date().setDate(new Date().getDate() + 1)), "date");
|
||||||
|
|
||||||
|
if (type == "day" || type == "today" || type == "ytd") {
|
||||||
|
let date = type == "ytd" ? ytd : now;
|
||||||
|
$('#his_startdate').css('display', 'block');
|
||||||
|
$('#his_enddate').css('display', 'none');
|
||||||
|
$('#getmonth').css('display', 'none');
|
||||||
|
$('#his_startdate').val(date);
|
||||||
|
|
||||||
|
if (type == "today")
|
||||||
|
getData(formatDate(now, "date", true), formatDate(tmr, "date", true));
|
||||||
|
else if (type == "ytd")
|
||||||
|
getData(formatDate(ytd, "date", true), formatDate(now, "date", true));
|
||||||
|
else {
|
||||||
|
$(`[onclick="setDateType('today', this)"]`).removeClass('btn-secondary');
|
||||||
|
$(`[onclick="setDateType('today', this)"]`).addClass('btn-info');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type == "range") {
|
||||||
|
$(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
|
||||||
|
$(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
|
||||||
|
|
||||||
|
$('#his_startdate').css('display', 'block');
|
||||||
|
$('#his_enddate').css('display', 'block');
|
||||||
|
$('#getmonth').css('display', 'none');
|
||||||
|
$('#his_startdate').val(now);
|
||||||
|
$('#his_startdate').data('val', now);
|
||||||
|
$('#his_enddate input').val(tmr);
|
||||||
|
$('#his_enddate input').data('val', tmr);
|
||||||
|
}
|
||||||
|
else if (type == "month") {
|
||||||
|
$(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).removeClass('btn-info');
|
||||||
|
$(`[onclick="setDateType('today', this)"], [onclick="setDateType('ytd', this)"]`).addClass('btn-secondary');
|
||||||
|
|
||||||
|
$('#his_startdate').css('display', 'none');
|
||||||
|
$('#his_enddate').css('display', 'none');
|
||||||
|
$('#getmonth').css('display', 'block');
|
||||||
|
$('#getmonth').val(now.substr(0, 7));
|
||||||
|
}
|
||||||
|
else if (type == "ytd") {
|
||||||
|
$('#his_startdate').css('display', 'block');
|
||||||
|
$('#his_enddate').css('display', 'none');
|
||||||
|
$('#getmonth').css('display', 'none');
|
||||||
|
$('#his_startdate').val(ytd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchDate() {
|
||||||
|
let start = new Date($('#his_startdate').val());
|
||||||
|
let end = new Date(new Date().setDate(new Date($('#his_enddate input').val()).getDate() + 1));
|
||||||
|
|
||||||
|
if (pageAct.dateType == "day")
|
||||||
|
end = new Date(new Date().setDate(start.getDate() + 1));
|
||||||
|
else if (pageAct.dateType == "month") {
|
||||||
|
start = new Date($('#getmonth').val());
|
||||||
|
end = new Date(new Date().setDate(start.getDate() + 30));
|
||||||
|
}
|
||||||
|
else if (pageAct.dateType != "range")
|
||||||
|
return;
|
||||||
|
|
||||||
|
getData(formatDate(start, "date", true), formatDate(end, "date", true));
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(date, type, send = false) {
|
||||||
|
if (!send)
|
||||||
|
return displayDate(date, type).replaceAll("/", "-");
|
||||||
|
else {
|
||||||
|
date = displayDate(date, type);
|
||||||
|
let month = date.split('/')[1];
|
||||||
|
let year = date.split('/')[0];
|
||||||
|
let day = date.split('/')[2];
|
||||||
|
return month + "/" + day + "/" + year;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadTable(data) {
|
||||||
|
if (data) {
|
||||||
|
$.each(data, function (i, v) {
|
||||||
|
// console.log("loadTable",pageAct.devicePoiName.split(" ")[0])
|
||||||
|
v.type = pageAct.devicePoiName.split(" ")[0];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let tag = "#historyTable";
|
||||||
|
|
||||||
|
let column_defs = [
|
||||||
|
{ "targets": [0], "width": "20%", "sortable": true },
|
||||||
|
{ "targets": [1], "width": "20%", "sortable": true },
|
||||||
|
{ "targets": [2], "width": "20%", "sortable": true }
|
||||||
|
];
|
||||||
|
|
||||||
|
let columns = [
|
||||||
|
{
|
||||||
|
"title": "類別",
|
||||||
|
"data": "type"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "設備名稱",
|
||||||
|
"data": "deviceName",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "數值",
|
||||||
|
"data": "value",
|
||||||
|
"render": function (data) {
|
||||||
|
if (isNaN(data)) {
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
return data.roundDecimal(2);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "紀錄時間",
|
||||||
|
"data": "timestamp",
|
||||||
|
"render": function (data) {
|
||||||
|
// console.log(data)
|
||||||
|
return displayDate(data, "datetime");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
historyTable = new YourTeam.JqDataTables.getTableByStatic(tag, data, columns, column_defs, null, null, null, null, "tpi");
|
||||||
|
}
|
||||||
|
|
||||||
|
function exportExcel() {
|
||||||
|
let url = baseApiUrl + "/History/OpeExportExcel";
|
||||||
|
objSendData.Data = $('#historyTable').dataTable().fnGetData();
|
||||||
|
|
||||||
|
$.each(objSendData.Data, function (i, v) {
|
||||||
|
v.starttime = (pageAct.dateType == "month" ? new Date($('#getmonth').val()) : new Date($('#his_startdate').val()));
|
||||||
|
v.endtime = $('#his_enddate input').val() === "" ? null : new Date($('#his_enddate input').val());
|
||||||
|
v.dateType = pageAct.dateType;
|
||||||
|
});
|
||||||
|
|
||||||
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (rel) {
|
||||||
|
if (rel.code == "0000")
|
||||||
|
location.href = baseApiUrl + "/api/df?path=" + rel.data.split('/')[0] + "&fileName=" + rel.data.split('/')[1] + "&token=" + cookies.get("JWT-Authorization");
|
||||||
|
}, null, "POST").send();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
@ -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");
|
||||||
@ -434,9 +438,11 @@
|
|||||||
setForgeHotSpotColor(matchDevice);
|
setForgeHotSpotColor(matchDevice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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) {
|
||||||
|
@ -1410,9 +1410,9 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
|||||||
{
|
{
|
||||||
"title": "發生/完成時間",
|
"title": "發生/完成時間",
|
||||||
"data": "normalTime",
|
"data": "normalTime",
|
||||||
"render": function (data, type, row) {
|
//"render": function (data, type, row) {
|
||||||
return row.timestamp + "<br>" + data;
|
// return row.timestamp + "<br>" + data;
|
||||||
},
|
//},
|
||||||
},
|
},
|
||||||
|
|
||||||
];
|
];
|
||||||
|
@ -93,20 +93,28 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
|
|||||||
var _index = 0;
|
var _index = 0;
|
||||||
var _recoverState = isRecover ? "!= null" : "= null";
|
var _recoverState = isRecover ? "!= null" : "= null";
|
||||||
var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
|
var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
|
||||||
/*console.log("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp asc")*/
|
console.log("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp asc")
|
||||||
require(['baja!'], function (baja) {
|
require(['baja!'], function (baja) {
|
||||||
baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackTime, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp asc").get()
|
baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackTime, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp asc").get()
|
||||||
.then(function (table) {
|
.then(function (table) {
|
||||||
return table.cursor({
|
return table.cursor({
|
||||||
each: function (record) {
|
each: function (record) {
|
||||||
_sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
|
const alarmDisplayName = record.get('alarmData').get('sourceName').split(":")[1] ?? record.get('alarmData').get('sourceName').split(":")[0]
|
||||||
|
//console.log(alarmDisplayName)
|
||||||
|
_sourceTmp = alarmDisplayName.split('_');
|
||||||
_bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
_bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||||
_sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
_sourceName = _sourceTmp.slice(0, 8).join("_");
|
||||||
_ss.push({ buildingFloorName_zh: _bfName, uuid: record.get('uuid'), timestamp: record.get('timestamp').$cEncStr, alarmClass: record.get('alarmClass'), sourceName_zh: _sourceName, msgText: record.get('alarmData').get('msgText'), ackState: record.get('ackState'), normalTime: record.get('normalTime'), ackedTime: record.get('ackTime').$cEncStr })
|
_sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||||
|
if (!_sourceTmp.includes("undefined")) {
|
||||||
|
_ss.push({ buildingFloorName_zh: _bfName, uuid: record.get('uuid'), timestamp: record.get('timestamp').$cEncStr, alarmClass: record.get('alarmClass'), sourceName_zh: _sourceName, sourceTmp: _sourceTmp, msgText: record.get('alarmData').get('msgText'), ackState: record.get('ackState'), normalTime: record.get('normalTime'), ackedTime: record.get('ackTime').$cEncStr })
|
||||||
|
}
|
||||||
_index++
|
_index++
|
||||||
},
|
},
|
||||||
after: function () {
|
after: function () {
|
||||||
_result = { count: _index, data: _ss }
|
_result = { count: _index, data: _ss }
|
||||||
|
|
||||||
|
//console.log(552, _result);
|
||||||
|
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback(_result);
|
callback(_result);
|
||||||
}
|
}
|
||||||
@ -153,8 +161,8 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
|
|||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
||||||
var _result = "";
|
var _result = {};
|
||||||
var _ss = "";
|
var _ss = [];
|
||||||
var _occurrenceTime = "";
|
var _occurrenceTime = "";
|
||||||
var _normalTime = "";
|
var _normalTime = "";
|
||||||
var _index = 0;
|
var _index = 0;
|
||||||
@ -166,28 +174,23 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
|
|||||||
each: function (record) {
|
each: function (record) {
|
||||||
_occurrenceTime = "";
|
_occurrenceTime = "";
|
||||||
_normalTime = "";
|
_normalTime = "";
|
||||||
|
// console.log(record.get('timestamp'),record.get('normalTime') )
|
||||||
var _resultUuid = record.get('uuid').toString().split("-");//43dc7846-bd96-4be2-ab35-f11aec729c60
|
var _resultUuid = record.get('uuid').toString().split("-");//43dc7846-bd96-4be2-ab35-f11aec729c60
|
||||||
|
|
||||||
var _timestampTemp = new Date(record.get('timestamp').toString());
|
var _occurrenceTime = new Date(record.get('timestamp').$cEncStr).toLocaleString('zh-tw', { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit" });
|
||||||
_occurrenceTime += _timestampTemp.getFullYear().toString() + "-" + addzero(_timestampTemp.getMonth() + 1).toString() + "-" + addzero(_timestampTemp.getDate()).toString() + " " + addzero(_timestampTemp.getHours()).toString() + ":" + addzero(_timestampTemp.getMinutes()).toString() + ":" + addzero(_timestampTemp.getSeconds()).toString();
|
// _occurrenceTime += _timestampTemp.getFullYear().toString() + "-" + addzero(_timestampTemp.getMonth() + 1).toString() + "-" + addzero(_timestampTemp.getDate()).toString() + " " + addzero(_timestampTemp.getHours()).toString() + ":" + addzero(_timestampTemp.getMinutes()).toString() + ":" + addzero(_timestampTemp.getSeconds()).toString();
|
||||||
|
|
||||||
//var _occurrenceTime = _timestamp.format("yyyy-MM-dd hh:mm:ss");//.toLocaleString();
|
//var _occurrenceTime = _timestamp.format("yyyy-MM-dd hh:mm:ss");//.toLocaleString();
|
||||||
var _normaltime = new Date(record.get('normalTime').toString());
|
var _normalTime = new Date(record.get('normalTime').$cEncStr).toLocaleString('zh-tw', { year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit" });
|
||||||
_normalTime += _normaltime.getFullYear().toString() + "-" + addzero(_normaltime.getMonth() + 1).toString() + "-" + addzero(_normaltime.getDate()).toString() + " " + addzero(_normaltime.getHours()).toString() + ":" + addzero(_normaltime.getMinutes()).toString() + ":" + addzero(_normaltime.getSeconds()).toString();
|
// _normalTime += _normaltime.getFullYear().toString() + "-" + addzero(_normaltime.getMonth() + 1).toString() + "-" + addzero(_normaltime.getDate()).toString() + " " + addzero(_normaltime.getHours()).toString() + ":" + addzero(_normaltime.getMinutes()).toString() + ":" + addzero(_normaltime.getSeconds()).toString();
|
||||||
|
|
||||||
var _msgText = record.get('alarmData').get('msgText');// == 1 ? _occurrenceTime : "未確認";
|
var _msgText = record.get('alarmData').get('msgText');// == 1 ? _occurrenceTime : "未確認";
|
||||||
var _ackText = record.get('ackState') == 1 ? _occurrenceTime : "未確認";
|
var _ackText = record.get('ackState') == 1 ? _occurrenceTime : "未確認";
|
||||||
|
_ss.push({ uuid: _resultUuid[0], msgText: _msgText, ackState: _ackText, timestamp: _occurrenceTime, normalTime: _normalTime })
|
||||||
if (_index == 0)
|
|
||||||
_ss += '{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + _ackText + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
|
|
||||||
else
|
|
||||||
_ss += ',{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + _ackText + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
|
|
||||||
_index++;
|
_index++;
|
||||||
},
|
},
|
||||||
after: function () {
|
after: function () {
|
||||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
_result = JSON.stringify({ count: _index, data: _ss })
|
||||||
_result += _ss + ']';
|
|
||||||
_result += '}';
|
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback(_result);
|
callback(_result);
|
||||||
}
|
}
|
||||||
@ -233,7 +236,7 @@ function getOneSystemAlarmStateByBaja(systemPath, callback) {
|
|||||||
var _result = "";
|
var _result = "";
|
||||||
var _ss = "";
|
var _ss = "";
|
||||||
var _index = 0;
|
var _index = 0;
|
||||||
console.log("local:|foxs:|alarm:|bql:select alarmData, alarmData.sourceName, sourceState, uuid where alarmData.sourceName like '%" + systemPath + "%' order by timestamp desc")
|
/* console.log("local:|foxs:|alarm:|bql:select alarmData, alarmData.sourceName, sourceState, uuid where alarmData.sourceName like '%" + systemPath + "%' order by timestamp desc")*/
|
||||||
require(['baja!'], function (baja) {
|
require(['baja!'], function (baja) {
|
||||||
baja.Ord.make("local:|foxs:|alarm:|bql:select alarmData, alarmData.sourceName, sourceState, uuid where alarmData.sourceName like '%" + systemPath + "%' order by timestamp desc").get()
|
baja.Ord.make("local:|foxs:|alarm:|bql:select alarmData, alarmData.sourceName, sourceState, uuid where alarmData.sourceName like '%" + systemPath + "%' order by timestamp desc").get()
|
||||||
.then(function (table) {
|
.then(function (table) {
|
||||||
@ -528,7 +531,7 @@ function getOneDeviceAlarmByBaja(devicePath, callback) {
|
|||||||
var _index = 0;
|
var _index = 0;
|
||||||
|
|
||||||
require(['baja!'], function (baja) {
|
require(['baja!'], function (baja) {
|
||||||
console.log("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc");
|
/* console.log("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc");*/
|
||||||
baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc").get()
|
baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc").get()
|
||||||
.then(function (table) {
|
.then(function (table) {
|
||||||
return table.cursor({
|
return table.cursor({
|
||||||
@ -542,7 +545,7 @@ function getOneDeviceAlarmByBaja(devicePath, callback) {
|
|||||||
after: function () {
|
after: function () {
|
||||||
_result = { count: _index, data: _ss }
|
_result = { count: _index, data: _ss }
|
||||||
|
|
||||||
console.log(552, _result);
|
//console.log(552, _result);
|
||||||
|
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback(_result);
|
callback(_result);
|
||||||
@ -561,12 +564,12 @@ function getAllDeviceAlarmByBaja(startDate_millisecond, endDate_millisecond, isR
|
|||||||
var _recoverState = isRecover ? "!= null" : "= null";
|
var _recoverState = isRecover ? "!= null" : "= null";
|
||||||
var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
|
var _ackState = isAck ? "= 'acked'" : "= 'unacked'";
|
||||||
|
|
||||||
|
let startUrl = "";
|
||||||
|
if (startDate_millisecond) {
|
||||||
|
startUrl = "timestamp.millis >= " + startDate_millisecond + " and ";
|
||||||
|
}
|
||||||
|
// console.log("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
|
||||||
require(['baja!'], function (baja) {
|
require(['baja!'], function (baja) {
|
||||||
let startUrl = "";
|
|
||||||
if (startDate_millisecond) {
|
|
||||||
startUrl = "timestamp.millis >= " + startDate_millisecond + " and ";
|
|
||||||
}
|
|
||||||
// console.log("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
|
|
||||||
|
|
||||||
baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get()
|
baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get()
|
||||||
.then(function (table) {
|
.then(function (table) {
|
||||||
@ -574,30 +577,35 @@ function getAllDeviceAlarmByBaja(startDate_millisecond, endDate_millisecond, isR
|
|||||||
each: function (record) {
|
each: function (record) {
|
||||||
// console.log(record,record.get('alarmData').get('sourceName').split(':'))
|
// console.log(record,record.get('alarmData').get('sourceName').split(':'))
|
||||||
let main = {};
|
let main = {};
|
||||||
console.log(record.get('alarmData').get('sourceName'), record.get('timestamp').$cEncStr)
|
// console.log(record.get('alarmData').get('sourceName'),record.get('timestamp').$cEncStr)
|
||||||
_sourcePoint = (record.get('alarmData').get('sourceName')).toString().split(':')[0];
|
const alarmDisplayName = record.get('alarmData').get('sourceName').split(":")[1] ?? record.get('alarmData').get('sourceName').split(":")[0]
|
||||||
_sourceTmp = _sourcePoint.split("_");
|
//console.log(alarmDisplayName)
|
||||||
|
_sourceTmp = alarmDisplayName.split('_');
|
||||||
|
let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4]
|
||||||
|
let _sourceName = _sourceTmp.slice(0, 8).join("_");
|
||||||
|
_sourceTmp = _sourceTmp[7] + "-" + _sourceTmp[8];
|
||||||
|
|
||||||
let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
|
||||||
let _sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
|
|
||||||
main.buildingFloorName_zh = _bfName;
|
main.buildingFloorName_zh = _bfName;
|
||||||
main.sourceName_zh = _sourceName;
|
main.sourceName_zh = _sourceName;
|
||||||
main.uuid = record.get('uuid').$val;
|
main.uuid = record.get('uuid').$val;
|
||||||
main.timestamp = record.get('timestamp').$cEncStr;
|
main.timestamp = record.get('timestamp').$cEncStr;
|
||||||
main.alarmClass = record.get('alarmClass');
|
main.alarmClass = record.get('alarmClass');
|
||||||
main.point = _sourcePoint;
|
main.point = _sourceTmp;
|
||||||
main.devicePath = _sourceTmp.slice(0, 8).join("_");;
|
main.sourceTmp = _sourceTmp;
|
||||||
|
main.devicePath = _sourceName;
|
||||||
main.msgText = record.get('alarmData').get('msgText');
|
main.msgText = record.get('alarmData').get('msgText');
|
||||||
main.normalTime = record.get('normalTime');
|
main.normalTime = record.get('normalTime');
|
||||||
main.priority = record.get('priority');
|
main.priority = record.get('priority');
|
||||||
main.ackedTime = record.get('ackTime').$cEncStr;
|
main.ackedTime = record.get('ackTime').$cEncStr;
|
||||||
_result.data.push(main);
|
if (!_sourceTmp.includes("undefined")) {
|
||||||
|
_result.data.push(main);
|
||||||
|
}
|
||||||
_index++;
|
_index++;
|
||||||
},
|
},
|
||||||
after: function () {
|
after: function () {
|
||||||
_result.count = _index;
|
_result.count = _index;
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
console.log(_result)
|
//console.log(_result)
|
||||||
callback(_result);
|
callback(_result);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -620,16 +628,16 @@ function getDeviceAlarmCardByBaja(startDate_millisecond, endDate_millisecond, is
|
|||||||
if (startDate_millisecond) {
|
if (startDate_millisecond) {
|
||||||
startUrl = "timestamp.millis >= " + startDate_millisecond + " and ";
|
startUrl = "timestamp.millis >= " + startDate_millisecond + " and ";
|
||||||
}
|
}
|
||||||
console.log("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");
|
/* console.log("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc");*/
|
||||||
|
|
||||||
baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get()
|
baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackTime, priority ,ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where " + startUrl + "timestamp.millis <= " + endDate_millisecond + " and normalTime " + _recoverState + " and ackState " + _ackState + " order by timestamp desc").get()
|
||||||
.then(function (table) {
|
.then(function (table) {
|
||||||
return table.cursor({
|
return table.cursor({
|
||||||
each: function (record) {
|
each: function (record) {
|
||||||
let main = {};
|
let main = {};
|
||||||
console.log(record.get('alarmData').get('sourceName'))
|
//console.log(record.get('alarmData').get('sourceName'))
|
||||||
_sourcePoint = (record.get('alarmData').get('sourceName')).toString().split(':')[1];
|
_sourcePoint = (record.get('alarmData').get('sourceName')).toString().split(':')[1];
|
||||||
console.log(_sourcePoint)
|
//console.log(_sourcePoint)
|
||||||
_sourceTmp = _sourcePoint.split("_");
|
_sourceTmp = _sourcePoint.split("_");
|
||||||
|
|
||||||
let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
let _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
|
||||||
|
@ -35,69 +35,83 @@
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
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) {
|
||||||
console.log('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond);
|
console.log('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond);
|
||||||
baja.Ord.make('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond).get()
|
baja.Ord.make('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond).get()
|
||||||
.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') + '"}';
|
// + '"}';
|
||||||
_index++;
|
// else
|
||||||
},
|
// _ss += ',{"deviceName":"' + deviceName + '", "value":' + record.get('value') + ', "timestamp":"' + record.get('timestamp').$cEncStr
|
||||||
after: function () {
|
// + '"}';
|
||||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
_ss.push({
|
||||||
_result += _ss;
|
deviceName: deviceName, value: record.get('value'), timestamp: record.get('timestamp').$cEncStr
|
||||||
_result += ']}';
|
});
|
||||||
if (typeof callback === 'function') {
|
_index++;
|
||||||
callback(_result);
|
},
|
||||||
}
|
after: function () {
|
||||||
},
|
_result = { count: _index, data: _ss }
|
||||||
limit: -1,
|
// _result += '{' + '"count": ' + _index + ', "data":[';
|
||||||
offset: 0
|
// _result += _ss;
|
||||||
});
|
// _result += ']}';
|
||||||
});
|
if (typeof callback === 'function') {
|
||||||
});
|
// console.log(_result)
|
||||||
|
_result = JSON.stringify(_result)
|
||||||
|
callback(_result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
limit: -1,
|
||||||
|
offset: 0
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
console.log("error");
|
||||||
|
// const res = JSON.stringify({count:0, data:[]})
|
||||||
|
callback()
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function test3000p(devicePath, startDate_millisecond, endDate_millisecond, deviceName, company, callback) {
|
function test3000p(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) {
|
||||||
"use strict";
|
"use strict";
|
||||||
baja.Ord.make('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond)
|
baja.Ord.make('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond)
|
||||||
.get(
|
.get(
|
||||||
function (table) {
|
function (table) {
|
||||||
|
|
||||||
table.cursor({
|
table.cursor({
|
||||||
each: function (item) {
|
each: function (item) {
|
||||||
console.log("item: " + item);
|
console.log("item: " + item);
|
||||||
if (_index == 0)
|
if (_index == 0)
|
||||||
_ss += '{"deviceName":"' + deviceName + '", "value":' + item.$map.$map.value.$display + ', "timestamp":"' + item.$map.$map.timestamp.$val.$cEncStr + '"}';
|
_ss += '{"deviceName":"' + deviceName + '", "value":' + item.$map.$map.value.$display + ', "timestamp":"' + item.$map.$map.timestamp.$val.$cEncStr + '"}';
|
||||||
else
|
else
|
||||||
_ss += ',{"deviceName":"' + deviceName + '", "value":' + item.$map.$map.value.$display + ', "timestamp":"' + item.$map.$map.timestamp.$val.$cEncStr + '"}';
|
_ss += ',{"deviceName":"' + deviceName + '", "value":' + item.$map.$map.value.$display + ', "timestamp":"' + item.$map.$map.timestamp.$val.$cEncStr + '"}';
|
||||||
_index++;
|
_index++;
|
||||||
},
|
},
|
||||||
after: function () {
|
after: function () {
|
||||||
_result += '{' + '"count": ' + _index + ', "data":[';
|
_result += '{' + '"count": ' + _index + ', "data":[';
|
||||||
_result += _ss;
|
_result += _ss;
|
||||||
_result += ']}';
|
_result += ']}';
|
||||||
if (typeof callback === 'function') {
|
if (typeof callback === 'function') {
|
||||||
callback(_result);
|
callback(_result);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
limit: -1,
|
limit: -1,
|
||||||
offset: 0
|
offset: 0
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -198,13 +198,15 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
{
|
{
|
||||||
var dbsub = await frontendRepository.GetAllAsync<HistoryDBMainSub>(
|
var dbsub = await frontendRepository.GetAllAsync<HistoryDBMainSub>(
|
||||||
@$"select distinct v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name, v2.system_value sub_system_tag, v1.system_priority, v2.system_priority,
|
@$"select distinct v1.system_key main_name, v1.system_value main_system_tag, v2.system_key sub_name, v2.system_value sub_system_tag, v1.system_priority, v2.system_priority,
|
||||||
d.device_number, d.full_name as device_full_name, d.device_serial_tag
|
d.device_number, d.full_name as device_full_name, d.device_serial_tag ,di.is_show_history device_item_is_show_hsitory
|
||||||
from role_auth a
|
from role_auth a
|
||||||
join auth_page b on a.AuthCode = b.AuthCode
|
join auth_page b on a.AuthCode = b.AuthCode
|
||||||
join userinfo c on c.role_guid = a.role_guid
|
join userinfo c on c.role_guid = a.role_guid
|
||||||
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
|
join variable v2 on b.ShowView = v2.id and v2.system_type = @sub_system_type
|
||||||
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
|
join variable v1 on v1.id = v2.system_parent_id and v1.system_type = @main_system_type
|
||||||
join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0 and d.visible = 1
|
join device d on v1.system_value = d.device_system_tag and v2.system_value = d.device_name_tag and d.deleted = 0 and d.visible = 1
|
||||||
|
join device_item di on d.device_system_tag=di.device_system_tag and d.device_name_tag=di.device_name_tag
|
||||||
|
and di.is_link = 1
|
||||||
where c.account = @account
|
where c.account = @account
|
||||||
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
order by v1.system_priority, v2.system_priority", new { @account = myUser.account, @sub_system_type = sub_system_type, @main_system_type = main_system_type });
|
||||||
var dbbuilding = await frontendRepository.GetAllAsync<History_Build>(
|
var dbbuilding = await frontendRepository.GetAllAsync<History_Build>(
|
||||||
@ -231,7 +233,7 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
History_Sub_system history_Sub_System = new History_Sub_system();
|
History_Sub_system history_Sub_System = new History_Sub_system();
|
||||||
history_Sub_System.full_name = sub.Select(x => x.sub_name).FirstOrDefault();
|
history_Sub_System.full_name = sub.Select(x => x.sub_name).FirstOrDefault();
|
||||||
history_Sub_System.sub_system_tag = sub.Select(x => x.sub_system_tag).FirstOrDefault();
|
history_Sub_System.sub_system_tag = sub.Select(x => x.sub_system_tag).FirstOrDefault();
|
||||||
|
history_Sub_System.is_show_history = sub.Select(x => x.device_item_is_show_hsitory).FirstOrDefault();
|
||||||
|
|
||||||
var devices = dbsub.Where(x => x.main_system_tag == main.Select(m => m.main_system_tag).FirstOrDefault() && x.sub_system_tag == sub.Select(x => x.sub_system_tag).FirstOrDefault() && x.device_number != null).ToList();
|
var devices = dbsub.Where(x => x.main_system_tag == main.Select(m => m.main_system_tag).FirstOrDefault() && x.sub_system_tag == sub.Select(x => x.sub_system_tag).FirstOrDefault() && x.device_number != null).ToList();
|
||||||
history_Sub_System.device = devices.Count > 0 ? new List<Device>() : null;
|
history_Sub_System.device = devices.Count > 0 ? new List<Device>() : null;
|
||||||
@ -244,7 +246,11 @@ namespace FrontendWebApi.ApiControllers
|
|||||||
history_Sub_System.device.Add(device);
|
history_Sub_System.device.Add(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
history_Main_System.History_Sub_systems.Add(history_Sub_System);
|
if (history_Sub_System.is_show_history==1)
|
||||||
|
{
|
||||||
|
history_Main_System.History_Sub_systems.Add(history_Sub_System);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
apiResult.Data.history_Main_Systems.Add(history_Main_System);
|
apiResult.Data.history_Main_Systems.Add(history_Main_System);
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,7 @@ namespace FrontendWebApi.Models
|
|||||||
public string device_item_points { get; set; }
|
public string device_item_points { get; set; }
|
||||||
public string device_item_unit { get; set; }
|
public string device_item_unit { get; set; }
|
||||||
public byte device_item_is_show { get; set; }
|
public byte device_item_is_show { get; set; }
|
||||||
|
public byte device_item_is_show_hsitory { get; set; }
|
||||||
public byte device_item_is_show_riserDiagram { get; set; }
|
public byte device_item_is_show_riserDiagram { get; set; }
|
||||||
public byte device_item_is_controll { get; set; }
|
public byte device_item_is_controll { get; set; }
|
||||||
public byte device_item_is_bool { get; set; }
|
public byte device_item_is_bool { get; set; }
|
||||||
@ -126,6 +127,7 @@ namespace FrontendWebApi.Models
|
|||||||
}
|
}
|
||||||
public class History_Sub_system
|
public class History_Sub_system
|
||||||
{
|
{
|
||||||
|
public byte is_show_history { get; set; }
|
||||||
public string sub_system_tag { get; set; }
|
public string sub_system_tag { get; set; }
|
||||||
public string full_name { get; set; }
|
public string full_name { get; set; }
|
||||||
public string device_normal_color { get; set; }
|
public string device_normal_color { get; set; }
|
||||||
|
@ -655,8 +655,9 @@ namespace Repository.BackendRepository.Implement
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
//先全部關閉
|
//先全部關閉
|
||||||
sb.Append("update device_item set is_show_history=0;");
|
sb.Append("update device_item set is_show_history=0;");
|
||||||
sb.Append("update device_item set is_show_history= 1" +
|
sb.Append("update device_item set is_show_history = 1 " +
|
||||||
"(select distinct device_system_tag, device_name_tag, device_point_name From import_niagara_item);");
|
"WHERE(device_system_tag, device_name_tag, points) IN " +
|
||||||
|
"(select distinct device_system_tag, device_name_tag, device_point_name From import_niagara_item);");
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
|
Loading…
Reference in New Issue
Block a user