From d1ef13d1f116e69a7f44e78d64fd0fe4ce2cad80 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期一, 10 二月 2025 13:17:10 +0800 Subject: [PATCH] # --- src/main/java/com/zy/common/utils/NavigatePositionConvert.java | 125 +++++++++++++++++++++++------------------ 1 files changed, 71 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/zy/common/utils/NavigatePositionConvert.java b/src/main/java/com/zy/common/utils/NavigatePositionConvert.java index be0be98..76a2bfd 100644 --- a/src/main/java/com/zy/common/utils/NavigatePositionConvert.java +++ b/src/main/java/com/zy/common/utils/NavigatePositionConvert.java @@ -1,15 +1,44 @@ 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; /** * 搴撲綅缂栧彿鍜孉*绠楁硶鐨剎y杞磋浆鎹㈠伐鍏风被 */ public class NavigatePositionConvert { + + public static String xyToPosition(int x, int y, int z) { + String locNo = Utils.getLocNo(x, y, z); + + //搴撲綅鍙疯浆灏忚溅浜岀淮鐮� + 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; + } + return locMast.getQrCodeValue(); + } + + //灏忚溅鏉″舰鐮佽浆璺緞绠楁硶鑺傜偣 + public static NavigateNode codeToNode(String code) { + 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; + } + NavigateNode node = new NavigateNode(locMast.getRow1(), locMast.getBay1()); + node.setZ(locMast.getLev1()); + return node; + } //鍧愭爣缂栧彿杞瑇y杞� public static int[] positionToXY(String position) { @@ -21,62 +50,50 @@ return newPosition; } - //xy杞磋浆鍧愭爣缂栧彿 - public static Short xyToPosition(int x, int y) { - StringBuffer sb = new StringBuffer(); - sb.append(x); - if (x < 10) { - sb.append("00"); - } else if (x < 100) { - sb.append("0"); - } - sb.append(y); - return Short.parseShort(sb.toString()); + //WCS绯荤粺搴撲綅鍙疯浆璺緞绠楁硶鑺傜偣 + public static NavigateNode locNoToNode(String locNo) { + int col = Integer.parseInt(locNo.substring(0, 2)); + int row = Integer.parseInt(locNo.substring(2, 5)); + int[] newPosition = coverPosition(col,row); + NavigateNode node = new NavigateNode(col, row); + node.setZ(Utils.getLev(locNo)); + return node; } - //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()); + //璺緞绠楁硶鑺傜偣杞琖CS绯荤粺搴撲綅鍙� + public static String nodeToLocNo(NavigateNode node) { + return xyzToLocNo(node.getX(), node.getY(), node.getZ()); } - //杞崲琛屽彿锛屽疄闄呬腑鏈�搴曞眰鍙兘鏄涓�琛岋紝鍦ㄦ暟缁勪腑鏈�搴曞眰鏄渶鍚庝竴琛岋紝鍥犳闇�瑕佽繘琛岃浆鎹㈡墠鍙互鍖归厤鏁版嵁 - public static int covertRow(int row) { - NavigateMapData mapData = new NavigateMapData(); - int[][] data = mapData.getData(); - //瀹為檯琛屾暟 - int realRow = data.length - 1; - return realRow - row; + //WCS鍧愭爣杞琖CS搴撲綅鍙� + public static String xyzToLocNo(int x, int y, int z) { + String locNo = Utils.getLocNo(x, y, z); + return locNo; + } + + //鐗涚溂鍧愭爣杞琖CS搴撲綅鍙� + public static String nyXyzToLocNo(int x, int y, int z) { + int[] ints = NyXyzToWCSXyz(x, y, z); + String locNo = Utils.getLocNo(ints[0],ints[1],ints[2]); + return locNo; + } + + //WCS绯荤粺鍧愭爣杞墰鐪煎潗鏍� + public 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; + return new int[]{x1, y1, z}; + } + + //鐗涚溂鍧愭爣杞琖CS绯荤粺鍧愭爣 + public static int[] NyXyzToWCSXyz(int x, int y, int z) { + //鐗涚溂X杞� => WCS绯荤粺Y杞村叕寮� + int y1 = Math.abs(x - 11 - 61); + //鐗涚溂Y杞� => WCS绯荤粺X杞村叕寮� + int x1 = y - 10; + return new int[]{x1, y1, z}; } public static int[] coverPosition(int col,int row) { -- Gitblit v1.9.1