#
Junjie
17 小时以前 c4b6b51afdd3374735ed5f358457987eaa6e476f
src/main/java/com/zy/common/utils/NavigatePositionConvert.java
@@ -1,17 +1,71 @@
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;
import com.zy.core.enums.RedisKeyType;
import java.util.HashMap;
/**
 * 库位编号和A*算法的xy轴转换工具类
 */
public class NavigatePositionConvert {
    public static String xyToPosition(int x, int y, int z) {
        String locNo = Utils.getLocNo(x, y, z);
        String code = null;
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        Object object = redisUtil.get(RedisKeyType.POINT_MAP.key);
        if(object == null) {
            //库位号转小车二维码
            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;
            }
            code = locMast.getQrCodeValue();
        }else {
            HashMap<String, String> cache = (HashMap<String, String>) object;
            code = cache.get(locNo);
        }
        return code;
    }
    //小车条形码转路径算法节点
    public static NavigateNode codeToNode(String code) {
        NavigateNode node = null;
        RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class);
        Object object = redisUtil.get(RedisKeyType.LOC_MAP.key);
        if (object == null) {
            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;
            }
            node = new NavigateNode(locMast.getRow1(), locMast.getBay1());
            node.setZ(locMast.getLev1());
        } else {
            HashMap<String, String> cache = (HashMap<String, String>) object;
            String locNo = cache.get(code);
            node = new NavigateNode(Utils.getRow(locNo), Utils.getBay(locNo));
            node.setZ(Utils.getLev(locNo));
        }
        return node;
    }
    //坐标编号转xy轴
    public static int[] positionToXY(String position) {
@@ -73,4 +127,10 @@
        return new int[]{col, row};
    }
    public static boolean equalsNode(NavigateNode node1, NavigateNode node2) {
        if(node1.getX() ==  node2.getX() && node1.getY() == node2.getY() && node1.getZ() == node2.getZ()) {
            return true;
        }
        return false;
    }
}