From 0d04bc5d8080b82338302fba0a59fccff2eaedfc Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期日, 06 七月 2025 11:28:29 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigatePositionConvert.java | 62 +++++++++++++------------------ 1 files changed, 26 insertions(+), 36 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigatePositionConvert.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigatePositionConvert.java index a44bd3d..44adfe3 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigatePositionConvert.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/NavigatePositionConvert.java @@ -12,47 +12,24 @@ public class NavigatePositionConvert { public static String xyToPosition(int x, int y, int z, Long hostId) { - 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();//搴撲綅鍙� + String locNo = Utils.getLocNo(x, y, z); //搴撲綅鍙疯浆灏忚溅浜岀淮鐮� - LocService locMastService = SpringUtils.getBean(LocService.class); - Loc locMast = locMastService.getOne(new LambdaQueryWrapper<Loc>() - .eq(Loc::getLocNo, position) - .eq(Loc::getHostId, hostId)); - if (locMast == null) { -// //褰撳墠搴撲綅鍙锋煡涓嶅埌锛屽彲鑳芥槸绔欑偣搴撲綅鍙� -// BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class); -// BasDevp basDevp = basDevpService.queryByLocNo(position); -// if (basDevp == null) { -// return null; -// } -// return Short.parseShort(basDevp.getQrCodeValue()); + LocService locService = SpringUtils.getBean(LocService.class); + Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>() + .eq(Loc::getLocNo, locNo) + .eq(Loc::getHostId, hostId) + .eq(Loc::getStatus, 1)); + if (loc == null) { return null; } - return locMast.getCode(); + return loc.getCode(); } //鍧愭爣缂栧彿杞瑇y杞� public static int[] positionToXY(String position) { - int col = Integer.parseInt(position.substring(0, 2)); - int row = Integer.parseInt(position.substring(2, 5)); + int col = Utils.getRow(position); + int row = Utils.getBay(position); int[] newPosition = coverPosition(col,row); //杩斿洖x鍜寉 // return new int[]{row, col}; @@ -61,14 +38,27 @@ //WCS绯荤粺搴撲綅鍙疯浆璺緞绠楁硶鑺傜偣 public static NavigateNode locNoToNode(String locNo) { - int col = Integer.parseInt(locNo.substring(0, 2)); - int row = Integer.parseInt(locNo.substring(2, 5)); + int col = Utils.getRow(locNo); + int row = Utils.getBay(locNo); int[] newPosition = coverPosition(col,row); - NavigateNode node = new NavigateNode(col, row); + NavigateNode node = new NavigateNode(newPosition[0], newPosition[1]); node.setZ(Utils.getLev(locNo)); return node; } + //灏忚溅鏉″舰鐮佽浆璺緞绠楁硶鑺傜偣 + public static NavigateNode codeToNode(String code, Long hostId) { + LocService locService = SpringUtils.getBean(LocService.class); + Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>() + .eq(Loc::getCode, code) + .eq(Loc::getHostId, hostId) + .eq(Loc::getStatus, 1)); + + NavigateNode node = new NavigateNode(loc.getRow(), loc.getBay()); + node.setZ(loc.getLev()); + return node; + } + //璺緞绠楁硶鑺傜偣杞琖CS绯荤粺搴撲綅鍙� public static String nodeToLocNo(NavigateNode node) { return xyzToLocNo(node.getX(), node.getY(), node.getZ()); -- Gitblit v1.9.1