package com.zy.asrs.wcs.core.utils;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.zy.asrs.framework.common.SpringUtils;
|
import com.zy.asrs.wcs.core.entity.Loc;
|
import com.zy.asrs.wcs.core.model.NavigateNode;
|
import com.zy.asrs.wcs.core.service.LocService;
|
|
/**
|
* 库位编号和A*算法的xy轴转换工具类
|
*/
|
public class NavigatePositionConvert {
|
|
public static String xyToPosition(int x, int y, int z, Long hostId) {
|
String locNo = Utils.getLocNo(x, y, z);
|
|
//库位号转小车二维码
|
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 loc.getCode();
|
}
|
|
//坐标编号转xy轴
|
public static int[] positionToXY(String position) {
|
int col = Utils.getRow(position);
|
int row = Utils.getBay(position);
|
int[] newPosition = coverPosition(col,row);
|
//返回x和y
|
// return new int[]{row, col};
|
return newPosition;
|
}
|
|
//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;
|
}
|
|
//小车条形码转路径算法节点
|
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());
|
}
|
|
//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;
|
}
|
|
//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};
|
}
|
|
//牛眼坐标转WCS系统坐标
|
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) {
|
return new int[]{col, row};
|
}
|
|
}
|