自动化立体仓库 - WMS系统
1
zhang
5 天以前 fcd35daf35247eb3c0b087f2042de1fd9013b5b6
src/main/java/com/zy/asrs/utils/Utils.java
@@ -8,17 +8,10 @@
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.RowLastno;
import com.zy.asrs.service.RowLastnoService;
import com.zy.common.CodeBuilder;
import com.zy.common.model.LocDetlDto;
import com.zy.common.properties.SlaveProperties;
import com.zy.common.service.CommonService;
import com.zy.system.service.UserService;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
@@ -122,71 +115,42 @@
     * 获取 深库位对应的浅库位号
     */
    public static String getShallowLoc(SlaveProperties slaveProperties, String deepLoc) {
//        int row = getRow(deepLoc);
//        int remainder = (int) Arith.remainder(row, slaveProperties.getGroupCount());
//        int shallowRow = remainder == 1 ? (row + 1) : (row - 1);
//        return zerofill(String.valueOf(shallowRow), 2) + deepLoc.substring(2);
        int row = getRow(deepLoc);
        boolean deepLocLeft = isDeepLocLeft(slaveProperties, row);//判断是否为左深库位
        int shallowRow = deepLocLeft? (row + 1) : (row - 1);
        int shallowRow = deepLocLeft ? (row + 1) : (row - 1);
        return zerofill(String.valueOf(shallowRow), 2) + deepLoc.substring(2);
    }
