From c4b6b51afdd3374735ed5f358457987eaa6e476f Mon Sep 17 00:00:00 2001 From: Junjie <540245094@qq.com> Date: 星期五, 05 九月 2025 16:55:20 +0800 Subject: [PATCH] # --- src/main/java/com/zy/common/utils/NavigatePositionConvert.java | 105 +++++++++++++++++++++++++++++++++------------------- 1 files changed, 67 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/zy/common/utils/NavigatePositionConvert.java b/src/main/java/com/zy/common/utils/NavigatePositionConvert.java index c3a8435..b6a473c 100644 --- a/src/main/java/com/zy/common/utils/NavigatePositionConvert.java +++ b/src/main/java/com/zy/common/utils/NavigatePositionConvert.java @@ -1,17 +1,71 @@ package com.zy.common.utils; +import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.core.common.SpringUtils; -import com.zy.asrs.entity.BasDevp; import com.zy.asrs.entity.LocMast; -import com.zy.asrs.service.BasDevpService; import com.zy.asrs.service.LocMastService; import com.zy.asrs.utils.Utils; import com.zy.common.model.NavigateNode; +import com.zy.core.enums.RedisKeyType; + +import java.util.HashMap; /** * 搴撲綅缂栧彿鍜孉*绠楁硶鐨剎y杞磋浆鎹㈠伐鍏风被 */ public class NavigatePositionConvert { + + public static String xyToPosition(int x, int y, int z) { + String locNo = Utils.getLocNo(x, y, z); + String code = null; + + RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); + Object object = redisUtil.get(RedisKeyType.POINT_MAP.key); + + if(object == null) { + //搴撲綅鍙疯浆灏忚溅浜岀淮鐮� + LocMastService locMastService = SpringUtils.getBean(LocMastService.class); + LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() + .eq("loc_no", locNo) + .eq("status", 1)); + if (locMast == null) { + return null; + } + + code = locMast.getQrCodeValue(); + }else { + HashMap<String, String> cache = (HashMap<String, String>) object; + code = cache.get(locNo); + } + return code; + } + + //灏忚溅鏉″舰鐮佽浆璺緞绠楁硶鑺傜偣 + public static NavigateNode codeToNode(String code) { + NavigateNode node = null; + + RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); + Object object = redisUtil.get(RedisKeyType.LOC_MAP.key); + + if (object == null) { + LocMastService locMastService = SpringUtils.getBean(LocMastService.class); + LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() + .eq("qr_code_value", code) + .eq("status", 1)); + if (locMast == null) { + return null; + } + node = new NavigateNode(locMast.getRow1(), locMast.getBay1()); + node.setZ(locMast.getLev1()); + } else { + HashMap<String, String> cache = (HashMap<String, String>) object; + String locNo = cache.get(code); + + node = new NavigateNode(Utils.getRow(locNo), Utils.getBay(locNo)); + node.setZ(Utils.getLev(locNo)); + } + return node; + } //鍧愭爣缂栧彿杞瑇y杞� public static int[] positionToXY(String position) { @@ -31,6 +85,11 @@ NavigateNode node = new NavigateNode(col, row); node.setZ(Utils.getLev(locNo)); return node; + } + + //璺緞绠楁硶鑺傜偣杞琖CS绯荤粺搴撲綅鍙� + public static String nodeToLocNo(NavigateNode node) { + return xyzToLocNo(node.getX(), node.getY(), node.getZ()); } //WCS鍧愭爣杞琖CS搴撲綅鍙� @@ -64,44 +123,14 @@ return new int[]{x1, y1, z}; } - //xyz杞磋浆鍧愭爣缂栧彿 - public static Short xyToPosition(int x, int y, int z) { - StringBuffer sb = new StringBuffer(); - if (x < 10) { - sb.append("0"); - } - sb.append(x); - - if (y < 10) { - sb.append("00"); - }else if (y < 100) { - sb.append("0"); - } - sb.append(y); - - if (z < 10) { - sb.append("0"); - } - sb.append(z); - String position = sb.toString();//搴撲綅鍙� - - //搴撲綅鍙疯浆灏忚溅浜岀淮鐮� - LocMastService locMastService = SpringUtils.getBean(LocMastService.class); - LocMast locMast = locMastService.queryByLoc(position); - if (locMast == null) { - //褰撳墠搴撲綅鍙锋煡涓嶅埌锛屽彲鑳芥槸绔欑偣搴撲綅鍙� - BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class); - BasDevp basDevp = basDevpService.queryByLocNo(position); - if (basDevp == null) { - return null; - } - return Short.parseShort(basDevp.getQrCodeValue()); - } - return Short.parseShort(locMast.getQrCodeValue()); - } - public static int[] coverPosition(int col,int row) { return new int[]{col, row}; } + public static boolean equalsNode(NavigateNode node1, NavigateNode node2) { + if(node1.getX() == node2.getX() && node1.getY() == node2.getY() && node1.getZ() == node2.getZ()) { + return true; + } + return false; + } } -- Gitblit v1.9.1