[前台] 各樓層隱藏天花板 | 運維維修 異常 error_code 修正
This commit is contained in:
		
							parent
							
								
									f528ab8737
								
							
						
					
					
						commit
						7c6e0b6411
					
				@ -1499,7 +1499,7 @@
 | 
			
		||||
 | 
			
		||||
		$.each(res.data, function (i, v) {
 | 
			
		||||
			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)
 | 
			
		||||
			$(pageAct.work_type == '1' ? '#inpErrCode' : '#inpErrCode_2').html(strHtml);
 | 
			
		||||
 | 
			
		||||
@ -46,8 +46,10 @@
 | 
			
		||||
        });
 | 
			
		||||
        initChart();
 | 
			
		||||
        getFloData();
 | 
			
		||||
 | 
			
		||||
        getFloData();
 | 
			
		||||
        if (pageAct.sysSubTag !== "L1") {
 | 
			
		||||
            subDevice();
 | 
			
		||||
        }
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    onEvent("click", "#resChartZoom", function () {
 | 
			
		||||
@ -87,7 +89,6 @@
 | 
			
		||||
        //currentData = selected_floor_objs[0].device;
 | 
			
		||||
 | 
			
		||||
        currentData = $.map(devList, function (item) {
 | 
			
		||||
 | 
			
		||||
            //資料處理
 | 
			
		||||
            if (selected_floor.device_number != undefined
 | 
			
		||||
                && selected_floor.device_number != null
 | 
			
		||||
@ -109,6 +110,7 @@
 | 
			
		||||
                && item.device_nodes != null
 | 
			
		||||
                && item.device_nodes.length > 0) {
 | 
			
		||||
 | 
			
		||||
                console.log("燈", item, selected_floor)
 | 
			
		||||
                if (item.device_master_number == selected_floor.device_master) {
 | 
			
		||||
                    //var datatable_data = {
 | 
			
		||||
                    //    device_full_name: item.full_name,
 | 
			
		||||
@ -152,8 +154,9 @@
 | 
			
		||||
            }
 | 
			
		||||
            return item;
 | 
			
		||||
        });
 | 
			
		||||
        console.log("currentData", currentData)
 | 
			
		||||
        if (currentData == null || currentData.length == 0) {
 | 
			
		||||
      this.currentData = [];
 | 
			
		||||
            currentData = [];
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // myBaja.setPrepareSubscribeDevices(currentData);
 | 
			
		||||
@ -187,6 +190,7 @@
 | 
			
		||||
                // animationDurationUpdate: 1500,
 | 
			
		||||
                tooltip: {
 | 
			
		||||
                    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 != "") {
 | 
			
		||||
                            return `<div >
 | 
			
		||||
              名稱:${params.data.device_node_full_name}<br>
 | 
			
		||||
@ -206,7 +210,7 @@
 | 
			
		||||
                    map: 'floor_svg',
 | 
			
		||||
                    roam: true,
 | 
			
		||||
                    scaleLimit: {  //限制放大縮小倍數
 | 
			
		||||
            max: 32,
 | 
			
		||||
                        max: 16,
 | 
			
		||||
                        min: 1
 | 
			
		||||
                    },
 | 
			
		||||
                    layoutSize: '100%',
 | 
			
		||||
@ -220,7 +224,7 @@
 | 
			
		||||
                        coordinateSystem: 'geo',
 | 
			
		||||
                        geoIndex: 0,
 | 
			
		||||
                        symbol: 'circle',
 | 
			
		||||
            symbolSize: 10,
 | 
			
		||||
                        symbolSize: 20,
 | 
			
		||||
                        symbolOffset: [10, 10],
 | 
			
		||||
                        label: {
 | 
			
		||||
                            show: false
 | 
			
		||||
@ -232,7 +236,7 @@
 | 
			
		||||
                        type: 'scatter',
 | 
			
		||||
                        coordinateSystem: 'geo',
 | 
			
		||||
                        geoIndex: 0,
 | 
			
		||||
            symbolSize: 30,
 | 
			
		||||
                        symbolSize: 50,
 | 
			
		||||
                        label: {
 | 
			
		||||
                            formatter: '{b}',
 | 
			
		||||
                            position: 'bottom',
 | 
			
		||||
@ -256,7 +260,7 @@
 | 
			
		||||
                        coordinateSystem: 'geo',
 | 
			
		||||
                        geoIndex: 0,
 | 
			
		||||
                        showEffectOn: 'render',
 | 
			
		||||
            symbolSize: 30,
 | 
			
		||||
                        symbolSize: 50,
 | 
			
		||||
                        label: {
 | 
			
		||||
                            formatter: '{b}',
 | 
			
		||||
                            position: 'bottom',
 | 
			
		||||
@ -280,7 +284,7 @@
 | 
			
		||||
                        coordinateSystem: 'geo',
 | 
			
		||||
                        geoIndex: 0,
 | 
			
		||||
                        symbol: 'circle',
 | 
			
		||||
            symbolSize: 10,
 | 
			
		||||
                        symbolSize: 20,
 | 
			
		||||
                        symbolOffset: [10, 10],
 | 
			
		||||
                        label: {
 | 
			
		||||
                            show: false
 | 
			
		||||
@ -292,7 +296,7 @@
 | 
			
		||||
                        type: 'scatter',
 | 
			
		||||
                        coordinateSystem: 'geo',
 | 
			
		||||
                        geoIndex: 0,
 | 
			
		||||
            symbolSize: 30,
 | 
			
		||||
                        symbolSize: 50,
 | 
			
		||||
                        label: {
 | 
			
		||||
                            formatter: '{b}',
 | 
			
		||||
                            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")
 | 
			
		||||
                setLightOpenOrClose(lightOn, matchDevice.device_guid);
 | 
			
		||||
                if (lightOn) {
 | 
			
		||||
                    //console.log(matchDevice)
 | 
			
		||||
                    setLightValues(matchDevice.device_guid, 200, 0xe1cf18);
 | 
			
		||||
                    console.log("SSC", matchDevice.device_number, 40)
 | 
			
		||||
                    heatMap?.changeTemp(matchDevice.device_number, 40);
 | 
			
		||||
                } else {
 | 
			
		||||
                    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() {
 | 
			
		||||
 | 
			
		||||
        console.log("reset", currentData)
 | 
			
		||||
        const scatter_symbol_convertData = function (data, zoom) { //正常、關閉排除CCVT(圓點)
 | 
			
		||||
            let res = [], temp = [];
 | 
			
		||||
            data.forEach(function (item, index) {
 | 
			
		||||
@ -840,6 +849,7 @@
 | 
			
		||||
                                item_node.device_image = item.device_image;
 | 
			
		||||
                                temp.push(item_node);
 | 
			
		||||
                            });
 | 
			
		||||
 | 
			
		||||
                        } else {
 | 
			
		||||
                            temp.push(item)
 | 
			
		||||
                        }
 | 
			
		||||
@ -1095,7 +1105,12 @@
 | 
			
		||||
                nextFloor = nextFloor.split("U")[1];
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            getLevelsData(curFloTag, nextFloor, function () {
 | 
			
		||||
                viewer.model.search("天花板", (nodeIds) => {
 | 
			
		||||
                    // console.log("2",nodeIds)
 | 
			
		||||
                    viewer.hide(nodeIds)
 | 
			
		||||
                }, (e) => { console.log(e) })
 | 
			
		||||
                $(loadEle).Loading("close");
 | 
			
		||||
            });
 | 
			
		||||
            setHeatMap();
 | 
			
		||||
@ -1120,7 +1135,7 @@
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function setHeatMap() {
 | 
			
		||||
    if (pageAct.sysMainTag !== "LT" && pageAct.sysSubTag !== "M12") {
 | 
			
		||||
        if (pageAct.sysSubTag !== "M12") {
 | 
			
		||||
            devices = currentData.map(x => {
 | 
			
		||||
                return {
 | 
			
		||||
                    roomDbId: !isNaN(parseInt(x.room_dbid)) ? parseInt(x.room_dbid) : -1,
 | 
			
		||||
@ -1139,9 +1154,9 @@
 | 
			
		||||
 | 
			
		||||
            heatMap = new ADHeatMaps(option);
 | 
			
		||||
            heatMap.onComplete = () => {
 | 
			
		||||
 | 
			
		||||
                $.each(currentData, (idx, dev) => {
 | 
			
		||||
                    heatMap.changeTemp(dev.device_number, dev._temp || 0);
 | 
			
		||||
                    subDevice();
 | 
			
		||||
                })
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@ -1230,7 +1245,7 @@
 | 
			
		||||
        let option = floChart.getOption();
 | 
			
		||||
        option.series.forEach(function (series) {
 | 
			
		||||
            series.data.forEach(function (point) {
 | 
			
		||||
        point.symbolSize = 10;
 | 
			
		||||
                point.symbolSize = 20;
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
        floChart.setOption(option);
 | 
			
		||||
@ -1243,7 +1258,7 @@
 | 
			
		||||
        option.series.forEach(function (series) {
 | 
			
		||||
            series.data.forEach(function (point) {
 | 
			
		||||
                if (point.device_guid == devGuid) {
 | 
			
		||||
          point.symbolSize = 10;
 | 
			
		||||
                    point.symbolSize = 20;
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
@ -8,8 +8,8 @@ var myDataList;
 | 
			
		||||
var lightDataList;
 | 
			
		||||
var lightList = [];//燈光清單
 | 
			
		||||
var levels;//剖面用
 | 
			
		||||
var lowerIdx;//剖面的下方樓層
 | 
			
		||||
var upperIdx;//剖面的上方樓層
 | 
			
		||||
var lowerIdx = 0;//剖面的下方樓層
 | 
			
		||||
var upperIdx = 0;//剖面的上方樓層
 | 
			
		||||
 | 
			
		||||
function launchViewer(urn, callback, failCallback, _selector = "#forgeViewer") {
 | 
			
		||||
    selector = _selector;
 | 
			
		||||
@ -340,12 +340,12 @@ class elevator3D {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function onDocumentLoadSuccess(doc, eleOption) {
 | 
			
		||||
 | 
			
		||||
    var viewables = doc.getRoot().getDefaultGeometry();
 | 
			
		||||
    viewer.loadDocumentNode(doc, viewables).then(i => {
 | 
			
		||||
        // documented loaded, any action?
 | 
			
		||||
 | 
			
		||||
    });
 | 
			
		||||
    // viewer.addEventListener(Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT, (args) => {
 | 
			
		||||
    //     var currSelection = viewer.getSelection();
 | 
			
		||||
@ -559,6 +559,7 @@ class ADHeatMaps {
 | 
			
		||||
        this.roomDbIds = [];  //房間 dbId
 | 
			
		||||
        this.model = null;
 | 
			
		||||
        this.dataVizExtn = null;
 | 
			
		||||
        this.shadingData = null;
 | 
			
		||||
        this.onComplete = option.onComplete ?? null;
 | 
			
		||||
        this.init();
 | 
			
		||||
    }
 | 
			
		||||
@ -571,54 +572,78 @@ class ADHeatMaps {
 | 
			
		||||
        this.model = viewer.model;
 | 
			
		||||
        this.addHeatMaps()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    async addHeatMaps() {
 | 
			
		||||
        const {
 | 
			
		||||
            SurfaceShadingData,
 | 
			
		||||
            SurfaceShadingPoint,
 | 
			
		||||
            SurfaceShadingNode,
 | 
			
		||||
            SurfaceShadingGroup
 | 
			
		||||
        } = 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);
 | 
			
		||||
        //nodeIds = Array.from(nodeIds);
 | 
			
		||||
        //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 加入到該物件中
 | 
			
		||||
        const heatmapData = new SurfaceShadingData();
 | 
			
		||||
        // // 建立一個 SurfaceShadingData 物件,並將 SurfaceShadingNode 加入到該物件中
 | 
			
		||||
        // const heatmapData = new SurfaceShadingData();
 | 
			
		||||
 | 
			
		||||
        $.each(this.roomDbIds, (idx, rDbid) => {
 | 
			
		||||
            // 建立一個名為 "Room Panel" 的 SurfaceShadingNode 物件,並將房間的模型給傳入,只在該房間呈現溫度
 | 
			
		||||
            const shadingNode = new SurfaceShadingNode("RoomPanel" + rDbid, rDbid);
 | 
			
		||||
        // $.each(this.roomDbIds, (idx, rDbid) => {
 | 
			
		||||
        //     // 建立一個名為 "Room Panel" 的 SurfaceShadingNode 物件,並將房間的模型給傳入,只在該房間呈現溫度
 | 
			
		||||
        //     const shadingNode = new SurfaceShadingNode("RoomPanel" + rDbid, rDbid);
 | 
			
		||||
 | 
			
		||||
            // 遍歷每個設備,建立一個 SurfaceShadingPoint 物件並加入到 SurfaceShadingNode 中,透過這些設備渲染溫度
 | 
			
		||||
            this.devices.filter(x => x.roomDbId == rDbid).forEach((device) => {
 | 
			
		||||
                const shadingPoint = new SurfaceShadingPoint(
 | 
			
		||||
                    device.id,
 | 
			
		||||
                    undefined,
 | 
			
		||||
                    device.sensorTypes
 | 
			
		||||
                );
 | 
			
		||||
                shadingPoint.positionFromDBId(this.model, device.roomDbId)
 | 
			
		||||
                shadingNode.addPoint(shadingPoint);
 | 
			
		||||
                // device.temp = 0;
 | 
			
		||||
            });
 | 
			
		||||
        //     // 遍歷每個設備,建立一個 SurfaceShadingPoint 物件並加入到 SurfaceShadingNode 中,透過這些設備渲染溫度
 | 
			
		||||
        //     this.devices.filter(x => x.roomDbId == rDbid).forEach((device) => {
 | 
			
		||||
        //         const shadingPoint = new SurfaceShadingPoint(
 | 
			
		||||
        //             device.id,
 | 
			
		||||
        //             undefined,
 | 
			
		||||
        //             device.sensorTypes
 | 
			
		||||
        //         );
 | 
			
		||||
        //         shadingPoint.positionFromDBId(this.model, device.roomDbId)
 | 
			
		||||
        //         shadingNode.addPoint(shadingPoint);
 | 
			
		||||
        //         // 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" 的溫度設定兩種顏色:紅色和藍色
 | 
			
		||||
        this.dataVizExtn.registerSurfaceShadingColors("temperature", [0x0000ff, 0x00ff00, 0xffff00, 0xff0000]);
 | 
			
		||||
        // // 對 "temperature" 的溫度設定兩種顏色:紅色和藍色
 | 
			
		||||
        // this.dataVizExtn.registerSurfaceShadingColors("temperature", [0x0000ff, 0x00ff00, 0xffff00, 0xff0000]);
 | 
			
		||||
 | 
			
		||||
        $.each(this.roomDbIds, (idx, rDbid) => {
 | 
			
		||||
            this.dataVizExtn.renderSurfaceShading("RoomPanel" + rDbid, "temperature", this.getSensorValue.bind(this));
 | 
			
		||||
        })
 | 
			
		||||
        // $.each(this.roomDbIds, (idx, rDbid) => {
 | 
			
		||||
        //     this.dataVizExtn.renderSurfaceShading("RoomPanel" + rDbid, "temperature", this.getSensorValue.bind(this));
 | 
			
		||||
        // })
 | 
			
		||||
 | 
			
		||||
        /*this.changeTemp(this.tempVal);*/
 | 
			
		||||
        //   /*this.changeTemp(this.tempVal);*/
 | 
			
		||||
        this.onComplete ? this.onComplete() : "";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -629,7 +654,7 @@ class ADHeatMaps {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // 改變溫度
 | 
			
		||||
    changeTemp = function (devId, temp) {
 | 
			
		||||
    changeTemp = async function (devId, temp) {
 | 
			
		||||
        this.tempVal = temp;
 | 
			
		||||
        // 透過 device id 取得 roomDbId
 | 
			
		||||
        this.devices.forEach((dev) => {
 | 
			
		||||
@ -637,9 +662,18 @@ class ADHeatMaps {
 | 
			
		||||
                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) {
 | 
			
		||||
        //    // 取得新的溫度值
 | 
			
		||||
        //    let getSensorValue = (device, sensorType) => {
 | 
			
		||||
@ -740,10 +774,11 @@ async function getLightData(data) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function testNewLight(dataList) {
 | 
			
		||||
    console.log("dataList", dataList)
 | 
			
		||||
    dataList.forEach((myData, index) => {
 | 
			
		||||
        const position = JSON.parse(myData.device_coordinate_3d);
 | 
			
		||||
        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);
 | 
			
		||||
@ -917,6 +952,7 @@ async function changeScaleForHotspot(dbId, type = true) {
 | 
			
		||||
 | 
			
		||||
//------------------ 熱圖 -------------------------------
 | 
			
		||||
async function loadHeatmaps(model) {
 | 
			
		||||
    //console.log("熱圖 loadHeat")
 | 
			
		||||
    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;
 | 
			
		||||
    levels2.sort((a, b) => b.elevation - a.elevation);
 | 
			
		||||
    return levels2;
 | 
			
		||||
function findLevels(model) {
 | 
			
		||||
    return new Promise((resolve, reject) => {
 | 
			
		||||
        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) {
 | 
			
		||||
    console.log(lowerFloor, upperFloor)
 | 
			
		||||
    // 樓層正規化 取得樓層
 | 
			
		||||
    const floorRegex = /[\d|\w]+F/gmi;
 | 
			
		||||
    const floorRegex2 = /^FL[\d|\w]+/gmi;
 | 
			
		||||
    const data = await this.getRemoteLevels();
 | 
			
		||||
    console.log(data)
 | 
			
		||||
    for (var i = 0; i < data.length; i++) {
 | 
			
		||||
        let name = data[i].name?.match(floorRegex);
 | 
			
		||||
        if (name && name[0] == lowerFloor) {
 | 
			
		||||
        let name = data[i].name?.match(floorRegex) || data[i].name?.match(floorRegex2)[0].split("L")[1] + "F";
 | 
			
		||||
        if (name && name[0] == lowerFloor || name == lowerFloor) {
 | 
			
		||||
            lowerIdx = i;
 | 
			
		||||
        }
 | 
			
		||||
        if (name && name[0] == upperFloor) {
 | 
			
		||||
        if (name && name[0] == upperFloor || name == upperFloor) {
 | 
			
		||||
            if (i > upperIdx && lowerFloor == upperFloor) {
 | 
			
		||||
 | 
			
		||||
            } else {
 | 
			
		||||
                upperIdx = i;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.levels = data;
 | 
			
		||||
    profile(callback);
 | 
			
		||||
}
 | 
			
		||||
@ -1118,7 +1199,7 @@ function getCutPlaneParam(idx, n) {
 | 
			
		||||
    const globalOffset = model.getData().globalOffset;
 | 
			
		||||
    const units = model.getUnitString();
 | 
			
		||||
    const elevRaw = Autodesk.Viewing.Private.convertUnits('ft', units, 1, level.elevation);
 | 
			
		||||
 | 
			
		||||
    console.log(globalOffset, units, elevRaw)
 | 
			
		||||
    let d = elevRaw - globalOffset.z - 0.5;
 | 
			
		||||
    if (n == 1)
 | 
			
		||||
        d = -1 * d;
 | 
			
		||||
 | 
			
		||||
@ -7,8 +7,8 @@ var baseImgUrl = "https://localhost:44376"; // 本地開發用
 | 
			
		||||
//var baseImgUrl = "http://220.132.206.5:8848"; // production 用
 | 
			
		||||
 | 
			
		||||
// WSP
 | 
			
		||||
//var baseApiUrl = "http://220.132.206.5"; // production 用
 | 
			
		||||
//var baseImgUrl = "http://220.132.206.5:8849"; // production 用
 | 
			
		||||
// var baseApiUrl = "http://220.132.206.5:8001"; // production 用
 | 
			
		||||
// var baseImgUrl = "http://220.132.206.5:8849"; // production 用
 | 
			
		||||
 | 
			
		||||
//var baseApiUrl = "http://localhost";
 | 
			
		||||
//var baseImgUrl = "http://localhost:8848";
 | 
			
		||||
@ -31,11 +31,17 @@ var common = {
 | 
			
		||||
}
 | 
			
		||||
var objSendData = { Data: null };
 | 
			
		||||
// Mitsubishi
 | 
			
		||||
var elevatorShow = true
 | 
			
		||||
var port = "";
 | 
			
		||||
var initAreaTag = "TPE";
 | 
			
		||||
var n4Sup = "Mitsubishi_JACE8000";
 | 
			
		||||
 | 
			
		||||
// WSP
 | 
			
		||||
//var initAreaTag = "NTPC";
 | 
			
		||||
//var n4Sup = "Banqiao";
 | 
			
		||||
// var elevatorShow = false
 | 
			
		||||
// var port = "4912";
 | 
			
		||||
// var initAreaTag = "NTPC";
 | 
			
		||||
// var n4Sup = "WSP_Supervisor";
 | 
			
		||||
 | 
			
		||||
var forgeTokenBase = {
 | 
			
		||||
    url: baseApiUrl + '/api/forge/oauth/token',
 | 
			
		||||
    res_access_token: ["dictionary", "access_token"],
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user