From d16d3b70e94f798d7e5abd145f8566d81d0c66c9 Mon Sep 17 00:00:00 2001
From: 18516761980 <4761516tqsxp>
Date: 星期二, 14 六月 2022 18:07:45 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/model/Shelves.java |   39 +++++++++++++++++++++++++++++++--------
 1 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/zy/common/model/Shelves.java b/src/main/java/com/zy/common/model/Shelves.java
index 0fe0ec8..f607fcb 100644
--- a/src/main/java/com/zy/common/model/Shelves.java
+++ b/src/main/java/com/zy/common/model/Shelves.java
@@ -1,5 +1,8 @@
 package com.zy.common.model;
 
+import com.alibaba.fastjson.JSON;
+import com.core.exception.CoolException;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -11,16 +14,16 @@
 public class Shelves {
 
     // 璐ф灦鎺掓暟閲�
-    private final int size;
+    public final int size;
 
     // 璐ф灦缁勬暟閲�
-    private final int group;
+    public final int group;
 
     // 鍋忕Щ閲廩default:0]
-    private final int offset;
+    public final int offset;
 
     // 璐ф灦瀹炰緥鑺傜偣闆嗗悎
-    private List<List<Integer>> nodes;
+    public List<List<Integer>> nodes;
 
     public Shelves(int size, int group) {
         this(size, group, 0);
@@ -61,7 +64,7 @@
      *
      *          璐ф灦鍛戒腑瑙勫垯濡備笅锛�
      *              瀹夎浣嶇疆锛�   [1]  [2]  |  [3]  [4]  --------  [5] [6]  |  [7] [8]
-     *                  鍛戒腑椤哄簭锛�      1 -> 5 -> 4 -> 8 -> 2 -> 6 -> 3 -> 9 -> 1 ...
+     *                  鍛戒腑椤哄簭锛�      1 -> 5 -> 4 -> 8 -> 2 -> 6 -> 3 -> 7 -> 1 ...
      *
      *          1.璇ヨ鍒欓�備笉闄愬埗璐ф灦鏁伴噺锛屾�绘暟涓庣粍鍒湪鏋勯�犲櫒涓缃�
      *          2.濡傛湁搴忓垪鍙疯捣濮嬮棶棰橈紝鐢ㄥ亸绉婚噺瑙勯伩鍗冲彲
@@ -94,17 +97,37 @@
                 }
             }
         }
-        return 0;
+        return -1;
     }
 
+    public Integer get(Integer curRow) {
+        for (List<Integer> node : nodes){
+            if (node.contains(curRow)) {
+                return nodes.indexOf(node) + 1;
+            }
+        }
+        throw new CoolException("璐ф帓妫�绱㈢郴缁熸姤閿欙紝 node:" + JSON.toJSONString(nodes) + ", curRow:" + curRow);
+    }
+
+    public int start0(int curSeq){
+        if (curSeq < 7) {
+            return curSeq + 1;
+        } else {
+            return 2;
+        }
+    }
+
+    public Integer get0(Integer curRow) {
+        return 1;
+    }
 
     public static void main(String[] args) throws InterruptedException {
-        Shelves shelves = new Shelves(8,2);
+        Shelves shelves = new Shelves(6,2);
         System.out.println(shelves.nodes.toString());
         int start = 1;
         while (true) {
             System.out.println(start);
-            start = shelves.start(start);
+            start = shelves.start0(start);
             Thread.sleep(500L);
         }
     }

--
Gitblit v1.9.1