自动化立体仓库 - WCS系统
Junjie
2023-07-27 84a9e3a9a624526116b42ab15e27ec852eaa7c21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
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;
import com.zy.asrs.utils.Utils;
 
/**
 * 库位编号和A*算法的xy轴转换工具类
 */
public class NavigatePositionConvert {
 
    //坐标编号转xy轴
    public static int[] positionToXY(String position) {
        int col = Integer.parseInt(position.substring(0, 2));
        int row = Integer.parseInt(position.substring(2, 5));
        int[] newPosition = coverPosition(col,row);
        //返回x和y
//        return new int[]{row, col};
        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());
    }
 
    //xyz轴转库位号
    public static String xyzToLocNo(int x, int y, int z) {
        String locNo = Utils.getLocNo(x, y, z);
        return locNo;
    }
 
    //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 covertRow(int row) {
        NavigateMapData mapData = new NavigateMapData();
        int[][] data = mapData.getData();
        //实际行数
        int realRow = data.length - 1;
        return realRow - row;
    }
 
    public static int[] coverPosition(int col,int row) {
        return new int[]{col, row};
    }
 
}