From 8ea4c0fa09a08ec40e5f453bcde0fc7397b15b0d Mon Sep 17 00:00:00 2001
From: zzgtfwq <zzgtfwq>
Date: 星期二, 09 十二月 2025 15:08:25 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/utils/Utils.java |  200 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 183 insertions(+), 17 deletions(-)

diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java
index 4ead5ce..076be95 100644
--- a/src/main/java/com/zy/asrs/utils/Utils.java
+++ b/src/main/java/com/zy/asrs/utils/Utils.java
@@ -35,6 +35,91 @@
         return (float) Arith.multiplys(2, f, 1);
     }
 
+    public static int armStaNo(int armNo,int staNo) {
+        switch (armNo){
+            case 1:
+                switch (staNo){
+                    case 0:
+                        return 7;
+                    case 1:
+                        return 8;
+                    case 2:
+                        return 101;
+                    case 3:
+                        return 102;
+                    default:
+                        return 0;
+                }
+            case 2:
+                switch (staNo){
+                    case 0:
+                        return 5;
+                    case 1:
+                        return 6;
+                    case 2:
+                        return 101;
+                    case 3:
+                        return 102;
+                    default:
+                        return 0;
+                }
+            case 3:
+                switch (staNo){
+                    case 0:
+                        return 3;
+                    case 1:
+                        return 4;
+                    case 2:
+                        return 101;
+                    case 3:
+                        return 102;
+                    default:
+                        return 0;
+                }
+            case 4:
+                switch (staNo){
+                    case 0:
+                        return 1;
+                    case 1:
+                        return 2;
+                    case 2:
+                        return 101;
+                    case 3:
+                        return 102;
+                    default:
+                        return 0;
+                }
+            case 5:
+                switch (staNo){
+                    case 0:
+                        return 11;
+                    case 1:
+                        return 12;
+                    case 2:
+                        return 101;
+                    case 3:
+                        return 102;
+                    default:
+                        return 0;
+                }
+            case 6:
+                switch (staNo){
+                    case 0:
+                        return 13;
+                    case 1:
+                        return 14;
+                    case 2:
+                        return 101;
+                    case 3:
+                        return 102;
+                    default:
+                        return 0;
+                }
+            default:
+                return 0;
+        }
+    }
+
     public static String zerofill(String msg, Integer count) {
         if (msg.length() == count) {
             return msg;
@@ -123,9 +208,17 @@
      */
     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);
+        boolean deepLocLeft = isDeepLocLeft(slaveProperties, row);
+        boolean deepLocRight = isDeepLocRight(slaveProperties, row);
+        int targetRow;
+        if (deepLocLeft) {
+            targetRow = row + 1;
+        } else if (deepLocRight) {
+            targetRow = row - 1;
+        } else {
+            throw new RuntimeException(deepLoc + "涓嶆槸娴呭簱浣嶏紝绯荤粺绻佸繖");
+        }
+        return zerofill(String.valueOf(targetRow), 2) + deepLoc.substring(2);
     }
 
     /**
@@ -141,30 +234,45 @@
      */
     public static String getDeepLoc(SlaveProperties slaveProperties, String shallowLoc) {
         int row = getRow(shallowLoc);
-        int remainder = (int) Arith.remainder(row, slaveProperties.getGroupCount());
+        boolean deepLocLeft = isDeepLocLeft(slaveProperties, row-1);
+        boolean deepLocRight = isDeepLocRight(slaveProperties, row+1);
         int targetRow;
-        if (remainder == 2) {
+        if (deepLocLeft) {
             targetRow = row - 1;
-        } else if (remainder == 3) {
+        } else if (deepLocRight) {
             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);
+//    }
 
     /**
      * 鑾峰彇 娴呭簱浣嶆帓瀵瑰簲鐨勬繁搴撲綅鎺�
      */
     public static Integer getDeepRow(SlaveProperties slaveProperties, Integer shallowRow) {
-        int remainder = (int) Arith.remainder(shallowRow, slaveProperties.getGroupCount());
+        boolean deepLocLeft = isDeepLocLeft(slaveProperties, shallowRow-1);
+        boolean deepLocRight = isDeepLocRight(slaveProperties, shallowRow+1);
         int targetRow;
-        if (remainder == 2) {
+        if (deepLocLeft) {
             targetRow = shallowRow - 1;
-        } else if (remainder == 3) {
+        } else if (deepLocRight) {
             targetRow = shallowRow + 1;
         } else {
-            throw new RuntimeException(shallowRow + "涓嶆槸娴呭簱浣嶆帓锛岀郴缁熺箒蹇�");
+            throw new RuntimeException(shallowRow + "涓嶆槸娴呭簱浣嶏紝绯荤粺绻佸繖");
         }
         return targetRow;
     }
@@ -249,6 +357,13 @@
         return false;
     }
 
+    public static boolean BooleanWhsTypeSta(Integer whsType) {
+        if (whsType == 1 || whsType == 2 || whsType == 5 || whsType==3 || whsType==4 || whsType == 9) {
+            return true;
+        }
+        return false;
+    }
+
     public static boolean BooleanWhsTypeSta(RowLastno rowLastno, Integer staDescId) {//绔欑偣璺緞鏇存柊
         if (rowLastno.getPointSwitch().equals("Y") && staDescId != 11 && staDescId != 111) {
             return true;
@@ -276,7 +391,8 @@
     public static int[] LocNecessaryParameters(RowLastno rowLastno, Integer curRow, Integer crnNumber) {
         switch (rowLastno.getTypeId()) {
             case 1://缁忓吀鍙屼几搴撲綅
-                return LocNecessaryParametersDoubleExtension(rowLastno, curRow, crnNumber); //宸插畬鍠�
+                return LocNecessaryParametersDoubleExtension9(rowLastno, curRow, crnNumber); //宸插畬鍠�
+//                return LocNecessaryParametersDoubleExtension(rowLastno, curRow, crnNumber); //宸插畬鍠�
             case 2://缁忓吀鍗曚几搴撲綅锛�2鎺掕揣鏋讹級
                 return LocNecessaryParametersDoubleExtension2(rowLastno, curRow, crnNumber); //宸插畬鍠�
             case 3://缁忓吀鍗曞弻浼稿簱浣�  宸﹀崟鍙冲弻(灏忓崟澶у弻)
@@ -289,9 +405,59 @@
                 return LocNecessaryParametersDoubleExtension6(rowLastno, curRow, crnNumber); //宸插畬鍠�
             case 7://骞冲簱  CTU搴�
                 return LocNecessaryParametersDoubleExtension7(rowLastno, curRow, crnNumber); //宸插畬鍠�
+            case 9://鍓嶅弻浼� 鍚庡乏鍗曞彸鍙�(灏忓崟澶у弻)  娓姇瀹氬埗
+                return LocNecessaryParametersDoubleExtension9(rowLastno, curRow, crnNumber); //宸插畬鍠�
             default:
                 return LocNecessaryParametersMove(rowLastno, curRow, crnNumber);//moveCrnNo
         }
+    }
+
+    public static int[] LocNecessaryParametersDoubleExtension9(RowLastno rowLastno, Integer curRow, Integer crnNumber) {
+        int[] necessaryParameters = new int[]{0, 0, 0, 0};
+
+        Integer sRow = rowLastno.getsRow();
+        Integer sCrnNo = rowLastno.getsCrnNo();
+        necessaryParameters[0] = crnNumber; // 杞娆℃暟
+        //婊℃澘姝e父鍏ュ簱
+        if (curRow.equals(14)) {
+            necessaryParameters[1] = 1;    //curRow   鏈�娣卞簱浣嶆帓
+            necessaryParameters[2] = 1;     //crnNo     鍫嗗灈鏈哄彿
+            necessaryParameters[3] = 2;    //nearRow  鏈�娴呭簱浣嶆帓
+        } else if (curRow.equals(11)) {
+            necessaryParameters[1] = 4;    //curRow   鏈�娣卞簱浣嶆帓
+            necessaryParameters[2] = 1;     //crnNo     鍫嗗灈鏈哄彿
+            necessaryParameters[3] = 3;    //nearRow  鏈�娴呭簱浣嶆帓
+        } else if (curRow.equals(10)) {
+            necessaryParameters[1] = 14;    //curRow   鏈�娣卞簱浣嶆帓
+            necessaryParameters[2] = 4;     //crnNo     鍫嗗灈鏈哄彿
+            necessaryParameters[3] = 13;    //nearRow  鏈�娴呭簱浣嶆帓
+        } else if (curRow.equals(9)) {
+            necessaryParameters[1] = 11;    //curRow   鏈�娣卞簱浣嶆帓
+            necessaryParameters[2] = 4;     //crnNo     鍫嗗灈鏈哄彿
+            necessaryParameters[3] = 12;    //nearRow  鏈�娴呭簱浣嶆帓
+        } else if (curRow.equals(8)) {
+            necessaryParameters[1] = 10;    //curRow   鏈�娣卞簱浣嶆帓
+            necessaryParameters[2] = 3;     //crnNo     鍫嗗灈鏈哄彿
+            necessaryParameters[3] = 10;    //nearRow  鏈�娴呭簱浣嶆帓
+        } else if (curRow.equals(5)) {
+            necessaryParameters[1] = 9;    //curRow   鏈�娣卞簱浣嶆帓
+            necessaryParameters[2] = 3;     //crnNo     鍫嗗灈鏈哄彿
+            necessaryParameters[3] = 9;    //nearRow  鏈�娴呭簱浣嶆帓
+        } else if (curRow.equals(4)) {
+            necessaryParameters[1] = 8;    //curRow   鏈�娣卞簱浣嶆帓
+            necessaryParameters[2] = 2;     //crnNo     鍫嗗灈鏈哄彿
+            necessaryParameters[3] = 7;    //nearRow  鏈�娴呭簱浣嶆帓
+        } else if (curRow.equals(1)) {
+            necessaryParameters[1] = 5;    //curRow   鏈�娣卞簱浣嶆帓
+            necessaryParameters[2] = 2;     //crnNo     鍫嗗灈鏈哄彿
+            necessaryParameters[3] = 6;    //nearRow  鏈�娴呭簱浣嶆帓
+        } else {
+            necessaryParameters[1] = 1;    //curRow   鏈�娣卞簱浣嶆帓
+            necessaryParameters[2] = 1;     //crnNo     鍫嗗灈鏈哄彿
+            necessaryParameters[3] = 2;    //nearRow  鏈�娴呭簱浣嶆帓
+        }
+
+        return necessaryParameters;
     }
 
     //缁忓吀鍙屼几搴撲綅
@@ -315,14 +481,14 @@
             if (curRow < sRow || curRow > (crnNumber * 4 + sRow - 1)) {
                 throw new CoolException("搴撲綅鎺掑彿寮傚父锛氭帓鍙凤細" + curRow);
             }
-            if ((curRow - sRow) % 4 == 0) {
+            if ((curRow - (sRow-1)) % 4 == 0) {
                 necessaryParameters[1] = curRow;    //curRow   鏈�娣卞簱浣嶆帓
-                necessaryParameters[2] = (curRow - sRow + 2) / 4 + sCrnNo - 1;     //crnNo     鍫嗗灈鏈哄彿
-                necessaryParameters[3] = curRow + 1;    //nearRow  鏈�娴呭簱浣嶆帓
-            } else if ((curRow - sRow + 1) % 4 == 0) {
-                necessaryParameters[1] = curRow;    //curRow   鏈�娣卞簱浣嶆帓
-                necessaryParameters[2] = (curRow - sRow + 1) / 4 + sCrnNo - 1;     //crnNo     鍫嗗灈鏈哄彿
+                necessaryParameters[2] = (curRow - (sRow-1)) / 4 + sCrnNo - 1;     //crnNo     鍫嗗灈鏈哄彿
                 necessaryParameters[3] = curRow - 1;    //nearRow  鏈�娴呭簱浣嶆帓
+            } else if ((curRow - (sRow-1)-1) % 4 == 0) {
+                necessaryParameters[1] = curRow;    //curRow   鏈�娣卞簱浣嶆帓
+                necessaryParameters[2] = (curRow - (sRow-1)-1) / 4 + sCrnNo;     //crnNo     鍫嗗灈鏈哄彿
+                necessaryParameters[3] = curRow + 1;    //nearRow  鏈�娴呭簱浣嶆帓
             } else {
                 throw new CoolException("搴撲綅鎺掑彿寮傚父锛氭帓鍙凤細" + curRow);
             }

--
Gitblit v1.9.1