2022-11-15 18:47:16 +08:00
|
|
|
|
<style>
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<div class="row">
|
2022-12-23 16:17:22 +08:00
|
|
|
|
<div id="leftDiv" class="col-sm-12 col-xl-6">
|
2022-12-26 18:32:21 +08:00
|
|
|
|
|
2022-11-15 18:47:16 +08:00
|
|
|
|
</div>
|
2022-12-23 16:17:22 +08:00
|
|
|
|
<div id="rightDiv" class="col-sm-12 col-xl-6">
|
|
|
|
|
|
2022-11-15 18:47:16 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2022-12-26 18:32:21 +08:00
|
|
|
|
<!-- Modal center Add -->
|
|
|
|
|
<div class="modal fade" id="lightSchModal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
|
|
|
|
|
<div class="modal-dialog modal-dialog-centered" role="document" style="min-width:60%">
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
<div class="modal-header">
|
|
|
|
|
<h4 class="modal-title">
|
|
|
|
|
燈控排程
|
|
|
|
|
</h4>
|
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
|
|
|
<span aria-hidden="true"><i class="fal fa-times"></i></span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-body">
|
|
|
|
|
<table id="lightSchTable" class="table table-bordered table-striped text-center m-0 w-100">
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-footer">
|
|
|
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">關閉</button>
|
|
|
|
|
<button type="button" id="lightSchSavBtn" class="btn btn-primary">儲存</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2022-11-15 18:47:16 +08:00
|
|
|
|
<script>
|
2022-11-25 18:46:40 +08:00
|
|
|
|
var allDevList = []; //全設備清單
|
2023-01-05 18:37:12 +08:00
|
|
|
|
var subDeviceData = [];
|
2022-12-31 18:03:16 +08:00
|
|
|
|
var heatMap = null;
|
2023-01-07 17:57:47 +08:00
|
|
|
|
var buildMenuData = {};
|
2022-12-29 16:03:58 +08:00
|
|
|
|
|
2022-11-15 18:47:16 +08:00
|
|
|
|
$(function () {
|
2022-12-26 18:32:21 +08:00
|
|
|
|
getBuildMenu((arr, data) => {
|
2023-01-07 17:57:47 +08:00
|
|
|
|
buildMenuData = data;
|
2022-12-23 16:17:22 +08:00
|
|
|
|
if (arr.indexOf(4) != -1) {
|
2023-01-07 17:57:47 +08:00
|
|
|
|
getFloDevList(arr[0] == 4 ? "left" :"right");
|
2022-12-23 16:17:22 +08:00
|
|
|
|
setLightColor();
|
|
|
|
|
}
|
2023-01-03 16:47:23 +08:00
|
|
|
|
if (arr.indexOf(3) != -1) {
|
2023-01-09 16:32:28 +08:00
|
|
|
|
getLightPoint();
|
2022-12-27 18:44:22 +08:00
|
|
|
|
getHotspotPoint(() => {
|
|
|
|
|
show3DModel(data.urn_3D);
|
|
|
|
|
});
|
2022-12-23 16:17:22 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2022-11-15 18:47:16 +08:00
|
|
|
|
})
|
|
|
|
|
|
2022-12-26 18:32:21 +08:00
|
|
|
|
// 依據 drawing type 決定呈現畫面
|
|
|
|
|
function getHtmlByType(type = 0, data = {}) {
|
2022-12-23 16:17:22 +08:00
|
|
|
|
let strHtml = ``;
|
|
|
|
|
switch (type) {
|
|
|
|
|
case 2:
|
2022-12-26 18:32:21 +08:00
|
|
|
|
strHtml = `<div style="height:85vh">
|
2022-12-23 16:17:22 +08:00
|
|
|
|
<iframe src="${data.system_url}" width="100%" height="100%"></iframe>
|
|
|
|
|
</div>`;
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
strHtml = `<div class="d-flex mb-4" style="gap:15px">
|
2023-01-05 18:37:12 +08:00
|
|
|
|
${setTopLight()}
|
2022-12-23 16:17:22 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-12 p-0" id="floDevList">
|
|
|
|
|
|
|
|
|
|
</div>`;
|
|
|
|
|
break;
|
2023-01-03 16:47:23 +08:00
|
|
|
|
case 3:
|
2023-01-09 19:15:27 +08:00
|
|
|
|
strHtml = `<div class="d-flex mb-4" style="gap:15px">
|
|
|
|
|
${setTopHeatBar()}
|
|
|
|
|
</div>
|
|
|
|
|
<div name="forgeViewer" style="height:85vh;"></div>`;
|
2022-12-23 16:17:22 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return strHtml;
|
|
|
|
|
}
|
2022-11-23 17:19:28 +08:00
|
|
|
|
//baja 訂閱設備
|
|
|
|
|
function subDevice() {
|
2023-01-03 16:47:23 +08:00
|
|
|
|
|
|
|
|
|
let myBaja = new subscriptionDevices();
|
|
|
|
|
var ordPath = {
|
|
|
|
|
"area_tag": pageAct.AreaTag,
|
|
|
|
|
"building_tag": pageAct.buiTag,
|
|
|
|
|
"system_tag": pageAct.sysMainTag,
|
|
|
|
|
"name_tag": pageAct.sysSubTag,
|
|
|
|
|
}
|
|
|
|
|
myBaja.setSubscribeDevicesByBql(ordPath);
|
|
|
|
|
myBaja.setSubscribeDevicesCallBack(function (data) {
|
2023-01-09 19:15:27 +08:00
|
|
|
|
console.log(data)
|
2023-01-03 16:47:23 +08:00
|
|
|
|
let matchDevice = allDevList.filter(x => x.device_number == data.device_number_full)[0];
|
|
|
|
|
if (!matchDevice) {
|
|
|
|
|
return false;
|
2022-12-08 17:27:32 +08:00
|
|
|
|
}
|
2023-01-09 19:15:27 +08:00
|
|
|
|
console.log(data)
|
2023-01-05 18:37:12 +08:00
|
|
|
|
//將訂閱值塞入 subDeviceData
|
|
|
|
|
if (subDeviceData.findIndex(x => x.device_number == matchDevice.device_number) == -1) {
|
|
|
|
|
let obj = {};
|
|
|
|
|
obj.device_number = matchDevice.device_number;
|
|
|
|
|
obj.dbid = matchDevice.forge_dbid;
|
|
|
|
|
subDeviceData.push(obj)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let subData = subDeviceData.filter(x => x.device_number == matchDevice.device_number)[0];
|
|
|
|
|
|
|
|
|
|
if (subData) {
|
|
|
|
|
subData[data.point_name] = data.value;
|
|
|
|
|
}
|
2022-12-22 14:27:17 +08:00
|
|
|
|
|
2023-01-03 16:47:23 +08:00
|
|
|
|
let norDevPoiName = matchDevice.device_normal_point_name;
|
|
|
|
|
let cloDevPoiName = matchDevice.device_close_point_name;
|
|
|
|
|
let errDevPoiName = matchDevice.device_error_point_name;
|
|
|
|
|
|
|
|
|
|
if (data.point_name == "Temp") {
|
|
|
|
|
heatMap?.changeTemp(data.device_number_full, !isNaN(parseInt(data.value)) ? parseInt(data.value) : 0);
|
|
|
|
|
let devIdx = allDevList.findIndex(x => x.device_number == data.device_number_full);
|
|
|
|
|
allDevList[devIdx]._temp = !isNaN(parseInt(data.value)) ? parseInt(data.value) : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data.point_name == norDevPoiName && data.value == matchDevice.device_normal_point_value) {
|
|
|
|
|
//顯示正常燈號
|
|
|
|
|
$(`#${matchDevice.device_number}_status`).attr("data-light-type", "normal").data("light-type", "normal");
|
|
|
|
|
} else if (data.point_name == cloDevPoiName && data.value == matchDevice.device_close_point_value) {
|
|
|
|
|
$(`#${matchDevice.device_number}_status`).attr("data-light-type", "close").data("light-type", "close");
|
|
|
|
|
} else if (data.point_name == errDevPoiName && data.value == matchDevice.device_error_point_value) {
|
|
|
|
|
$(`#${matchDevice.device_number}_status`).attr("data-light-type", "error").data("light-type", "error");
|
|
|
|
|
}
|
2023-01-07 17:57:47 +08:00
|
|
|
|
|
2023-01-03 16:47:23 +08:00
|
|
|
|
setLightColor();
|
2023-01-05 18:37:12 +08:00
|
|
|
|
setForgeHotSpotColor(matchDevice);
|
2023-01-07 17:57:47 +08:00
|
|
|
|
lightDevForgeSpotLig(matchDevice)
|
2023-01-06 18:39:55 +08:00
|
|
|
|
// 從設備訂閱更新每個設備卡片即時點位
|
|
|
|
|
setDevItemPoiValBySub(data);
|
2023-01-03 16:47:23 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
myBaja.setSubscribeDeviceEndCallBack(function (data) {
|
|
|
|
|
endPageLoading();
|
|
|
|
|
});
|
|
|
|
|
|
2022-11-23 15:38:52 +08:00
|
|
|
|
}
|
2023-01-09 19:15:27 +08:00
|
|
|
|
|
2023-01-07 17:57:47 +08:00
|
|
|
|
function lightDevForgeSpotLig(devObj) {
|
|
|
|
|
|
2023-01-09 19:15:27 +08:00
|
|
|
|
|
2023-01-07 17:57:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 18:39:55 +08:00
|
|
|
|
// 從設備訂閱更新每個設備卡片即時點位
|
|
|
|
|
function setDevItemPoiValBySub(data) {
|
|
|
|
|
|
|
|
|
|
let pointSpan = $(`.card.device-wrap[data-number=${data.device_number_full}] span[name=devItemPoiVal]`);
|
|
|
|
|
if (pointSpan && pointSpan.data("point") == data.point_name) {
|
|
|
|
|
console.log(data)
|
|
|
|
|
pointSpan.text(data.value);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-05 18:37:12 +08:00
|
|
|
|
|
2022-11-21 18:47:47 +08:00
|
|
|
|
function setLightColor() {
|
|
|
|
|
$("[data-light-type]").each((index, ele) => {
|
|
|
|
|
let type = $(ele).data("light-type");
|
2022-11-23 17:19:28 +08:00
|
|
|
|
let isFlashing = false;
|
2022-11-21 18:47:47 +08:00
|
|
|
|
let color = "#000";
|
|
|
|
|
switch (type) {
|
|
|
|
|
case "normal":
|
|
|
|
|
color = pageAct.sysSubObj.device_normal_color ?? "var(--theme-success)";
|
2022-11-25 18:46:40 +08:00
|
|
|
|
isFlashing = pageAct.sysSubObj.device_normal_flashing == "1";
|
2022-11-21 18:47:47 +08:00
|
|
|
|
break;
|
|
|
|
|
case "close":
|
|
|
|
|
color = pageAct.sysSubObj.device_close_color ?? "var(--theme-secondary)";
|
2022-11-25 18:46:40 +08:00
|
|
|
|
isFlashing = pageAct.sysSubObj.device_close_flashing == "1";
|
2022-11-21 18:47:47 +08:00
|
|
|
|
break;
|
|
|
|
|
case "error":
|
|
|
|
|
color = pageAct.sysSubObj.device_error_color ?? "var(--theme-danger)";
|
2022-11-25 18:46:40 +08:00
|
|
|
|
isFlashing = pageAct.sysSubObj.device_error_flashing == "1";
|
2022-11-21 18:47:47 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
$(ele).css("background-color", color);
|
2022-11-25 18:46:40 +08:00
|
|
|
|
//是否閃爍
|
2022-11-23 17:19:28 +08:00
|
|
|
|
if (isFlashing) {
|
|
|
|
|
$(ele).parents(".card.device-wrap").addClass("light-flash");
|
|
|
|
|
}
|
2022-11-21 18:47:47 +08:00
|
|
|
|
})
|
2022-11-18 18:30:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-05 18:37:12 +08:00
|
|
|
|
// 設置昇位圖上方 燈號
|
|
|
|
|
function setTopLight() {
|
|
|
|
|
let sysSubObj = pageAct.sysSubObj;
|
|
|
|
|
let strHtml = ``;
|
|
|
|
|
if (sysSubObj.device_normal_point_name != null && sysSubObj.device_normal_point_value != null) {
|
|
|
|
|
strHtml += ` <div class="row m-0 align-items-center">
|
|
|
|
|
<span id="sysNorLight" class="circle-light mr-2 " data-light-type="normal"></span>
|
|
|
|
|
<label class="mb-0">${sysSubObj.device_normal_text}</label>
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
if (sysSubObj.device_close_point_name != null && sysSubObj.device_close_point_value != null) {
|
|
|
|
|
strHtml += ` <div class="row m-0 align-items-center">
|
|
|
|
|
<span id="sysCloLight" class="circle-light mr-2" data-light-type="close"></span>
|
|
|
|
|
<label class="mb-0">${sysSubObj.device_close_text}</label>
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
if (sysSubObj.device_error_point_name != null && sysSubObj.device_error_point_value != null) {
|
|
|
|
|
strHtml += ` <div class="row m-0 align-items-center">
|
|
|
|
|
<span id="sysErrLight" class="circle-light mr-2" data-light-type="error"></span>
|
|
|
|
|
<label class="mb-0">${sysSubObj.device_error_text}</label>
|
|
|
|
|
</div>`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return strHtml;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-09 19:15:27 +08:00
|
|
|
|
// 設置 Forge 3D 溫度條
|
|
|
|
|
function setTopHeatBar() {
|
|
|
|
|
let strHtml = `<canvas name="forgeHeatBar" width="200" height="30" style="z-index:9999"></canvas>`;
|
|
|
|
|
return strHtml;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-05 18:37:12 +08:00
|
|
|
|
// forge 3D 異常點位變紅色
|
|
|
|
|
function setForgeHotSpotColor(device) {
|
|
|
|
|
let subData = subDeviceData.filter(x => x.device_number == device.device_number)[0]
|
|
|
|
|
if (subData && subData[device.device_error_point_name] == device.device_error_point_value && !isNaN(parseInt(device.spriteDbid))) {
|
|
|
|
|
changeColorForHotspot(parseInt(device.spriteDbid), "error");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 18:39:55 +08:00
|
|
|
|
// 取得昇位圖點位 (deviceItem)
|
|
|
|
|
function getRiserPoiObj() {
|
|
|
|
|
let tarDevItem = pageAct.devItems?.filter(x => x.is_show_riserDiagram == 1);
|
|
|
|
|
if (tarDevItem && tarDevItem[0]) {
|
|
|
|
|
return tarDevItem[0];
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-05 18:37:12 +08:00
|
|
|
|
// 取得設備列表 並繪製卡片
|
2023-01-07 17:57:47 +08:00
|
|
|
|
function getFloDevList(position = "left") {
|
2022-11-16 14:53:22 +08:00
|
|
|
|
let url = baseApiUrl + "/api/Device/GetDeviceList";
|
|
|
|
|
let sendData = {
|
2022-11-17 15:32:39 +08:00
|
|
|
|
sub_system_tag: pageAct.sysSubTag,
|
2022-11-16 14:53:22 +08:00
|
|
|
|
building_tag: pageAct.buiTag,
|
|
|
|
|
floor_tag: pageAct.floTag,
|
|
|
|
|
};
|
|
|
|
|
objSendData.Data = sendData;
|
|
|
|
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
let strHtml = ``;
|
|
|
|
|
$.each(res.data, (index, floObj) => {
|
2022-12-22 14:27:17 +08:00
|
|
|
|
strHtml += `<div class='d-flex justify-content-start mb-5 ' style="">`
|
|
|
|
|
strHtml += `<button id="floItemBtn${floObj.full_name}" type="button" class="btn btn-primary waves-effect waves-themed mr-5 mt-1 align-self-start" >${floObj.full_name}</button>`
|
|
|
|
|
strHtml += `<div class="col p-0 d-grid grid-gap-5 grid-temp-col-c" style="--c-grid-temp-col:repeat(auto-fill,minmax(250px,1fr))">`
|
2022-11-16 14:53:22 +08:00
|
|
|
|
$.each(floObj.device_list, (index2, devObj) => {
|
2022-11-23 15:38:52 +08:00
|
|
|
|
allDevList.push(devObj);
|
2023-01-06 18:39:55 +08:00
|
|
|
|
let devItem = getRiserPoiObj();
|
2023-01-07 17:57:47 +08:00
|
|
|
|
strHtml += `<div class="card m-1 border device-wrap" data-number="${devObj.device_number}" data-position="${position}">
|
2022-11-21 18:47:47 +08:00
|
|
|
|
<div class="card-body p-2">
|
|
|
|
|
<div class="d-flex mb-2">
|
|
|
|
|
<div class="mr-5 cur-poi">
|
|
|
|
|
<span class="d-inline-block mr-3">
|
2022-12-26 18:32:21 +08:00
|
|
|
|
<img src="${baseImgUrl + varPathDevIcon + devObj.device_image}" class="profile-image rounded-circle" onerror="defDev(this)" alt="...">
|
2022-11-21 18:47:47 +08:00
|
|
|
|
</span>
|
|
|
|
|
<a href="javascript:;">${devObj.full_name}</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="d-flex mb-0 mt-2 align-items-center">
|
2022-11-23 15:38:52 +08:00
|
|
|
|
<span id="${devObj.device_number}_status" class="circle-light"></span>
|
2023-01-06 18:39:55 +08:00
|
|
|
|
<span class="${devItem ? "" : "d-none"} ml-2">${devItem?.full_name}:<span name="devItemPoiVal" data-point="${devItem?.points}"></span>${devItem?.unit}</span>
|
2022-11-21 18:47:47 +08:00
|
|
|
|
<a href="javascript:;" name="devItem" data-id="${devObj.device_guid}" data-number="${devObj.device_number}" data-name="${devObj.full_name}" class=" ml-2 mb-0 ">詳細資料</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2022-11-16 14:53:22 +08:00
|
|
|
|
</div>`;
|
|
|
|
|
})
|
2022-12-22 14:27:17 +08:00
|
|
|
|
strHtml += "</div></div>";
|
2022-11-16 14:53:22 +08:00
|
|
|
|
})
|
2022-12-26 18:32:21 +08:00
|
|
|
|
// Niagara 產生 file 開頭字串問題
|
|
|
|
|
strHtml = strHtml.replaceAll(`src="/file/`, `src="`);
|
2022-12-22 14:27:17 +08:00
|
|
|
|
if (!res.data || res.data.length == 0) {
|
|
|
|
|
endPageLoading();
|
|
|
|
|
} else {
|
|
|
|
|
subDevice();
|
|
|
|
|
}
|
2022-11-16 14:53:22 +08:00
|
|
|
|
$("#floDevList").append(strHtml);
|
2022-12-31 18:03:16 +08:00
|
|
|
|
initPopover();
|
2022-11-16 14:53:22 +08:00
|
|
|
|
}
|
|
|
|
|
}, null, "POST").send();
|
|
|
|
|
}
|
2023-01-05 18:37:12 +08:00
|
|
|
|
|
2022-12-23 16:17:22 +08:00
|
|
|
|
function getBuildMenu(callback = null) {
|
|
|
|
|
let url = baseApiUrl + "/api/Device/GetBuildMenu";
|
|
|
|
|
let sendData = {
|
|
|
|
|
main_system_tag: pageAct.sysMainTag,
|
|
|
|
|
sub_system_tag: pageAct.sysSubTag,
|
|
|
|
|
building_tag: pageAct.buiTag,
|
|
|
|
|
};
|
|
|
|
|
objSendData.Data = sendData;
|
|
|
|
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
2022-11-23 17:19:28 +08:00
|
|
|
|
|
2022-12-23 16:17:22 +08:00
|
|
|
|
} else {
|
|
|
|
|
let leftData = {}, rightData = {};
|
2023-01-03 16:47:23 +08:00
|
|
|
|
|
2022-12-23 16:17:22 +08:00
|
|
|
|
for (var key in res.data) {
|
|
|
|
|
if (key.startsWith("left")) {
|
|
|
|
|
leftData[key.split("left_")[1]] = res.data[key];
|
|
|
|
|
} else if (key.startsWith("right")) {
|
|
|
|
|
rightData[key.split("right_")[1]] = res.data[key];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (res.data.left_drawing != null) {
|
|
|
|
|
$("#leftDiv").html(getHtmlByType(res.data.left_drawing, leftData));
|
|
|
|
|
} else {
|
2022-12-26 18:32:21 +08:00
|
|
|
|
$("#leftDiv").html(getHtmlByType(0, leftData));
|
2022-12-23 16:17:22 +08:00
|
|
|
|
}
|
|
|
|
|
if (res.data.right_drawing != null) {
|
|
|
|
|
$("#rightDiv").html(getHtmlByType(res.data.right_drawing), rightData);
|
|
|
|
|
} else {
|
2022-12-26 18:32:21 +08:00
|
|
|
|
$("#rightDiv").html(getHtmlByType(0, rightData));
|
2022-12-23 16:17:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-26 18:32:21 +08:00
|
|
|
|
callback ? callback([res.data.left_drawing, res.data.right_drawing], res.data) : "";
|
2022-12-23 16:17:22 +08:00
|
|
|
|
}
|
|
|
|
|
}, null, "POST").send();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-27 15:17:52 +08:00
|
|
|
|
// Card 即時狀態
|
2023-01-05 18:37:12 +08:00
|
|
|
|
function drawStateTabBlo(devNum) {
|
|
|
|
|
let devPath = devNum.replaceAll("_", "/");
|
2023-01-07 17:57:47 +08:00
|
|
|
|
let position = $(`.card.device-wrap[data-number=${devNum}]`).data("position");
|
|
|
|
|
let width = buildMenuData[position + "_icon_click_url_width"] ? buildMenuData[position + "_icon_click_url_width"] + "px" : "100%";
|
|
|
|
|
let height = buildMenuData[position + "_icon_click_url_height"] ? buildMenuData[position + "_icon_click_url_height"] + "px" : "100%";
|
|
|
|
|
let strHtml = `<div style="height:100%;width:100%">
|
|
|
|
|
<iframe src="/ord?station:%7Cslot:/${devPath}|view:?fullScreen=true" style="width:${width};height:${height};min-height:100px;"></iframe>
|
2022-12-27 15:17:52 +08:00
|
|
|
|
</div>`
|
|
|
|
|
return strHtml;
|
|
|
|
|
}
|
2023-01-09 19:15:27 +08:00
|
|
|
|
|
2023-01-05 18:37:12 +08:00
|
|
|
|
function iframeResize(obj) {
|
|
|
|
|
obj.style.height = obj.contentWindow.document.documentElement.scrollHeight + 'px';
|
|
|
|
|
}
|
2023-01-09 19:15:27 +08:00
|
|
|
|
|
2022-12-23 16:17:22 +08:00
|
|
|
|
function show3DModel(urn) {
|
2023-01-04 18:49:37 +08:00
|
|
|
|
$(loadEle).Loading("start");
|
2023-01-09 19:15:27 +08:00
|
|
|
|
getLightData(allDevList);
|
2022-12-26 18:20:32 +08:00
|
|
|
|
launchViewerForHotspot(urn, (viewer, nodeIds) => {
|
2023-01-09 19:15:27 +08:00
|
|
|
|
showHeat("[name=forgeHeatBar]");
|
2023-01-04 18:49:37 +08:00
|
|
|
|
let devDbIds = allDevList.map(x => x.forge_dbid);
|
2023-01-05 18:37:12 +08:00
|
|
|
|
/*hideAllObjects(devDbIds);*/
|
2023-01-09 19:15:27 +08:00
|
|
|
|
|
2023-01-05 18:37:12 +08:00
|
|
|
|
setTransparentBuilding(0, devDbIds);
|
2023-01-04 18:49:37 +08:00
|
|
|
|
$(loadEle).Loading("close");
|
2023-01-05 18:37:12 +08:00
|
|
|
|
|
2022-12-31 18:03:16 +08:00
|
|
|
|
let devices = allDevList.map(x => {
|
|
|
|
|
return {
|
|
|
|
|
roomDbId: !isNaN(parseInt(x.room_dbid)) ? parseInt(x.room_dbid) : -1,
|
|
|
|
|
id: x.device_number,
|
|
|
|
|
position: isJSON(x.device_coordinate_3d) ? JSON.parse(x.device_coordinate_3d) : {}, // x: 0, y: 25, z: -2.5 (3.35, -4.81, 12.88
|
|
|
|
|
sensorTypes: ["temperature", "humidity"]
|
|
|
|
|
}
|
|
|
|
|
})
|
2023-01-03 16:47:23 +08:00
|
|
|
|
|
2022-12-29 18:44:09 +08:00
|
|
|
|
let option = {
|
2022-12-30 19:03:31 +08:00
|
|
|
|
devices: devices,
|
2022-12-29 18:44:09 +08:00
|
|
|
|
}
|
2023-01-03 16:47:23 +08:00
|
|
|
|
|
2022-12-31 18:03:16 +08:00
|
|
|
|
heatMap = new ADHeatMaps(option);
|
|
|
|
|
heatMap.onComplete = () => {
|
2023-01-03 16:47:23 +08:00
|
|
|
|
$.each(allDevList, (idx, dev) => {
|
2022-12-31 18:03:16 +08:00
|
|
|
|
heatMap.changeTemp(dev.device_number, dev._temp || 0);
|
|
|
|
|
})
|
2022-12-29 18:44:09 +08:00
|
|
|
|
}
|
2023-01-03 16:47:23 +08:00
|
|
|
|
|
|
|
|
|
let elevOption = {
|
2023-01-05 18:37:12 +08:00
|
|
|
|
selector: "[name=forgeViewer]",
|
2023-01-03 16:47:23 +08:00
|
|
|
|
viewer: viewer,
|
|
|
|
|
ordPath: {
|
|
|
|
|
"area_tag": pageAct.AreaTag,
|
|
|
|
|
"building_tag": pageAct.buiTag,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 電梯移動訂閱程序載入
|
|
|
|
|
let forge3DElev = new Forge3DElevFull(elevOption);
|
|
|
|
|
forge3DElev.bajaEndCallback = function () {
|
|
|
|
|
endPageLoading();
|
|
|
|
|
}
|
|
|
|
|
forge3DElev.init();
|
2023-01-05 18:37:12 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (subDeviceData.length != 0) {
|
|
|
|
|
let stSubArr = subDeviceData.map(x => Object.keys(x).filter(y => y == "ST").map(y => x));
|
|
|
|
|
|
|
|
|
|
for (let sub of stSubArr) {
|
|
|
|
|
let matchDevice = allDevList.filter(x => x.device_number == sub[0]?.device_number)[0];
|
|
|
|
|
if (matchDevice) {
|
|
|
|
|
setForgeHotSpotColor(matchDevice);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getWaterNodeId();
|
2023-01-04 18:49:37 +08:00
|
|
|
|
}, () => {
|
|
|
|
|
$(loadEle).Loading("close");
|
2023-01-03 16:47:23 +08:00
|
|
|
|
}, "[name=forgeViewer]");
|
2022-12-26 18:32:21 +08:00
|
|
|
|
}
|
2022-12-23 16:17:22 +08:00
|
|
|
|
|
2023-01-05 18:37:12 +08:00
|
|
|
|
// 供水系統 - 取得欲染色 dbid
|
|
|
|
|
function getWaterNodeId() {
|
|
|
|
|
let url = baseApiUrl + "/api/Device/GetForgeNodeIdFromVar";
|
|
|
|
|
let sendData = { forgeNodeKey: "water_wupply" };
|
|
|
|
|
objSendData.Data = sendData;
|
|
|
|
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
if (!isNaN(parseInt(res.data[0]?.system_value))) {
|
|
|
|
|
changeColor(parseInt(res.data[0]?.system_value))
|
|
|
|
|
}
|
|
|
|
|
console.log(res.data)
|
|
|
|
|
}
|
|
|
|
|
}, null, "POST").send();
|
|
|
|
|
|
|
|
|
|
}
|
2023-01-03 16:47:23 +08:00
|
|
|
|
|
2022-12-27 18:44:22 +08:00
|
|
|
|
function getHotspotPoint(callback = null) {
|
2022-12-26 18:20:32 +08:00
|
|
|
|
let url = baseApiUrl + "/api/GetDevForCor";
|
2022-12-27 18:44:22 +08:00
|
|
|
|
let sendData = {
|
2022-12-27 15:17:52 +08:00
|
|
|
|
"device_area_tag": pageAct.AreaTag,
|
|
|
|
|
"device_building_tag": pageAct.buiTag,
|
|
|
|
|
"device_system_tag": pageAct.sysMainTag,
|
|
|
|
|
"device_name_tag": pageAct.sysSubTag,
|
2022-12-27 18:44:22 +08:00
|
|
|
|
};
|
2022-12-26 18:20:32 +08:00
|
|
|
|
objSendData.Data = sendData;
|
2022-12-27 15:17:52 +08:00
|
|
|
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
|
|
|
|
|
} else {
|
2023-01-03 16:47:23 +08:00
|
|
|
|
|
2022-12-28 13:12:08 +08:00
|
|
|
|
let myDataList = [];
|
|
|
|
|
$.each(res.data, (idx, data) => {
|
|
|
|
|
let item = {};
|
|
|
|
|
item.position = {};
|
2023-01-03 16:47:23 +08:00
|
|
|
|
if (data.device_coordinate_3d != null && isJSON(data.device_coordinate_3d)) {
|
2022-12-28 18:47:09 +08:00
|
|
|
|
item.position = JSON.parse(data.device_coordinate_3d);
|
2022-12-28 13:12:08 +08:00
|
|
|
|
}
|
|
|
|
|
$.extend(item, data);
|
|
|
|
|
myDataList.push(item);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
console.log("1", myDataList)
|
2022-12-27 18:44:22 +08:00
|
|
|
|
setHotspotPoint(myDataList);
|
|
|
|
|
callback ? callback() : "";
|
2022-12-26 18:20:32 +08:00
|
|
|
|
}
|
2022-12-27 15:17:52 +08:00
|
|
|
|
}, null, "POST").send();
|
2023-01-03 16:47:23 +08:00
|
|
|
|
|
2022-12-26 18:20:32 +08:00
|
|
|
|
}
|
2022-12-26 18:32:21 +08:00
|
|
|
|
|
2023-01-09 16:32:28 +08:00
|
|
|
|
async function getLightPoint(callback = null) {
|
|
|
|
|
let url = baseApiUrl + "/api/GetDevNodeForCor";
|
|
|
|
|
let sendData = {
|
|
|
|
|
"device_area_tag": pageAct.AreaTag,
|
|
|
|
|
"device_building_tag": pageAct.buiTag,
|
|
|
|
|
"device_system_tag": pageAct.sysMainTag,
|
|
|
|
|
"device_name_tag": pageAct.sysSubTag,
|
|
|
|
|
};
|
|
|
|
|
objSendData.Data = sendData;
|
|
|
|
|
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
|
|
|
|
if (!res || res.code != "0000" || !res.data) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
let myDataList = [];
|
|
|
|
|
$.each(res.data, (idx, data) => {
|
|
|
|
|
let item = {};
|
|
|
|
|
item.position = {};
|
|
|
|
|
if (data.device_node_coordinate_3d != null && isJSON(data.device_node_coordinate_3d)) {
|
|
|
|
|
item.position = JSON.parse(data.device_node_coordinate_3d);
|
|
|
|
|
}
|
|
|
|
|
$.extend(item, data);
|
|
|
|
|
myDataList.push(item);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
console.log("2", myDataList)
|
|
|
|
|
setLightPoint(myDataList);
|
|
|
|
|
callback ? callback() : "";
|
|
|
|
|
}
|
|
|
|
|
}, null, "POST").send();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-27 18:44:22 +08:00
|
|
|
|
function setHotspotPoint(myDataList = []) {
|
|
|
|
|
console.log(myDataList)
|
|
|
|
|
getHopspotPoint(myDataList);
|
2022-12-23 13:22:50 +08:00
|
|
|
|
}
|
2023-01-03 16:47:23 +08:00
|
|
|
|
|
2023-01-09 16:32:28 +08:00
|
|
|
|
async function setLightPoint(myDataList = []) {
|
|
|
|
|
console.log(myDataList)
|
|
|
|
|
getLightData(myDataList);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-29 16:03:58 +08:00
|
|
|
|
var parentEle = "";
|
2022-12-28 18:47:09 +08:00
|
|
|
|
onEvent("autodesk:click:sprite", "[name=forgeViewer]", function (e, obj) {
|
2022-12-31 18:03:16 +08:00
|
|
|
|
forgeUnFocusAll();
|
|
|
|
|
let position = [obj.event.target.toolController.lastClickX, obj.event.target.toolController.lastClickY];
|
2022-12-28 18:47:09 +08:00
|
|
|
|
let devObj = obj.myData;
|
|
|
|
|
let name = allDevList.filter(x => x.device_guid == devObj.device_guid)[0]?.full_name;
|
2022-12-31 18:03:16 +08:00
|
|
|
|
devObj.full_name = name;
|
|
|
|
|
parentEle = crePosPopover(position, devObj);
|
2023-01-03 16:47:23 +08:00
|
|
|
|
|
2022-12-28 18:47:09 +08:00
|
|
|
|
$(parentEle).click();
|
|
|
|
|
})
|
2022-12-29 16:03:58 +08:00
|
|
|
|
|
|
|
|
|
onEvent("autodesk:clickOut:sprite", "[name=forgeViewer]", function (e) {
|
|
|
|
|
$(parentEle).YTTooltip("hide");
|
|
|
|
|
})
|
2023-01-03 16:47:23 +08:00
|
|
|
|
|
2022-12-28 18:47:09 +08:00
|
|
|
|
onEvent("autodesk:complete:sprite", "[name=forgeViewer]", function (e, obj) {
|
2023-01-05 18:37:12 +08:00
|
|
|
|
|
2022-12-28 18:47:09 +08:00
|
|
|
|
$("#floDevList a[name=devItem]").each((idx, ele) => {
|
|
|
|
|
let devNum = $(ele).data("number");
|
|
|
|
|
let dbid = obj.myDataList.filter(x => x.device_number == devNum)[0]?._dbId;
|
2023-01-05 18:37:12 +08:00
|
|
|
|
allDevList.forEach((dev, idx) => {
|
|
|
|
|
if (dev.device_number == devNum) {
|
|
|
|
|
dev.spriteDbid = dbid;
|
|
|
|
|
setForgeHotSpotColor(dev);
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-12-28 18:47:09 +08:00
|
|
|
|
$(ele).data("dbId", dbid);
|
2023-01-05 18:37:12 +08:00
|
|
|
|
|
2022-12-28 18:47:09 +08:00
|
|
|
|
})
|
2022-12-31 18:03:16 +08:00
|
|
|
|
})
|
2023-01-03 16:47:23 +08:00
|
|
|
|
|
2022-12-31 18:03:16 +08:00
|
|
|
|
onEvent("yt:tooltip:show", "[name=devItem]", function (e, obj) {
|
|
|
|
|
forgeUnFocusAll();
|
2022-12-27 18:44:22 +08:00
|
|
|
|
})
|
2022-12-26 18:20:32 +08:00
|
|
|
|
|
2022-12-31 18:03:16 +08:00
|
|
|
|
function forgeUnFocusAll() {
|
|
|
|
|
$("#floDevList a[name=devItem]").each((idx, ele) => {
|
|
|
|
|
controlFocusHotspot($(ele).data("dbId"), false);
|
|
|
|
|
})
|
|
|
|
|
}
|
2022-11-15 18:47:16 +08:00
|
|
|
|
</script>
|