From ab0db76dc627a63699380dc65e2773c47d12f449 Mon Sep 17 00:00:00 2001 From: qlsxk <qlsxk@qq.com> Date: 星期二, 14 十月 2025 15:22:59 +0800 Subject: [PATCH] # --- src/main/java/com/zy/asrs/controller/ConsoleController.java | 113 ++++++++++++++++++ src/main/java/com/zy/asrs/ws/ConsoleWebSocket.java | 8 + src/main/webapp/views/console4.html | 216 +++++++++++++++++------------------ 3 files changed, 224 insertions(+), 113 deletions(-) diff --git a/src/main/java/com/zy/asrs/controller/ConsoleController.java b/src/main/java/com/zy/asrs/controller/ConsoleController.java index af8220c..1c61d5e 100644 --- a/src/main/java/com/zy/asrs/controller/ConsoleController.java +++ b/src/main/java/com/zy/asrs/controller/ConsoleController.java @@ -1,21 +1,31 @@ package com.zy.asrs.controller; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.core.annotations.ManagerAuth; import com.core.common.Cools; import com.core.common.R; import com.zy.asrs.domain.param.SystemSwitchParam; import com.zy.asrs.entity.BasMap; +import com.zy.asrs.entity.DeviceConfig; import com.zy.asrs.entity.LocMast; import com.zy.asrs.service.BasMapService; +import com.zy.asrs.service.DeviceConfigService; import com.zy.asrs.service.LocMastService; +import com.zy.asrs.utils.Utils; import com.zy.common.model.MapNode; +import com.zy.common.model.NavigateNode; import com.zy.common.model.enums.NavigationMapType; import com.zy.common.utils.NavigateMapData; import com.zy.common.utils.RedisUtil; +import com.zy.core.cache.SlaveConnection; import com.zy.core.enums.RedisKeyType; +import com.zy.core.enums.SlaveType; +import com.zy.core.model.command.ShuttleRedisCommand; +import com.zy.core.model.protocol.ShuttleProtocol; import com.zy.core.properties.SystemProperties; +import com.zy.core.thread.ShuttleThread; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -40,6 +50,8 @@ private NavigateMapData navigateMapData; @Autowired private LocMastService locMastService; + @Autowired + private DeviceConfigService deviceConfigService; @PostMapping("/system/running/status") @ManagerAuth(memo = "绯荤粺杩愯鐘舵��") @@ -153,4 +165,105 @@ return R.ok(); } + /** + * 鑾峰彇棰勮璺緞 + */ + @GetMapping("/getMoveAdvancePath/{lev}/auth") + @ManagerAuth + public R getMoveAdvancePath(@PathVariable Integer lev) { + HashMap<String, Object> pathMap = new HashMap<>(); + + List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() + .eq("device_type", String.valueOf(SlaveType.Shuttle))); + for (DeviceConfig deviceConfig : shuttleList) { + // 鑾峰彇鍥涘悜绌挎杞︿俊鎭� + ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, deviceConfig.getDeviceNo()); + if (shuttleThread == null) { + continue; + } + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null || shuttleProtocol.getShuttleNo()==null) { + continue; + } + + if (shuttleProtocol.getCurrentLocNo() == null) { + continue; + } + + if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) != lev) { + continue; + } + + if (shuttleProtocol.getTaskNo() == 0) { + + } + + //瀛樺湪浠诲姟锛岃幏鍙栨寚浠� + Object object = redisUtil.get(RedisKeyType.SHUTTLE_WORK_FLAG.key + shuttleProtocol.getTaskNo()); + if (object != null) { + ShuttleRedisCommand redisCommand = JSON.parseObject(object.toString(), ShuttleRedisCommand.class); + List<NavigateNode> nodes = redisCommand.getAssignCommand().getNodes();//绌挎杞﹂璁¤矾寰� + + for (NavigateNode node : nodes) { + String locNo = Utils.getLocNo(node.getX(), node.getY(), node.getZ()); + + List<Integer> shuttleNoList = new ArrayList<>(); + Object tmp = pathMap.get(locNo); + if(tmp != null) { + shuttleNoList = (List<Integer>) tmp; + } + + if (!shuttleNoList.contains(shuttleProtocol.getShuttleNo())) { + shuttleNoList.add(shuttleProtocol.getShuttleNo()); + } + + pathMap.put(locNo, shuttleNoList); + } + } + } + + List<HashMap<String, Object>> pathList = new ArrayList<>(); + for (Map.Entry<String, Object> entry : pathMap.entrySet()) { + String locNo = entry.getKey(); + Object shuttleNoList = entry.getValue(); + + HashMap<String, Object> map = new HashMap<>(); + map.put("locNo", locNo); + map.put("x", Utils.getRow(locNo)); + map.put("y", Utils.getBay(locNo)); + map.put("z", Utils.getLev(locNo)); + map.put("shuttleNoList", shuttleNoList); + pathList.add(map); + } + return R.ok().add(pathList); + } + + /** + * 鑾峰彇閿佸畾璺緞 + */ + @GetMapping("/getLockPath/{lev}/auth") + @ManagerAuth + public R getLockPath(@PathVariable Integer lev) { + HashMap<String, Object> lockMap = new HashMap<>(); + Object o = redisUtil.get(RedisKeyType.LOCK_MAP_NODES.key + lev); + if (o != null) { + lockMap = (HashMap<String, Object>) o; + } + + List<HashMap<String, Object>> lockList = new ArrayList<>(); + for (Map.Entry<String, Object> entry : lockMap.entrySet()) { + String locNo = entry.getKey(); + Object shuttleNo = entry.getValue(); + + HashMap<String, Object> map = new HashMap<>(); + map.put("locNo", locNo); + map.put("x", Utils.getRow(locNo)); + map.put("y", Utils.getBay(locNo)); + map.put("z", Utils.getLev(locNo)); + map.put("shuttleNo", shuttleNo); + lockList.add(map); + } + return R.ok().add(lockList); + } + } diff --git a/src/main/java/com/zy/asrs/ws/ConsoleWebSocket.java b/src/main/java/com/zy/asrs/ws/ConsoleWebSocket.java index 77bde72..d1e6de7 100644 --- a/src/main/java/com/zy/asrs/ws/ConsoleWebSocket.java +++ b/src/main/java/com/zy/asrs/ws/ConsoleWebSocket.java @@ -96,6 +96,14 @@ R result = consoleController.getLocMap(Integer.parseInt(socketMessage.getData())); socketMessage.setData(JSON.toJSONString(result)); this.sendMessage(JSON.toJSONString(socketMessage)); + } else if (socketMessage.getUrl().equals("/console/getMoveAdvancePath/auth")) { + R result = consoleController.getMoveAdvancePath(Integer.parseInt(socketMessage.getData())); + socketMessage.setData(JSON.toJSONString(result)); + this.sendMessage(JSON.toJSONString(socketMessage)); + } else if (socketMessage.getUrl().equals("/console/getLockPath/auth")) { + R result = consoleController.getLockPath(Integer.parseInt(socketMessage.getData())); + socketMessage.setData(JSON.toJSONString(result)); + this.sendMessage(JSON.toJSONString(socketMessage)); } // log.info("鏀跺埌鏉ヨ嚜杩炴帴锛�" + sessionId + "鐨勪俊鎭�:" + message); } diff --git a/src/main/webapp/views/console4.html b/src/main/webapp/views/console4.html index a02a8ac..dabc9ac 100644 --- a/src/main/webapp/views/console4.html +++ b/src/main/webapp/views/console4.html @@ -43,9 +43,6 @@ <div class="floorBtnBox" v-for="(lev,idx) in floorList"> <el-button :style="{background:currentLev === lev ? '#7DCDFF':''}" @click="changeFloor(lev)">{{lev}}F</el-button> </div> - <div style="margin-top: 10px;"> - <el-button @click="resetMap()">閲嶇疆鍦板浘</el-button> - </div> </el-drawer> <el-drawer @@ -60,6 +57,8 @@ <div style="margin-top: 5px;">Y锛歿{drawerLocNoData.y}}</div> <div style="margin-top: 5px;">Z锛歿{drawerLocNoData.z}}</div> <div style="margin-top: 5px;">搴撲綅鍙凤細{{drawerLocNoData.locNo}}</div> + <div style="margin-top: 5px;">棰勮璺緞杞﹁締锛歿{drawerLocNoData.moveAdvancePath}}</div> + <div style="margin-top: 5px;">璺緞閿佸畾杞﹁締锛歿{drawerLocNoData.lockPathShuttleNo}}</div> </div> </div> </el-drawer> @@ -127,9 +126,9 @@ let pixiStageList = []; let pixiShuttleMap = new Map(); let pixiShuttleMoveAdvancePathMap = new Map(); - let pixiShuttleMoveAdvancePathList = []; let pixiShuttleLockPathMap = new Map(); let pixiStaMap = new Map(); + let lockPathInfoMap = new Map(); let objectsContainer; let objectsContainer2; let objectsContainer3; @@ -147,7 +146,7 @@ data: { map: [], currentLev: 1, - floorList: [1, 2, 3], //褰撳墠椤圭洰妤煎眰 + floorList: [], //褰撳墠椤圭洰妤煎眰 currentLevShuttleList: [],//褰撳墠妤煎眰鍥涘悜绌挎杞﹂泦鍚� shuttleColorList: [],//鍥涘悜绌挎杞﹂鑹查泦鍚� drawer: false, @@ -196,6 +195,7 @@ ws.onclose = this.webSocketClose this.getMap(this.currentLev) + this.initLev()//鍒濆鍖栨ゼ灞備俊鎭� // this.getSystemRunningStatus() //鑾峰彇绯荤粺杩愯鐘舵�� this.consoleInterval = setInterval(() => { @@ -203,6 +203,8 @@ this.getShuttleStateInfo() //鑾峰彇鍥涘悜绌挎杞︿俊鎭� this.getLiftStateInfo() //鑾峰彇鎻愬崌鏈轰俊鎭� this.getSiteInfo() //鑾峰彇杈撻�佺珯鐐规暟鎹� + this.getMoveAdvancePath(this.currentLev) + this.getLockPath(this.currentLev) }, 1000) }, @@ -247,8 +249,8 @@ 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.x = (item.point.y - 0) * width;//鏇存柊鍧愭爣x + shuttle.y = (item.point.x - 1) * height;//鏇存柊鍧愭爣y shuttle.updateMoveStatus = true;//鍔ㄧ敾鎵ц瀹屾垚 shuttle.interactive = true; // 蹇呴』瑕佽缃墠鑳芥帴鏀朵簨浠� shuttle.buttonMode = true; // 璁╁厜鏍囧湪hover鏃跺彉涓烘墜鍨嬫寚閽� @@ -260,28 +262,12 @@ 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; } @@ -316,7 +302,6 @@ //娓呯┖棰勮璺緞 objectsContainer2.removeChildren(); pixiShuttleMoveAdvancePathMap = new Map(); - pixiShuttleMoveAdvancePathList = [] }, createMap(){ //Create a Pixi Application @@ -546,11 +531,32 @@ this.map = map; }, - rightEvent(x, y, e) { - this.drawerLocNo = true - let locNo = this.getLocNoByXYZ(x, y, this.currentLev); - this.drawerLocNoData = {x:x, y: y, z: this.currentLev, locNo: locNo}; - }, + rightEvent(x, y, e) { + this.drawerLocNo = true + let locNo = this.getLocNoByXYZ(x, y, this.currentLev); + let tmpData = { + x: x, + y: y, + z: this.currentLev, + locNo: locNo + }; + + let moveAdvancePath = pixiShuttleMoveAdvancePathMap.get(locNo) + if (moveAdvancePath == null || moveAdvancePath == undefined) { + moveAdvancePath = ""; + }else { + moveAdvancePath = JSON.stringify(moveAdvancePath.shuttleNos); + } + tmpData.moveAdvancePath = moveAdvancePath; + + let lockPathShuttleNo = lockPathInfoMap.get(locNo) + if (lockPathShuttleNo == null || lockPathShuttleNo == undefined) { + lockPathShuttleNo = ""; + } + tmpData.lockPathShuttleNo = lockPathShuttleNo; + + this.drawerLocNoData = tmpData; + }, findDiffList(arr1, arr2) { let diff = [] arr1.forEach((item,index) => { @@ -633,9 +639,36 @@ this.setSiteInfo(JSON.parse(result.data)) }else if (result.url == "/console/map/auth") { this.setMap(JSON.parse(result.data)) - }else if (result.url == "/console/barcode/output/site") { - this.setCodeData(JSON.parse(result.data)) + }else if (result.url == "/console/getMoveAdvancePath/auth") { + this.setMoveAdvancePath(JSON.parse(result.data)) + }else if (result.url == "/console/getLockPath/auth") { + this.setLockPath(JSON.parse(result.data)) } + }, + getMoveAdvancePath(lev) { + this.sendWs(JSON.stringify({ + "url": "/console/getMoveAdvancePath/auth", + "data": lev + })) + }, + setMoveAdvancePath(res) { + let data = res.data; + this.addMoveAdvancePath(data) + }, + getLockPath(lev) { + this.sendWs(JSON.stringify({ + "url": "/console/getLockPath/auth", + "data": lev + })) + }, + setLockPath(res) { + let data = res.data; + let tmpMap = new Map(); + data.forEach((item) => { + let locNo = this.getLocNoByXYZ(item.x,item.y,item.z) + tmpMap.set(locNo, item.shuttleNo); + }) + lockPathInfoMap = tmpMap; }, webSocketClose(e) { console.log("close"); @@ -657,11 +690,11 @@ if (shuttle.updateMoveStatus) {//鍔ㄧ敾鎵ц瀹屾垚鎵嶅彲缁х画鎵ц鍔ㄧ敾 shuttle.updateMoveStatus = false;//鍔ㄧ敾鎵ц涓� // 璁$畻涓ょ偣涔嬮棿鐨勮窛绂�1 - const distance = Math.sqrt(Math.pow((item.wcsPoint.x * width) - shuttle.x, 2) + Math.pow((item.wcsPoint.y * height) - shuttle.y, 2)); + const distance = Math.sqrt(Math.pow((item.point.x * width) - shuttle.x, 2) + Math.pow((item.point.y * height) - shuttle.y, 2)); gsap.killTweensOf(shuttle); // 鏉�姝绘墍鏈夐拡瀵�".class"鐨勫姩鐢� gsap.to(shuttle, { - x: (item.wcsPoint.y - 0) * width, // 鐩爣浣嶇疆 - y: (item.wcsPoint.x - 1) * height, // 鐩爣浣嶇疆 + x: (item.point.y - 0) * width, // 鐩爣浣嶇疆 + y: (item.point.x - 1) * height, // 鐩爣浣嶇疆 duration: 0.2, // 鍔ㄧ敾鎸佺画鏃堕棿锛堢锛� ease: "power1.inOut", // 缂撳姩绫诲瀷 onComplete: () => { @@ -797,21 +830,23 @@ } }, getLocNoByXYZ(x, y, z) { - let locNo = x + "-" + y + "-" + z; - return locNo; + let locNo = x + "-" + y + "-" + z; + return locNo; }, - addMoveAdvancePath(moveAdvancePath, shuttleNo) {//娣诲姞棰勮璺緞 - let that = this; + addMoveAdvancePath(moveAdvancePath) {//娣诲姞棰勮璺緞 + //娓呯┖棰勮璺緞 + objectsContainer2.removeChildren(); + pixiShuttleMoveAdvancePathMap = new Map(); moveAdvancePath.forEach((path, idx) => { - let locNo = that.getLocNoByXYZ(path.x, path.y, path.z); - if (!pixiShuttleMoveAdvancePathMap.has(locNo)) { + let locNo = this.getLocNoByXYZ(path.x, path.y, path.z); + let shuttleNos = path.shuttleNoList; let graphics = getGraphics(0x9966ff, width, height, path.y * width, (path.x - 1) * height); - let shuttleNos = [shuttleNo]; + // 鍒涘缓鏂囨湰瀵硅薄 const style = new PIXI.TextStyle({ - fontFamily: 'Arial', - fontSize: 10, - fill: '#000000', + fontFamily: 'Arial', + fontSize: 10, + fill: '#000000', }); const text = new PIXI.Text(JSON.stringify(shuttleNos), style); text.anchor.set(0.5); // 璁剧疆鏂囨湰閿氱偣涓轰腑蹇冪偣 @@ -821,80 +856,35 @@ graphics.textObj = text; objectsContainer2.addChild(graphics) pixiShuttleMoveAdvancePathMap.set(locNo, { - path: path, - sprite: graphics, - textObj: text, - shuttleNos: shuttleNos + path: path, + sprite: graphics, + textObj: text, + shuttleNos: shuttleNos }) - - if (pixiShuttleMoveAdvancePathList[shuttleNo] == null) { - let locNos = new Set() - locNos.add(locNo); - pixiShuttleMoveAdvancePathList[shuttleNo] = locNos; - }else { - pixiShuttleMoveAdvancePathList[shuttleNo].add(locNo); - } - }else { - let pathMap = pixiShuttleMoveAdvancePathMap.get(locNo) - let shuttleNos = pathMap.shuttleNos; - shuttleNos.push(shuttleNo); - pathMap.textObj.text = JSON.stringify(shuttleNos); - pixiShuttleMoveAdvancePathMap.set(locNo, pathMap); - if (pixiShuttleMoveAdvancePathList[shuttleNo] == null) { - let locNos = new Set() - locNos.add(locNo); - pixiShuttleMoveAdvancePathList[shuttleNo] = locNos; - }else { - pixiShuttleMoveAdvancePathList[shuttleNo].add(locNo); - } - } }); }, - removeMoveAdvancePath(shuttleNo) {//鍒犻櫎棰勮璺緞 - let locNos = pixiShuttleMoveAdvancePathList[shuttleNo]; - if (locNos != null) { - locNos.forEach((locNo,index) => { - let pathMap = pixiShuttleMoveAdvancePathMap.get(locNo); - if (pathMap != null) { - let shuttleNos = pathMap.shuttleNos; - let shuttleNosNew = []; - shuttleNos.forEach((shuttle, idx) => { - if (shuttle != shuttleNo) { - shuttleNosNew.push(shuttle); + initLev(){ + let that = this + $.ajax({ + url: baseUrl + "/console/map/lev/list", + headers: { + 'token': localStorage.getItem('token') + }, + data: {}, + method: 'get', + success: function(res) { + if (res.code === 200) { + that.floorList = res.data; + } else if (res.code === 403) { + parent.location.href = baseUrl + "/login"; + } else { + that.$message({ + message: res.msg, + type: 'error' + }); + } } - }); - - if (shuttleNosNew.length === 0) { - //棰勮璺緞娌℃湁灏忚溅锛岀洿鎺ュ垹闄よ矾寰� - objectsContainer2.removeChild(pathMap.sprite); - pixiShuttleMoveAdvancePathMap.delete(locNo) - }else { - //棰勮璺緞瀛樺湪鍏朵粬灏忚溅锛屾洿鏂版枃瀛椾俊鎭� - pathMap.textObj.text = JSON.stringify(shuttleNosNew); - pathMap.shuttleNos = shuttleNosNew; - pixiShuttleMoveAdvancePathMap.set(locNo, pathMap); - } - } - }) - } - }, - resetMap() { - //閲嶇疆鍦板浘 - let that = this - $.ajax({ - url:baseUrl+"/console/map/resetMap/" + this.currentLev, - headers:{ - 'token': localStorage.getItem('token') - }, - data:{}, - method:'get', - success:function (res) { - that.$message({ - message: that.currentLev + '灞傚湴鍥鹃噸缃畬鎴�', - type: 'success' }); - } - }) }, } }) -- Gitblit v1.9.1