//    /**
//     * 获取 深库位对应的浅库位号
//     */
//    public static String getShallowLoc(SlaveProperties slaveProperties, String deepLoc) {
//        int row = getRow(deepLoc);
//        int remainder = (int) Arith.remainder(row, slaveProperties.getGroupCount());
//        int shallowRow = remainder == 1 ? (row + 1) : (row - 1);
//        return zerofill(String.valueOf(shallowRow), 2) + deepLoc.substring(2);
//    }
//    /**
//     * 获取 深库位排对应的浅库位排
//     */
//    public static Integer getShallowRow(SlaveProperties slaveProperties, Integer deepRow) {
//        int remainder = (int) Arith.remainder(deepRow, slaveProperties.getGroupCount());
//        return remainder == 1 ? (deepRow + 1) : (deepRow - 1);
//    }
//    /**
//     * 获取 浅库位对应的深库位号
//     */
//    public static String getDeepLoc(SlaveProperties slaveProperties, String shallowLoc) {
//        int row = getRow(shallowLoc);
//        int remainder = (int) Arith.remainder(row, slaveProperties.getGroupCount());
//        int targetRow;
//        if (remainder == 2) {
//            targetRow = row - 1;
//        } else if (remainder == 3) {
//            targetRow = row + 1;
//        } else {
//            throw new RuntimeException(shallowLoc + "不是浅库位,系统繁忙");
//        }
//        return zerofill(String.valueOf(targetRow), 2) + shallowLoc.substring(2);
//    }
    /**
     * 获取 浅库位对应的深库位号
     */
    public static String getDeepLoc(SlaveProperties slaveProperties, String shallowLoc) {
//        int row = getRow(shallowLoc);
//        int remainder = (int) Arith.remainder(row, slaveProperties.getGroupCount());
//        int targetRow;
//        if (remainder == 2) {
//            targetRow = row - 1;
//        } else if (remainder == 3) {
//            targetRow = row + 1;
//        } else {
//            throw new RuntimeException(shallowLoc + "不是浅库位,系统繁忙");
//        }
//        return zerofill(String.valueOf(targetRow), 2) + shallowLoc.substring(2);
        int row = getRow(shallowLoc);
        boolean deepLocLeft = isDeepLocLeft(slaveProperties, row-1);//判断是否为左浅库位
        int shallowRow = deepLocLeft? (row - 1) : (row + 1);
        boolean deepLocLeft = isDeepLocLeft(slaveProperties, row - 1);//判断是否为左浅库位
        int shallowRow = deepLocLeft ? (row - 1) : (row + 1);
        return zerofill(String.valueOf(shallowRow), 2) + shallowLoc.substring(2);
    }
    /**
     * 获取 浅库位对应的深库位号,如果没有深库位,则返回为空
     */
    public static String getDeepLoc2(SlaveProperties slaveProperties, String shallowLoc) {
        int row = getRow(shallowLoc);
        boolean deepLoc = isDeepLoc(slaveProperties, row);//判断是否为深库位
        if (deepLoc) {
            return null;
        }
        if (row == 1 || row == 6) {
            return null;
        }
        //4,7,11,15,19,23
        if (row == 4 || row == 7 || row == 11 || row == 15 || row == 19 || row == 23) {
            return zerofill(String.valueOf(row + 1), 2) + shallowLoc.substring(2);
        } else {
            return zerofill(String.valueOf(row - 1), 2) + shallowLoc.substring(2);
        }
    }
    /**
     * 获取 深库位排对应的浅库位排
@@ -197,38 +161,12 @@
        return deepLocLeft ? (deepRow + 1) : (deepRow - 1);
    }
//    /**
//     * 获取 浅库位排对应的深库位排
//     */
//    public static Integer getDeepRow(SlaveProperties slaveProperties, Integer shallowRow) {
//        int remainder = (int) Arith.remainder(shallowRow, slaveProperties.getGroupCount());
//        int targetRow;
//        if (remainder == 2) {
//            targetRow = shallowRow - 1;
//        } else if (remainder == 3) {
//            targetRow = shallowRow + 1;
//        } else {
//            throw new RuntimeException(shallowRow + "不是浅库位排,系统繁忙");
//        }
//        return targetRow;
//    }
    /**
     * 获取 浅库位排对应的深库位排
     */
    public static Integer getDeepRow(SlaveProperties slaveProperties, Integer shallowRow) {
//        int remainder = (int) Arith.remainder(shallowRow, slaveProperties.getGroupCount());
//        int targetRow;
//        if (remainder == 2) {
//            targetRow = shallowRow - 1;
//        } else if (remainder == 3) {
//            targetRow = shallowRow + 1;
//        } else {
//            throw new RuntimeException(shallowRow + "不是浅库位排,系统繁忙");
//        }
//        return targetRow;
        boolean deepLocLeft = isDeepLocLeft(slaveProperties, shallowRow-1);//判断是否为左浅库位
        return deepLocLeft? (shallowRow - 1) : (shallowRow + 1);
        boolean deepLocLeft = isDeepLocLeft(slaveProperties, shallowRow - 1);//判断是否为左浅库位
        return deepLocLeft ? (shallowRow - 1) : (shallowRow + 1);
    }
    /**
@@ -278,17 +216,6 @@
        String targetLoc = zerofill(String.valueOf(targetRow), 2) + shallowLoc.substring(2);
    }
//    public static void main(String[] args) {
//        SlaveProperties slaveProperties = new SlaveProperties();
//        slaveProperties.setDoubleDeep(true);
//        List<Integer> list = new ArrayList<>();
//        list.add(1);list.add(4);list.add(5);list.add(8);list.add(9);list.add(12);
//        slaveProperties.setDoubleLocs(list);
//        slaveProperties.setGroupCount(4);
//        Integer deepRow = getDeepRow(slaveProperties, 6);
//        System.out.println(deepRow);
//    }
    public static Integer GetWhsType(Integer sourceStaNo) {
        RowLastnoService rowLastnoService = SpringUtils.getBean(RowLastnoService.class);
@@ -551,6 +478,7 @@
        return necessaryParameters;
    }
    //四向库(牛眼\光泰)
    public static int[] LocNecessaryParametersDoubleExtension6(RowLastno rowLastno, Integer curRow, Integer crnNumber) {
        int[] necessaryParameters = new int[]{0, 0, 0, 0};
@@ -560,7 +488,7 @@
        necessaryParameters[0] = crnNumber; // 轮询次数
        curRow = curRow - offset;
        //满板正常入库
        switch (curRow){
        switch (curRow) {
            case 1:
                necessaryParameters[1] = 4;    //curRow   最深库位排
                necessaryParameters[2] = sCrnNo;     //crnNo     堆垛机号
@@ -606,7 +534,7 @@
        Integer sCrnNo = rowLastno.getsCrnNo();//起始堆垛机号
        necessaryParameters[0] = crnNumber; // 轮询次数
        //满板正常入库
        if (curRow.equals(rowLastno.geteRow())){
        if (curRow.equals(rowLastno.geteRow())) {
            necessaryParameters[1] = sRow;    //curRow   最深库位排
            necessaryParameters[2] = sCrnNo;     //crnNo     堆垛机号
            necessaryParameters[3] = sRow;    //nearRow  最浅库位排
@@ -681,12 +609,12 @@
    // 外侧方向的货位  优先入库方向 ===>> 反之
    public static List<String> getGroupOutLocCrn(Integer curRow, Integer nearRow, String locNo, boolean pakin) {
        List<String> result = new ArrayList<>();
        if (pakin){
            for (int row = curRow;row>=nearRow;row--){
        if (pakin) {
            for (int row = curRow; row >= nearRow; row--) {
                result.add(zerofill(String.valueOf(row), 2) + locNo.substring(2));
            }
        }else {
            for (int row = curRow;row<=nearRow;row++){
        } else {
            for (int row = curRow; row <= nearRow; row++) {
                result.add(zerofill(String.valueOf(row), 2) + locNo.substring(2));
            }
        }