From e9cc2b361b5788c5e7aac0af3fe53031a76a6787 Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期四, 04 九月 2025 09:40:50 +0800
Subject: [PATCH] 1

---
 zy-acs-common/src/main/java/com/zy/acs/common/utils/Utils.java |   44 ++++++++++++++++++++++++++++----------------
 1 files changed, 28 insertions(+), 16 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 c50cb92..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.isEmpty()) {
+                if (!children.isEmpty()) {
                     consumer.accept(d, children);
                 }
                 result.add(d);
@@ -76,6 +73,7 @@
 
     /**
      * 鎴彇鏁扮粍
+     *
      * @param bytes 鍘熸暟缁�
      * @param pos   瀹氫綅锛堟埅鍙栧悗鍖呭惈瀹氫綅鐐规暟鎹級
      * @param len   闀垮害
@@ -120,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;
             }
@@ -143,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();
         }
@@ -187,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;
@@ -228,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;
@@ -258,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