#
luxiaotao1123
2020-06-11 dc38614bc3cba86365175fec2d897f24fcb8a084
#
1个文件已修改
23 ■■■■ 已修改文件
src/main/java/com/zy/common/model/Shelves.java 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/model/Shelves.java
@@ -5,6 +5,7 @@
import java.util.List;
/**
 * <strong>立库货架实体类</strong>
 * Created by vincent on 2020/6/11
 */
public class Shelves {
@@ -16,15 +17,20 @@
    private final int group;
    // 偏移量[default:0]
    private int offset = 0;
    private final int offset;
    // 货架实例节点
    // 货架实例节点集合
    private List<List<Integer>> nodes;
    public Shelves(int size, int group) {
        this(size, group, 0);
    }
    /**
     * @param size 货架单排总数
     * @param group 货架组数量
     * @param offset 序列号偏移量
     */
    public Shelves(int size, int group, int offset) {
        this.size = size;
        this.group = group;
@@ -33,15 +39,15 @@
    }
    /**
     * 初始化
     * 初始化方法【私有】
     */
    private void init(){
        if (group == 0 || size%group != 0) {
            throw new RuntimeException("shelves init fail!");
        }
        nodes = new ArrayList<>();
        for (int g = 1; g <= this.group; g++){ // 1 2
            int unit = size/group;  // 4
        for (int g = 1; g <= this.group; g++){
            int unit = size/group;
            List<Integer> node = new ArrayList<>();
            for (int i = (g-1)*unit+1+offset ; i <= g*unit+offset; i++){
                node.add(i);
@@ -51,6 +57,12 @@
    }
    /**
     * 开始计算 =======>>>
     *          货架命中规则如下:
     *              安装位置:   [1]  [2]  |  [3]  [4]  --------  [5] [6]  |  [7] [8]
     *                  命中顺序:      1 -> 5 -> 4 -> 8 -> 2 -> 6 -> 3 -> 9
     *          1.该规则适不限制货架数量,总数与组别在构造器中设置
     *          2.如有序列号起始问题,用偏移量规避即可
     *
     * @param curSeq 当前货架号
     * @return 规则命中货架号
@@ -83,6 +95,7 @@
        return 0;
    }
    public static void main(String[] args) throws InterruptedException {
        Shelves shelves = new Shelves(4,2);
        System.out.println(shelves.nodes.toString());