| | |
| | | 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(); |
| | | } |
| | | |
| | | //坐标编号转xy轴 |
| | | 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和y |
| | | // return new int[]{row, col}; |
| | |
| | | |
| | | //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; |
| | | } |
| | | |
| | | //路径算法节点转WCS系统库位号 |
| | | public static String nodeToLocNo(NavigateNode node) { |
| | | return xyzToLocNo(node.getX(), node.getY(), node.getZ()); |