From efbd157c0d810c39d04cd86752e769a3f3a1a1fc Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期四, 11 九月 2025 16:57:03 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/impl/NyShuttleThread.java | 75 +++++++++++++++++++++---------------- 1 files changed, 42 insertions(+), 33 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 e167988..e124f84 100644 --- a/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java +++ b/src/main/java/com/zy/core/thread/impl/NyShuttleThread.java @@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.core.common.DateUtils; import com.core.common.SpringUtils; -import com.core.exception.CoolException; import com.fasterxml.jackson.databind.ObjectMapper; import com.zy.asrs.entity.BasShuttle; import com.zy.asrs.entity.DeviceConfig; @@ -578,7 +577,7 @@ } @Override - public boolean isRequireCharge() { + public ShuttleRequireChargeType isRequireCharge() { if (this.shuttleProtocol.getDeviceStatus() == null || this.shuttleProtocol.getPakMk() == null || this.shuttleProtocol.getErrorCode() == null @@ -586,7 +585,7 @@ || this.shuttleProtocol.getMode() == null || this.shuttleProtocol.getExtend() == null ) { - return false; + return ShuttleRequireChargeType.NONE; } InnerSuhttleExtend extend = (InnerSuhttleExtend) this.shuttleProtocol.getExtend(); @@ -599,25 +598,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; } } } @@ -983,6 +1000,7 @@ request.setBody(body); NavigateNode startNode = nodes.get(0); + List<List<MapNode>> mapData = navigateMapData.getJsonData(startNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); for (NavigateNode node : nodes) { HashMap<String, Object> data = new HashMap<>(); String codeNum = NavigatePositionConvert.xyToPosition(node.getX(), node.getY(), node.getZ()); @@ -991,7 +1009,6 @@ int yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); int z = Integer.parseInt(String.valueOf(nyNode.get("z"))); - List<List<MapNode>> mapData = navigateMapData.getJsonData(startNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); List<MapNode> mapNodes = mapData.get(node.getX()); MapNode mapNode = mapNodes.get(node.getY()); @@ -1005,18 +1022,15 @@ httpStandard.setRequest(request); - LocMastService locMastService = SpringUtils.getBean(LocMastService.class); - LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() - .eq("qr_code_value", distCodeNum)); - if (locMast == null) { - throw new CoolException("搴撲綅淇℃伅涓嶅瓨鍦�"); - } + Object object = redisUtil.get(RedisKeyType.LOC_MAP.key); + HashMap<String, String> locMap = (HashMap<String, String>) object; + String targetLocNo = locMap.get(distCodeNum); ShuttleCommand command = new ShuttleCommand(); command.setShuttleNo(deviceConfig.getDeviceNo()); command.setBody(JSON.toJSONString(httpStandard)); command.setMode(ShuttleCommandModeType.MOVE.id); - command.setTargetLocNo(locMast.getLocNo()); + command.setTargetLocNo(targetLocNo); command.setTaskNo(taskId); return command; } @@ -1041,6 +1055,7 @@ request.setBody(body); NavigateNode startNode = nodes.get(0); + List<List<MapNode>> mapData = navigateMapData.getJsonData(startNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); for (NavigateNode node : nodes) { HashMap<String, Object> data = new HashMap<>(); String codeNum = NavigatePositionConvert.xyToPosition(node.getX(), node.getY(), node.getZ()); @@ -1049,7 +1064,6 @@ int yp = Integer.parseInt(String.valueOf(nyNode.get("x"))); int z = Integer.parseInt(String.valueOf(nyNode.get("z"))); - List<List<MapNode>> mapData = navigateMapData.getJsonData(startNode.getZ(), NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); List<MapNode> mapNodes = mapData.get(node.getX()); MapNode mapNode = mapNodes.get(node.getY()); @@ -1063,18 +1077,15 @@ httpStandard.setRequest(request); - LocMastService locMastService = SpringUtils.getBean(LocMastService.class); - LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() - .eq("qr_code_value", distCodeNum)); - if (locMast == null) { - throw new CoolException("搴撲綅淇℃伅涓嶅瓨鍦�"); - } + Object object = redisUtil.get(RedisKeyType.LOC_MAP.key); + HashMap<String, String> locMap = (HashMap<String, String>) object; + String targetLocNo = locMap.get(distCodeNum); ShuttleCommand command = new ShuttleCommand(); command.setShuttleNo(deviceConfig.getDeviceNo()); command.setBody(JSON.toJSONString(httpStandard)); command.setMode(ShuttleCommandModeType.MOVE.id); - command.setTargetLocNo(locMast.getLocNo()); + command.setTargetLocNo(targetLocNo); command.setTaskNo(taskId); return command; } @@ -1143,7 +1154,6 @@ //鑾峰彇灏忚溅澶嶄綅鍝嶅簲鍛戒护 public ShuttleCommand getInitCommand(Integer taskNo, Integer code) { - LocMastService locMastService = SpringUtils.getBean(LocMastService.class); NavigateMapData navigateMapData = SpringUtils.getBean(NavigateMapData.class); NyShuttleHttpCommand httpStandard = getHttpStandard(deviceConfig.getDeviceNo(), taskNo); NyShuttleHttpCommand.NyRequest request = httpStandard.getRequest(); @@ -1159,15 +1169,14 @@ map.put("z", lev); String mapStr = JSON.toJSONString(map); - LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() - .eq("qr_code_value", mapStr)); - if (locMast == null) { - throw new CoolException("鍦板潃鐮佷笉瀛樺湪"); - } + + Object object = redisUtil.get(RedisKeyType.LOC_MAP.key); + HashMap<String, String> locMap = (HashMap<String, String>) object; + String targetLocNo = locMap.get(mapStr); List<List<MapNode>> mapData = navigateMapData.getJsonData(lev, NavigationMapType.getMapTypes(NavigationMapType.NONE), null, null); - List<MapNode> mapNodes = mapData.get(locMast.getRow1()); - MapNode mapNode = mapNodes.get(locMast.getBay1()); + List<MapNode> mapNodes = mapData.get(Utils.getRow(targetLocNo)); + MapNode mapNode = mapNodes.get(Utils.getBay(targetLocNo)); HashMap<String, Object> location = new HashMap<>(); location.put("xp", row); -- Gitblit v1.9.1