From 1864f916e0359d0814416cf94feda3a3662ed193 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期五, 05 九月 2025 16:39:29 +0800
Subject: [PATCH] 1
---
zy-acs-common/src/main/java/com/zy/acs/common/utils/Utils.java | 49 ++++++++++++++++++++++++++++---------------------
1 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/zy-acs-common/src/main/java/com/zy/acs/common/utils/Utils.java b/zy-acs-common/src/main/java/com/zy/acs/common/utils/Utils.java
index 9aeb598..26fa54b 100644
--- a/zy-acs-common/src/main/java/com/zy/acs/common/utils/Utils.java
+++ b/zy-acs-common/src/main/java/com/zy/acs/common/utils/Utils.java
@@ -2,10 +2,7 @@
import com.zy.acs.framework.common.Cools;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Optional;
+import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.Function;
@@ -37,7 +34,7 @@
if (parentId.equals(dParentId)) {
R dId = idMapper.apply(d);
List<T> children = toTreeData(data, dId, parentIdMapper, idMapper, consumer);
- if(children.size() > 0) {
+ if (!children.isEmpty()) {
consumer.accept(d, children);
}
result.add(d);
@@ -63,8 +60,6 @@
/**
* 鏁扮粍鍊掑簭
- * @param bytes
- * @param <T>
*/
public static <T> byte[] reverse(byte[] bytes) {
if (bytes == null) return null;
@@ -78,6 +73,7 @@
/**
* 鎴彇鏁扮粍
+ *
* @param bytes 鍘熸暟缁�
* @param pos 瀹氫綅锛堟埅鍙栧悗鍖呭惈瀹氫綅鐐规暟鎹級
* @param len 闀垮害
@@ -122,7 +118,7 @@
idx += bytes.length;
}
if (object instanceof Byte) {
- byte[] bytes = new byte[] {(Byte) object};
+ byte[] bytes = new byte[]{(Byte) object};
System.arraycopy(bytes, 0, arr, idx, bytes.length);
idx += bytes.length;
}
@@ -145,14 +141,14 @@
public static String zeroFill(String msg, Integer len) {
len = Optional.ofNullable(len).orElse(16);
- if (msg.length() == len){
+ if (msg.length() == len) {
return msg;
- } else if (msg.length() > len){
+ } else if (msg.length() > len) {
return msg.substring(0, 16);
} else {
StringBuilder msgBuilder = new StringBuilder(msg);
- for (int i = 0; i<len-msg.length(); i++){
- msgBuilder.insert(0,"0");
+ for (int i = 0; i < len - msg.length(); i++) {
+ msgBuilder.insert(0, "0");
}
return msgBuilder.toString();
}
@@ -182,9 +178,6 @@
}
}
- /**
- * 澶ч┘宄� 杞� symbol灏忛┘宄�
- */
public static String toSymbolCase(String str, char symbol) {
if (str == null) {
return null;
@@ -192,7 +185,7 @@
int length = str.length();
StringBuilder sb = new StringBuilder();
- for(int i = 0; i < length; ++i) {
+ for (int i = 0; i < length; ++i) {
char c = str.charAt(i);
if (Character.isUpperCase(c)) {
Character preChar = i > 0 ? str.charAt(i - 1) : null;
@@ -233,7 +226,7 @@
StringBuilder sb = new StringBuilder(length);
boolean upperCase = false;
- for(int i = 0; i < length; ++i) {
+ for (int i = 0; i < length; ++i) {
char c = name2.charAt(i);
if (c == '_') {
upperCase = true;
@@ -263,15 +256,29 @@
if (Cools.isEmpty(lastSeqNum)) {
return zeroFill("1", 4);
} else {
- int i = Integer.parseInt(lastSeqNum);
- if (i >= 9999) {
- return zeroFill("1", 4);
+ if (isNumericZidai(lastSeqNum)) {
+ int i = Integer.parseInt(lastSeqNum);
+ if (i >= 9999) {
+ return zeroFill("1", 4);
+ } else {
+ return zeroFill(String.valueOf(i + 1), 4);
+ }
} else {
- return zeroFill(String.valueOf(i+1), 4);
+ return zeroFill(new Random().nextInt(1000000) + "", 6);
}
}
}
+
+ public static boolean isNumericZidai(String str) {
+ for (int i = 0; i < str.length(); i++) {
+ if (!Character.isDigit(str.charAt(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
// pos start in 0
public static boolean getBit(byte b, int position) {
if (position < 0 || position > 7) {
--
Gitblit v1.9.1