[前台] 各樓層隱藏天花板 | 運維維修 異常 error_code 修正

This commit is contained in:
Celeste 2023-03-13 12:00:31 +08:00
parent f528ab8737
commit 7c6e0b6411
4 changed files with 1335 additions and 1233 deletions

View File

@ -1499,7 +1499,7 @@
$.each(res.data, function (i, v) { $.each(res.data, function (i, v) {
msg = v.msgText != null ? ($.trim(v.msgText.toString()).length > 0 ? v.msgText.split(':')[0] : '') : ''; msg = v.msgText != null ? ($.trim(v.msgText.toString()).length > 0 ? v.msgText.split(':')[0] : '') : '';
strHtml += `<option value=${v.uuid}>${v.uuid}</option>`; strHtml += `<option value=${v.uuid}>${v.uuid.split("-")[0]}</option>`;
}); });
if (res.count > 0) if (res.count > 0)
$(pageAct.work_type == '1' ? '#inpErrCode' : '#inpErrCode_2').html(strHtml); $(pageAct.work_type == '1' ? '#inpErrCode' : '#inpErrCode_2').html(strHtml);

View File

@ -46,8 +46,10 @@
}); });
initChart(); initChart();
getFloData(); getFloData();
getFloData();
if (pageAct.sysSubTag !== "L1") {
subDevice(); subDevice();
}
}) })
onEvent("click", "#resChartZoom", function () { onEvent("click", "#resChartZoom", function () {
@ -87,7 +89,6 @@
//currentData = selected_floor_objs[0].device; //currentData = selected_floor_objs[0].device;
currentData = $.map(devList, function (item) { currentData = $.map(devList, function (item) {
//資料處理 //資料處理
if (selected_floor.device_number != undefined if (selected_floor.device_number != undefined
&& selected_floor.device_number != null && selected_floor.device_number != null
@ -109,6 +110,7 @@
&& item.device_nodes != null && item.device_nodes != null
&& item.device_nodes.length > 0) { && item.device_nodes.length > 0) {
console.log("燈", item, selected_floor)
if (item.device_master_number == selected_floor.device_master) { if (item.device_master_number == selected_floor.device_master) {
//var datatable_data = { //var datatable_data = {
// device_full_name: item.full_name, // device_full_name: item.full_name,
@ -152,8 +154,9 @@
} }
return item; return item;
}); });
console.log("currentData", currentData)
if (currentData == null || currentData.length == 0) { if (currentData == null || currentData.length == 0) {
this.currentData = []; currentData = [];
} }
// myBaja.setPrepareSubscribeDevices(currentData); // myBaja.setPrepareSubscribeDevices(currentData);
@ -187,6 +190,7 @@
// animationDurationUpdate: 1500, // animationDurationUpdate: 1500,
tooltip: { tooltip: {
formatter: function (params) { formatter: function (params) {
console.log("params", params)
if (params.data.device_node_guid != undefined && params.data.device_node_guid != null && params.data.device_node_guid != "") { if (params.data.device_node_guid != undefined && params.data.device_node_guid != null && params.data.device_node_guid != "") {
return `<div > return `<div >
名稱:${params.data.device_node_full_name}<br> 名稱:${params.data.device_node_full_name}<br>
@ -206,7 +210,7 @@
map: 'floor_svg', map: 'floor_svg',
roam: true, roam: true,
scaleLimit: { //限制放大縮小倍數 scaleLimit: { //限制放大縮小倍數
max: 32, max: 16,
min: 1 min: 1
}, },
layoutSize: '100%', layoutSize: '100%',
@ -220,7 +224,7 @@
coordinateSystem: 'geo', coordinateSystem: 'geo',
geoIndex: 0, geoIndex: 0,
symbol: 'circle', symbol: 'circle',
symbolSize: 10, symbolSize: 20,
symbolOffset: [10, 10], symbolOffset: [10, 10],
label: { label: {
show: false show: false
@ -232,7 +236,7 @@
type: 'scatter', type: 'scatter',
coordinateSystem: 'geo', coordinateSystem: 'geo',
geoIndex: 0, geoIndex: 0,
symbolSize: 30, symbolSize: 50,
label: { label: {
formatter: '{b}', formatter: '{b}',
position: 'bottom', position: 'bottom',
@ -256,7 +260,7 @@
coordinateSystem: 'geo', coordinateSystem: 'geo',
geoIndex: 0, geoIndex: 0,
showEffectOn: 'render', showEffectOn: 'render',
symbolSize: 30, symbolSize: 50,
label: { label: {
formatter: '{b}', formatter: '{b}',
position: 'bottom', position: 'bottom',
@ -280,7 +284,7 @@
coordinateSystem: 'geo', coordinateSystem: 'geo',
geoIndex: 0, geoIndex: 0,
symbol: 'circle', symbol: 'circle',
symbolSize: 10, symbolSize: 20,
symbolOffset: [10, 10], symbolOffset: [10, 10],
label: { label: {
show: false show: false
@ -292,7 +296,7 @@
type: 'scatter', type: 'scatter',
coordinateSystem: 'geo', coordinateSystem: 'geo',
geoIndex: 0, geoIndex: 0,
symbolSize: 30, symbolSize: 50,
label: { label: {
formatter: '{b}', formatter: '{b}',
position: 'bottom', position: 'bottom',
@ -476,13 +480,18 @@
} }
if (data.point_name == "SSC") { if (data.point_name == "SSC" && pageAct.sysSubTag === "L1") {
const lightOn = data.value.includes("true") const lightOn = data.value.includes("true")
setLightOpenOrClose(lightOn, matchDevice.device_guid); setLightOpenOrClose(lightOn, matchDevice.device_guid);
if (lightOn) { if (lightOn) {
//console.log(matchDevice)
setLightValues(matchDevice.device_guid, 200, 0xe1cf18); setLightValues(matchDevice.device_guid, 200, 0xe1cf18);
console.log("SSC", matchDevice.device_number, 40)
heatMap?.changeTemp(matchDevice.device_number, 40);
} else { } else {
setLightValues(matchDevice.device_guid, 0, 0xffffff); setLightValues(matchDevice.device_guid, 0, 0xffffff);
// console.log("SSC",matchDevice.device_number, 0)
heatMap?.changeTemp(matchDevice.device_number, 0);
} }
} }
@ -653,7 +662,7 @@
// 重設平面圖設備資料 // 重設平面圖設備資料
function resetData() { function resetData() {
console.log("reset", currentData)
const scatter_symbol_convertData = function (data, zoom) { //正常、關閉排除CCVT(圓點) const scatter_symbol_convertData = function (data, zoom) { //正常、關閉排除CCVT(圓點)
let res = [], temp = []; let res = [], temp = [];
data.forEach(function (item, index) { data.forEach(function (item, index) {
@ -840,6 +849,7 @@
item_node.device_image = item.device_image; item_node.device_image = item.device_image;
temp.push(item_node); temp.push(item_node);
}); });
} else { } else {
temp.push(item) temp.push(item)
} }
@ -1095,7 +1105,12 @@
nextFloor = nextFloor.split("U")[1]; nextFloor = nextFloor.split("U")[1];
} }
getLevelsData(curFloTag, nextFloor, function () { getLevelsData(curFloTag, nextFloor, function () {
viewer.model.search("天花板", (nodeIds) => {
// console.log("2",nodeIds)
viewer.hide(nodeIds)
}, (e) => { console.log(e) })
$(loadEle).Loading("close"); $(loadEle).Loading("close");
}); });
setHeatMap(); setHeatMap();
@ -1120,7 +1135,7 @@
} }
function setHeatMap() { function setHeatMap() {
if (pageAct.sysMainTag !== "LT" && pageAct.sysSubTag !== "M12") { if (pageAct.sysSubTag !== "M12") {
devices = currentData.map(x => { devices = currentData.map(x => {
return { return {
roomDbId: !isNaN(parseInt(x.room_dbid)) ? parseInt(x.room_dbid) : -1, roomDbId: !isNaN(parseInt(x.room_dbid)) ? parseInt(x.room_dbid) : -1,
@ -1139,9 +1154,9 @@
heatMap = new ADHeatMaps(option); heatMap = new ADHeatMaps(option);
heatMap.onComplete = () => { heatMap.onComplete = () => {
$.each(currentData, (idx, dev) => { $.each(currentData, (idx, dev) => {
heatMap.changeTemp(dev.device_number, dev._temp || 0); heatMap.changeTemp(dev.device_number, dev._temp || 0);
subDevice();
}) })
} }
} }
@ -1230,7 +1245,7 @@
let option = floChart.getOption(); let option = floChart.getOption();
option.series.forEach(function (series) { option.series.forEach(function (series) {
series.data.forEach(function (point) { series.data.forEach(function (point) {
point.symbolSize = 10; point.symbolSize = 20;
}); });
}); });
floChart.setOption(option); floChart.setOption(option);
@ -1243,7 +1258,7 @@
option.series.forEach(function (series) { option.series.forEach(function (series) {
series.data.forEach(function (point) { series.data.forEach(function (point) {
if (point.device_guid == devGuid) { if (point.device_guid == devGuid) {
point.symbolSize = 10; point.symbolSize = 20;
} }
}); });
}); });

View File

@ -8,8 +8,8 @@ var myDataList;
var lightDataList; var lightDataList;
var lightList = [];//燈光清單 var lightList = [];//燈光清單
var levels;//剖面用 var levels;//剖面用
var lowerIdx;//剖面的下方樓層 var lowerIdx = 0;//剖面的下方樓層
var upperIdx;//剖面的上方樓層 var upperIdx = 0;//剖面的上方樓層
function launchViewer(urn, callback, failCallback, _selector = "#forgeViewer") { function launchViewer(urn, callback, failCallback, _selector = "#forgeViewer") {
selector = _selector; selector = _selector;
@ -340,12 +340,12 @@ class elevator3D {
} }
} }
function onDocumentLoadSuccess(doc, eleOption) { function onDocumentLoadSuccess(doc, eleOption) {
var viewables = doc.getRoot().getDefaultGeometry(); var viewables = doc.getRoot().getDefaultGeometry();
viewer.loadDocumentNode(doc, viewables).then(i => { viewer.loadDocumentNode(doc, viewables).then(i => {
// documented loaded, any action? // documented loaded, any action?
}); });
// viewer.addEventListener(Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT, (args) => { // viewer.addEventListener(Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT, (args) => {
// var currSelection = viewer.getSelection(); // var currSelection = viewer.getSelection();
@ -559,6 +559,7 @@ class ADHeatMaps {
this.roomDbIds = []; //房間 dbId this.roomDbIds = []; //房間 dbId
this.model = null; this.model = null;
this.dataVizExtn = null; this.dataVizExtn = null;
this.shadingData = null;
this.onComplete = option.onComplete ?? null; this.onComplete = option.onComplete ?? null;
this.init(); this.init();
} }
@ -571,54 +572,78 @@ class ADHeatMaps {
this.model = viewer.model; this.model = viewer.model;
this.addHeatMaps() this.addHeatMaps()
} }
async addHeatMaps() { async addHeatMaps() {
const { const {
SurfaceShadingData, SurfaceShadingData,
SurfaceShadingPoint, SurfaceShadingPoint,
SurfaceShadingNode, SurfaceShadingNode,
SurfaceShadingGroup
} = Autodesk.DataVisualization.Core; } = Autodesk.DataVisualization.Core;
// test
const shadingGroup = new SurfaceShadingGroup('iot-heatmap');
const rooms = new Map();
for (const { id, roomDbId, position, sensorTypes } of this.devices) {
// console.log(id, roomDbId, position, sensorTypes)
if (!id || roomDbId == -1) {
continue;
}
if (!rooms.has(roomDbId)) {
const room = new SurfaceShadingNode(id, roomDbId);
shadingGroup.addChild(room);
rooms.set(roomDbId, room);
}
const room = rooms.get(roomDbId);
room.addPoint(new SurfaceShadingPoint(id, position, sensorTypes));
}
this.shadingData = new SurfaceShadingData();
this.shadingData.addChild(shadingGroup)
this.shadingData.initialize(this.model);
await this.dataVizExtn.setupSurfaceShading(this.model, this.shadingData);
this.dataVizExtn.renderSurfaceShading('iot-heatmap', "temperature", this.getSensorValue.bind(this));
//let nodeIds = await getNodeIdByDbIds(this.checkNodeString); //let nodeIds = await getNodeIdByDbIds(this.checkNodeString);
//nodeIds = Array.from(nodeIds); //nodeIds = Array.from(nodeIds);
//nodeIds = nodeIds.map(x => { return { room: x[0] , nodeId: x[1]} }); //nodeIds = nodeIds.map(x => { return { room: x[0] , nodeId: x[1]} });
this.roomDbIds = this.devices.filter(x => x.roomDbId != -1).map(x => x.roomDbId).Distinct(); // this.roomDbIds = this.devices.filter(x => x.roomDbId != -1).map(x => x.roomDbId).Distinct();
// 建立一個 SurfaceShadingData 物件,並將 SurfaceShadingNode 加入到該物件中 // // 建立一個 SurfaceShadingData 物件,並將 SurfaceShadingNode 加入到該物件中
const heatmapData = new SurfaceShadingData(); // const heatmapData = new SurfaceShadingData();
$.each(this.roomDbIds, (idx, rDbid) => { // $.each(this.roomDbIds, (idx, rDbid) => {
// 建立一個名為 "Room Panel" 的 SurfaceShadingNode 物件,並將房間的模型給傳入,只在該房間呈現溫度 // // 建立一個名為 "Room Panel" 的 SurfaceShadingNode 物件,並將房間的模型給傳入,只在該房間呈現溫度
const shadingNode = new SurfaceShadingNode("RoomPanel" + rDbid, rDbid); // const shadingNode = new SurfaceShadingNode("RoomPanel" + rDbid, rDbid);
// 遍歷每個設備,建立一個 SurfaceShadingPoint 物件並加入到 SurfaceShadingNode 中,透過這些設備渲染溫度 // // 遍歷每個設備,建立一個 SurfaceShadingPoint 物件並加入到 SurfaceShadingNode 中,透過這些設備渲染溫度
this.devices.filter(x => x.roomDbId == rDbid).forEach((device) => { // this.devices.filter(x => x.roomDbId == rDbid).forEach((device) => {
const shadingPoint = new SurfaceShadingPoint( // const shadingPoint = new SurfaceShadingPoint(
device.id, // device.id,
undefined, // undefined,
device.sensorTypes // device.sensorTypes
); // );
shadingPoint.positionFromDBId(this.model, device.roomDbId) // shadingPoint.positionFromDBId(this.model, device.roomDbId)
shadingNode.addPoint(shadingPoint); // shadingNode.addPoint(shadingPoint);
// device.temp = 0; // // device.temp = 0;
}); // });
heatmapData.addChild(shadingNode); // heatmapData.addChild(shadingNode);
}) // })
// 將資料初始化並顯示在模型上 // // 將資料初始化並顯示在模型上
heatmapData.initialize(this.model); // heatmapData.initialize(this.model);
// 對模型做表面顏色的渲染 // // 對模型做表面顏色的渲染
await this.dataVizExtn.setupSurfaceShading(this.model, heatmapData); // await this.dataVizExtn.setupSurfaceShading(this.model, heatmapData);
// 對 "temperature" 的溫度設定兩種顏色:紅色和藍色 // // 對 "temperature" 的溫度設定兩種顏色:紅色和藍色
this.dataVizExtn.registerSurfaceShadingColors("temperature", [0x0000ff, 0x00ff00, 0xffff00, 0xff0000]); // this.dataVizExtn.registerSurfaceShadingColors("temperature", [0x0000ff, 0x00ff00, 0xffff00, 0xff0000]);
$.each(this.roomDbIds, (idx, rDbid) => { // $.each(this.roomDbIds, (idx, rDbid) => {
this.dataVizExtn.renderSurfaceShading("RoomPanel" + rDbid, "temperature", this.getSensorValue.bind(this)); // this.dataVizExtn.renderSurfaceShading("RoomPanel" + rDbid, "temperature", this.getSensorValue.bind(this));
}) // })
/*this.changeTemp(this.tempVal);*/ // /*this.changeTemp(this.tempVal);*/
this.onComplete ? this.onComplete() : ""; this.onComplete ? this.onComplete() : "";
} }
@ -629,7 +654,7 @@ class ADHeatMaps {
} }
// 改變溫度 // 改變溫度
changeTemp = function (devId, temp) { changeTemp = async function (devId, temp) {
this.tempVal = temp; this.tempVal = temp;
// 透過 device id 取得 roomDbId // 透過 device id 取得 roomDbId
this.devices.forEach((dev) => { this.devices.forEach((dev) => {
@ -637,9 +662,18 @@ class ADHeatMaps {
dev.temp = temp; dev.temp = temp;
} }
}) })
$.each(this.roomDbIds, async (idx, rDbid) => {
this.dataVizExtn.renderSurfaceShading("RoomPanel" + rDbid, "temperature", this.getSensorValue.bind(this)); if (!this.shadingData) {
}) await this.addHeatMaps();
this.dataVizExtn.renderSurfaceShading('iot-heatmap', "temperature", this.getSensorValue.bind(this));
}
else {
this.dataVizExtn.updateSurfaceShading(this.getSensorValue.bind(this));
}
// $.each(this.roomDbIds, async (idx, rDbid) => {
// this.dataVizExtn.renderSurfaceShading("RoomPanel" + rDbid, "temperature", this.getSensorValue.bind(this));
// })
//if (rDbid != null) { //if (rDbid != null) {
// // 取得新的溫度值 // // 取得新的溫度值
// let getSensorValue = (device, sensorType) => { // let getSensorValue = (device, sensorType) => {
@ -740,10 +774,11 @@ async function getLightData(data) {
} }
async function testNewLight(dataList) { async function testNewLight(dataList) {
console.log("dataList", dataList)
dataList.forEach((myData, index) => { dataList.forEach((myData, index) => {
const position = JSON.parse(myData.device_coordinate_3d); const position = JSON.parse(myData.device_coordinate_3d);
if (lightList.findIndex(x => x.device_guid == myData.device_guid) == -1) { if (lightList.findIndex(x => x.device_guid == myData.device_guid) == -1) {
lightList.push({ dbid: myData.forge_dbid, device_guid: myData.device_guid, lightObject: new THREE.SpotLight(0xe1cf18, 0, 20, 0.6, 0.5, 10) }); lightList.push({ dbid: myData.forge_dbid, device_guid: myData.device_guid, lightObject: new THREE.SpotLight(0xe1cf18, 10, 200, 1, 1, 2) });
} }
lightList[index].lightObject.position.set(position.x, position.y, position.z); lightList[index].lightObject.position.set(position.x, position.y, position.z);
@ -917,6 +952,7 @@ async function changeScaleForHotspot(dbId, type = true) {
//------------------ 熱圖 ------------------------------- //------------------ 熱圖 -------------------------------
async function loadHeatmaps(model) { async function loadHeatmaps(model) {
//console.log("熱圖 loadHeat")
const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization"); const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
//取三個空調設備的位置打點 //取三個空調設備的位置打點
@ -1082,28 +1118,73 @@ async function loadHeatmapForFloor() {
} }
//------------ 剖面 ---------------------- //------------ 剖面 ----------------------
async function getRemoteLevels() {
const aecData = await Autodesk.Viewing.Document.getAecModelData(this.viewer.model.getDocumentNode());
if (!aecData || !aecData.levels) return null;
const levels2 = aecData.levels; function findLevels(model) {
levels2.sort((a, b) => b.elevation - a.elevation); return new Promise((resolve, reject) => {
return levels2; model.search("layer", (nodeIds) => {
let levels = []
const tree = viewer.model.getInstanceTree();
for (let i = 0; i < nodeIds.length; i++) {
const dbId = nodeIds[i];
const name = tree.getNodeName(dbId);
if (!name || name.includes('<沒有層級>')) continue;
levels.push({
guid: dbId,
name,
dbId,
extension: {
buildingStory: true,
structure: false,
computationHeight: 0,
groundPlane: false,
hasAssociatedViewPlans: false,
}
});
}
resolve(levels)
}, (e) => { reject(e) })
});
}
async function getRemoteLevels() {
let aecData = await Autodesk.Viewing.Document.getAecModelData(this.viewer.model.getDocumentNode());
let levels;
if (!aecData || !aecData.levels) {
const levelExt = await viewer.loadExtension('Autodesk.AEC.LevelsExtension');
levelExt.setAecModelData(undefined, viewer.model); //!<<< Clear before reset
levels = await findLevels(viewer.model)
aecdata = Autodesk.AEC.AecModelData.computeLevels(levels, viewer.model); //!<<< Rebuild aec model data
} else {
levels = aecData.levels;
}
levels.sort((a, b) => b.elevation - a.elevation);
return levels;
} }
async function getLevelsData(lowerFloor, upperFloor, callback = null) { async function getLevelsData(lowerFloor, upperFloor, callback = null) {
console.log(lowerFloor, upperFloor)
// 樓層正規化 取得樓層 // 樓層正規化 取得樓層
const floorRegex = /[\d|\w]+F/gmi; const floorRegex = /[\d|\w]+F/gmi;
const floorRegex2 = /^FL[\d|\w]+/gmi;
const data = await this.getRemoteLevels(); const data = await this.getRemoteLevels();
console.log(data)
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
let name = data[i].name?.match(floorRegex); let name = data[i].name?.match(floorRegex) || data[i].name?.match(floorRegex2)[0].split("L")[1] + "F";
if (name && name[0] == lowerFloor) { if (name && name[0] == lowerFloor || name == lowerFloor) {
lowerIdx = i; lowerIdx = i;
} }
if (name && name[0] == upperFloor) { if (name && name[0] == upperFloor || name == upperFloor) {
if (i > upperIdx && lowerFloor == upperFloor) {
} else {
upperIdx = i; upperIdx = i;
} }
} }
}
this.levels = data; this.levels = data;
profile(callback); profile(callback);
} }
@ -1118,7 +1199,7 @@ function getCutPlaneParam(idx, n) {
const globalOffset = model.getData().globalOffset; const globalOffset = model.getData().globalOffset;
const units = model.getUnitString(); const units = model.getUnitString();
const elevRaw = Autodesk.Viewing.Private.convertUnits('ft', units, 1, level.elevation); const elevRaw = Autodesk.Viewing.Private.convertUnits('ft', units, 1, level.elevation);
console.log(globalOffset, units, elevRaw)
let d = elevRaw - globalOffset.z - 0.5; let d = elevRaw - globalOffset.z - 0.5;
if (n == 1) if (n == 1)
d = -1 * d; d = -1 * d;

View File

@ -7,8 +7,8 @@ var baseImgUrl = "https://localhost:44376"; // 本地開發用
//var baseImgUrl = "http://220.132.206.5:8848"; // production 用 //var baseImgUrl = "http://220.132.206.5:8848"; // production 用
// WSP // WSP
//var baseApiUrl = "http://220.132.206.5"; // production 用 // var baseApiUrl = "http://220.132.206.5:8001"; // production 用
//var baseImgUrl = "http://220.132.206.5:8849"; // production 用 // var baseImgUrl = "http://220.132.206.5:8849"; // production 用
//var baseApiUrl = "http://localhost"; //var baseApiUrl = "http://localhost";
//var baseImgUrl = "http://localhost:8848"; //var baseImgUrl = "http://localhost:8848";
@ -31,11 +31,17 @@ var common = {
} }
var objSendData = { Data: null }; var objSendData = { Data: null };
// Mitsubishi // Mitsubishi
var elevatorShow = true
var port = "";
var initAreaTag = "TPE"; var initAreaTag = "TPE";
var n4Sup = "Mitsubishi_JACE8000"; var n4Sup = "Mitsubishi_JACE8000";
// WSP // WSP
//var initAreaTag = "NTPC"; // var elevatorShow = false
//var n4Sup = "Banqiao"; // var port = "4912";
// var initAreaTag = "NTPC";
// var n4Sup = "WSP_Supervisor";
var forgeTokenBase = { var forgeTokenBase = {
url: baseApiUrl + '/api/forge/oauth/token', url: baseApiUrl + '/api/forge/oauth/token',
res_access_token: ["dictionary", "access_token"], res_access_token: ["dictionary", "access_token"],