|  |  |  | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 库位编号和A*算法的xy轴转换工具类 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //坐标编号转xy轴 | 
|---|
|  |  |  | public static int[] positionToXY(String position) { | 
|---|
|  |  |  | 
|---|
|  |  |  | return newPosition; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //牛眼坐标转WCS库位号 | 
|---|
|  |  |  | //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; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //路径算法节点转WCS系统库位号 | 
|---|
|  |  |  | public static String nodeToLocNo(NavigateNode node) { | 
|---|
|  |  |  | return xyzToLocNo(node.getX(), node.getY(), node.getZ()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //WCS坐标转WCS库位号 | 
|---|
|  |  |  | public static String xyzToLocNo(int x, int y, int z) { | 
|---|
|  |  |  | String locNo = Utils.getLocNo(x, y, z); | 
|---|
|  |  |  | return locNo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //牛眼坐标转WCS库位号 | 
|---|
|  |  |  | 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; | 
|---|
|  |  |  | 
|---|
|  |  |  | //牛眼Y轴 => WCS系统X轴公式 | 
|---|
|  |  |  | int x1 = y - 10; | 
|---|
|  |  |  | 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) { | 
|---|