[Frontend] forge 熱點共用化調整 |
This commit is contained in:
parent
3e149a2cd9
commit
64e9b8e3f0
@ -36,7 +36,7 @@
|
||||
|
||||
<script>
|
||||
var allDevList = []; //全設備清單
|
||||
let devicePointList = [];
|
||||
var devicePointList = [];
|
||||
|
||||
$(function () {
|
||||
getBuildMenu((arr, data) => {
|
||||
@ -47,7 +47,6 @@
|
||||
if (arr.indexOf(5) != -1) {
|
||||
setHotspotPoint();
|
||||
show3DModel(data.urn_3D);
|
||||
console.log("start ---------");
|
||||
|
||||
}
|
||||
});
|
||||
@ -246,28 +245,37 @@
|
||||
}, null, "POST").send();
|
||||
}
|
||||
|
||||
// Card 即時狀態
|
||||
function drawStateTabBlo() {
|
||||
let strHtml = `<div style="height:15rem">
|
||||
<iframe src="/ord?station:%7Cslot:/TPE/B1/EE/E4/R2F/NA/WHT/N1|view:?fullScreen=true" width="100%" height="100%"></iframe>
|
||||
</div>`
|
||||
return strHtml;
|
||||
}
|
||||
|
||||
function show3DModel(urn) {
|
||||
launchViewerForHotspot(urn, (viewer, nodeIds) => {
|
||||
|
||||
});
|
||||
getHotspotPoint();
|
||||
},"[name=forgeViewer]");
|
||||
}
|
||||
|
||||
function getHotspotPoint() {
|
||||
let url = baseApiUrl + "/api/GetDevForCor";
|
||||
let sendData = {
|
||||
"area_tag": pageAct.AreaTag,
|
||||
"building_tag": pageAct.buiTag,
|
||||
"system_tag": pageAct.sysMainTag,
|
||||
"name_tag": pageAct.sysSubTag,
|
||||
};
|
||||
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;
|
||||
$.post(url, sendData, function (rel) {
|
||||
if (rel.code == "9999") {
|
||||
toast_error(rel.msg);
|
||||
return;
|
||||
ytAjax = new YourTeam.Ajax(url, objSendData, function (res) {
|
||||
if (!res || res.code != "0000" || !res.data) {
|
||||
|
||||
} else {
|
||||
devicePointList.push(res.data.device_coordinate_3d);
|
||||
}
|
||||
devicePointList.push(rel.data.device_coordinate_3d);
|
||||
}, 'json');
|
||||
}, null, "POST").send();
|
||||
|
||||
}
|
||||
|
||||
function setHotspotPoint() {
|
||||
|
@ -2248,7 +2248,6 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
|
||||
})
|
||||
|
||||
onEvent("yt:tab:change", "#lightSch-tab", function () {
|
||||
debugger
|
||||
if (pageAct.sysMainTag == "LT" && $("#lightSchModal").length != 0) {
|
||||
loadLightSchTable();
|
||||
$("#lightSchModal").modal("show");
|
||||
|
@ -6,7 +6,8 @@ var elevatorSpeed;
|
||||
var selector = "#forgeViewer";
|
||||
let myDataList;
|
||||
|
||||
function launchViewer(urn, callback, selector = "#forgeViewer") {
|
||||
function launchViewer(urn, callback, _selector = "#forgeViewer") {
|
||||
selector = _selector;
|
||||
var options = {
|
||||
env: 'AutodeskProduction',
|
||||
getAccessToken: getForgeToken
|
||||
@ -20,7 +21,7 @@ function launchViewer(urn, callback, selector = "#forgeViewer") {
|
||||
|
||||
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
|
||||
|
||||
$(selector).on("autodesk:loaded", function (e,nodeIds) {
|
||||
$(selector).on("autodesk:loaded", function (e, nodeIds) {
|
||||
callback ? callback(viewer, nodeIds) : "";
|
||||
})
|
||||
|
||||
@ -52,7 +53,8 @@ function launchViewer(urn, callback, selector = "#forgeViewer") {
|
||||
});
|
||||
}
|
||||
|
||||
function launchViewerForHotspot(urn, callback, selector = "#forgeViewer") {
|
||||
function launchViewerForHotspot(urn, callback, _selector = "#forgeViewer") {
|
||||
selector = _selector;
|
||||
var av = Autodesk.Viewing;
|
||||
var options = {
|
||||
env: 'AutodeskProduction',
|
||||
@ -145,14 +147,14 @@ class elevator3D {
|
||||
}
|
||||
|
||||
let nodeId = this.nodeId;
|
||||
|
||||
|
||||
if (nodeId) {
|
||||
let childCnt = tree.getChildCount(nodeId);
|
||||
let curIdx = 1;
|
||||
|
||||
|
||||
this.fragProxys.filter(x => x.nodeId == nodeId).forEach((x) => {
|
||||
let idx = this.fragProxys.indexOf(x);
|
||||
this.fragProxys.splice(idx,1);
|
||||
this.fragProxys.splice(idx, 1);
|
||||
})
|
||||
tree.enumNodeFragments(nodeId, (frag) => {
|
||||
let fragProxy = this.viewer.impl.getFragmentProxy(this.viewer.model, frag);
|
||||
@ -201,9 +203,9 @@ class elevator3D {
|
||||
return;
|
||||
}
|
||||
changeColor(nodeId);
|
||||
|
||||
|
||||
if ((this.movStatus == 2 && fragProxy.position.z.roundDecimal(2) < this.targetFloorZ.roundDecimal(2)) ||
|
||||
(this.movStatus == 1 && fragProxy.position.z.roundDecimal(2) > this.targetFloorZ.roundDecimal(2)) ||
|
||||
(this.movStatus == 1 && fragProxy.position.z.roundDecimal(2) > this.targetFloorZ.roundDecimal(2)) ||
|
||||
fragProxy.position.z.roundDecimal(2) == this.targetFloorZ.roundDecimal(2)) {
|
||||
stoped(this);
|
||||
}
|
||||
@ -261,7 +263,7 @@ class elevator3D {
|
||||
} else {
|
||||
stoped(this);
|
||||
}
|
||||
|
||||
|
||||
function stoped(obj) {
|
||||
obj.movStatus = 0;
|
||||
/*recoverTransparentBuilding();*/
|
||||
@ -295,30 +297,31 @@ function onDocumentLoadSuccess(doc, eleOption) {
|
||||
console.log(instanceTree.nodeAccess)
|
||||
allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex);
|
||||
getNodeIdByDbIds(allDbIdsStr, (nodeIds) => {
|
||||
$(selector).trigger("autodesk:loaded", nodeIds );
|
||||
$(selector).trigger("autodesk:loaded", nodeIds);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getNodeIdByDbIds(allDbIdsStr,callback) {
|
||||
function getNodeIdByDbIds(allDbIdsStr, callback = null) {
|
||||
let curDbId = 0;
|
||||
let tagId = 0;
|
||||
let _parentId = 0;
|
||||
let _childId = 0;
|
||||
let evelMap = new Map();
|
||||
let finTimeout = null;
|
||||
let isCalled = false;
|
||||
|
||||
allDbIdsStr.forEach((dbId) => {
|
||||
curDbId = parseInt(dbId);
|
||||
viewer.getProperties(curDbId, function (e) {
|
||||
e.properties.forEach(function (item, idx) {
|
||||
if (item.displayName == "tag_id" && e.name == "【電梯】") {
|
||||
|
||||
|
||||
tagId = e.dbId;
|
||||
viewer.getProperties(tagId, function (e2) {
|
||||
e2.properties.forEach(function (item2, idx2) {
|
||||
@ -338,18 +341,29 @@ function getNodeIdByDbIds(allDbIdsStr,callback) {
|
||||
console.log("map: " + evelMap);
|
||||
clearTimeout(finTimeout)
|
||||
finTimeout = setTimeout(() => {
|
||||
callback ? callback(evelMap) : "";
|
||||
if (isCalled == false) {
|
||||
isCalled = true;
|
||||
callback ? callback(evelMap) : "";
|
||||
}
|
||||
}, 10)
|
||||
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
})
|
||||
} else {
|
||||
clearTimeout(finTimeout)
|
||||
finTimeout = setTimeout(() => {
|
||||
if (isCalled == false) {
|
||||
isCalled = true;
|
||||
callback ? callback([]) : "";
|
||||
}
|
||||
}, 10)
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
return evelMap;
|
||||
}
|
||||
@ -441,9 +455,25 @@ function onDocumentLoadFailure(viewerErrorCode) {
|
||||
}
|
||||
|
||||
function getForgeToken(callback) {
|
||||
fetch(baseApiUrl + '/api/forge/oauth/token').then(res => {
|
||||
fetch(forgeTokenBase.url).then(res => {
|
||||
res.json().then(data => {
|
||||
callback(data.dictionary.access_token, data.dictionary.expires_in);
|
||||
let limitResType = ["object", "undefined"];
|
||||
let access_token = data;
|
||||
$.each(forgeTokenBase.res_access_token, (idx, dict) => {
|
||||
access_token = access_token[dict];
|
||||
})
|
||||
|
||||
let expires_in = data;
|
||||
$.each(forgeTokenBase.res_expires_in, (idx, dict) => {
|
||||
expires_in = expires_in[dict];
|
||||
})
|
||||
|
||||
if (limitResType.includes(typeof access_token) || limitResType.includes(typeof expires_in)) {
|
||||
access_token = "", expires_in = "";
|
||||
throw "access_token or expires_in on the ForgeTokenBase object for getting forge token by URL is not the correct path.";
|
||||
}
|
||||
|
||||
callback(access_token, expires_in);
|
||||
});
|
||||
});
|
||||
//callback("eyJhbGciOiJSUzI1NiIsImtpZCI6IlU3c0dGRldUTzlBekNhSzBqZURRM2dQZXBURVdWN2VhIn0.eyJzY29wZSI6WyJkYXRhOndyaXRlIiwiZGF0YTpyZWFkIiwiYnVja2V0OnJlYWQiLCJidWNrZXQ6dXBkYXRlIiwiYnVja2V0OmNyZWF0ZSJdLCJjbGllbnRfaWQiOiJUQTNocXNGZnpRYk5PVVhLcGxkS1VLU2V3NFNKMjF3NSIsImF1ZCI6Imh0dHBzOi8vYXV0b2Rlc2suY29tL2F1ZC9hand0ZXhwNjAiLCJqdGkiOiJiemxzWE5qWElvZ2R1UjUzTUJkdlhrTTNTT01qeVB1bHJrMmdTVWJudGNTeDg1b01kRG1xejg3Z05jenJkRzhpIiwiZXhwIjoxNjY4MTgzMDM2fQ.VU3qLwTJ9nlXnomKCdk4y5UcgszGEO_zlvE7w5mWWajeBMwKLo-zw7LJEqUEajRksvssppR9SbVsjLSx-vDVc3DRhCo3jYTWKPT1T3wQrlkOSqLeIrAdnKdBDNBWKgrGJt_xcmXc3dZ3XNKf9L_F6Ex808rUlo6cem1mcPpKl1jCBDqKu1mAX7aDtZ65TTQZbGGhbG4HdnET-d1i5w4LunGN11UAHhDUW3n0SWWIBL27PiiUQONZttajhD5st6IngYLcjr93BYVyJmDF7-wm4WZlHSw2OnXIfbJcFXEd83uVv_Rej4UXjzZ0e6kHwzc2nvGvKSIFu3Nt7CabdR8CkA", 3599);
|
||||
@ -505,7 +535,7 @@ async function loadHeatmaps(model) {
|
||||
// This value can also be a room instead of a floor
|
||||
const floorName = "01 - Entry Level";
|
||||
dataVizExtn.renderSurfaceShading(floorName, sensorType, getSensorValue);
|
||||
}
|
||||
}
|
||||
|
||||
function setTransparentBuilding() {
|
||||
//allDbIdsStr.forEach((dbId) => {
|
||||
@ -563,7 +593,7 @@ function changeColor(nodeId) {//電梯變綠色
|
||||
instanceTree.enumNodeChildren(nodeId, function (chiNodeId) {
|
||||
var color = new THREE.Vector4(0, 1, 0, 1);
|
||||
viewer.setThemingColor(chiNodeId, color);
|
||||
},true)
|
||||
}, true)
|
||||
}
|
||||
|
||||
function hideColor(nodeId) {//顏色改成透明
|
||||
@ -571,8 +601,8 @@ function hideColor(nodeId) {//顏色改成透明
|
||||
instanceTree.enumNodeChildren(nodeId, function (chiNodeId) {
|
||||
var color = new THREE.Vector4(0, 1, 0, 0);
|
||||
viewer.setThemingColor(chiNodeId, color);
|
||||
},true)
|
||||
|
||||
}, true)
|
||||
|
||||
}
|
||||
|
||||
//------------------ 紀錄熱點座標 ---------------
|
||||
|
@ -17,6 +17,13 @@ var common = {
|
||||
SysErr: "系統內部發生錯誤,請聯繫系統管理員"
|
||||
}
|
||||
var objSendData = { Data: null };
|
||||
var initAreaTag = "TPE";
|
||||
var n4Sup = "Mitsubishi_Sup";
|
||||
var forgeTokenBase = {
|
||||
url: baseApiUrl + '/api/forge/oauth/token',
|
||||
res_access_token: ["dictionary", "access_token"],
|
||||
res_expires_in: ["dictionary", "expires_in"]
|
||||
};
|
||||
|
||||
//重新轉址 for Niagara4
|
||||
var temp_cuurent_Url_pathname = window.location.pathname.split("/").slice(0, 3);
|
||||
|
Loading…
Reference in New Issue
Block a user