| | |
| | | } |
| | | }); |
| | | }, |
| | | getShuttleStateInfo() { |
| | | this.sendWs(JSON.stringify({ |
| | | "url": "/shuttle/table/shuttle/state", |
| | | "data": {} |
| | | })) |
| | | }, |
| | | setShuttleStateInfo(res) { |
| | | // 四向穿梭车信息表获取 |
| | | let that = this |
| | | if (res.code == 200) { |
| | | let currentLevShuttle = []//当前楼层小车集合 |
| | | res.data.forEach((item,idx) => { |
| | | if (item != null && item.point != undefined && item.point != null) { |
| | | if (item.point.z == that.currentLev) { |
| | | currentLevShuttle.push(item); |
| | | } |
| | | } |
| | | }) |
| | | that.shuttleList = res.data |
| | | if (that.shuttleColorList.length == 0) { |
| | | let colorList = []//随机小车颜色 |
| | | res.data.forEach((item,idx) => { |
| | | colorList[item.shuttleNo] = that.colorRGB() |
| | | }) |
| | | that.shuttleColorList = colorList |
| | | } |
| | | |
| | | const result = this.findShuttleDiffList(this.currentLevShuttleList, currentLevShuttle); |
| | | if (!result) { |
| | | //小车存在变动,重新渲染全部小车 |
| | | pixiShuttleMap.forEach((shuttle,index) => { |
| | | pixiApp.stage.removeChild(shuttle) |
| | | pixiShuttleMap.delete(index) |
| | | }) |
| | | |
| | | currentLevShuttle.forEach((item,index) => { |
| | | pixiApp.loader.load((loader, resources) => { |
| | | // 纹理创建小车 |
| | | const shuttle = new PIXI.Sprite(resources.shuttle.texture); |
| | | shuttle.width = width |
| | | shuttle.height = height |
| | | shuttle.x = (item.wcsPoint.y - 0) * width;//更新坐标x |
| | | shuttle.y = (item.wcsPoint.x - 1) * height;//更新坐标y |
| | | shuttle.updateMoveStatus = true;//动画执行完成 |
| | | shuttle.interactive = true; // 必须要设置才能接收事件 |
| | | shuttle.buttonMode = true; // 让光标在hover时变为手型指针 |
| | | shuttle.on('pointerdown', (e) => { |
| | | this.drawerShuttle = true; |
| | | this.drawerShuttleData = item; |
| | | }) |
| | | pixiApp.stage.addChild(shuttle); |
| | | pixiShuttleMap.set(item.shuttleNo, shuttle); |
| | | }) |
| | | |
| | | if (item.moveAdvancePath != null && item.moveAdvancePath.length > 0) {//存在预计路径,进行渲染 |
| | | this.addMoveAdvancePath(item.moveAdvancePath, item.shuttleNo);//添加预计路径 |
| | | } |
| | | |
| | | }) |
| | | }else { |
| | | //小车不存在变动,渲染小车位置 |
| | | currentLevShuttle.forEach((item,index) => { |
| | | this.updateShuttleXY(item) |
| | | }) |
| | | |
| | | const resultPath = this.findShuttlePathDiffList(JSON.parse(JSON.stringify(this.currentLevShuttleList)), JSON.parse(JSON.stringify(currentLevShuttle))); |
| | | if (!resultPath) { |
| | | //预计路径存在变动,渲染路径 |
| | | currentLevShuttle.forEach((item,index) => { |
| | | //删除预计路径 |
| | | this.removeMoveAdvancePath(item.shuttleNo); |
| | | if (item.moveAdvancePath != null && item.moveAdvancePath.length > 0) {//存在预计路径,进行渲染 |
| | | this.addMoveAdvancePath(item.moveAdvancePath, item.shuttleNo);//添加预计路径 |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | that.currentLevShuttleList = currentLevShuttle; |
| | | } |
| | | }, |
| | | //获取地图数据 |
| | | getMap(lev) { |
| | | this.sendWs(JSON.stringify({ |
| | | "url": "/console/locMap/auth", |
| | | "data": lev |
| | | })) |
| | | }, |
| | | setMap(res) { |
| | | //获取地图数据 |
| | | let data = res.data |
| | | let tmp = [] |
| | | for (let i = 1; i < data.length - 1; i++) { |
| | | tmp.push(data[i]) |
| | | } |
| | | this.createMapData(tmp) |
| | | let that = this; |
| | | $.ajax({ |
| | | url: baseUrl + "/console/map/" + lev + "/auth", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: {}, |
| | | method: 'get', |
| | | success: function(res) { |
| | | //获取地图数据 |
| | | let data = res.data |
| | | that.createMapData(data) |
| | | } |
| | | }) |
| | | }, |
| | | changeFloor(lev) { |
| | | this.currentLev = lev |
| | |
| | | pixiApp.loader.add('shuttle', '../static/images/sxcar.png'); |
| | | |
| | | // 从Graphics对象创建一个纹理 |
| | | graphicsF = pixiApp.renderer.generateTexture(getContainer(1000)); |
| | | graphicsF = pixiApp.renderer.generateTexture(getContainer(1000)); |
| | | graphics0 = pixiApp.renderer.generateTexture(getContainer(0)); |
| | | graphics3 = pixiApp.renderer.generateTexture(getContainer(3)); |
| | | graphics4 = pixiApp.renderer.generateTexture(getContainer(4)); |
| | |
| | | this.reloadMap = false |
| | | pixiStageList = [map.length]//初始化列表 |
| | | pixiStaMap = new Map();//重置 |
| | | |
| | | objectsContainer.removeChildren() |
| | | map.forEach((item,index) => { |
| | | pixiStageList[index] = [item.length] |