自动化立体仓库 - WCS系统
Junjie
2023-07-26 14cf00a11479cb1696eec55e10208490bd4aa09d
src/main/java/com/zy/common/utils/NavigatePositionConvert.java
@@ -1,5 +1,11 @@
package com.zy.common.utils;
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;
/**
 * 库位编号和A*算法的xy轴转换工具类
 */
@@ -18,14 +24,50 @@
    //xy轴转坐标编号
    public static Short xyToPosition(int x, int y) {
        StringBuffer sb = new StringBuffer();
        sb.append(y);
        sb.append(x);
        if (x < 10) {
            sb.append("00");
        } else if (x < 100) {
            sb.append("0");
        }
        sb.append(x);
        sb.append(y);
        return Short.parseShort(sb.toString());
    }
    //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());
    }
    //转换行号,实际中最底层可能是第一行,在数组中最底层是最后一行,因此需要进行转换才可以匹配数据
@@ -38,7 +80,7 @@
    }
    public static int[] coverPosition(int col,int row) {
        return new int[]{row, col};
        return new int[]{col, row};
    }
}