From 22fc6125f32ecb4d05c7a2e9397a4eabd6a5d7ad Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期三, 20 九月 2023 14:41:33 +0800
Subject: [PATCH] #入库逻辑2.0 简单方便易理解
---
src/main/java/com/zy/asrs/utils/Utils.java | 182 ++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 160 insertions(+), 22 deletions(-)
diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java
index 03cb782..90c58c9 100644
--- a/src/main/java/com/zy/asrs/utils/Utils.java
+++ b/src/main/java/com/zy/asrs/utils/Utils.java
@@ -2,10 +2,14 @@
import com.core.common.Arith;
import com.core.common.Cools;
+import com.core.exception.CoolException;
import com.zy.common.properties.SlaveProperties;
+import com.zy.common.service.CommonService;
import java.text.DecimalFormat;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
/**
@@ -60,6 +64,29 @@
}
/**
+ * 鍒ゆ柇鏄惁涓哄乏娣卞簱浣�
+ */
+ public static boolean isDeepLocLeft(SlaveProperties slaveProperties, Integer row){
+ if (slaveProperties.isDoubleDeep()) {
+ return slaveProperties.getDoubleLocsLeft().contains(row);
+ } else {
+ return false;
+ }
+ }
+
+
+ /**
+ * 鍒ゆ柇鏄惁涓哄彸娣卞簱浣�
+ */
+ public static boolean isDeepLocRight(SlaveProperties slaveProperties, Integer row){
+ if (slaveProperties.isDoubleDeep()) {
+ return slaveProperties.getDoubleLocsRight().contains(row);
+ } else {
+ return false;
+ }
+ }
+
+ /**
* 鍒ゆ柇鏄惁涓烘祬搴撲綅
*/
public static boolean isShallowLoc(SlaveProperties slaveProperties, String locNo){
@@ -88,14 +115,7 @@
public static String getShallowLoc(SlaveProperties slaveProperties, String deepLoc) {
int row = getRow(deepLoc);
int remainder = (int) Arith.remainder(row, slaveProperties.getGroupCount());
- int shallowRow ;
- if (row == 15 || row == 9) {
- shallowRow = row + 1;
- } else if (row == 12 || row==18) {
- shallowRow = row - 1;
- } else {
- throw new RuntimeException(row + "涓嶆槸娴呭簱浣嶏紝绯荤粺绻佸繖");
- }
+ int shallowRow = remainder == 1 ? (row + 1) : (row - 1);
return zerofill(String.valueOf(shallowRow), 2) + deepLoc.substring(2);
}
@@ -114,12 +134,12 @@
int row = getRow(shallowLoc);
int remainder = (int) Arith.remainder(row, slaveProperties.getGroupCount());
int targetRow;
- if (row == 10 || row == 16) {
+ if (remainder == 2) {
targetRow = row - 1;
- } else if (row == 11 || row == 17) {
+ } else if (remainder == 3) {
targetRow = row + 1;
} else {
- throw new RuntimeException(row + "涓嶆槸娴呭簱浣嶆帓锛岀郴缁熺箒蹇�");
+ throw new RuntimeException(shallowLoc + "涓嶆槸娴呭簱浣嶏紝绯荤粺绻佸繖");
}
return zerofill(String.valueOf(targetRow), 2) + shallowLoc.substring(2);
}
@@ -130,9 +150,9 @@
public static Integer getDeepRow(SlaveProperties slaveProperties, Integer shallowRow) {
int remainder = (int) Arith.remainder(shallowRow, slaveProperties.getGroupCount());
int targetRow;
- if (shallowRow == 10 || shallowRow == 16) {
+ if (remainder == 2) {
targetRow = shallowRow - 1;
- } else if (shallowRow == 11 || shallowRow == 17) {
+ } else if (remainder == 3) {
targetRow = shallowRow + 1;
} else {
throw new RuntimeException(shallowRow + "涓嶆槸娴呭簱浣嶆帓锛岀郴缁熺箒蹇�");
@@ -146,6 +166,26 @@
public static int getRow(String locNo) {
if (!Cools.isEmpty(locNo)) {
return Integer.parseInt(locNo.substring(0, 2));
+ }
+ throw new RuntimeException("搴撲綅瑙f瀽寮傚父");
+ }
+
+ /**
+ * 閫氳繃搴撲綅鍙疯幏鍙� 鍒�
+ */
+ public static int getBay(String locNo) {
+ if (!Cools.isEmpty(locNo)) {
+ return Integer.parseInt(locNo.substring(2, 5));
+ }
+ throw new RuntimeException("搴撲綅瑙f瀽寮傚父");
+ }
+
+ /**
+ * 閫氳繃搴撲綅鍙疯幏鍙� 灞�
+ */
+ public static int getLev(String locNo) {
+ if (!Cools.isEmpty(locNo)) {
+ return Integer.parseInt(locNo.substring(5, 7));
}
throw new RuntimeException("搴撲綅瑙f瀽寮傚父");
}
@@ -168,15 +208,113 @@
}
- 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 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 List<String> getGroupOutsideLocCrn(String locNo,boolean pakin){
+ int row = getRow(locNo);
+ List<String> result = new ArrayList<>();
+ result.add(locNo);
+
+// result.add(zerofill(String.valueOf(32), 2) + locNo.substring(2));
+
+ return result;
+ }
+
+ public static boolean BooleanWhsTypeSta(Integer whsType){
+ if (whsType==1){
+ return true;
+ }
+ return false;
+ }
+
+ public static int RowCount(Integer whsType,Integer curRow){
+ return LocNecessaryParameters(whsType, curRow)[0];
+ }
+ public static int getCurRow(Integer whsType,Integer curRow){
+ return LocNecessaryParameters(whsType, curRow)[1];
+ }
+ public static int getCrnNo(Integer whsType,Integer curRow){
+ return LocNecessaryParameters(whsType, curRow)[2];
+ }
+ public static int getNearRow(Integer whsType,Integer curRow){
+ return LocNecessaryParameters(whsType, curRow)[3];
+ }
+
+ //搴撲綅鎺掑彿鍒嗛厤
+ public static int[] LocNecessaryParameters(Integer whsType,Integer curRow){
+ int[] necessaryParameters=new int[]{0,0,0,0};
+ if (BooleanWhsTypeSta(whsType)){
+ necessaryParameters[0] = 6;
+ switch (curRow){ //婊℃澘姝e父鍏ュ簱
+ case 24:
+ necessaryParameters[1] = 1; //curRow 鏈�娣卞簱浣嶆帓
+ necessaryParameters[2] = 1; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[3] = 2; //nearRow 鏈�娴呭簱浣嶆帓
+ break;
+ case 21:
+ necessaryParameters[1] = 4; //curRow 鏈�娣卞簱浣嶆帓
+ necessaryParameters[2] = 1; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[3] = 3; //nearRow 鏈�娴呭簱浣嶆帓
+ break;
+ default:
+ curRow=curRow+4;
+ if (curRow<1 || curRow>24){
+ throw new CoolException("搴撲綅鎺掑彿寮傚父锛氭帓鍙凤細"+curRow);
+ }
+ if ((curRow-1)%4==0){
+ necessaryParameters[1] = curRow; //curRow 鏈�娣卞簱浣嶆帓
+ necessaryParameters[2] = (curRow+3)/4; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[3] = curRow+1; //nearRow 鏈�娴呭簱浣嶆帓
+ }else if (curRow%4==0){
+ necessaryParameters[1] = curRow; //curRow 鏈�娣卞簱浣嶆帓
+ necessaryParameters[2] = curRow/4; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[3] = curRow-1; //nearRow 鏈�娴呭簱浣嶆帓
+ }else {
+ throw new CoolException("搴撲綅鎺掑彿寮傚父锛氭帓鍙凤細"+curRow);
+ }
+ }
+ }else {//绌烘澘涓嶅叆1鍙�
+ necessaryParameters[0] = 5;
+ switch (curRow){
+ case 24:
+ necessaryParameters[1] = 5; //curRow 鏈�娣卞簱浣嶆帓
+ necessaryParameters[2] = 2; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[3] = 6; //nearRow 鏈�娴呭簱浣嶆帓
+ break;
+ case 21:
+ necessaryParameters[1] = 8; //curRow 鏈�娣卞簱浣嶆帓
+ necessaryParameters[2] = 2; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[3] = 7; //nearRow 鏈�娴呭簱浣嶆帓
+ break;
+ default:
+ curRow=curRow+4;
+ if (curRow<5 || curRow>24){
+ throw new CoolException("搴撲綅鎺掑彿寮傚父锛氭帓鍙凤細"+curRow);
+ }
+ if ((curRow-1)%4==0){
+ necessaryParameters[1] = curRow; //curRow 鏈�娣卞簱浣嶆帓
+ necessaryParameters[2] = (curRow+3)/4; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[3] = curRow+1; //nearRow 鏈�娴呭簱浣嶆帓
+ }else if (curRow%4==0){
+ necessaryParameters[1] = curRow; //curRow 鏈�娣卞簱浣嶆帓
+ necessaryParameters[2] = curRow/4; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[3] = curRow-1; //nearRow 鏈�娴呭簱浣嶆帓
+ }else {
+ throw new CoolException("搴撲綅鎺掑彿寮傚父锛氭帓鍙凤細"+curRow);
+ }
+ }
+ }
+ return necessaryParameters;
}
}
--
Gitblit v1.9.1