From 15b5002fd412a5d33be5d5c6deb63b3d02c77c41 Mon Sep 17 00:00:00 2001 From: zjj <3272660260@qq.com> Date: 星期二, 23 九月 2025 14:35:39 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/impl/NyShuttleThread.java | 84 ++++++++++++++++++++++++++++-------------- 1 files changed, 56 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java index 53fbe7f..1ac69f0 100644 --- a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java +++ b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java @@ -58,6 +58,7 @@ private List<JSONObject> socketReadResults = new ArrayList<>(); private List<DeviceMsgModel> socketResults = new ArrayList<>(); + private Long requestReadTime = System.currentTimeMillis(); //鍘熷璁惧鏁版嵁 private Object originDeviceData; @@ -199,7 +200,10 @@ //鎸囦护瓒呰繃2鏉★紝涓嶅啀涓嬪彂浠诲姟鐘舵�佽姹� TreeSet<String> deviceCommandMsgListKey = deviceMsgUtils.getDeviceCommandMsgListKey(SlaveType.Shuttle, deviceConfig.getDeviceNo()); if (deviceCommandMsgListKey.size() < 2) { - requestCommand(readStatusCommand);//璇锋眰鐘舵�� + if ((System.currentTimeMillis() - requestReadTime) > 500) { + requestCommand(readStatusCommand);//璇锋眰鐘舵�� + requestReadTime = System.currentTimeMillis(); + } } if (this.socketReadResults.isEmpty()) { @@ -577,7 +581,7 @@ } @Override - public boolean isRequireCharge() { + public ShuttleRequireChargeType isRequireCharge() { if (this.shuttleProtocol.getDeviceStatus() == null || this.shuttleProtocol.getPakMk() == null || this.shuttleProtocol.getErrorCode() == null @@ -585,7 +589,7 @@ || this.shuttleProtocol.getMode() == null || this.shuttleProtocol.getExtend() == null ) { - return false; + return ShuttleRequireChargeType.NONE; } InnerSuhttleExtend extend = (InnerSuhttleExtend) this.shuttleProtocol.getExtend(); @@ -598,25 +602,43 @@ && extend.getSuspendState() == 0 ; if (!res) { - return res; + return ShuttleRequireChargeType.NONE; } else { // 鐢甸噺灏忎簬闃堝�奸渶瑕佽繘琛屽厖鐢� try { BasShuttleService shuttleService = SpringUtils.getBean(BasShuttleService.class); if (shuttleService == null) { - return false; + return ShuttleRequireChargeType.NONE; } + BasShuttle basShuttle = shuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", deviceConfig.getDeviceNo())); if (basShuttle == null) { - return false; + return ShuttleRequireChargeType.NONE; } + Integer chargeLine = basShuttle.getChargeLine(); if (chargeLine == null) { - return false; + return ShuttleRequireChargeType.NONE; } - return Integer.valueOf(this.shuttleProtocol.getBatteryPower()) < chargeLine; + + boolean chargeResult = Integer.valueOf(this.shuttleProtocol.getBatteryPower()) < chargeLine; + if (chargeResult) { + return ShuttleRequireChargeType.FORCE_CHARGE;//闇�瑕佸己鍒跺厖鐢� + } + + Integer suggestChargeLine = basShuttle.getSuggestChargeLine(); + if (suggestChargeLine == null) { + return ShuttleRequireChargeType.NONE; + } + + boolean suggestChargeResult = Integer.valueOf(this.shuttleProtocol.getBatteryPower()) < suggestChargeLine; + if (suggestChargeResult) { + return ShuttleRequireChargeType.SUGGEST_CHARGE;//寤鸿鍏呯數 + } + + return ShuttleRequireChargeType.NONE; } catch (Exception e) { - return false; + return ShuttleRequireChargeType.NONE; } } } @@ -967,7 +989,7 @@ } @Override - public ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes) { + public ShuttleCommand getMoveCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean shuttleDirectionReverse) { NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class); NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo); NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest(); @@ -987,8 +1009,14 @@ HashMap<String, Object> data = new HashMap<>(); String codeNum = NavigatePositionConvert.xyToPosition(node.getX(), node.getY(), node.getZ()); Map<String, Object> nyNode = navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(codeNum)); - int xp = Integer.parseInt(String.valueOf(nyNode.get("y"))); - int yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); + + int xp = Integer.parseInt(String.valueOf(nyNode.get("x"))); + int yp = Integer.parseInt(String.valueOf(nyNode.get("y"))); + if (shuttleDirectionReverse) { + xp = Integer.parseInt(String.valueOf(nyNode.get("y"))); + yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); + } + int z = Integer.parseInt(String.valueOf(nyNode.get("z"))); List<MapNode> mapNodes = mapData.get(node.getX()); @@ -1018,7 +1046,7 @@ } @Override - public ShuttleCommand getMoveLiftCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean moveIn) { + public ShuttleCommand getMoveLiftCommand(Integer taskNo, String startCodeNum, String distCodeNum, Integer allDistance, Integer runDirection, Integer runSpeed, List<NavigateNode> nodes, Boolean moveIn, Boolean shuttleDirectionReverse) { NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class); NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo); NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest(); @@ -1027,11 +1055,12 @@ Integer taskId = getTaskId(); HashMap<String, Object> body = new HashMap<>(); - if (moveIn) { - body.put("requestType", "intoLift");//杩涙彁鍗囨満 - }else { - body.put("requestType", "outLift");//鍑烘彁鍗囨満 - } +// if (moveIn) { +// body.put("requestType", "intoLift");//杩涙彁鍗囨満 +// } else { +// body.put("requestType", "outLift");//鍑烘彁鍗囨満 +// } + body.put("requestType", "move");//绉诲姩鍛戒护 body.put("taskId", taskId);//TaskID闇�瑕侀殢鏈� body.put("path", path); request.setBody(body); @@ -1042,8 +1071,14 @@ HashMap<String, Object> data = new HashMap<>(); String codeNum = NavigatePositionConvert.xyToPosition(node.getX(), node.getY(), node.getZ()); Map<String, Object> nyNode = navigateNodeToNyPointNode(NavigatePositionConvert.codeToNode(codeNum)); - int xp = Integer.parseInt(String.valueOf(nyNode.get("y"))); - int yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); + + int xp = Integer.parseInt(String.valueOf(nyNode.get("x"))); + int yp = Integer.parseInt(String.valueOf(nyNode.get("y"))); + if (shuttleDirectionReverse) { + xp = Integer.parseInt(String.valueOf(nyNode.get("y"))); + yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); + } + int z = Integer.parseInt(String.valueOf(nyNode.get("z"))); List<MapNode> mapNodes = mapData.get(node.getX()); @@ -1308,13 +1343,6 @@ //WCS绯荤粺鍧愭爣杞墰鐪煎潗鏍� private static int[] WCSXyzToNyXyz(int x, int y, int z) { -// //WCS绯荤粺Y杞� => 鐗涚溂X杞磋浆鎹㈠叕寮� -// int x1 = Math.abs(y - 61) + 11; -// //WCS绯荤粺X杞� => 鐗涚溂Y杞磋浆鎹㈠叕寮� -// int y1 = x + 10; - -// int x1 = x + 10; -// int y1 = y + 10; LocMastService locMastService = SpringUtils.getBean(LocMastService.class); LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() .eq("row1", x) @@ -1327,7 +1355,7 @@ String qrCodeValue = locMast.getQrCodeValue(); JSONObject data = JSON.parseObject(qrCodeValue); - return new int[]{data.getInteger("y"), data.getInteger("x"), z}; + return new int[]{data.getInteger("x"), data.getInteger("y"), z}; } @Override -- Gitblit v1.9.1