From 44b6b79dd5dee0ebbd2d11b08abbc2be275bed58 Mon Sep 17 00:00:00 2001
From: zwl <1051256694@qq.com>
Date: 星期一, 09 二月 2026 16:10:17 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/utils/Utils.java | 145 ++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 127 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/zy/asrs/utils/Utils.java b/src/main/java/com/zy/asrs/utils/Utils.java
index b2690ec..0c4b4aa 100644
--- a/src/main/java/com/zy/asrs/utils/Utils.java
+++ b/src/main/java/com/zy/asrs/utils/Utils.java
@@ -16,10 +16,13 @@
import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
/**
* Created by vincent on 2020/8/27
@@ -47,6 +50,26 @@
}
return msgBuilder.toString();
}
+ }
+
+ public static boolean isValidFormat(String dateStr, String format) {
+ SimpleDateFormat sdf = new SimpleDateFormat(format);
+ sdf.setLenient(false); // 涓ユ牸妯″紡锛屽繀椤诲畬鍏ㄥ尮閰嶆牸寮�
+ try {
+ sdf.parse(dateStr);
+ return true;
+ } catch (ParseException e) {
+ return false;
+ }
+ }
+
+ public static Date getFormateDate(String datestr) {
+ //瀛楃涓茶浆鏃ユ湡
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+ LocalDateTime parse = LocalDateTime.parse(datestr, dateTimeFormatter);
+ Instant instant = parse.atZone(ZoneId.systemDefault()).toInstant();
+ Date date = Date.from(instant);
+ return date;
}
/**
@@ -180,6 +203,23 @@
}
/**
+ * 灏� 1-1-1 鏍煎紡鐨勫簱浣嶈浆鎹负 0100101 鏍煎紡 (鎺�-鍒�-灞�)
+ * 鍏煎 1-11-1 -> 0101101
+ * @param locStr 1-1-1
+ * @return 0100101
+ */
+ public static String convertLocFormat(String locStr) {
+ if (Cools.isEmpty(locStr)) {
+ return null;
+ }
+ String[] split = locStr.split("-");
+ if (split.length != 3) {
+ return locStr;
+ }
+ return zerofill(split[0].trim(), 2) + zerofill(split[1].trim(), 3) + zerofill(split[2].trim(), 2);
+ }
+
+ /**
* 閫氳繃搴撲綅鍙疯幏鍙� 鍒�
*/
public static int getBay(String locNo) {
@@ -287,6 +327,8 @@
return LocNecessaryParametersDoubleExtension5(rowLastno, curRow, crnNumber); //宸插畬鍠�
case 6://鍥涘悜搴�(鐗涚溂杞�)eg:鍏夋嘲鍥涘悜
return LocNecessaryParametersDoubleExtension6(rowLastno, curRow, crnNumber); //宸插畬鍠�
+ case 7://骞冲簱 CTU搴�
+ return LocNecessaryParametersDoubleExtension7(rowLastno, curRow, crnNumber); //宸插畬鍠�
default:
return LocNecessaryParametersMove(rowLastno, curRow, crnNumber);//moveCrnNo
}
@@ -474,7 +516,7 @@
}
if ((curRow - sRow) % 4 == 0) {
necessaryParameters[1] = curRow; //curRow 鏈�娣卞簱浣嶆帓
- necessaryParameters[2] = (curRow - sRow + 2) / 4 + sCrnNo - 1; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[2] = (curRow - sRow + 2) / 4 + sCrnNo; //crnNo 鍫嗗灈鏈哄彿
necessaryParameters[3] = curRow + 1; //nearRow 鏈�娴呭簱浣嶆帓
} else if ((curRow - sRow + 1) % 4 == 0) {
necessaryParameters[1] = curRow; //curRow 鏈�娣卞簱浣嶆帓
@@ -491,31 +533,21 @@
public static int[] LocNecessaryParametersDoubleExtension6(RowLastno rowLastno, Integer curRow, Integer crnNumber) {
int[] necessaryParameters = new int[]{0, 0, 0, 0};
Integer sRow = rowLastno.getsRow();//璧峰鎺掑彿
- Integer offset = 0;//璧峰鎺掑彿
+ Integer offset = 4;//璧峰鎺掑彿
Integer sCrnNo = rowLastno.getsCrnNo();//璧峰鍫嗗灈鏈哄彿
necessaryParameters[0] = crnNumber; // 杞娆℃暟
curRow = curRow - offset;
//婊℃澘姝e父鍏ュ簱
switch (curRow){
- case 2:
+ case 1:
necessaryParameters[1] = 4; //curRow 鏈�娣卞簱浣嶆帓
necessaryParameters[2] = sCrnNo; //crnNo 鍫嗗灈鏈哄彿
necessaryParameters[3] = 7; //nearRow 鏈�娴呭簱浣嶆帓
break;
- case 7:
+ case 4:
necessaryParameters[1] = 9; //curRow 鏈�娣卞簱浣嶆帓
necessaryParameters[2] = sCrnNo; //crnNo 鍫嗗灈鏈哄彿
necessaryParameters[3] = 12; //nearRow 鏈�娴呭簱浣嶆帓
- break;
- case 12:
- necessaryParameters[1] = 7; //curRow 鏈�娣卞簱浣嶆帓
- necessaryParameters[2] = sCrnNo; //crnNo 鍫嗗灈鏈哄彿
- necessaryParameters[3] = 4; //nearRow 鏈�娴呭簱浣嶆帓
- break;
- case 4:
- necessaryParameters[1] = 12; //curRow 鏈�娣卞簱浣嶆帓
- necessaryParameters[2] = sCrnNo; //crnNo 鍫嗗灈鏈哄彿
- necessaryParameters[3] = 9; //nearRow 鏈�娴呭簱浣嶆帓
break;
case 9:
necessaryParameters[1] = 14; //curRow 鏈�娣卞簱浣嶆帓
@@ -523,6 +555,16 @@
necessaryParameters[3] = 14; //nearRow 鏈�娴呭簱浣嶆帓
break;
case 14:
+ necessaryParameters[1] = 7; //curRow 鏈�娣卞簱浣嶆帓
+ necessaryParameters[2] = sCrnNo; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[3] = 4; //nearRow 鏈�娴呭簱浣嶆帓
+ break;
+ case 7:
+ necessaryParameters[1] = 12; //curRow 鏈�娣卞簱浣嶆帓
+ necessaryParameters[2] = sCrnNo; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[3] = 9; //nearRow 鏈�娴呭簱浣嶆帓
+ break;
+ case 12:
necessaryParameters[1] = 1; //curRow 鏈�娣卞簱浣嶆帓
necessaryParameters[2] = sCrnNo; //crnNo 鍫嗗灈鏈哄彿
necessaryParameters[3] = 2; //nearRow 鏈�娴呭簱浣嶆帓
@@ -532,6 +574,26 @@
}
necessaryParameters[1] = necessaryParameters[1] + offset;
necessaryParameters[3] = necessaryParameters[3] + offset;
+ return necessaryParameters;
+ }
+
+ //骞冲簱锛堝厜娉癨CTU锛�
+ public static int[] LocNecessaryParametersDoubleExtension7(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(rowLastno.geteRow())){
+ necessaryParameters[1] = sRow; //curRow 鏈�娣卞簱浣嶆帓
+ necessaryParameters[2] = sCrnNo; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[3] = sRow; //nearRow 鏈�娴呭簱浣嶆帓
+ } else {
+ necessaryParameters[1] = curRow + 1; //curRow 鏈�娣卞簱浣嶆帓
+ necessaryParameters[2] = sCrnNo; //crnNo 鍫嗗灈鏈哄彿
+ necessaryParameters[3] = curRow + 1; //nearRow 鏈�娴呭簱浣嶆帓
+ }
+
return necessaryParameters;
}
@@ -609,4 +671,51 @@
return result;
}
+ /**
+ * 鏃ユ湡杞崲涓哄瓧绗︿覆
+ * @param date 鏃ユ湡
+ * @param format 鏍煎紡
+ * @return 瀛楃涓�
+ */
+ public static String dateToStr(Date date, String format) {
+ SimpleDateFormat sdf = new SimpleDateFormat(format);
+ return sdf.format(date);
+ }
+
+
+ //灏唚ms搴撲綅鍙疯浆鎹㈡垚wcs搴撲綅鍙�
+ public static String WMSLocToWCSLoc(String locNo) {
+ String row = locNo.substring(0, 2);
+ int i = 0;
+ for (char c : row.toCharArray()) {
+ if (c == '0') {
+ i++;
+ }else {
+ break;
+ }
+ }
+ row = row.substring(i);
+ int j = 0;
+ String boy = locNo.substring(2, 5);
+ for (char c : boy.toCharArray()) {
+ if (c == '0') {
+ j++;
+ }else {
+ break;
+ }
+ }
+ boy = boy.substring(j);
+ int k = 0;
+ String lev = locNo.substring(5);
+ for (char c : lev.toCharArray()) {
+ if (c == '0') {
+ k++;
+ }else {
+ break;
+ }
+ }
+ lev = lev.substring(k);
+ return row + "-" + boy + "-" + lev;
+ }
+
}
--
Gitblit v1.9.1