#
Junjie
1 天以前 c4b6b51afdd3374735ed5f358457987eaa6e476f
src/main/java/com/zy/common/utils/NavigatePositionConvert.java
@@ -6,6 +6,9 @@
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轴转换工具类
@@ -14,29 +17,53 @@
    public static String xyToPosition(int x, int y, int z) {
        String locNo = Utils.getLocNo(x, y, z);
        String code = 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;
        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 locMast.getQrCodeValue();
        return code;
    }
    //小车条形码转路径算法节点
    public static NavigateNode codeToNode(String code) {
        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;
        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));
        }
        NavigateNode node = new NavigateNode(locMast.getRow1(), locMast.getBay1());
        node.setZ(locMast.getLev1());
        return node;
    }